Commits

Anonymous committed d0eb1c2

CWS-TOOLING: integrate CWS aw057

  • Participants
  • Parent commits f615012

Comments (0)

Files changed (279)

File basegfx/inc/basegfx/polygon/b2dpolygontools.hxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b2dpolygontools.hxx,v $
- * $Revision: 1.24 $
+ * $Revision: 1.24.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 		bool isInEpsilonRange(const B2DPoint& rEdgeStart, const B2DPoint& rEdgeEnd, const B2DPoint& rTestPosition, double fDistance);
 
 		// test if point is inside epsilon-range around the given Polygon. Can be used 
-		// for HitTesting. The epsilon-range is defined to be the tube around the polygon
-		// with distance fDistance and rounded edges (start and end point).
+		// for HitTesting. The epsilon-range is defined to be the rectangle centered 
+        // to the given edge, using height 2 x fDistance, and the circle around both points 
+        // with radius fDistance.
 		bool isInEpsilonRange(const B2DPolygon& rCandidate, const B2DPoint& rTestPosition, double fDistance);
 
         /** Create a polygon from a rectangle.
 
 		/** Create an unit ellipse polygon with the given angles, from start to end
          */
-        B2DPolygon createPolygonFromEllipseSegment( const B2DPoint& rCenter, double fRadiusX, double fRadiusY, double fStart, double fEnd );
+        B2DPolygon createPolygonFromEllipseSegment( const B2DPoint& rCenter, double fRadiusX, double fRadiusY, double	fStart, double fEnd );
 
         B2DPolygon createPolygonFromUnitEllipseSegment( double fStart, double fEnd );
 

File basegfx/inc/basegfx/polygon/b3dpolygontools.hxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b3dpolygontools.hxx,v $
- * $Revision: 1.10 $
+ * $Revision: 1.10.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 		// get area of polygon
 		double getArea(const B3DPolygon& rCandidate);
 
-		// get normal vector of polygon
-		::basegfx::B3DVector getNormal(const ::basegfx::B3DPolygon& rCandidate);
-
 		// get signed area of polygon
 		double getSignedArea(const B3DPolygon& rCandidate);
 
          */
 		B3DPolygon applyDefaultTextureCoordinatesSphere( const B3DPolygon& rCandidate, const B3DPoint& rCenter, bool bChangeX = true, bool bChangeY = true);
 
+		// test if point is inside epsilon-range around an edge defined
+		// by the two given points. Can be used for HitTesting. The epsilon-range
+		// is defined to be the cylinder centered to the given edge, using radius
+		// fDistance, and the sphere around both points with radius fDistance.
+		bool isInEpsilonRange(const B3DPoint& rEdgeStart, const B3DPoint& rEdgeEnd, const B3DPoint& rTestPosition, double fDistance);
+
+		// test if point is inside epsilon-range around the given Polygon. Can be used 
+		// for HitTesting. The epsilon-range is defined to be the cylinder centered to 
+        // the given edge, using radius fDistance, and the sphere around both points with radius fDistance.
+		bool isInEpsilonRange(const B3DPolygon& rCandidate, const B3DPoint& rTestPosition, double fDistance);
+
+		// isInside tests for B3DPoint and other B3DPolygon. On border is not inside as long as
+		// not true is given in bWithBorder flag.
+		bool isInside(const B3DPolygon& rCandidate, const B3DPoint& rPoint, bool bWithBorder = false);
+		bool isInside(const B3DPolygon& rCandidate, const B3DPolygon& rPolygon, bool bWithBorder = false);
+
+		// calculates if given point is on given line, taking care of the numerical epsilon
+		bool isPointOnLine(const B3DPoint& rStart, const B3DPoint& rEnd, const B3DPoint& rCandidate, bool bWithPoints = false);
+
+        // calculates if given point is on given polygon, taking care of the numerical epsilon. Uses 
+		// isPointOnLine internally
+		bool isPointOnPolygon(const B3DPolygon& rCandidate, const B3DPoint& rPoint, bool bWithPoints = true);
+
+        // helper to get a fCut position between a plane (given with normal and a point)
+        // and a line given by start and end point
+        bool getCutBetweenLineAndPlane(const B3DVector& rPlaneNormal, const B3DPoint& rPlanePoint, const B3DPoint& rEdgeStart, const B3DPoint& rEdgeEnd, double& fCut);
+
+        // helper to get a fCut position between a 3d Polygon
+        // and a line given by start and end point
+        bool getCutBetweenLineAndPolygon(const B3DPolygon& rCandidate, const B3DPoint& rEdgeStart, const B3DPoint& rEdgeEnd, double& fCut);
+
 		//////////////////////////////////////////////////////////////////////
 		// comparators with tolerance for 3D Polygons
 		bool equal(const B3DPolygon& rCandidateA, const B3DPolygon& rCandidateB, const double& rfSmallValue);

File basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b3dpolypolygontools.hxx,v $
- * $Revision: 1.8 $
+ * $Revision: 1.8.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
          */
 		B3DPolyPolygon applyDefaultTextureCoordinatesSphere( const B3DPolyPolygon& rCandidate, const B3DPoint& rCenter, bool bChangeX = true, bool bChangeY = true);
 
+        // isInside test for B3DPoint. On border is not inside as long as not true is given 
+		// in bWithBorder flag. It is assumed that the orientations of the given polygon are correct.
+		bool isInside(const B3DPolyPolygon& rCandidate, const B3DPoint& rPoint, bool bWithBorder = false);
+
 		//////////////////////////////////////////////////////////////////////
 		// comparators with tolerance for 3D PolyPolygons
 		bool equal(const B3DPolyPolygon& rCandidateA, const B3DPolyPolygon& rCandidateB, const double& rfSmallValue);

File basegfx/inc/basegfx/vector/b3dvector.hxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b3dvector.hxx,v $
- * $Revision: 1.12 $
+ * $Revision: 1.12.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 		return aPerpendicular;
 	}
 
