summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-08-02 12:55:37 +0000
committerArmin Le Grand <alg@apache.org>2013-08-02 12:55:37 +0000
commitd9804cd7c4f01ac54dc5947bfefea2bc0296b414 (patch)
tree9a361b10acd895da11556f028bfc061164aecb3c
parent269719ba0422aaf8f49cf3d579972ef2070716be (diff)
corrected first PolyPolygon handling stuff in xmloff
-rw-r--r--basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx11
-rw-r--r--basegfx/source/matrix/b2dhommatrixtools.cxx23
-rw-r--r--svgio/source/svgreader/svgpolynode.cxx2
-rw-r--r--svx/source/svdraw/svdopath.cxx52
-rw-r--r--xmloff/source/draw/shapeexport2.cxx12
-rw-r--r--xmloff/source/draw/xexptran.cxx15
-rw-r--r--xmloff/source/draw/ximpshap.cxx3
7 files changed, 78 insertions, 40 deletions
diff --git a/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx b/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx
index b718896313e8..24b77edb7c10 100644
--- a/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx
+++ b/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx
@@ -187,10 +187,10 @@ namespace basegfx
class B2DHomMatrixBufferedDecompose
{
private:
- B2DVector maScale;
+ B2DVector maScale;
B2DPoint maTranslate;
- double mfRotate;
- double mfShearX;
+ double mfRotate;
+ double mfShearX;
public:
B2DHomMatrixBufferedDecompose(const B2DHomMatrix& rB2DHomMatrix = B2DHomMatrix())
@@ -236,12 +236,13 @@ namespace basegfx
bool mbDecomposed : 1;
bool mbCombined : 1;
+ void impDecompose();
+
void impCheckDecompose()
{
if(!mbDecomposed)
{
- maB2DHomMatrix.decompose(maScale, maTranslate, mfRotate, mfShearX);
- mbDecomposed = true;
+ impDecompose();
}
}
diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx b/basegfx/source/matrix/b2dhommatrixtools.cxx
index 900430da2799..fbbab06822ce 100644
--- a/basegfx/source/matrix/b2dhommatrixtools.cxx
+++ b/basegfx/source/matrix/b2dhommatrixtools.cxx
@@ -515,4 +515,27 @@ namespace basegfx
} // end of namespace basegfx
///////////////////////////////////////////////////////////////////////////////
+
+namespace basegfx
+{
+ namespace tools
+ {
+ void B2DHomMatrixBufferedOnDemandDecompose::impDecompose()
+ {
+ maB2DHomMatrix.decompose(maScale, maTranslate, mfRotate, mfShearX);
+
+ if(maScale.getX() < 0.0 && maScale.getY() < 0.0)
+ {
+ // mirrored in X and Y, same as rotated by 180 degrees; prefer rotation
+ maScale.setX(-maScale.getX());
+ maScale.setY(-maScale.getY());
+ mfRotate = fmod(mfRotate + F_PI, F_2PI);
+ }
+
+ mbDecomposed = true;
+ }
+ } // end of namespace tools
+} // end of namespace basegfx
+
+///////////////////////////////////////////////////////////////////////////////
// eof
diff --git a/svgio/source/svgreader/svgpolynode.cxx b/svgio/source/svgreader/svgpolynode.cxx
index a218c0da5acb..deb2ae07a944 100644
--- a/svgio/source/svgreader/svgpolynode.cxx
+++ b/svgio/source/svgreader/svgpolynode.cxx
@@ -24,7 +24,7 @@
#include <svgio/svgreader/svgpolynode.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
//////////////////////////////////////////////////////////////////////////////
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index ea25c0221b2c..04f10ab7f331 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1627,9 +1627,31 @@ void SdrPathObj::impSetPathPolyPolygonWithTransformationAdaption(const basegfx::
return;
}
- static bool bRsetCoordinateSystemAfterWasLine(true);
+ // remember if this was a line before geometry change
+ static bool bResetCoordinateSystemAfterWasLine(true);
+ const bool bWasLineAndReset(bResetCoordinateSystemAfterWasLine && isLine());
- if(bRsetCoordinateSystemAfterWasLine && isLine())
+ // in all other cases, set new geometry
+ maPathPolyPolygon = rNew;
+
+ if(isLine())
+ {
+ // new geometry is a non-curved line, create unit transformation so that (0,0) is
+ // 1st point and (1,0) is 2nd point
+ const basegfx::B2DPoint aPointA(rNew.getB2DPolygon(0).getB2DPoint(0));
+ const basegfx::B2DPoint aPointB(rNew.getB2DPolygon(0).getB2DPoint(1));
+ const basegfx::B2DVector aDelta(aPointB - aPointA);
+
+ maSdrObjectTransformation.setB2DHomMatrix(
+ basegfx::tools::createScaleRotateTranslateB2DHomMatrix(
+ basegfx::B2DTuple(aDelta.getLength(), 1.0),
+ atan2(aDelta.getY(), aDelta.getX()),
+ aPointA));
+ return;
+ }
+
+
+ if(bWasLineAndReset)
{
// the SdrPathObj has two basic states, line and other. Line is for two points
// and no bezier, it uses a specialized geometry (unified line from 0.0, to 1.0)
@@ -1646,10 +1668,9 @@ void SdrPathObj::impSetPathPolyPolygonWithTransformationAdaption(const basegfx::
// For this reason this is disabled and the old behaviour activated by adding this
// case to esp. change back to the most trivial transformation in the transition
// between line status and other. To try out the also possible new alternative,
- // change the value of bRsetCoordinateSystemAfterWasLine to false.
+ // change the value of bResetCoordinateSystemAfterWasLine to false.
const basegfx::B2DRange aRangeNewGeometry(rNew.getB2DRange());
- maPathPolyPolygon = rNew;
maSdrObjectTransformation.setB2DHomMatrix(
basegfx::tools::createScaleTranslateB2DHomMatrix(
aRangeNewGeometry.getRange(),
@@ -1657,27 +1678,6 @@ void SdrPathObj::impSetPathPolyPolygonWithTransformationAdaption(const basegfx::
return;
}
- // set new geometry
- maPathPolyPolygon = rNew;
-
- if(!rNew.areControlPointsUsed()
- && 1 == rNew.count()
- && 2 == rNew.getB2DPolygon(0).count())
- {
- // new geometry is a non-curved line, create unit transformation so that (0,0) is
- // 1st point and (1,0) is 2nd point
- const basegfx::B2DPoint aPointA(rNew.getB2DPolygon(0).getB2DPoint(0));
- const basegfx::B2DPoint aPointB(rNew.getB2DPolygon(0).getB2DPoint(1));
- const basegfx::B2DVector aDelta(aPointB - aPointA);
-
- maSdrObjectTransformation.setB2DHomMatrix(
- basegfx::tools::createScaleRotateTranslateB2DHomMatrix(
- basegfx::B2DTuple(aDelta.getLength(), 1.0),
- atan2(aDelta.getY(), aDelta.getX()),
- aPointA));
- return;
- }
-
// get range of the target geometry
const basegfx::B2DRange aRangeNewGeometry(rNew.getB2DRange());
@@ -2167,7 +2167,7 @@ SdrPathObjType SdrPathObj::getSdrPathObjType() const
}
}
- // default
+ // default; unreachable but safe
return PathType_Line;
}
diff --git a/xmloff/source/draw/shapeexport2.cxx b/xmloff/source/draw/shapeexport2.cxx
index be1c3584d991..5fbd9c1748ea 100644
--- a/xmloff/source/draw/shapeexport2.cxx
+++ b/xmloff/source/draw/shapeexport2.cxx
@@ -161,12 +161,14 @@ void XMLShapeExport::ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple& rTR
}
// write positive svg:width
- mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(aTRScale.getX()));
+ mrExport.GetMM100UnitConverter().convertDouble(sStringBuffer, aTRScale.getX(), true);
+ //mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(aTRScale.getX()));
aStr = sStringBuffer.makeStringAndClear();
mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStr);
// write positive svg:height
- mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(aTRScale.getY()));
+ mrExport.GetMM100UnitConverter().convertDouble(sStringBuffer, aTRScale.getY(), true);
+ //mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(aTRScale.getY()));
aStr = sStringBuffer.makeStringAndClear();
mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStr);
@@ -232,7 +234,8 @@ void XMLShapeExport::ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple& rTR
if(nFeatures & SEF_EXPORT_X)
{
// svg: x
- mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(rTRTranslate.getX()));
+ mrExport.GetMM100UnitConverter().convertDouble(sStringBuffer, rTRTranslate.getX(), true);
+ //mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(rTRTranslate.getX()));
aStr = sStringBuffer.makeStringAndClear();
mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X, aStr);
}
@@ -240,7 +243,8 @@ void XMLShapeExport::ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple& rTR
if(nFeatures & SEF_EXPORT_Y)
{
// svg: y
- mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(rTRTranslate.getY()));
+ mrExport.GetMM100UnitConverter().convertDouble(sStringBuffer, rTRTranslate.getY(), true);
+ //mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(rTRTranslate.getY()));
aStr = sStringBuffer.makeStringAndClear();
mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y, aStr);
}
diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx
index 9aee767bdd5f..125ea9a3997c 100644
--- a/xmloff/source/draw/xexptran.cxx
+++ b/xmloff/source/draw/xexptran.cxx
@@ -143,6 +143,13 @@ void Imp_PutNumberChar(OUString& rStr, sal_Int32 nValue)
rStr += OUString(sStringBuffer.makeStringAndClear());
}
+void Imp_PutDoubleChar(OUString& rStr, double fValue)
+{
+ OUStringBuffer sStringBuffer;
+ SvXMLUnitConverter::convertDouble(sStringBuffer, fValue);
+ rStr += OUString(sStringBuffer.makeStringAndClear());
+}
+
void Imp_PutNumberCharWithSpace(OUString& rStr, sal_Int32 nValue)
{
const sal_Int32 aLen(rStr.getLength());
@@ -1295,16 +1302,16 @@ const OUString& SdXMLImExViewBox::GetExportString()
OUString aNewString;
OUString aEmptySpace(sal_Unicode(' '));
- Imp_PutNumberChar(aNewString, mfX);
+ Imp_PutDoubleChar(aNewString, mfX);
aNewString += aEmptySpace;
- Imp_PutNumberChar(aNewString, mfY);
+ Imp_PutDoubleChar(aNewString, mfY);
aNewString += aEmptySpace;
- Imp_PutNumberChar(aNewString, mfW);
+ Imp_PutDoubleChar(aNewString, mfW);
aNewString += aEmptySpace;
- Imp_PutNumberChar(aNewString, mfH);
+ Imp_PutDoubleChar(aNewString, mfH);
// set new string
msString = aNewString;
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index a5b646108c35..f234c55ce195 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -1467,6 +1467,9 @@ void SdXMLPathShapeContext::StartElement(const uno::Reference< xml::sax::XAttrib
}
}
+ // Add, set Style and properties from base shape
+ AddShape(pService);
+
// #89344# test for mxShape.is() and not for mxShapes.is() to support
// shape import helper classes WITHOUT XShapes (member mxShapes). This
// is used by the writer.