summaryrefslogtreecommitdiff
path: root/xmloff/source/style/MarkerStyle.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/style/MarkerStyle.cxx')
-rw-r--r--xmloff/source/style/MarkerStyle.cxx260
1 files changed, 155 insertions, 105 deletions
diff --git a/xmloff/source/style/MarkerStyle.cxx b/xmloff/source/style/MarkerStyle.cxx
index 9947e86deac0..e7352aa9a04a 100644
--- a/xmloff/source/style/MarkerStyle.cxx
+++ b/xmloff/source/style/MarkerStyle.cxx
@@ -19,10 +19,9 @@
*
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx"
+
#include "xmloff/MarkerStyle.hxx"
#include "xexptran.hxx"
#include <xmloff/attrlist.hxx>
@@ -35,6 +34,9 @@
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.hxx>
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
using namespace ::com::sun::star;
using ::rtl::OUString;
@@ -103,50 +105,83 @@ sal_Bool XMLMarkerStyleImport::importXML(
if( bHasViewBox && bHasPathData )
{
- SdXMLImExSvgDElement aPoints(strPathData, *pViewBox, awt::Point( 0, 0 ),
- awt::Size( pViewBox->GetWidth(), pViewBox->GetHeight() ),
- rUnitConverter );
+ basegfx::B2DPolyPolygon aPolyPolygon;
- if(aPoints.IsCurve())
- {
- drawing::PolyPolygonBezierCoords aSourcePolyPolygon(
- aPoints.GetPointSequenceSequence(),
- aPoints.GetFlagSequenceSequence());
- rValue <<= aSourcePolyPolygon;
- }
- else
+ if(basegfx::tools::importFromSvgD(aPolyPolygon, strPathData))
{
- drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
- aSourcePolyPolygon.Coordinates = aPoints.GetPointSequenceSequence();
- aSourcePolyPolygon.Flags.realloc(aSourcePolyPolygon.Coordinates.getLength());
-
- // Zeiger auf innere sequences holen
- const drawing::PointSequence* pInnerSequence = aSourcePolyPolygon.Coordinates.getConstArray();
- drawing::FlagSequence* pInnerSequenceFlags = aSourcePolyPolygon.Flags.getArray();
-
- for(sal_Int32 a(0); a < aSourcePolyPolygon.Coordinates.getLength(); a++)
+ if(aPolyPolygon.count())
{
- pInnerSequenceFlags->realloc(pInnerSequence->getLength());
- drawing::PolygonFlags* pPolyFlags = pInnerSequenceFlags->getArray();
+ // TTTT: ViewBox probably not used, but stay with former processing inside of
+ // SdXMLImExSvgDElement
+ const basegfx::B2DRange aSourceRange(
+ pViewBox->GetX(), pViewBox->GetY(),
+ pViewBox->GetX() + pViewBox->GetWidth(), pViewBox->GetY() + pViewBox->GetHeight());
+ const basegfx::B2DRange aTargetRange(
+ 0.0, 0.0,
+ pViewBox->GetWidth(), pViewBox->GetHeight());
+
+ if(!aSourceRange.equal(aTargetRange))
+ {
+ aPolyPolygon.transform(
+ basegfx::tools::createSourceRangeTargetRangeTransform(
+ aSourceRange,
+ aTargetRange));
+ }
- for(sal_Int32 b(0); b < pInnerSequence->getLength(); b++)
- *pPolyFlags++ = drawing::PolygonFlags_NORMAL;
+ // always use PolyPolygonBezierCoords here
+ drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
- // next run
- pInnerSequence++;
- pInnerSequenceFlags++;
+ basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords(
+ aPolyPolygon,
+ aSourcePolyPolygon);
+ rValue <<= aSourcePolyPolygon;
}
-
- rValue <<= aSourcePolyPolygon;
}
+ // TTTT
+ //SdXMLImExSvgDElement aPoints(strPathData, *pViewBox, awt::Point( 0, 0 ),
+ // awt::Size( pViewBox->GetWidth(), pViewBox->GetHeight() ),
+ // rUnitConverter );
+ //
+ //if(aPoints.IsCurve())
+ //{
+ // drawing::PolyPolygonBezierCoords aSourcePolyPolygon(
+ // aPoints.GetPointSequenceSequence(),
+ // aPoints.GetFlagSequenceSequence());
+ // rValue <<= aSourcePolyPolygon;
+ //}
+ //else
+ //{
+ // drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
+ // aSourcePolyPolygon.Coordinates = aPoints.GetPointSequenceSequence();
+ // aSourcePolyPolygon.Flags.realloc(aSourcePolyPolygon.Coordinates.getLength());
+ //
+ // // Zeiger auf innere sequences holen
+ // const drawing::PointSequence* pInnerSequence = aSourcePolyPolygon.Coordinates.getConstArray();
+ // drawing::FlagSequence* pInnerSequenceFlags = aSourcePolyPolygon.Flags.getArray();
+ //
+ // for(sal_Int32 a(0); a < aSourcePolyPolygon.Coordinates.getLength(); a++)
+ // {
+ // pInnerSequenceFlags->realloc(pInnerSequence->getLength());
+ // drawing::PolygonFlags* pPolyFlags = pInnerSequenceFlags->getArray();
+ //
+ // for(sal_Int32 b(0); b < pInnerSequence->getLength(); b++)
+ // *pPolyFlags++ = drawing::PolygonFlags_NORMAL;
+ //
+ // // next run
+ // pInnerSequence++;
+ // pInnerSequenceFlags++;
+ // }
+ //
+ // rValue <<= aSourcePolyPolygon;
+ //}
+
if( aDisplayName.getLength() )
{
rImport.AddStyleDisplayName( XML_STYLE_FAMILY_SD_MARKER_ID, rStrName,
aDisplayName );
rStrName = aDisplayName;
}
-
}
if( pViewBox )
@@ -183,96 +218,111 @@ sal_Bool XMLMarkerStyleExport::exportXML(
if(rValue >>= aBezier)
{
- OUString aStrValue;
- OUStringBuffer aOut;
-
/////////////////
// Name
- sal_Bool bEncoded = sal_False;
+ sal_Bool bEncoded(sal_False);
OUString aStrName( rStrName );
- rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME,
- rExport.EncodeStyleName( aStrName,
- &bEncoded ) );
- if( bEncoded )
- rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY_NAME,
- aStrName );
-
- /////////////////
- // Viewbox (viewBox="0 0 1500 1000")
- sal_Int32 nMinX(0x7fffffff);
- sal_Int32 nMaxX(0x80000000);
- sal_Int32 nMinY(0x7fffffff);
- sal_Int32 nMaxY(0x80000000);
- sal_Int32 nOuterCnt(aBezier.Coordinates.getLength());
- drawing::PointSequence* pOuterSequence = aBezier.Coordinates.getArray();
- sal_Int32 a, b;
- sal_Bool bClosed(sal_False);
-
- for (a = 0; a < nOuterCnt; a++)
- {
- drawing::PointSequence* pSequence = pOuterSequence++;
- const awt::Point *pPoints = pSequence->getConstArray();
- sal_Int32 nPointCount(pSequence->getLength());
- if(nPointCount)
- {
- const awt::Point aStart = pPoints[0];
- const awt::Point aEnd = pPoints[nPointCount - 1];
-
- if(aStart.X == aEnd.X && aStart.Y == aEnd.Y)
- {
- bClosed = sal_True;
- }
- }
-
- for (b = 0; b < nPointCount; b++)
- {
- const awt::Point aPoint = pPoints[b];
+ rExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NAME, rExport.EncodeStyleName( aStrName, &bEncoded ) );
- if( aPoint.X < nMinX )
- nMinX = aPoint.X;
-
- if( aPoint.X > nMaxX )
- nMaxX = aPoint.X;
-
- if( aPoint.Y < nMinY )
- nMinY = aPoint.Y;
-
- if( aPoint.Y > nMaxY )
- nMaxY = aPoint.Y;
- }
+ if( bEncoded )
+ {
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY_NAME, aStrName );
}
- sal_Int32 nDifX(nMaxX - nMinX);
- sal_Int32 nDifY(nMaxY - nMinY);
+ const basegfx::B2DPolyPolygon aPolyPolygon(
+ basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
+ aBezier));
+ const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange());
+
+ /////////////////
+ // Viewbox (viewBox="0 0 1500 1000")
- SdXMLImExViewBox aViewBox( 0, 0, nDifX, nDifY );
+ // TTTT
+ //sal_Int32 nMinX(0x7fffffff);
+ //sal_Int32 nMaxX(0x80000000);
+ //sal_Int32 nMinY(0x7fffffff);
+ //sal_Int32 nMaxY(0x80000000);
+ //sal_Int32 nOuterCnt(aBezier.Coordinates.getLength());
+ //drawing::PointSequence* pOuterSequence = aBezier.Coordinates.getArray();
+ //sal_Int32 a, b;
+ //sal_Bool bClosed(sal_False);
+ //
+ //for (a = 0; a < nOuterCnt; a++)
+ //{
+ // drawing::PointSequence* pSequence = pOuterSequence++;
+ // const awt::Point *pPoints = pSequence->getConstArray();
+ // sal_Int32 nPointCount(pSequence->getLength());
+ //
+ // if(nPointCount)
+ // {
+ // const awt::Point aStart = pPoints[0];
+ // const awt::Point aEnd = pPoints[nPointCount - 1];
+ //
+ // if(aStart.X == aEnd.X && aStart.Y == aEnd.Y)
+ // {
+ // bClosed = sal_True;
+ // }
+ // }
+ //
+ // for (b = 0; b < nPointCount; b++)
+ // {
+ // const awt::Point aPoint = pPoints[b];
+ //
+ // if( aPoint.X < nMinX )
+ // nMinX = aPoint.X;
+ //
+ // if( aPoint.X > nMaxX )
+ // nMaxX = aPoint.X;
+ //
+ // if( aPoint.Y < nMinY )
+ // nMinY = aPoint.Y;
+ //
+ // if( aPoint.Y > nMaxY )
+ // nMaxY = aPoint.Y;
+ // }
+ //}
+ //
+ //sal_Int32 nDifX(nMaxX - nMinX);
+ //sal_Int32 nDifY(nMaxY - nMinY);
+
+ SdXMLImExViewBox aViewBox(
+ aPolyPolygonRange.getMinX(),
+ aPolyPolygonRange.getMinY(),
+ aPolyPolygonRange.getWidth(),
+ aPolyPolygonRange.getHeight());
rExport.AddAttribute( XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString() );
/////////////////
// Pathdata
- pOuterSequence = aBezier.Coordinates.getArray();
- drawing::FlagSequence* pOuterFlags = aBezier.Flags.getArray();
- SdXMLImExSvgDElement aSvgDElement(aViewBox);
-
- for (a = 0; a < nOuterCnt; a++)
- {
- drawing::PointSequence* pSequence = pOuterSequence++;
- drawing::FlagSequence* pFlags = pOuterFlags++;
-
- aSvgDElement.AddPolygon(pSequence, pFlags,
- awt::Point( 0, 0 ),
- awt::Size( aViewBox.GetWidth(), aViewBox.GetHeight() ),
- bClosed);
- }
+ const ::rtl::OUString aPolygonString(
+ basegfx::tools::exportToSvgD(
+ aPolyPolygon,
+ true, // bUseRelativeCoordinates
+ false)); // bDetectQuadraticBeziers TTTT: not used in old, but maybe activated now
+
+ // TTTT
+ //pOuterSequence = aBezier.Coordinates.getArray();
+ //drawing::FlagSequence* pOuterFlags = aBezier.Flags.getArray();
+ //SdXMLImExSvgDElement aSvgDElement(aViewBox);
+ //
+ //for (a = 0; a < nOuterCnt; a++)
+ //{
+ // drawing::PointSequence* pSequence = pOuterSequence++;
+ // drawing::FlagSequence* pFlags = pOuterFlags++;
+ //
+ // aSvgDElement.AddPolygon(pSequence, pFlags,
+ // awt::Point( 0, 0 ),
+ // awt::Size( aViewBox.GetWidth(), aViewBox.GetHeight() ),
+ // bClosed);
+ //}
// write point array
- rExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString());
+ rExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString);
/////////////////
// Do Write
- SvXMLElementExport rElem( rExport, XML_NAMESPACE_DRAW, XML_MARKER,
- sal_True, sal_False );
+ SvXMLElementExport rElem( rExport, XML_NAMESPACE_DRAW, XML_MARKER, sal_True, sal_False );
}
}