+	/** Test two vectors which need not to be normalized for parallelism
+
+		@param rVecA
+		The first 3D Vector
+
+		@param rVecB
+		The second 3D Vector
+
+		@return
+		bool if the two values are parallel. Also true if
+		one of the vectors is empty.
+	*/
+	bool areParallel( const B3DVector& rVecA, const B3DVector& rVecB );
+
 	/** Transform vector by given transformation matrix.
 	    
 		Since this is a vector, translational components of the

File basegfx/source/polygon/b2dpolygontools.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b2dpolygontools.cxx,v $
- * $Revision: 1.29 $
+ * $Revision: 1.29.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 		{
 			// build edge vector
 			const B2DVector aEdge(rEdgeEnd - rEdgeStart);
-			bool bDeltaXIsZero(fTools::equalZero(aEdge.getX()));
-			bool bDeltaYIsZero(fTools::equalZero(aEdge.getY()));
 			bool bDoDistanceTestStart(false);
 			bool bDoDistanceTestEnd(false);
 
-			if(bDeltaXIsZero && bDeltaYIsZero)
+			if(aEdge.equalZero())
 			{
 				// no edge, just a point. Do one of the distance tests.
 				bDoDistanceTestStart = true;
 					(aPerpend.getY() * (rTestPosition.getX() - rEdgeStart.getX())
 					+ aPerpend.getX() * (rEdgeStart.getY() - rTestPosition.getY())) /
 					(aEdge.getX() * aEdge.getX() + aEdge.getY() * aEdge.getY()));
-
 				const double fZero(0.0);
 				const double fOne(1.0);
 
 				{
 					// inside line [0.0 .. 1.0]
 					const B2DPoint aCutPoint(interpolate(rEdgeStart, rEdgeEnd, fCut));
-					const double fDeltaX(rTestPosition.getX() - aCutPoint.getX());
-					const double fDeltaY(rTestPosition.getY() - aCutPoint.getY());
-					const double fDistanceSquare(fDeltaX * fDeltaX + fDeltaY * fDeltaY);
+    			    const B2DVector aDelta(rTestPosition - aCutPoint);
+					const double fDistanceSquare(aDelta.scalar(aDelta));
 
 					if(fDistanceSquare <= fDistance * fDistance)
 					{
 					}
 					else
 					{
-						return sal_False;
+						return false;
 					}
 				}
 			}
 
 			if(bDoDistanceTestStart)
 			{
-				const double fDeltaX(rTestPosition.getX() - rEdgeStart.getX());
-				const double fDeltaY(rTestPosition.getY() - rEdgeStart.getY());
-				const double fDistanceSquare(fDeltaX * fDeltaX + fDeltaY * fDeltaY);
+			    const B2DVector aDelta(rTestPosition - rEdgeStart);
+				const double fDistanceSquare(aDelta.scalar(aDelta));
 
 				if(fDistanceSquare <= fDistance * fDistance)
 				{
 			}
 			else if(bDoDistanceTestEnd)
 			{
-				const double fDeltaX(rTestPosition.getX() - rEdgeEnd.getX());
-				const double fDeltaY(rTestPosition.getY() - rEdgeEnd.getY());
-				const double fDistanceSquare(fDeltaX * fDeltaX + fDeltaY * fDeltaY);
+			    const B2DVector aDelta(rTestPosition - rEdgeEnd);
+				const double fDistanceSquare(aDelta.scalar(aDelta));
 
 				if(fDistanceSquare <= fDistance * fDistance)
 				{

File basegfx/source/polygon/b2dpolypolygon.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b2dpolypolygon.cxx,v $
- * $Revision: 1.21 $
+ * $Revision: 1.21.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 
 			for(sal_uInt32 a(0L); a < nCount; a++)
 			{
-				maPolygons.insert(aIndex, rPolyPolygon.getB2DPolygon(a));
+				aIndex = maPolygons.insert(aIndex, rPolyPolygon.getB2DPolygon(a));
 				aIndex++;
 			}
 		}

File basegfx/source/polygon/b2dpolypolygontools.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b2dpolypolygontools.cxx,v $
- * $Revision: 1.19 $
+ * $Revision: 1.19.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 				for(sal_uInt32 a(0L); a < nPolygonCount; a++)
 				{
 					const B2DPolygon aPolygon(rCandidate.getB2DPolygon(a));
-					const sal_Bool bInside(isInside(aPolygon, rPoint, bWithBorder));
+					const bool bInside(isInside(aPolygon, rPoint, bWithBorder));
 
 					if(bInside)
 					{

File basegfx/source/polygon/b3dpolygontools.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b3dpolygontools.cxx,v $
- * $Revision: 1.11 $
+ * $Revision: 1.11.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 #include <basegfx/numeric/ftools.hxx>
 #include <basegfx/range/b3drange.hxx>
 #include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/matrix/b3dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
 #include <numeric>
 
 //////////////////////////////////////////////////////////////////////////////
 			return aRetval;
 		}
 
+		bool isInEpsilonRange(const B3DPoint& rEdgeStart, const B3DPoint& rEdgeEnd, const B3DPoint& rTestPosition, double fDistance)
+		{
+			// build edge vector
+			const B3DVector aEdge(rEdgeEnd - rEdgeStart);
+			bool bDoDistanceTestStart(false);
+			bool bDoDistanceTestEnd(false);
+
+			if(aEdge.equalZero())
+			{
+				// no edge, just a point. Do one of the distance tests.
+				bDoDistanceTestStart = true;
+			}
+			else
+			{
+                // calculate fCut in aEdge
+    			const B3DVector aTestEdge(rTestPosition - rEdgeStart);
+                const double fScalarTestEdge(aEdge.scalar(aTestEdge));
+                const double fScalarStartEdge(aEdge.scalar(rEdgeStart));
+                const double fScalarEdge(aEdge.scalar(aEdge));
+                const double fCut((fScalarTestEdge - fScalarStartEdge) / fScalarEdge);
+				const double fZero(0.0);
+				const double fOne(1.0);
+
+				if(fTools::less(fCut, fZero))
+				{
+					// left of rEdgeStart
+					bDoDistanceTestStart = true;
+				}
+				else if(fTools::more(fCut, fOne))
+				{
+					// right of rEdgeEnd
+					bDoDistanceTestEnd = true;
+				}
+				else
+				{
+					// inside line [0.0 .. 1.0]
+					const B3DPoint aCutPoint(interpolate(rEdgeStart, rEdgeEnd, fCut));
+    			    const B3DVector aDelta(rTestPosition - aCutPoint);
+				    const double fDistanceSquare(aDelta.scalar(aDelta));
+
+				    if(fDistanceSquare <= fDistance * fDistance * fDistance)
+				    {
+						return true;
+					}
+					else
+					{
+						return false;
+					}
+				}
+			}
+
+			if(bDoDistanceTestStart)
+			{
+    			const B3DVector aDelta(rTestPosition - rEdgeStart);
+				const double fDistanceSquare(aDelta.scalar(aDelta));
+
+				if(fDistanceSquare <= fDistance * fDistance * fDistance)
+				{
+					return true;
+				}
+			}
+			else if(bDoDistanceTestEnd)
+			{
+    			const B3DVector aDelta(rTestPosition - rEdgeEnd);
+				const double fDistanceSquare(aDelta.scalar(aDelta));
+
+				if(fDistanceSquare <= fDistance * fDistance * fDistance)
+				{
+					return true;
+				}
+			}
+
+			return false;
+		}
+
+		bool isInEpsilonRange(const B3DPolygon& rCandidate, const B3DPoint& rTestPosition, double fDistance)
+		{
+			const sal_uInt32 nPointCount(rCandidate.count());
+			
+			if(nPointCount)
+			{
+                const sal_uInt32 nEdgeCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1L);
+				B3DPoint aCurrent(rCandidate.getB3DPoint(0));
+
+				if(nEdgeCount)
+				{
+					// edges
+					for(sal_uInt32 a(0); a < nEdgeCount; a++)
+					{
+						const sal_uInt32 nNextIndex((a + 1) % nPointCount);
+						const B3DPoint aNext(rCandidate.getB3DPoint(nNextIndex));
+
+						if(isInEpsilonRange(aCurrent, aNext, rTestPosition, fDistance))
+						{
+							return true;
+						}
+
+						// prepare next step
+						aCurrent = aNext;
+					}
+				}
+				else
+				{
+					// no edges, but points -> not closed. Check single point. Just
+					// use isInEpsilonRange with twice the same point, it handles those well
+					if(isInEpsilonRange(aCurrent, aCurrent, rTestPosition, fDistance))
+					{
+						return true;
+					}
+				}
+			}
+
+			return false;
+		}
+
+		bool isInside(const B3DPolygon& rCandidate, const B3DPoint& rPoint, bool bWithBorder)
+        {
+			if(bWithBorder && isPointOnPolygon(rCandidate, rPoint, true))
+			{
+				return true;
+			}
+			else
+			{
+				const B3DVector aPlaneNormal(rCandidate.getNormal());
+
+				if(!aPlaneNormal.equalZero())
+				{
+					const double fAbsX(fabs(aPlaneNormal.getX()));
+					const double fAbsY(fabs(aPlaneNormal.getY()));
+					const double fAbsZ(fabs(aPlaneNormal.getZ()));
+
+					if(fAbsX > fAbsY && fAbsX > fAbsZ)
+					{
+						// normal points mostly in X-Direction, use YZ-Polygon projection for check
+						B3DHomMatrix aTrans;
+
+						aTrans.set(0, 0, 0.0);
+						aTrans.set(0, 1, 1.0);
+						aTrans.set(1, 1, 0.0);
+						aTrans.set(1, 2, 1.0);
+		
+						const B2DPolygon aYZ(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
+
+						return isInside(aYZ, B2DPoint(rPoint.getY(), rPoint.getZ()), bWithBorder);
+					}
+					else if(fAbsY > fAbsX && fAbsY > fAbsZ)
+					{
+						// normal points mostly in Y-Direction, use XZ-Polygon projection for check
+						B3DHomMatrix aTrans;
+						
+						aTrans.set(1, 1, 0.0);
+						aTrans.set(1, 2, 1.0);
+						
+						const B2DPolygon aXZ(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
+
+						return isInside(aXZ, B2DPoint(rPoint.getX(), rPoint.getZ()), bWithBorder);
+					}
+					else
+					{
+						// normal points mostly in Z-Direction, use XY-Polygon projection for check
+						B3DHomMatrix aTrans;
+						
+						const B2DPolygon aXY(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
+
+						return isInside(aXY, B2DPoint(rPoint.getX(), rPoint.getY()), bWithBorder);
+					}
+				}
+
+				return false;
+			}
+        }
+
+		bool isInside(const B3DPolygon& rCandidate, const B3DPolygon& rPolygon, bool bWithBorder)
+        {
+			const sal_uInt32 nPointCount(rPolygon.count());
+
+			for(sal_uInt32 a(0L); a < nPointCount; a++)
+			{
+				const B3DPoint aTestPoint(rPolygon.getB3DPoint(a));
+
+				if(!isInside(rCandidate, aTestPoint, bWithBorder))
+				{
+					return false;
+				}
+			}
+
+			return true;
+        }
+
+		bool isPointOnLine(const B3DPoint& rStart, const B3DPoint& rEnd, const B3DPoint& rCandidate, bool bWithPoints)
+        {
+			if(rCandidate.equal(rStart) || rCandidate.equal(rEnd))
+			{
+				// candidate is in epsilon around start or end -> inside
+				return bWithPoints;
+			}
+			else if(rStart.equal(rEnd))
+			{
+				// start and end are equal, but candidate is outside their epsilon -> outside
+				return false;
+			}
+			else
+			{
+				const B3DVector aEdgeVector(rEnd - rStart);
+				const B3DVector aTestVector(rCandidate - rStart);
+
+				if(areParallel(aEdgeVector, aTestVector))
+				{
+					const double fZero(0.0);
+					const double fOne(1.0);
+                    double fParamTestOnCurr(0.0);
+					
+                    if(aEdgeVector.getX() > aEdgeVector.getY())
+                    {
+                        if(aEdgeVector.getX() > aEdgeVector.getZ())
+                        {
+                            // X is biggest
+                            fParamTestOnCurr = aTestVector.getX() / aEdgeVector.getX();
+                        }
+                        else
+                        {
+                            // Z is biggest
+                            fParamTestOnCurr = aTestVector.getZ() / aEdgeVector.getZ();
+                        }
+                    }
+                    else
+                    {
+                        if(aEdgeVector.getY() > aEdgeVector.getZ())
+                        {
+                            // Y is biggest
+                            fParamTestOnCurr = aTestVector.getY() / aEdgeVector.getY();
+                        }
+                        else
+                        {
+                            // Z is biggest
+                            fParamTestOnCurr = aTestVector.getZ() / aEdgeVector.getZ();
+                        }
+                    }
+
+					if(fTools::more(fParamTestOnCurr, fZero) && fTools::less(fParamTestOnCurr, fOne))
+					{
+						return true;
+					}
+				}
+
+				return false;
+			}
+        }
+
+		bool isPointOnPolygon(const B3DPolygon& rCandidate, const B3DPoint& rPoint, bool bWithPoints)
+        {
+			const sal_uInt32 nPointCount(rCandidate.count());
+
+			if(nPointCount > 1L)
+			{
+				const sal_uInt32 nLoopCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1L);
+				B3DPoint aCurrentPoint(rCandidate.getB3DPoint(0));
+
+				for(sal_uInt32 a(0); a < nLoopCount; a++)
+				{
+					const B3DPoint aNextPoint(rCandidate.getB3DPoint((a + 1) % nPointCount));
+
+					if(isPointOnLine(aCurrentPoint, aNextPoint, rPoint, bWithPoints))
+					{
+						return true;
+					}
+
+					aCurrentPoint = aNextPoint;
+				}
+			}
+			else if(nPointCount && bWithPoints)
+			{
+				return rPoint.equal(rCandidate.getB3DPoint(0));
+			}
+
+			return false;
+        }
+
+        bool getCutBetweenLineAndPlane(const B3DVector& rPlaneNormal, const B3DPoint& rPlanePoint, const B3DPoint& rEdgeStart, const B3DPoint& rEdgeEnd, double& fCut)
+        {
+            if(!rPlaneNormal.equalZero() && !rEdgeStart.equal(rEdgeEnd))
+            {
+			    const B3DVector aTestEdge(rEdgeEnd - rEdgeStart);
+                const double fScalarEdge(rPlaneNormal.scalar(aTestEdge));
+
+				if(!fTools::equalZero(fScalarEdge))
+				{
+					const B3DVector aCompareEdge(rPlanePoint - rEdgeStart);
+					const double fScalarCompare(rPlaneNormal.scalar(aCompareEdge));
+	                
+					fCut = fScalarCompare / fScalarEdge;
+					return true;
+				}
+            }
+
+            return false;
+        }
+
+        bool getCutBetweenLineAndPolygon(const B3DPolygon& rCandidate, const B3DPoint& rEdgeStart, const B3DPoint& rEdgeEnd, double& fCut)
+        {
+            const sal_uInt32 nPointCount(rCandidate.count());
+
+            if(nPointCount > 2 && !rEdgeStart.equal(rEdgeEnd))
+            {
+                const B3DVector aPlaneNormal(rCandidate.getNormal());
+
+                if(!aPlaneNormal.equalZero())
+                {
+                    const B3DPoint aPointOnPlane(rCandidate.getB3DPoint(0));
+
+                    return getCutBetweenLineAndPlane(aPlaneNormal, aPointOnPlane, rEdgeStart, rEdgeEnd, fCut);
+                }
+            }
+            
+            return false;
+        }
+
 		//////////////////////////////////////////////////////////////////////
 		// comparators with tolerance for 3D Polygons
 

File basegfx/source/polygon/b3dpolypolygontools.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b3dpolypolygontools.cxx,v $
- * $Revision: 1.8 $
+ * $Revision: 1.8.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 			return aRetval;
 		}
 
+		bool isInside(const B3DPolyPolygon& rCandidate, const B3DPoint& rPoint, bool bWithBorder)
+		{
+			const sal_uInt32 nPolygonCount(rCandidate.count());
+
+			if(1L == nPolygonCount)
+			{
+				return isInside(rCandidate.getB3DPolygon(0), rPoint, bWithBorder);
+			}
+			else
+			{
+				sal_Int32 nInsideCount(0);
+
+				for(sal_uInt32 a(0); a < nPolygonCount; a++)
+				{
+					const B3DPolygon aPolygon(rCandidate.getB3DPolygon(a));
+					const bool bInside(isInside(aPolygon, rPoint, bWithBorder));
+
+					if(bInside)
+					{
+						nInsideCount++;
+					}
+				}
+
+				return (nInsideCount % 2L);
+			}
+		}
+
 		//////////////////////////////////////////////////////////////////////
 		// comparators with tolerance for 3D PolyPolygons
 

File basegfx/source/vector/b3dvector.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: b3dvector.cxx,v $
- * $Revision: 1.9 $
+ * $Revision: 1.9.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
 		B3DVector aRes( rVec );
 		return aRes*=rMat;
 	}
+
+    bool areParallel( const B3DVector& rVecA, const B3DVector& rVecB )
+    {
+        // i think fastest is to compare relations, need no square or division
+        if(!fTools::equal(rVecA.getX() * rVecB.getY(), rVecA.getY() * rVecB.getX()))
+            return false;
+
+        if(!fTools::equal(rVecA.getX() * rVecB.getZ(), rVecA.getZ() * rVecB.getX()))
+			return false;
+
+		return (fTools::equal(rVecA.getY() * rVecB.getZ(), rVecA.getZ() * rVecB.getY()));
+    }
+
 } // end of namespace basegfx
 
 //////////////////////////////////////////////////////////////////////////////

File chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: tp_3D_SceneIllumination.cxx,v $
- * $Revision: 1.4 $
+ * $Revision: 1.4.68.1 $
  *
  * This file is part of OpenOffice.org.
  *
 // header for define RET_OK
 #include <vcl/msgbox.hxx>
 
+#include <svx/svx3ditems.hxx>
+#include <svx/svddef.hxx>
+
 //.............................................................................
 namespace chart
 {
     return 0;
 }
 
-void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( Base3DLightNumber nLightNumber )
+void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( sal_uInt32 nLightNumber )
 {
     ControllerLockGuard aGuard( m_xChartModel );
 	m_bInCommitToModel = true;
     m_aTimerTriggeredControllerLock.startTimer();
     ControllerLockGuard aGuard( m_xChartModel );
     for( sal_Int32 nL=0; nL<8; nL++)
-        applyLightSourceToModel( static_cast< Base3DLightNumber >( nL ));
+        applyLightSourceToModel( nL );
     m_aTimerTriggeredControllerLock.startTimer();
 }
 
     m_aTimerTriggeredControllerLock.startTimer();
 
     //update m_pLightSourceInfoList from preview
-    B3dLightGroup* pLightGroup = m_aCtl_Preview.GetPreviewControl().GetLightGroup();
-    for( sal_Int32 nL=0; nL<8; nL++)
-    {
-        LightSourceInfo* pInfo = &m_pLightSourceInfoList[nL];
-        Base3DLightNumber nLightNumber = Base3DLightNumber(nL);
+	const SfxItemSet a3DLightAttributes(m_aCtl_Preview.GetSvx3DLightControl().Get3DAttributes());
+    LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
 
-        pInfo->aLightSource.nDiffuseColor = pLightGroup->GetIntensity( Base3DMaterialDiffuse, nLightNumber ).GetColor();
-        pInfo->aLightSource.bIsEnabled = pLightGroup->IsEnabled( nLightNumber );
-        pInfo->aLightSource.aDirection = B3DVectorToDirection3D( pLightGroup->GetDirection( nLightNumber ) );
-    }
+    pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().GetColor();
+    pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue();
+    pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue());
+
+    pInfo = &m_pLightSourceInfoList[1];
+    pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().GetColor();
+    pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue();
+    pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue());
+
+    pInfo = &m_pLightSourceInfoList[2];
+    pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().GetColor();
+    pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue();
+    pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue());
+
+    pInfo = &m_pLightSourceInfoList[3];
+    pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().GetColor();
+    pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue();
+    pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue());
+
+    pInfo = &m_pLightSourceInfoList[4];
+    pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().GetColor();
+    pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue();
+    pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue());
+
+    pInfo = &m_pLightSourceInfoList[5];
+    pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().GetColor();
+    pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue();
+    pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue());
+
+    pInfo = &m_pLightSourceInfoList[6];
+    pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().GetColor();
+    pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue();
+    pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue());
+
+    pInfo = &m_pLightSourceInfoList[7];
+    pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().GetColor();
+    pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue();
+    pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue());
 
     applyLightSourcesToModel();
     
 
 IMPL_LINK( ThreeD_SceneIllumination_TabPage, PreviewSelectHdl, void*, EMPTYARG )
 {
-    Base3DLightNumber nLightNumber = m_aCtl_Preview.GetPreviewControl().GetSelectedLight();
-    if(nLightNumber>=0&&nLightNumber<8)
+    sal_uInt32 nLightNumber = m_aCtl_Preview.GetSvx3DLightControl().GetSelectedLight();
+    if(nLightNumber<8)
     {
         LightButton* pButton = m_pLightSourceInfoList[nLightNumber].pButton;
         if(!pButton->IsChecked())
                 pInfo = 0;
             }
             if(pInfo)
-                applyLightSourceToModel( Base3DLightNumber( nL ));
+                applyLightSourceToModel( nL );
         }
         SelectColorHdl( pListBox );
 	}
         if(pInfo)
         {
             pInfo->aLightSource.nDiffuseColor = pListBox->GetSelectEntryColor().GetColor();
-            applyLightSourceToModel( Base3DLightNumber( nL ));
+            applyLightSourceToModel( nL );
         }
     }
     this->updatePreview();
         if(pInfo)
         {
             pInfo->aLightSource.bIsEnabled=pButton->isLightOn();
-            applyLightSourceToModel( Base3DLightNumber( nL ));
+            applyLightSourceToModel( nL );
         }
     }
     else
 
 void ThreeD_SceneIllumination_TabPage::updatePreview()
 {
-    B3dLightGroup* pLightGroup = m_aCtl_Preview.GetPreviewControl().GetLightGroup();
-    pLightGroup->SetGlobalAmbientLight( m_aLB_AmbientLight.GetSelectEntryColor() );
-    Base3DLightNumber nSelectLightSource = Base3DLightNone;
+    SfxItemSet aItemSet(m_aCtl_Preview.GetSvx3DLightControl().Get3DAttributes());
+    LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
 
-    for( sal_Int32 nL=8; nL--;)
+	// AmbientColor
+	aItemSet.Put(Svx3DAmbientcolorItem(m_aLB_AmbientLight.GetSelectEntryColor()));
+
+	aItemSet.Put(Svx3DLightcolor1Item(pInfo->aLightSource.nDiffuseColor));
+	aItemSet.Put(Svx3DLightOnOff1Item(pInfo->aLightSource.bIsEnabled));
+	aItemSet.Put(Svx3DLightDirection1Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
+    
+    pInfo = &m_pLightSourceInfoList[1];
+	aItemSet.Put(Svx3DLightcolor2Item(pInfo->aLightSource.nDiffuseColor));
+	aItemSet.Put(Svx3DLightOnOff2Item(pInfo->aLightSource.bIsEnabled));
+	aItemSet.Put(Svx3DLightDirection2Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
+    
+    pInfo = &m_pLightSourceInfoList[2];
+	aItemSet.Put(Svx3DLightcolor3Item(pInfo->aLightSource.nDiffuseColor));
+	aItemSet.Put(Svx3DLightOnOff3Item(pInfo->aLightSource.bIsEnabled));
+	aItemSet.Put(Svx3DLightDirection3Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
+    
+    pInfo = &m_pLightSourceInfoList[3];
+	aItemSet.Put(Svx3DLightcolor4Item(pInfo->aLightSource.nDiffuseColor));
+	aItemSet.Put(Svx3DLightOnOff4Item(pInfo->aLightSource.bIsEnabled));
+	aItemSet.Put(Svx3DLightDirection4Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
+    
+    pInfo = &m_pLightSourceInfoList[4];
+	aItemSet.Put(Svx3DLightcolor5Item(pInfo->aLightSource.nDiffuseColor));
+	aItemSet.Put(Svx3DLightOnOff5Item(pInfo->aLightSource.bIsEnabled));
+	aItemSet.Put(Svx3DLightDirection5Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
+    
+    pInfo = &m_pLightSourceInfoList[5];
+	aItemSet.Put(Svx3DLightcolor6Item(pInfo->aLightSource.nDiffuseColor));
+	aItemSet.Put(Svx3DLightOnOff6Item(pInfo->aLightSource.bIsEnabled));
+	aItemSet.Put(Svx3DLightDirection6Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
+    
+    pInfo = &m_pLightSourceInfoList[6];
+	aItemSet.Put(Svx3DLightcolor7Item(pInfo->aLightSource.nDiffuseColor));
+	aItemSet.Put(Svx3DLightOnOff7Item(pInfo->aLightSource.bIsEnabled));
+	aItemSet.Put(Svx3DLightDirection7Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
+    
+    pInfo = &m_pLightSourceInfoList[7];
+	aItemSet.Put(Svx3DLightcolor8Item(pInfo->aLightSource.nDiffuseColor));
+	aItemSet.Put(Svx3DLightOnOff8Item(pInfo->aLightSource.bIsEnabled));
+	aItemSet.Put(Svx3DLightDirection8Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
+
+    // set lights and ambient light
+    m_aCtl_Preview.GetSvx3DLightControl().Set3DAttributes(aItemSet);
+
+    // select light
+    for(sal_uInt32 a(0); a < 8; a++)
     {
-        LightSourceInfo* pInfo = &m_pLightSourceInfoList[nL];
-        Base3DLightNumber nLightNumber = Base3DLightNumber(nL);
-        pLightGroup->SetIntensity( Color( pInfo->aLightSource.nDiffuseColor ), Base3DMaterialDiffuse, nLightNumber );
-        pLightGroup->Enable( pInfo->aLightSource.bIsEnabled, nLightNumber );
-        pLightGroup->SetDirection( Direction3DToB3DPoint( pInfo->aLightSource.aDirection ), nLightNumber );
-        if(pInfo->pButton->IsChecked())
-            nSelectLightSource = Base3DLightNumber(nL);
+        if(m_pLightSourceInfoList[a].pButton->IsChecked())
+        {
+            m_aCtl_Preview.GetSvx3DLightControl().SelectLight(a);
+            m_aCtl_Preview.CheckSelection();
+            break;
+        }
     }
-
-    m_aCtl_Preview.GetPreviewControl().SelectLight( nSelectLightSource );
-    m_aCtl_Preview.CheckSelection();
-    m_aCtl_Preview.Invalidate();
 }
 
 //.............................................................................

File chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: tp_3D_SceneIllumination.hxx,v $
- * $Revision: 1.3 $
+ * $Revision: 1.3.68.1 $
  *
  * This file is part of OpenOffice.org.
  *
 private:
     DECL_LINK(fillControlsFromModel, void *);
 
-    void applyLightSourceToModel( Base3DLightNumber nLightNumber );
+    void applyLightSourceToModel( sal_uInt32 nLightNumber );
     void applyLightSourcesToModel();
 
     FixedText   m_aFT_LightSource;

File chart2/source/controller/drawinglayer/DrawViewWrapper.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: DrawViewWrapper.cxx,v $
- * $Revision: 1.20 $
+ * $Revision: 1.20.6.1 $
  *
  * This file is part of OpenOffice.org.
  *
 #include <com/sun/star/lang/XUnoTunnel.hpp>
 
 #include <sfx2/objsh.hxx>
+#include <svx/helperhittest3d.hxx>
 
 using namespace ::com::sun::star;
 
             E3dScene* pScene = pE3d->GetScene();
             if( pScene )
             {
-                ::std::vector< SdrObject* > aHitList;
-                sal_uInt32 nHitCount = pScene->HitTest( rPnt, aHitList );
-                if( nHitCount )
-                    pRet = aHitList[0];
+                // prepare result vector and call helper
+                ::std::vector< const E3dCompoundObject* > aHitList;
+                const basegfx::B2DPoint aHitPoint(rPnt.X(), rPnt.Y());
+                getAllHit3DObjectsSortedFrontToBack(aHitPoint, *pScene, aHitList);
+
+                if(aHitList.size())
+                {
+                    // choose the frontmost hit 3D object of the scene
+                    pRet = const_cast< E3dCompoundObject* >(aHitList[0]);
+                }
             }
         }
     }

File chart2/source/controller/main/ChartController_Window.cxx

 			&& aKeyCode.GetCode() == KEY_R)
 		{
 				// 3D-Kontext wieder zerstoeren
-			Base3D* pBase3D = (Base3D*) GetWindow()->Get3DContext();
-
-			if (pBase3D)
-			{
-				pBase3D->Destroy(GetWindow());
-			}
 			GetWindow()->Invalidate();
 			bReturn = TRUE;
 		}

File chart2/source/controller/main/DragMethod_PieSegment.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: DragMethod_PieSegment.cxx,v $
- * $Revision: 1.4 $
+ * $Revision: 1.4.68.1 $
  *
  * This file is part of OpenOffice.org.
  *
     SdrPageView* pPV = m_rDrawViewWrapper.GetPageView();
     if( pObj && pPV )
 	{
-        pPV->setDragPoly0(pObj->TakeXorPoly(true));
+        pPV->setDragPoly0(pObj->TakeXorPoly());
         pPV->setDragPoly(pPV->getDragPoly0());
 	}
     Show();

File chart2/source/controller/main/DragMethod_RotateDiagram.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: DragMethod_RotateDiagram.cxx,v $
- * $Revision: 1.6 $
+ * $Revision: 1.6.60.1 $
  *
  * This file is part of OpenOffice.org.
  *
 #include <svx/scene3d.hxx>
 #include <basegfx/matrix/b3dhommatrix.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <drawinglayer/geometry/viewinformation3d.hxx>
 
 #define FIXED_SIZE_FOR_3D_CHART_VOLUME (10000.0)
 
     , m_pScene(0)
     , m_aReferenceRect(100,100,100,100)
     , m_aStartPos(0,0)
-    , m_aWireframePoly()
+    , m_aWireframePolyPolygon()
     , m_fInitialXAngleRad(0.0)
     , m_fInitialYAngleRad(0.0)
     , m_fInitialZAngleRad(0.0)
         m_aReferenceRect = pObj->GetLogicRect();
         Rectangle aTemp = m_pScene->GetLogicRect();
 
-        m_pScene->CreateWireframe(m_aWireframePoly, NULL );
+        m_aWireframePolyPolygon = m_pScene->CreateWireframe();
 
         uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram(this->getChartModel()) );
         uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY );
         aCurrentTransform.shearXY(fResultY,-(fResultX));
     }
     
-    const sal_uInt32 nPntCnt(m_aWireframePoly.count());
- 	if(nPntCnt > 1L && m_pScene)
+	if(m_aWireframePolyPolygon.count() && m_pScene)
 	{
-        B3dCamera& rCameraSet = m_pScene->GetCameraSet();
-        for(sal_uInt32 b(0L); b < nPntCnt; b += 2L)
-		{
-            ::basegfx::B2DPolygon aLine;
-            ::basegfx::B3DPoint aPnt1(aCurrentTransform * m_aWireframePoly.getB3DPoint(b));
-            aPnt1 = rCameraSet.WorldToViewCoor(aPnt1);
-            aLine.append(::basegfx::B2DPoint(aPnt1.getX(), aPnt1.getY()));
-			
-			::basegfx::B3DPoint aPnt2(aCurrentTransform * m_aWireframePoly.getB3DPoint(b + 1L));
-            aPnt2 = rCameraSet.WorldToViewCoor(aPnt2);
-            aLine.append(::basegfx::B2DPoint(aPnt2.getX(), aPnt2.getY()));
+        const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(m_pScene->GetViewContact());
+		const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+		const basegfx::B3DHomMatrix aWorldToView(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection() * aViewInfo3D.getOrientation());
+	    const basegfx::B3DHomMatrix aTransform(aWorldToView * aCurrentTransform);
 
-            basegfx::B2DPolyPolygon aResult(aLine);
-            ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aResult);
-		    rOverlayManager.add(*pNew);
-		    rOverlayList.append(*pNew);
-		}
+		// transform to relative scene coordinates
+		basegfx::B2DPolyPolygon aPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(m_aWireframePolyPolygon, aTransform));
+
+		// transform to 2D view coordinates
+		aPolyPolygon.transform(rVCScene.getObjectTransformation());
+
+		sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aPolyPolygon);
+		rOverlayManager.add(*pNew);
+		rOverlayList.append(*pNew);
 	}
 }
 

File chart2/source/controller/main/DragMethod_RotateDiagram.hxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: DragMethod_RotateDiagram.hxx,v $
- * $Revision: 1.5 $
+ * $Revision: 1.5.60.1 $
  *
  * This file is part of OpenOffice.org.
  *
 
 #include "DragMethod_Base.hxx"
 
-// header for class ::basegfx::B3DPolygon
-#include <basegfx/polygon/b3dpolygon.hxx>
+// header for class ::basegfx::B3DPolyPolygon
+#include <basegfx/polygon/b3dpolypolygon.hxx>
 
 namespace chart
 {
 
     Rectangle   m_aReferenceRect;
     Point       m_aStartPos;
-    ::basegfx::B3DPolygon m_aWireframePoly;
+    basegfx::B3DPolyPolygon m_aWireframePolyPolygon;
     
     double      m_fInitialXAngleRad;
     double      m_fInitialYAngleRad;

File chart2/source/controller/main/SelectionHelper.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: SelectionHelper.cxx,v $
- * $Revision: 1.11 $
+ * $Revision: 1.11.68.1 $
  *
  * This file is part of OpenOffice.org.
  *
                 for( sal_uInt32 nM = 0L; nM < aPolygon.count(); nM++)
                 {
 					const ::basegfx::B2DPoint aPoint(aPolygon.getB2DPoint(nM));
-                    SdrHdl* pHdl = new SdrHdl(Point(FRound(aPoint.getX()), FRound(aPoint.getY())), HDL_POLY);
+                    SdrHdl* pHdl = new SdrHdl(Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())), HDL_POLY);
 	                rHdlList.AddHdl(pHdl);
                 }
             }

File chart2/source/controller/makefile.mk

 #
 # $RCSfile: makefile.mk,v $
 #
-# $Revision: 1.12 $
+# $Revision: 1.12.68.1 $
 #
 # This file is part of OpenOffice.org.
 #
 				$(CPPUHELPERLIB)	\
 				$(COMPHELPERLIB)	\
 				$(BASEGFXLIB)		\
+	            $(DRAWINGLAYERLIB)	\
 				$(GOODIESLIB)		\
 				$(BASEGFXLIB) 		\
 				$(SALLIB)			\

File chart2/source/inc/CommonConverters.hxx

 ::basegfx::B3DPoint Direction3DToB3DPoint( const com::sun::star::drawing::Direction3D& rDirection);
 
 //-----------------------------------------------------------------------------
+/** Direction3D -> B3DVector
+*/
+::basegfx::B3DVector Direction3DToB3DVector( const com::sun::star::drawing::Direction3D& rDirection);
+
+//-----------------------------------------------------------------------------
+/** two drawing::Position3D -> PolyPolygonShape3D
+*/
+::com::sun::star::drawing::PolyPolygonShape3D
+    MakeLine3D( const ::com::sun::star::drawing::Position3D & rStart,
+                const ::com::sun::star::drawing::Position3D & rEnd );
+
+//-----------------------------------------------------------------------------
 /** PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D
 */
 void AddPointToPoly( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly

File chart2/source/tools/CommonConverters.cxx

         );
 }
 
