Modified: openoffice/branches/l10n40/main/xmloff/source/draw/ximpshap.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/xmloff/source/draw/ximpshap.cxx?rev=1538352&r1=1538351&r2=1538352&view=diff ============================================================================== --- openoffice/branches/l10n40/main/xmloff/source/draw/ximpshap.cxx (original) +++ openoffice/branches/l10n40/main/xmloff/source/draw/ximpshap.cxx Sun Nov 3 12:35:41 2013 @@ -80,6 +80,10 @@ #include <com/sun/star/text/XTextDocument.hpp> #include <basegfx/vector/b2dvector.hxx> #include <basegfx/point/b2dpoint.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -1308,46 +1312,71 @@ SdXMLPolygonShapeContext::~SdXMLPolygonS void SdXMLPolygonShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) { - // Add, set Style and properties from base shape - if(mbClosed) - AddShape("com.sun.star.drawing.PolyPolygonShape"); - else - AddShape("com.sun.star.drawing.PolyLineShape"); + // Add, set Style and properties from base shape + if(mbClosed) + AddShape("com.sun.star.drawing.PolyPolygonShape"); + else + AddShape("com.sun.star.drawing.PolyLineShape"); - if( mxShape.is() ) - { - SetStyle(); - SetLayer(); + if( mxShape.is() ) + { + SetStyle(); + SetLayer(); - // set local parameters on shape - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - // set polygon - if(maPoints.getLength() && maViewBox.getLength()) - { - SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); - awt::Size aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); - if (maSize.Width != 0 && maSize.Height !=0) - { - aSize = maSize; - } - awt::Point aPosition(aViewBox.GetX(), aViewBox.GetY()); - SdXMLImExPointsElement aPoints(maPoints, aViewBox, - aPosition, aSize, GetImport().GetMM100UnitConverter()); + // set local parameters on shape + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + // set polygon + if(maPoints.getLength() && maViewBox.getLength()) + { + const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); + basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); - uno::Any aAny; - aAny <<= aPoints.GetPointSequenceSequence(); - xPropSet->setPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny); - } - } + // Is this correct? It overrides ViewBox stuff; OTOH it makes no + // sense to have the geometry content size different from object size + if(maSize.Width != 0 && maSize.Height != 0) + { + aSize = basegfx::B2DVector(maSize.Width, maSize.Height); + } - // set pos, size, shear and rotate and get copy of matrix - SetTransformation(); + basegfx::B2DPolygon aPolygon; - SdXMLShapeContext::StartElement(xAttrList); - } + if(basegfx::tools::importFromSvgPoints(aPolygon, maPoints)) + { + if(aPolygon.count()) + { + const basegfx::B2DRange aSourceRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); + const basegfx::B2DRange aTargetRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY()); + + if(!aSourceRange.equal(aTargetRange)) + { + aPolygon.transform( + basegfx::tools::createSourceRangeTargetRangeTransform( + aSourceRange, + aTargetRange)); + } + + com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence; + uno::Any aAny; + + basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(basegfx::B2DPolyPolygon(aPolygon), aPointSequenceSequence); + aAny <<= aPointSequenceSequence; + xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny); + } + } + } + } + + // set pos, size, shear and rotate and get copy of matrix + SetTransformation(); + + SdXMLShapeContext::StartElement(xAttrList); + } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1399,90 +1428,115 @@ void SdXMLPathShapeContext::processAttri void SdXMLPathShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) { - // create polygon shape - if(maD.getLength()) - { - // prepare some of the parameters - SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); - awt::Size aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); - awt::Point aPosition(aViewBox.GetX(), aViewBox.GetY()); - if (maSize.Width != 0 && maSize.Height !=0) - { - aSize = maSize; - } - SdXMLImExSvgDElement aPoints(maD, aViewBox, - aPosition, aSize, GetImport().GetMM100UnitConverter()); + // create polygon shape + if(maD.getLength()) + { + const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); + basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); - const char* pService; - // now create shape - if(aPoints.IsCurve()) - { - if(aPoints.IsClosed()) - { - pService = "com.sun.star.drawing.ClosedBezierShape"; - } - else - { - pService = "com.sun.star.drawing.OpenBezierShape"; - } - } - else - { - if(aPoints.IsClosed()) - { - pService = "com.sun.star.drawing.PolyPolygonShape"; - } - else - { - pService = "com.sun.star.drawing.PolyLineShape"; - } - } + // Is this correct? It overrides ViewBox stuff; OTOH it makes no + // sense to have the geometry content size different from object size + if(maSize.Width != 0 && maSize.Height != 0) + { + aSize = basegfx::B2DVector(maSize.Width, maSize.Height); + } - // Add, set Style and properties from base shape - AddShape(pService); + basegfx::B2DPolyPolygon aPolyPolygon; - // #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. - if( mxShape.is() ) - { - SetStyle(); - SetLayer(); + if(basegfx::tools::importFromSvgD(aPolyPolygon, maD, true, 0)) + { + if(aPolyPolygon.count()) + { + const basegfx::B2DRange aSourceRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); + const basegfx::B2DRange aTargetRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY()); - // set local parameters on shape - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - uno::Any aAny; + if(!aSourceRange.equal(aTargetRange)) + { + aPolyPolygon.transform( + basegfx::tools::createSourceRangeTargetRangeTransform( + aSourceRange, + aTargetRange)); + } - // set svg:d - if(maD.getLength()) - { - if(aPoints.IsCurve()) - { - drawing::PolyPolygonBezierCoords aSourcePolyPolygon( - aPoints.GetPointSequenceSequence(), - aPoints.GetFlagSequenceSequence()); - - aAny <<= aSourcePolyPolygon; - xPropSet->setPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny); - } - else - { - aAny <<= aPoints.GetPointSequenceSequence(); - xPropSet->setPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny); - } - } - } + // create shape + const char* pService; - // set pos, size, shear and rotate - SetTransformation(); + if(aPolyPolygon.areControlPointsUsed()) + { + if(aPolyPolygon.isClosed()) + { + pService = "com.sun.star.drawing.ClosedBezierShape"; + } + else + { + pService = "com.sun.star.drawing.OpenBezierShape"; + } + } + else + { + if(aPolyPolygon.isClosed()) + { + pService = "com.sun.star.drawing.PolyPolygonShape"; + } + else + { + pService = "com.sun.star.drawing.PolyLineShape"; + } + } - SdXMLShapeContext::StartElement(xAttrList); - } - } + // 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. + if( mxShape.is() ) + { + SetStyle(); + SetLayer(); + + // set local parameters on shape + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + + if(xPropSet.is()) + { + uno::Any aAny; + + // set polygon data + if(aPolyPolygon.areControlPointsUsed()) + { + drawing::PolyPolygonBezierCoords aSourcePolyPolygon; + + basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords( + aPolyPolygon, + aSourcePolyPolygon); + aAny <<= aSourcePolyPolygon; + } + else + { + drawing::PointSequenceSequence aSourcePolyPolygon; + + basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence( + aPolyPolygon, + aSourcePolyPolygon); + aAny <<= aSourcePolyPolygon; + } + + xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny); + } + + // set pos, size, shear and rotate + SetTransformation(); + + SdXMLShapeContext::StartElement(xAttrList); + } + } + } + } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1843,35 +1897,36 @@ void SdXMLConnectorShapeContext::process GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue); return; } - if( IsXMLToken( rLocalName, XML_D ) ) - { - SdXMLImExViewBox aViewBox( 0, 0, 1, 1 ); - awt::Point aPoint( 0, 0 ); - awt::Size aSize( 1, 1 ); - - SdXMLImExSvgDElement aPoints( rValue, aViewBox, - aPoint, aSize, GetImport().GetMM100UnitConverter() ); + if( IsXMLToken( rLocalName, XML_D ) ) + { + basegfx::B2DPolyPolygon aPolyPolygon; - if ( aPoints.IsCurve() ) - { - drawing::PolyPolygonBezierCoords aSourcePolyPolygon( - aPoints.GetPointSequenceSequence(), - aPoints.GetFlagSequenceSequence()); - maPath <<= aSourcePolyPolygon; - } - else - { - const drawing::PointSequenceSequence& rOuterSeq = aPoints.GetPointSequenceSequence(); - drawing::FlagSequenceSequence aFlagSeqSeq( rOuterSeq.getLength() ); - for ( int a = 0; a < rOuterSeq.getLength(); a++ ) - aFlagSeqSeq[ a ] = drawing::FlagSequence( rOuterSeq[ a ].getLength() ); - - drawing::PolyPolygonBezierCoords aSourcePolyPolygon( - aPoints.GetPointSequenceSequence(), - aFlagSeqSeq ); - maPath <<= aSourcePolyPolygon; - } - } + if(basegfx::tools::importFromSvgD(aPolyPolygon, rValue, true, 0)) + { + if(aPolyPolygon.count()) + { + // set polygon data + if(aPolyPolygon.areControlPointsUsed()) + { + drawing::PolyPolygonBezierCoords aSourcePolyPolygon; + + basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords( + aPolyPolygon, + aSourcePolyPolygon); + maPath <<= aSourcePolyPolygon; + } + else + { + drawing::PointSequenceSequence aSourcePolyPolygon; + + basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence( + aPolyPolygon, + aSourcePolyPolygon); + maPath <<= aSourcePolyPolygon; + } + } + } + } } }
Modified: openoffice/branches/l10n40/main/xmloff/source/style/MarkerStyle.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/xmloff/source/style/MarkerStyle.cxx?rev=1538352&r1=1538351&r2=1538352&view=diff ============================================================================== --- openoffice/branches/l10n40/main/xmloff/source/style/MarkerStyle.cxx (original) +++ openoffice/branches/l10n40/main/xmloff/source/style/MarkerStyle.cxx Sun Nov 3 12:35:41 2013 @@ -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; @@ -101,53 +103,48 @@ sal_Bool XMLMarkerStyleImport::importXML } } - if( bHasViewBox && bHasPathData ) - { - 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( bHasViewBox && bHasPathData ) + { + basegfx::B2DPolyPolygon aPolyPolygon; + + if(basegfx::tools::importFromSvgD(aPolyPolygon, strPathData, true, 0)) + { + if(aPolyPolygon.count()) + { + // 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)); + } + + // always use PolyPolygonBezierCoords here + drawing::PolyPolygonBezierCoords aSourcePolyPolygon; + + basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords( + aPolyPolygon, + aSourcePolyPolygon); + rValue <<= aSourcePolyPolygon; + } + } + + if( aDisplayName.getLength() ) + { + rImport.AddStyleDisplayName( XML_STYLE_FAMILY_SD_MARKER_ID, rStrName, + aDisplayName ); + rStrName = aDisplayName; + } + } if( pViewBox ) delete pViewBox; @@ -175,108 +172,60 @@ sal_Bool XMLMarkerStyleExport::exportXML const OUString& rStrName, const uno::Any& rValue ) { - sal_Bool bRet(sal_False); - - if(rStrName.getLength()) - { - drawing::PolyPolygonBezierCoords aBezier; - - if(rValue >>= aBezier) - { - OUString aStrValue; - OUStringBuffer aOut; - - ///////////////// - // Name - 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]; - - 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( 0, 0, nDifX, nDifY ); - 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); - } - - // write point array - rExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString()); - - ///////////////// - // Do Write - SvXMLElementExport rElem( rExport, XML_NAMESPACE_DRAW, XML_MARKER, - sal_True, sal_False ); - } - } - - return bRet; + sal_Bool bRet(sal_False); + + if(rStrName.getLength()) + { + drawing::PolyPolygonBezierCoords aBezier; + + if(rValue >>= aBezier) + { + ///////////////// + // Name + 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 ); + } + + const basegfx::B2DPolyPolygon aPolyPolygon( + basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( + aBezier)); + const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange()); + + ///////////////// + // Viewbox (viewBox="0 0 1500 1000") + + SdXMLImExViewBox aViewBox( + aPolyPolygonRange.getMinX(), + aPolyPolygonRange.getMinY(), + aPolyPolygonRange.getWidth(), + aPolyPolygonRange.getHeight()); + rExport.AddAttribute( XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString() ); + + ///////////////// + // Pathdata + const ::rtl::OUString aPolygonString( + basegfx::tools::exportToSvgD( + aPolyPolygon, + true, // bUseRelativeCoordinates + false, // bDetectQuadraticBeziers: not used in old, but maybe activated now + true)); // bHandleRelativeNextPointCompatible + + // write point array + rExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); + + ///////////////// + // Do Write + SvXMLElementExport rElem( rExport, XML_NAMESPACE_DRAW, XML_MARKER, sal_True, sal_False ); + } + } + + return bRet; } #endif // #ifndef SVX_LIGHT Modified: openoffice/branches/l10n40/main/xmloff/source/text/XMLTextFrameContext.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/xmloff/source/text/XMLTextFrameContext.cxx?rev=1538352&r1=1538351&r2=1538352&view=diff ============================================================================== --- openoffice/branches/l10n40/main/xmloff/source/text/XMLTextFrameContext.cxx (original) +++ openoffice/branches/l10n40/main/xmloff/source/text/XMLTextFrameContext.cxx Sun Nov 3 12:35:41 2013 @@ -19,10 +19,9 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" + #include <tools/debug.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> @@ -52,15 +51,16 @@ #include <xmloff/XMLEventsImportContext.hxx> #include "XMLImageMapContext.hxx" #include "XMLTextFrameContext.hxx" - #include "XMLTextListBlockContext.hxx" #include "XMLTextListItemContext.hxx" #include <xmloff/attrlist.hxx> #include <comphelper/stl_types.hxx> - +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> #include <map> - using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -234,113 +234,130 @@ public: TYPEINIT1( XMLTextFrameContourContext_Impl, SvXMLImportContext ); XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl( - SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList > & xAttrList, - const Reference < XPropertySet >& rPropSet, - sal_Bool bPath ) : - SvXMLImportContext( rImport, nPrfx, rLName ), - xPropSet( rPropSet ) -{ - OUString sD, sPoints, sViewBox; - sal_Bool bPixelWidth = sal_False, bPixelHeight = sal_False; - sal_Bool bAuto = sal_False; - sal_Int32 nWidth = 0; - sal_Int32 nHeight = 0; + SvXMLImport& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & xAttrList, + const Reference < XPropertySet >& rPropSet, + sal_Bool bPath ) : + SvXMLImportContext( rImport, nPrfx, rLName ), + xPropSet( rPropSet ) +{ + OUString sD, sPoints, sViewBox; + sal_Bool bPixelWidth = sal_False, bPixelHeight = sal_False; + sal_Bool bAuto = sal_False; + sal_Int32 nWidth = 0; + sal_Int32 nHeight = 0; - const SvXMLTokenMap& rTokenMap = - GetImport().GetTextImport()->GetTextContourAttrTokenMap(); + const SvXMLTokenMap& rTokenMap = + GetImport().GetTextImport()->GetTextContourAttrTokenMap(); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) - { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - const OUString& rValue = xAttrList->getValueByIndex( i ); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const OUString& rAttrName = xAttrList->getNameByIndex( i ); + const OUString& rValue = xAttrList->getValueByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_TEXT_CONTOUR_VIEWBOX: - sViewBox = rValue; - break; - case XML_TOK_TEXT_CONTOUR_D: - if( bPath ) - sD = rValue; - break; - case XML_TOK_TEXT_CONTOUR_POINTS: - if( !bPath ) - sPoints = rValue; - break; - case XML_TOK_TEXT_CONTOUR_WIDTH: - if( GetImport().GetMM100UnitConverter().convertMeasurePx( nWidth, - rValue) ) - bPixelWidth = sal_True; - else - GetImport().GetMM100UnitConverter().convertMeasure( nWidth, - rValue); - break; - case XML_TOK_TEXT_CONTOUR_HEIGHT: - if( GetImport().GetMM100UnitConverter().convertMeasurePx( nHeight, - rValue) ) - bPixelHeight = sal_True; - else - GetImport().GetMM100UnitConverter().convertMeasure( nHeight, - rValue); - break; - case XML_TOK_TEXT_CONTOUR_AUTO: - bAuto = IsXMLToken(rValue, XML_TRUE); - break; - } - } + OUString aLocalName; + sal_uInt16 nPrefix = + GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, + &aLocalName ); + switch( rTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_TEXT_CONTOUR_VIEWBOX: + sViewBox = rValue; + break; + case XML_TOK_TEXT_CONTOUR_D: + if( bPath ) + sD = rValue; + break; + case XML_TOK_TEXT_CONTOUR_POINTS: + if( !bPath ) + sPoints = rValue; + break; + case XML_TOK_TEXT_CONTOUR_WIDTH: + if( GetImport().GetMM100UnitConverter().convertMeasurePx( nWidth, + rValue) ) + bPixelWidth = sal_True; + else + GetImport().GetMM100UnitConverter().convertMeasure( nWidth, + rValue); + break; + case XML_TOK_TEXT_CONTOUR_HEIGHT: + if( GetImport().GetMM100UnitConverter().convertMeasurePx( nHeight, + rValue) ) + bPixelHeight = sal_True; + else + GetImport().GetMM100UnitConverter().convertMeasure( nHeight, + rValue); + break; + case XML_TOK_TEXT_CONTOUR_AUTO: + bAuto = IsXMLToken(rValue, XML_TRUE); + break; + } + } - OUString sContourPolyPolygon( - RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon") ); - Reference < XPropertySetInfo > xPropSetInfo = - rPropSet->getPropertySetInfo(); - if( xPropSetInfo->hasPropertyByName( - sContourPolyPolygon ) && - nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && - (bPath ? sD : sPoints).getLength() ) - { - awt::Point aPoint( 0, 0 ); - awt::Size aSize( nWidth, nHeight ); - SdXMLImExViewBox aViewBox( sViewBox, - GetImport().GetMM100UnitConverter()); - Any aAny; - if( bPath ) - { - SdXMLImExSvgDElement aPoints( sD, aViewBox, aPoint, aSize, - GetImport().GetMM100UnitConverter() ); - aAny <<= aPoints.GetPointSequenceSequence(); - } - else - { - SdXMLImExPointsElement aPoints( sPoints, aViewBox, aPoint, aSize, - GetImport().GetMM100UnitConverter() ); - aAny <<= aPoints.GetPointSequenceSequence(); - } + OUString sContourPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon")); + Reference < XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo(); - OUString sIsPixelContour( - RTL_CONSTASCII_USTRINGPARAM("IsPixelContour") ); - xPropSet->setPropertyValue( sContourPolyPolygon, aAny ); + if(xPropSetInfo->hasPropertyByName(sContourPolyPolygon) && nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && (bPath ? sD : sPoints).getLength()) + { + const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter()); + basegfx::B2DPolyPolygon aPolyPolygon; + Any aAny; - if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) ) - { - aAny.setValue( &bPixelWidth, ::getBooleanCppuType() ); - xPropSet->setPropertyValue( sIsPixelContour, aAny ); - } + if( bPath ) + { + basegfx::tools::importFromSvgD(aPolyPolygon, sD, true, 0); + } + else + { + basegfx::B2DPolygon aPolygon; - OUString sIsAutomaticContour( - RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour") ); - if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) - { - aAny.setValue( &bAuto, ::getBooleanCppuType() ); - xPropSet->setPropertyValue( sIsAutomaticContour, aAny ); - } - } + if(basegfx::tools::importFromSvgPoints(aPolygon, sPoints)) + { + aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon); + } + } + + if(aPolyPolygon.count()) + { + const basegfx::B2DRange aSourceRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); + const basegfx::B2DRange aTargetRange( + 0.0, 0.0, + nWidth, nHeight); + + if(!aSourceRange.equal(aTargetRange)) + { + aPolyPolygon.transform( + basegfx::tools::createSourceRangeTargetRangeTransform( + aSourceRange, + aTargetRange)); + } + + com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence; + basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPolygon, aPointSequenceSequence); + aAny <<= aPointSequenceSequence; + xPropSet->setPropertyValue( sContourPolyPolygon, aAny ); + } + + const OUString sIsPixelContour(RTL_CONSTASCII_USTRINGPARAM("IsPixelContour")); + + if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) ) + { + aAny.setValue( &bPixelWidth, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sIsPixelContour, aAny ); + } + + const OUString sIsAutomaticContour(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour") ); + + if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) + { + aAny.setValue( &bAuto, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sIsAutomaticContour, aAny ); + } + } } XMLTextFrameContourContext_Impl::~XMLTextFrameContourContext_Impl() Modified: openoffice/branches/l10n40/main/xmloff/source/text/txtparae.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/xmloff/source/text/txtparae.cxx?rev=1538352&r1=1538351&r2=1538352&view=diff ============================================================================== --- openoffice/branches/l10n40/main/xmloff/source/text/txtparae.cxx (original) +++ openoffice/branches/l10n40/main/xmloff/source/text/txtparae.cxx Sun Nov 3 12:35:41 2013 @@ -19,8 +19,6 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" #include "unointerfacetouniqueidentifiermapper.hxx" @@ -32,11 +30,9 @@ #include <svl/svarray.hxx> #include <rtl/ustrbuf.hxx> #include <sal/types.h> - #include <vector> #include <list> #include <hash_map> - #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XEnumeration.hpp> @@ -70,15 +66,12 @@ #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> #include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/document/XRedlinesSupplier.hpp> - #include <com/sun/star/text/XBookmarksSupplier.hpp> #include <com/sun/star/text/XFormField.hpp> - #include <com/sun/star/text/XTextSection.hpp> #include <com/sun/star/text/SectionFileLink.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/text/XTextShapesSupplier.hpp> - #include <com/sun/star/style/XAutoStylesSupplier.hpp> #include <com/sun/star/style/XAutoStyleFamily.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp> @@ -112,11 +105,11 @@ #include <xmloff/formlayerexport.hxx> #include "XMLTextCharStyleNamesElementExport.hxx" #include <comphelper/stlunosequence.hxx> - -// --> OD 2008-04-25 #refactorlists# #include <txtlists.hxx> -// <-- #include <com/sun/star/rdf/XMetadatable.hpp> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -2873,119 +2866,102 @@ void XMLTextParagraphExport::_exportText } void XMLTextParagraphExport::exportContour( - const Reference < XPropertySet > & rPropSet, - const Reference < XPropertySetInfo > & rPropSetInfo ) + const Reference < XPropertySet > & rPropSet, + const Reference < XPropertySetInfo > & rPropSetInfo ) { - if( !rPropSetInfo->hasPropertyByName( sContourPolyPolygon ) ) - return; + if( !rPropSetInfo->hasPropertyByName( sContourPolyPolygon ) ) + { + return; + } - PointSequenceSequence aSourcePolyPolygon; - rPropSet->getPropertyValue( sContourPolyPolygon ) >>= aSourcePolyPolygon; + PointSequenceSequence aSourcePolyPolygon; + rPropSet->getPropertyValue( sContourPolyPolygon ) >>= aSourcePolyPolygon; + const basegfx::B2DPolyPolygon aPolyPolygon( + basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon( + aSourcePolyPolygon)); + const sal_uInt32 nPolygonCount(aPolyPolygon.count()); - if( !aSourcePolyPolygon.getLength() ) - return; + if(!nPolygonCount) + { + return; + } - awt::Point aPoint( 0, 0 ); - awt::Size aSize( 0, 0 ); - sal_Int32 nPolygons = aSourcePolyPolygon.getLength(); - const PointSequence *pPolygons = aSourcePolyPolygon.getConstArray(); - while( nPolygons-- ) - { - sal_Int32 nPoints = pPolygons->getLength(); - const awt::Point *pPoints = pPolygons->getConstArray(); - while( nPoints-- ) - { - if( aSize.Width < pPoints->X ) - aSize.Width = pPoints->X; - if( aSize.Height < pPoints->Y ) - aSize.Height = pPoints->Y; - pPoints++; - } - pPolygons++; - } + const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange()); + bool bPixel(false); - sal_Bool bPixel = sal_False; - if( rPropSetInfo->hasPropertyByName( sIsPixelContour ) ) - { - bPixel = *(sal_Bool *)rPropSet->getPropertyValue( sIsPixelContour ).getValue(); - } + if( rPropSetInfo->hasPropertyByName( sIsPixelContour ) ) + { + bPixel = *(sal_Bool *)rPropSet->getPropertyValue( sIsPixelContour ).getValue(); + } - // svg: width - OUStringBuffer aStringBuffer( 10 ); - if( bPixel ) - GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer, aSize.Width); - else - GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer, aSize.Width); - GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, - aStringBuffer.makeStringAndClear() ); - - // svg: height - if( bPixel ) - GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer, aSize.Height); - else - GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer, aSize.Height); - GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, - aStringBuffer.makeStringAndClear() ); - - // svg:viewbox - SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height); - GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, - aViewBox.GetExportString()); - - sal_Int32 nOuterCnt( aSourcePolyPolygon.getLength() ); - - enum XMLTokenEnum eElem = XML_TOKEN_INVALID; - if( 1L == nOuterCnt ) - { - // simple polygon shape, can be written as svg:points sequence - /*const*/ PointSequence* pSequence = - (PointSequence*)aSourcePolyPolygon.getConstArray(); - - SdXMLImExPointsElement aPoints( pSequence, aViewBox, aPoint, aSize ); - - // write point array - GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_POINTS, - aPoints.GetExportString()); - eElem = XML_CONTOUR_POLYGON; - } - else - { - // polypolygon, needs to be written as a svg:path sequence - /*const*/ PointSequence* pOuterSequence = - (PointSequence*)aSourcePolyPolygon.getConstArray(); - if(pOuterSequence) - { - // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement( aViewBox ); + // svg: width + OUStringBuffer aStringBuffer( 10 ); - for(sal_Int32 a(0L); a < nOuterCnt; a++) - { - /*const*/ PointSequence* pSequence = pOuterSequence++; - if(pSequence) - { - aSvgDElement.AddPolygon(pSequence, 0L, aPoint, - aSize, sal_True ); - } - } + if(bPixel) + { + GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer, basegfx::fround(aPolyPolygonRange.getWidth())); + } + else + { + GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer, basegfx::fround(aPolyPolygonRange.getWidth())); + } - // write point array - GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_D, - aSvgDElement.GetExportString()); - eElem = XML_CONTOUR_PATH; - } - } + GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStringBuffer.makeStringAndClear()); - if( rPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) - { + // svg: height + if(bPixel) + { + GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer, basegfx::fround(aPolyPolygonRange.getHeight())); + } + else + { + GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer, basegfx::fround(aPolyPolygonRange.getHeight())); + } + + GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStringBuffer.makeStringAndClear()); + + // svg:viewbox + SdXMLImExViewBox aViewBox(0.0, 0.0, aPolyPolygonRange.getWidth(), aPolyPolygonRange.getHeight()); + GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString()); + enum XMLTokenEnum eElem = XML_TOKEN_INVALID; + + if(1 == nPolygonCount ) + { + // simple polygon shape, can be written as svg:points sequence + const ::rtl::OUString aPointString( + basegfx::tools::exportToSvgPoints( + aPolyPolygon.getB2DPolygon(0))); + + // write point array + GetExport().AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString); + eElem = XML_CONTOUR_POLYGON; + } + else + { + // polypolygon, needs to be written as a svg:path sequence + const ::rtl::OUString aPolygonString( + basegfx::tools::exportToSvgD( + aPolyPolygon, + true, // bUseRelativeCoordinates + false, // bDetectQuadraticBeziers: not used in old, but maybe activated now + true)); // bHandleRelativeNextPointCompatible + + // write point array + GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_D, aPolygonString); + eElem = XML_CONTOUR_PATH; + } + + if( rPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) + { sal_Bool bTmp = *(sal_Bool *)rPropSet->getPropertyValue( sIsAutomaticContour ).getValue(); GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_RECREATE_ON_EDIT, bTmp ? XML_TRUE : XML_FALSE ); - } + } - // write object now - SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, eElem, - sal_True, sal_True ); + // write object now + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, eElem, + sal_True, sal_True ); } void XMLTextParagraphExport::_exportTextGraphic( Propchange: openoffice/branches/l10n40/test/ ------------------------------------------------------------------------------ Merged /openoffice/trunk/test:r1526980-1538342 Propchange: openoffice/branches/l10n40/test/testcommon/source/org/openoffice/test/vcl/ ------------------------------------------------------------------------------ Merged /openoffice/trunk/test/testcommon/source/org/openoffice/test/vcl:r1526980-1538342