You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2013/10/29 15:11:46 UTC
svn commit: r1536730 [5/5] - in /openoffice/trunk/main:
basegfx/inc/basegfx/polygon/ basegfx/source/inc/ basegfx/source/polygon/
basegfx/source/tools/ basegfx/test/ canvas/source/tools/ sd/source/core/
sdext/source/pdfimport/test/ sdext/source/pdfimpor...
Modified: openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx?rev=1536730&r1=1536729&r2=1536730&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx (original)
+++ openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx Tue Oct 29 14:11:45 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/trunk/main/xmloff/source/text/txtparae.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/source/text/txtparae.cxx?rev=1536730&r1=1536729&r2=1536730&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/source/text/txtparae.cxx (original)
+++ openoffice/trunk/main/xmloff/source/text/txtparae.cxx Tue Oct 29 14:11:45 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(