+::basegfx::B3DVector Direction3DToB3DVector( const drawing::Direction3D& rDirection)
+{
+    return ::basegfx::B3DVector(
+          rDirection.DirectionX
+        , rDirection.DirectionY
+        , rDirection.DirectionZ
+        );
+}
+
+drawing::PolyPolygonShape3D MakeLine3D(
+    const drawing::Position3D & rStart,
+    const drawing::Position3D & rEnd )
+{
+    drawing::PolyPolygonShape3D aPP;
+
+	aPP.SequenceX.realloc(1);
+	aPP.SequenceY.realloc(1);
+	aPP.SequenceZ.realloc(1);
+
+	drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
+	drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
+	drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
+
+    pOuterSequenceX->realloc(2);
+    pOuterSequenceY->realloc(2);
+	pOuterSequenceZ->realloc(2);
+
+    double* pInnerSequenceX = pOuterSequenceX->getArray();
+	double* pInnerSequenceY = pOuterSequenceY->getArray();
+	double* pInnerSequenceZ = pOuterSequenceZ->getArray();
+
+    *pInnerSequenceX++ = rStart.PositionX;
+    *pInnerSequenceY++ = rStart.PositionY;
+    *pInnerSequenceZ++ = rStart.PositionZ;
+
+    *pInnerSequenceX++ = rEnd.PositionX;
+    *pInnerSequenceY++ = rEnd.PositionY;
+    *pInnerSequenceZ++ = rEnd.PositionZ;
+
+    return aPP;
+}
+
 void AddPointToPoly( drawing::PolyPolygonShape3D& rPoly, const drawing::Position3D& rPos, sal_Int32 nPolygonIndex )
 {
     if(nPolygonIndex<0)

File chart2/source/view/diagram/VDiagram.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: VDiagram.cxx,v $
- * $Revision: 1.18 $
+ * $Revision: 1.18.60.1 $
  *
  * This file is part of OpenOffice.org.
  *
 // header for class E3dScene
 #include <svx/scene3d.hxx>
 #include <rtl/math.hxx>
+#include <svx/e3dsceneupdater.hxx>
 
 //.............................................................................
 namespace chart
                             FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0,
                             FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 );
 
