[Libreoffice-commits] .: basegfx/source

2012-02-15 Thread Thorsten Behrens
 basegfx/source/tools/unotools.cxx |  113 +++---
 1 file changed, 58 insertions(+), 55 deletions(-)

New commits:
commit d37abad97d72bae0fd0269de12e94c7a7d3fd7e1
Author: Thorsten Behrens tbehr...@suse.com
Date:   Wed Feb 15 11:25:57 2012 +0100

Fix fdo#45779 - accessing empty polygon.

Guard access to first polygon point.

diff --git a/basegfx/source/tools/unotools.cxx 
b/basegfx/source/tools/unotools.cxx
index 63b0f4e..6febfd3 100644
--- a/basegfx/source/tools/unotools.cxx
+++ b/basegfx/source/tools/unotools.cxx
@@ -187,70 +187,73 @@ namespace unotools
 std::vectorawt::Point aPoints; aPoints.reserve(nLoopCount);
 std::vectordrawing::PolygonFlags aFlags; 
aFlags.reserve(nLoopCount);
 
-// prepare insert index and current point
-basegfx::B2DCubicBezier aBezier;
-aBezier.setStartPoint(rPoly.getB2DPoint(0));
-
-for(sal_uInt32 b(0L); bnLoopCount; b++)
+if( nCount )
 {
-// add current point (always) and remember StartPointIndex for 
evtl. later corrections
-const awt::Point 
aStartPoint(fround(aBezier.getStartPoint().getX()),
- 
fround(aBezier.getStartPoint().getY()));
-const sal_uInt32 nStartPointIndex(aPoints.size());
-aPoints.push_back(aStartPoint);
-aFlags.push_back(drawing::PolygonFlags_NORMAL);
-
-// prepare next segment
-const sal_uInt32 nNextIndex((b + 1) % nCount);
-aBezier.setEndPoint(rPoly.getB2DPoint(nNextIndex));
-aBezier.setControlPointA(rPoly.getNextControlPoint(b));
-
aBezier.setControlPointB(rPoly.getPrevControlPoint(nNextIndex));
-
-if(aBezier.isBezier())
-{
-// if one is used, add always two control points due to 
the old schema
-aPoints.push_back( 
awt::Point(fround(aBezier.getControlPointA().getX()),
-  
fround(aBezier.getControlPointA().getY())) );
-aFlags.push_back(drawing::PolygonFlags_CONTROL);
-
-aPoints.push_back( 
awt::Point(fround(aBezier.getControlPointB().getX()),
-  
fround(aBezier.getControlPointB().getY())) );
-aFlags.push_back(drawing::PolygonFlags_CONTROL);
-}
+// prepare insert index and current point
+basegfx::B2DCubicBezier aBezier;
+aBezier.setStartPoint(rPoly.getB2DPoint(0));
 
-// test continuity with previous control point to set flag 
value
-if(aBezier.getControlPointA() != aBezier.getStartPoint()  
(bClosed || b))
+for(sal_uInt32 b(0L); bnLoopCount; b++)
 {
-const basegfx::B2VectorContinuity 
eCont(rPoly.getContinuityInPoint(b));
-
-if(basegfx::CONTINUITY_C1 == eCont)
+// add current point (always) and remember StartPointIndex 
for evtl. later corrections
+const awt::Point 
aStartPoint(fround(aBezier.getStartPoint().getX()),
+ 
fround(aBezier.getStartPoint().getY()));
+const sal_uInt32 nStartPointIndex(aPoints.size());
+aPoints.push_back(aStartPoint);
+aFlags.push_back(drawing::PolygonFlags_NORMAL);
+
+// prepare next segment
+const sal_uInt32 nNextIndex((b + 1) % nCount);
+aBezier.setEndPoint(rPoly.getB2DPoint(nNextIndex));
+aBezier.setControlPointA(rPoly.getNextControlPoint(b));
+
aBezier.setControlPointB(rPoly.getPrevControlPoint(nNextIndex));
+
+if(aBezier.isBezier())
 {
-aFlags[nStartPointIndex] = 
drawing::PolygonFlags_SMOOTH;
+// if one is used, add always two control points due 
to the old schema
+aPoints.push_back( 
awt::Point(fround(aBezier.getControlPointA().getX()),
+  
fround(aBezier.getControlPointA().getY())) );
+aFlags.push_back(drawing::PolygonFlags_CONTROL);
+
+aPoints.push_back( 
awt::Point(fround(aBezier.getControlPointB().getX()),
+  
fround(aBezier.getControlPointB().getY())) );
+aFlags.push_back(drawing::PolygonFlags_CONTROL);
 }
-else if(basegfx::CONTINUITY_C2 == eCont)
+
+// test continuity with previous control point to set flag 
value
+if(aBezier.getControlPointA() != aBezier.getStartPoint() 
 (bClosed || b))
 

[Libreoffice-commits] .: basegfx/source

2012-02-06 Thread Jan Holesovsky
 basegfx/source/tools/zoomtools.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 4db617efd924ad7ff4ce6988771ad36612c329ec
Author: Jan Holesovsky ke...@suse.cz
Date:   Mon Feb 6 16:12:40 2012 +0100

Change the zoom factor to 2^(1/6), hopefully it fits all :-)

diff --git a/basegfx/source/tools/zoomtools.cxx 
b/basegfx/source/tools/zoomtools.cxx
index c6c8044..89ea0cc 100644
--- a/basegfx/source/tools/zoomtools.cxx
+++ b/basegfx/source/tools/zoomtools.cxx
@@ -33,12 +33,12 @@ namespace basegfx
 namespace zoomtools
 {
 
-/** 2^(1/4) as the default step
+/** 2^(1/6) as the default step
 
-This ensures (unless the rounding is used) that 4 steps lead
+This ensures (unless the rounding is used) that 6 steps lead
 to double / half zoom level.
 */
-const double ZOOM_FACTOR = 1.1892071150027210667175;
+const double ZOOM_FACTOR = 1.12246205;
 
 /**
 * Round a value against a specified multiple. Values below half
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: basegfx/source basegfx/test

2012-01-18 Thread Kohei Yoshida
 basegfx/source/matrix/b2dhommatrix.cxx |8 
 basegfx/test/basegfx2d.cxx |   17 +
 2 files changed, 25 insertions(+)

New commits:
commit 800806ba850c7fd03e37acb011fa993e08cb8fc8
Author: Thorsten Behrens tbehr...@suse.com
Date:   Wed Jan 18 14:52:20 2012 -0500

decompose() should return the original rotation angle and scales.

decompose() would return incorrect rotation angle and scales when the
angle was exactly 180 degrees, due to FPU rounding error.  This commit
fixes it.

This problem would manifest itself when inserting an image into
Calc/Draw, cropping it, and flipping it vertically or rotating it
at exactly 180 degrees.  Before the fix the image would simply disappear.

diff --git a/basegfx/source/matrix/b2dhommatrix.cxx 
b/basegfx/source/matrix/b2dhommatrix.cxx
index 942f313..8538d22 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -289,6 +289,14 @@ namespace basegfx
 // no rotation and shear, copy scale values
 rScale.setX(get(0, 0));
 rScale.setY(get(1, 1));
+
+// or is there?
+if( rScale.getX()  0  rScale.getY()  0 )
+{
+// there is - 180 degree rotated
+rScale *= -1;
+rRotate = 180*F_PI180;
+}
 }
 else
 {
diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx
index 65f778f..0f0c9c7 100644
--- a/basegfx/test/basegfx2d.cxx
+++ b/basegfx/test/basegfx2d.cxx
@@ -36,6 +36,7 @@
 #include cppunit/extensions/HelperMacros.h
 
 #include basegfx/matrix/b2dhommatrix.hxx
+#include basegfx/matrix/b2dhommatrixtools.hxx
 #include basegfx/polygon/b2dpolygon.hxx
 #include basegfx/polygon/b2dpolygontools.hxx
 #include basegfx/curve/b2dcubicbezier.hxx
@@ -666,6 +667,22 @@ public:
 CPPUNIT_ASSERT_MESSAGE(decompose: error test I2, 
impDecomposeComposeTest(-fSX, fSY, tan(-fS), -fR));
 CPPUNIT_ASSERT_MESSAGE(decompose: error test I3, 
impDecomposeComposeTest(fSX, -fSY, tan(-fS), -fR));
 CPPUNIT_ASSERT_MESSAGE(decompose: error test I4, 
impDecomposeComposeTest(-fSX, -fSY, tan(-fS), -fR));
+
+// cover special case of 180 degree rotation
+B2DHomMatrix aTest=tools::createScaleShearXRotateTranslateB2DHomMatrix(
+6425,3938,
+0,
+180*F_PI180,
+10482,4921);
+// decompose that matrix
+B2DTuple aDScale;
+B2DTuple aDTrans;
+double fDRot;
+double fDShX;
+aTest.decompose(aDScale, aDTrans, fDRot, fDShX);
+CPPUNIT_ASSERT_MESSAGE(decompose: error test J1, aDScale.getX() == 
6425  aDScale.getY() == 3938);
+CPPUNIT_ASSERT_MESSAGE(decompose: error test J1, aDTrans.getX() == 
10482  aDTrans.getY() == 4921);
+CPPUNIT_ASSERT_MESSAGE(decompose: error test J1, fDRot == 
180*F_PI180);
 }
 
 // Change the following lines only, if you add, remove or rename
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: basegfx/source

2012-01-06 Thread Julien Nabet
 basegfx/source/polygon/b2dpolypolygoncutter.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 66fd9a610cd876c236486a2089d8d58dca866e25
Author: Julien Nabet serval2...@yahoo.fr
Date:   Fri Jan 6 18:57:39 2012 +0100

Fix Same expression on both sides of '' (reported by cppcheck)

diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx 
b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
index d32ee87..8745241 100644
--- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx
+++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
@@ -282,7 +282,7 @@ namespace basegfx
 bOnEdge = false;
 }
 }
-while(bOnEdge  pPNa2 != rPNa  pPNa2 != rPNa);
+while(bOnEdge  pPNa2 != rPNa  pPNb2 != rPNb);
 
 if(bOnEdge)
 {
@@ -408,7 +408,7 @@ namespace basegfx
 bOnEdge = false;
 }
 }
-while(bOnEdge  pPNa2 != rPNa  pPNa2 != rPNa);
+while(bOnEdge  pPNa2 != rPNa  pPNb2 != rPNb);
 
 if(bOnEdge)
 {
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: basegfx/source chart2/source connectivity/source dbaccess/source oox/source registry/source sal/rtl scaddins/source sc/source sdext/source svl/source tools/source vcl/unx xmlo

2011-12-01 Thread Thorsten Behrens
 basegfx/source/polygon/b2dsvgpolypolygon.cxx|4 +--
 chart2/source/tools/TitleHelper.cxx |2 -
 chart2/source/view/main/ShapeFactory.cxx|3 --
 connectivity/source/parse/sqlnode.cxx   |   12 -
 dbaccess/source/filter/xml/xmlExport.cxx|4 +--
 oox/source/xls/worksheetbuffer.cxx  |2 -
 registry/source/keyimpl.cxx |2 -
 sal/rtl/source/uri.cxx  |2 -
 sc/source/ui/Accessibility/AccessibleCsvControl.cxx |6 ++--
 scaddins/source/datefunc/datefunc.cxx   |2 -
 sdext/source/pdfimport/tree/writertreevisiting.cxx  |7 +++--
 svl/source/misc/urihelper.cxx   |2 -
 tools/source/fsys/urlobj.cxx|   13 --
 vcl/unx/x11/x11sys.cxx  |4 +--
 xmloff/source/style/xmlnumfi.cxx|   26 ++--
 15 files changed, 45 insertions(+), 46 deletions(-)

New commits:
commit 443a7229f96806e6bbece775cc7cd643e1c4a042
Author: August Sodora aug...@gmail.com
Date:   Mon Nov 28 21:44:30 2011 -0500

Remove uses of charAt

diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx 
b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
index 931c344..7a34219 100644
--- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
@@ -190,9 +190,9 @@ namespace basegfx
 fValue -= fOldValue;
 
 const sal_Int32 aLen( rStr.getLength() );
-if(aLen)
+if(aLen  0)
 {
-if( lcl_isOnNumberChar(rStr.charAt(aLen - 1), false) 
+if( lcl_isOnNumberChar(rStr[aLen - 1], false) 
 fValue = 0.0 )
 {
 rStr.append( sal_Unicode(' ') );
diff --git a/chart2/source/tools/TitleHelper.cxx 
b/chart2/source/tools/TitleHelper.cxx
index 09a4b18..7a7a6ae 100644
--- a/chart2/source/tools/TitleHelper.cxx
+++ b/chart2/source/tools/TitleHelper.cxx
@@ -285,7 +285,7 @@ void TitleHelper::setCompleteString( const rtl::OUString 
rNewText
 sal_Int32 nLen = rNewText.getLength();
 for( sal_Int32 nPos = 0; nPos  nLen; ++nPos )
 {
-sal_Unicode aChar = aSource.charAt( nPos );
+sal_Unicode aChar = aSource[nPos];
 if( aChar != '\n' )
 {
 aUnstackedStr.append( aChar );
diff --git a/chart2/source/view/main/ShapeFactory.cxx 
b/chart2/source/view/main/ShapeFactory.cxx
index 40f2536..e6ba468 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -2245,7 +2245,6 @@ rtl::OUString ShapeFactory::getStackedString( const 
rtl::OUString rString, bool
 return rString;
 
 rtl::OUStringBuffer aStackStr;
-rtl::OUStringBuffer aSource(rString);
 
 //add a newline after each letter
 //as we do not no letters here add a newline after each char
@@ -2253,7 +2252,7 @@ rtl::OUString ShapeFactory::getStackedString( const 
rtl::OUString rString, bool
 {
 if( nPosSrc )
 aStackStr.append( sal_Unicode('\r') );
-aStackStr.append( aSource.charAt( nPosSrc ) );
+aStackStr.append(rString[nPosSrc]);
 }
 return aStackStr.makeStringAndClear();
 }
diff --git a/connectivity/source/parse/sqlnode.cxx 
b/connectivity/source/parse/sqlnode.cxx
index 5571bb6..dfc3796 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -2464,15 +2464,15 @@ void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer 
rString, const SQLParseNode
 
rString.append(SetQuotation(m_aNodeValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\')),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\'\';
 break;
 case SQL_NODE_NAME:
-if (rString.getLength())
+if (rString.getLength()  0)
 {
-switch(rString.charAt(rString.getLength()-1) )
+switch(rString[rString.getLength()-1])
 {
 case ' ' :
 case '.' : break;
 default  :
 if  (   
!rParam.aMetaData.getCatalogSeparator().getLength()
-||  rString.charAt( rString.getLength()-1 ) != 
rParam.aMetaData.getCatalogSeparator().toChar()
+|| rString[rString.getLength() - 1] != 
rParam.aMetaData.getCatalogSeparator().toChar()
 )
 rString.appendAscii( ); break;
 }
@@ -2520,15 +2520,15 @@ void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer 
rString, const SQLParseNode
 }
 // fall through
 default:
-if (rString.getLength()  m_aNodeValue.toChar() != '.'  
m_aNodeValue.toChar() != ':' )
+if