incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1232392 - in /incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon: b3dpolygontools.cxx b3dpolypolygontools.cxx
Date Tue, 17 Jan 2012 11:48:51 GMT
Author: alg
Date: Tue Jan 17 11:48:51 2012
New Revision: 1232392

URL: http://svn.apache.org/viewvc?rev=1232392&view=rev
Log:
#118805# Secured applyLineDashing for zero length edges, secured createUnitSphereFillPolyPolygon
for too big values of hor/ver segments

Modified:
    incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolygontools.cxx
    incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolypolygontools.cxx

Modified: incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolygontools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolygontools.cxx?rev=1232392&r1=1232391&r2=1232392&view=diff
==============================================================================
--- incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolygontools.cxx (original)
+++ incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolygontools.cxx Tue
Jan 17 11:48:51 2012
@@ -407,68 +407,71 @@ namespace basegfx
                 sal_uInt32 nDotDashIndex(0);
                 bool bIsLine(true);
                 double fDotDashMovingLength(rDotDashArray[0]);
-				B3DPolygon aSnippet;
+                B3DPolygon aSnippet;
 
-				// iterate over all edges
+                // iterate over all edges
                 for(sal_uInt32 a(0); a < nEdgeCount; a++)
                 {
                     // update current edge
-					double fLastDotDashMovingLength(0.0);
+                    double fLastDotDashMovingLength(0.0);
                     const sal_uInt32 nNextIndex((a + 1) % nPointCount);
-					const B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
-					const double fEdgeLength(B3DVector(aNextPoint - aCurrentPoint).getLength());
+                    const B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
+                    const double fEdgeLength(B3DVector(aNextPoint - aCurrentPoint).getLength());
 
-					while(fTools::less(fDotDashMovingLength, fEdgeLength))
-					{
-						// new split is inside edge, create and append snippet [fLastDotDashMovingLength, fDotDashMovingLength]
-						const bool bHandleLine(bIsLine && pLineTarget);
-						const bool bHandleGap(!bIsLine && pGapTarget);
+                    if(!fTools::equalZero(fEdgeLength))
+                    {
+                        while(fTools::less(fDotDashMovingLength, fEdgeLength))
+                        {
+                            // new split is inside edge, create and append snippet [fLastDotDashMovingLength,
fDotDashMovingLength]
+                            const bool bHandleLine(bIsLine && pLineTarget);
+                            const bool bHandleGap(!bIsLine && pGapTarget);
+                            
+                            if(bHandleLine || bHandleGap)
+                            {
+                                if(!aSnippet.count())
+                                {
+                                    aSnippet.append(interpolate(aCurrentPoint, aNextPoint,
fLastDotDashMovingLength / fEdgeLength));
+                                }
+
+                                aSnippet.append(interpolate(aCurrentPoint, aNextPoint, fDotDashMovingLength
/ fEdgeLength));
+
+                                if(bHandleLine)
+                                {
+                                    pLineTarget->append(aSnippet);
+                                }
+                                else
+                                {
+                                    pGapTarget->append(aSnippet);
+                                }
+
+                                aSnippet.clear();
+                            }
+
+                            // prepare next DotDashArray step and flip line/gap flag
+                            fLastDotDashMovingLength = fDotDashMovingLength;
+                            fDotDashMovingLength += rDotDashArray[(++nDotDashIndex) % nDotDashCount];
+                            bIsLine = !bIsLine;
+                        }
 
+                        // append snippet [fLastDotDashMovingLength, fEdgeLength]
+                        const bool bHandleLine(bIsLine && pLineTarget);
+                        const bool bHandleGap(!bIsLine && pGapTarget);
+                                       
                         if(bHandleLine || bHandleGap)
                         {
-							if(!aSnippet.count())
-							{
-								aSnippet.append(interpolate(aCurrentPoint, aNextPoint, fLastDotDashMovingLength /
fEdgeLength));
-							}
+                            if(!aSnippet.count())
+                            {
+                                aSnippet.append(interpolate(aCurrentPoint, aNextPoint, fLastDotDashMovingLength
/ fEdgeLength));
+                            }
 
-							aSnippet.append(interpolate(aCurrentPoint, aNextPoint, fDotDashMovingLength / fEdgeLength));
-
-							if(bHandleLine)
-							{
-								pLineTarget->append(aSnippet);
-							}
-							else
-							{
-								pGapTarget->append(aSnippet);
-							}
-
-							aSnippet.clear();
-						}
-						
-						// prepare next DotDashArray step and flip line/gap flag
-						fLastDotDashMovingLength = fDotDashMovingLength;
-                        fDotDashMovingLength += rDotDashArray[(++nDotDashIndex) % nDotDashCount];
-                        bIsLine = !bIsLine;
-					}
+                            aSnippet.append(aNextPoint);
+                        }
 