+            // To get the 3D aspect ratio's effect on the 2D scene size, the scene's 2D size needs to be adapted to
+            // 3D content changes here. The tooling class remembers the current 3D transformation stack
+            // and in it's destructor, calculates a new 2D SnapRect for the scene and it's modified 3D geometry.
+            E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape ));
+
             m_xAspectRatio3D->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX )
                 , uno::makeAny(BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aResult )) );
         }
 {
     adjustAspectRatio3d( rAvailableSize );
 
-    //calculate correct 2d dimensions for getting a correct initial 2D aspect ratio
-    E3dScene* pScene = lcl_getE3dScene( m_xOuterGroupShape );
-    pScene->CorrectSceneDimensions();
-
     //do not change aspect ratio of 3D scene with 2D bound rect
     m_aCurrentSizeWithoutAxes = ShapeFactory::calculateNewSizeRespectingAspectRatio(
                     rAvailableSize, m_xOuterGroupShape->getSize() );

File drawinglayer/inc/drawinglayer/attribute/materialattribute3d.hxx

 //////////////////////////////////////////////////////////////////////////////
 // predefines
 
-namespace drawinglayer { namespace {
+namespace drawinglayer { namespace attribute {
 	class ImpMaterialAttribute3D;
 }}
 

File drawinglayer/inc/drawinglayer/geometry/viewinformation2d.hxx

 //////////////////////////////////////////////////////////////////////////////
 // predefines
 
-namespace drawinglayer { namespace {
+namespace drawinglayer { namespace geometry {
 	class ImpViewInformation2D;
 }}
 

File drawinglayer/inc/drawinglayer/geometry/viewinformation3d.hxx

 //////////////////////////////////////////////////////////////////////////////
 // predefines
 
-namespace drawinglayer { namespace {
+namespace drawinglayer { namespace geometry {
 	class ImpViewInformation3D;
 }}
 

File drawinglayer/inc/drawinglayer/primitive2d/animatedprimitive2d.hxx

 
 namespace drawinglayer
 {
-	namespace
+	namespace primitive2d
 	{
 		class BufferedMatrixDecompose
 		{

File drawinglayer/inc/drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx

 #define PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D			(PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 15)
 #define PRIMITIVE3D_ID_ALPHATEXTUREPRIMITIVE3D			(PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 16)
 #define PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D				(PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 17)
+#define PRIMITIVE3D_ID_HITTESTPRIMITIVE3D				(PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 18)
 
 //////////////////////////////////////////////////////////////////////////////
 

File drawinglayer/inc/drawinglayer/primitive3d/hittestprimitive3d.hxx

+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: hittestprimitive3d.hxx,v $
+ *
+ *  $Revision: 1.1.2.1 $
+ *
+ *  last change: $Author: aw $ $Date: 2008/09/24 14:27:39 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License version 2.1, as published by the Free Software Foundation.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Lesser General Public License for more details.
+ *
+ *    You should have received a copy of the GNU Lesser General Public
+ *    License along with this library; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HITTESTPRIMITIVE3D_HXX
+#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HITTESTPRIMITIVE3D_HXX
+
+#include <drawinglayer/primitive3d/groupprimitive3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+	namespace primitive3d
+	{
+		// This primitive is used to represent geometry for non-visible objects,
+		// e.g. a 3D cube without fill attributes. To still be able to use 
+		// primitives for HitTest functionality, the 3d decompositions produce 
+		// an as much as possible simplified fill geometry encapsulated in this 
+		// primtive when there is no fill geometry. Currently, the 3d hit test
+		// uses only areas, so maybe in a further enchanced version this will change
+		// to 'if neither filled nor lines' creation criteria. The whole primitive
+		// decomposes to nothing, so no one not knowing it will be influenced. Only
+		// helper processors for hit test (and maybe BoundRect extractors) will
+		// use it and it's children subcontent.
+		class HitTestPrimitive3D : public GroupPrimitive3D
+		{
+		protected:
+			// local decomposition. Implementation will return empty Primitive3DSequence
+			// since this is no visualisation data
+			virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
+
+		public:
+			HitTestPrimitive3D(const Primitive3DSequence& rChildren);
+
+			// despite returning an empty decomposition since it's no visualisation data, 
+			// range calculation is intended to use invisible replacement geometry, so
+			// the local implementation will return the children's range
+			virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const;
+
+			// provide unique ID
+			DeclPrimitrive3DIDBlock()
+		};
+	} // end of namespace primitive3d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HITTESTPRIMITIVE3D_HXX
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

File drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx

 #include <com/sun/star/rendering/RenderState.hpp>
 #include <i18npool/lang.h>
 #include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <vcl/mapmod.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // forward declaration
     class XPolyPolygon2D;
 }}}}
 
+namespace drawinglayer { namespace primitive2d {
+    class MaskPrimitive2D;
+    class MetafilePrimitive2D;
+    class TextSimplePortionPrimitive2D;
+    class BitmapPrimitive2D;
+    class AlphaPrimitive2D;
+    class PolygonStrokePrimitive2D;
+    class FillBitmapPrimitive2D;
+    class UnifiedAlphaPrimitive2D;
+}}
+
 //////////////////////////////////////////////////////////////////////////////
 
 namespace drawinglayer
 		class canvasProcessor2D : public BaseProcessor2D
 		{
 		private:
-            // the destination canvas   
+			// The Pixel renderer resets the original MapMode from the OutputDevice.
+			// For some situations it is necessary to get it again, so it is rescued here
+			MapMode								                    maOriginalMapMode;
+            
+            // the (current) destination OutDev and canvas
+			OutputDevice*											mpOutputDevice;
             com::sun::star::uno::Reference< com::sun::star::rendering::XCanvas >	mxCanvas;
 			com::sun::star::rendering::ViewState                    maViewState;
             com::sun::star::rendering::RenderState                  maRenderState;
 			// SvtOptionsDrawinglayer incarnation to react on diverse settings
             const SvtOptionsDrawinglayer							maDrawinglayerOpt;
 
-            // the current clipping PolyPolygon from MaskPrimitive2D
+            // the current clipping PolyPolygon from MaskPrimitive2D, always in
+            // object coordinates
             basegfx::B2DPolyPolygon                                 maClipPolyPolygon;
 
             // determined LanguageType
 			// virtual render method when the primitive implementation is BasePrimitive2D-based.
 			virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
 
-		public:
+            // direct primitive renderer support
+            void impRenderMaskPrimitive2D(const primitive2d::MaskPrimitive2D& rMaskCandidate);
+            void impRenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate);
+            void impRenderTextSimplePortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate);
+            void impRenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate);
+            void impRenderAlphaPrimitive2D(const primitive2d::AlphaPrimitive2D& rAlphaCandidate);
+            void impRenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive);
+            void impRenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapPrimitive2D);
+            void impRenderUnifiedAlphaPrimitive2D(const primitive2d::UnifiedAlphaPrimitive2D& rUniAlphaCandidate);
+        
+        public:
 			canvasProcessor2D(
 				const geometry::ViewInformation2D& rViewInformation, 
-				const com::sun::star::uno::Reference< com::sun::star::rendering::XCanvas >& rCanvas);
+                OutputDevice& rOutDev);
 			virtual ~canvasProcessor2D();
 
 			// access to Drawinglayer configuration options

File drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx

 	class MarkerArrayPrimitive2D;
 	class PointArrayPrimitive2D;
 	class ModifiedColorPrimitive2D;
-    class WrongSpellPrimitive2D;
 	class PolygonStrokePrimitive2D;
 	class ControlPrimitive2D;
 	class PagePreviewPrimitive2D;
-	class ChartPrimitive2D;
 }}
 
 //////////////////////////////////////////////////////////////////////////////
     		void RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate);
 			void RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate);
 			void RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate);
-			void RenderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate);
 			void RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate);
-			void RenderChartPrimitive2D(const primitive2d::ChartPrimitive2D& rChartCandidate);
 
 			/////////////////////////////////////////////////////////////////////////////
 			// DrawMode adaption support

File drawinglayer/prj/d.lst

 ..\inc\drawinglayer\primitive3d\baseprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\baseprimitive3d.hxx
 ..\inc\drawinglayer\primitive3d\groupprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\groupprimitive3d.hxx
 ..\inc\drawinglayer\primitive3d\hatchtextureprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\hatchtextureprimitive3d.hxx
+..\inc\drawinglayer\primitive3d\hittestprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\hittestprimitive3d.hxx
 ..\inc\drawinglayer\primitive3d\modifiedcolorprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\modifiedcolorprimitive3d.hxx
 ..\inc\drawinglayer\primitive3d\polygonprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\polygonprimitive3d.hxx
 ..\inc\drawinglayer\primitive3d\polygontubeprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\polygontubeprimitive3d.hxx