-					// append snippet [fLastDotDashMovingLength, fEdgeLength]
-					const bool bHandleLine(bIsLine && pLineTarget);
-					const bool bHandleGap(!bIsLine && pGapTarget);
-                    
-					if(bHandleLine || bHandleGap)
-                    {
-						if(!aSnippet.count())
-						{
-							aSnippet.append(interpolate(aCurrentPoint, aNextPoint, fLastDotDashMovingLength /
fEdgeLength));
-						}
+                        // prepare move to next edge
+                        fDotDashMovingLength -= fEdgeLength;
+                    }
 
-						aSnippet.append(aNextPoint);
-					}
-					
-					// prepare move to next edge
-					fDotDashMovingLength -= fEdgeLength;
-					
-					// prepare next edge step (end point gets new start point)
+                    // prepare next edge step (end point gets new start point)
                     aCurrentPoint = aNextPoint;
                 }
 

Modified: incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolypolygontools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolypolygontools.cxx?rev=1232392&r1=1232391&r2=1232392&view=diff
==============================================================================
--- incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolypolygontools.cxx
(original)
+++ incubator/ooo/branches/alg/linecap/main/basegfx/source/polygon/b3dpolypolygontools.cxx
Tue Jan 17 11:48:51 2012
@@ -34,6 +34,11 @@
 #include <osl/mutex.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
+// predefines
+#define nMinSegments sal_uInt32(1)
+#define nMaxSegments sal_uInt32(512)
+
+//////////////////////////////////////////////////////////////////////////////
 
 namespace basegfx
 {
@@ -268,20 +273,16 @@ namespace basegfx
 				nHorSeg = fround(fabs(fHorStop - fHorStart) / (F_2PI / 24.0));
 			}
 
-			if(!nHorSeg)
-			{
-				nHorSeg = 1L;
-			}
+            // min/max limitations
+            nHorSeg = ::std::min(nMaxSegments, ::std::max(nMinSegments, nHorSeg));
 
 			if(!nVerSeg)
 			{
 				nVerSeg = fround(fabs(fVerStop - fVerStart) / (F_2PI / 24.0));
 			}
 
-			if(!nVerSeg)
-			{
-				nVerSeg = 1L;
-			}
+            // min/max limitations
+            nVerSeg = ::std::min(nMaxSegments, ::std::max(nMinSegments, nVerSeg));
 
 			// create constants
 			const double fVerDiffPerStep((fVerStop - fVerStart) / (double)nVerSeg);
@@ -371,20 +372,16 @@ namespace basegfx
 				nHorSeg = fround(fabs(fHorStop - fHorStart) / (F_2PI / 24.0));
 			}
 
-			if(!nHorSeg)
-			{
-				nHorSeg = 1L;
-			}
+            // min/max limitations
+            nHorSeg = ::std::min(nMaxSegments, ::std::max(nMinSegments, nHorSeg));
 
 			if(!nVerSeg)
 			{
 				nVerSeg = fround(fabs(fVerStop - fVerStart) / (F_2PI / 24.0));
 			}
 
-			if(!nVerSeg)
-			{
-				nVerSeg = 1L;
-			}
+            // min/max limitations
+            nVerSeg = ::std::min(nMaxSegments, ::std::max(nMinSegments, nVerSeg));
 
 			// vertical loop
 			for(sal_uInt32 a(0L); a < nVerSeg; a++)



Mime
View raw message