Modified: openoffice/branches/capstone2013/main/svx/source/sdr/properties/customshapeproperties.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/svx/source/sdr/properties/customshapeproperties.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/svx/source/sdr/properties/customshapeproperties.cxx (original) +++ openoffice/branches/capstone2013/main/svx/source/sdr/properties/customshapeproperties.cxx Mon Nov 4 19:00:37 2013 @@ -39,21 +39,32 @@ namespace sdr { namespace properties { - void CustomShapeProperties::UpdateTextFrameStatus() + void CustomShapeProperties::UpdateTextFrameStatus(bool bInvalidateRenderGeometry) { SdrObjCustomShape& rObj = static_cast< SdrObjCustomShape& >(GetSdrObject()); const bool bOld(rObj.bTextFrame); + // change TextFrame flag when bResizeShapeToFitText changes (which is mapped + // on the item SDRATTR_TEXT_AUTOGROWHEIGHT for custom shapes, argh) rObj.bTextFrame = 0 != static_cast< const SdrTextAutoGrowHeightItem& >(GetObjectItemSet().Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue(); + // check if it did change if(rObj.bTextFrame != bOld) { - rObj.InvalidateRenderGeometry(); + // on change also invalidate render geometry + bInvalidateRenderGeometry = true; - // #115391# Potential recursuin, since it calls SetObjectItemSet again, but rObj.bTextFrame - // will not change again, thus it will be only one level and terminate + // #115391# Potential recursion, since it calls SetObjectItemSet again, but rObj.bTextFrame + // will not change again. Thus it will be only one level and terminate safely rObj.AdaptTextMinSize(); } + + if(bInvalidateRenderGeometry) + { + // if asked for or bResizeShapeToFitText changed, make sure that + // the render geometry is reconstructed using changed parameters + rObj.InvalidateRenderGeometry(); + } } SfxItemSet& CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) @@ -134,7 +145,7 @@ namespace sdr TextProperties::ItemSetChanged(rSet); // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); + UpdateTextFrameStatus(true); } void CustomShapeProperties::PostItemChange(const sal_uInt16 nWhich) @@ -144,7 +155,7 @@ namespace sdr case SDRATTR_TEXT_AUTOGROWHEIGHT: { // #115391# update bTextFrame and RenderGeometry using AdaptTextMinSize() - UpdateTextFrameStatus(); + UpdateTextFrameStatus(false); break; } default: @@ -163,7 +174,7 @@ namespace sdr TextProperties::ItemChange( nWhich, pNewItem ); // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); + UpdateTextFrameStatus(true); } void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) @@ -172,13 +183,13 @@ namespace sdr TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr ); // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); + UpdateTextFrameStatus(true); } void CustomShapeProperties::ForceDefaultAttributes() { // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); + UpdateTextFrameStatus(true); // SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml // This means: Do *not* call parent here is by purpose... @@ -226,11 +237,8 @@ namespace sdr bRemoveRenderGeometry = sal_True; } - if ( bRemoveRenderGeometry ) - { - // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); - } + // update bTextFrame and RenderGeometry + UpdateTextFrameStatus(bRemoveRenderGeometry); } } // end of namespace properties } // end of namespace sdr
Modified: openoffice/branches/capstone2013/main/svx/source/xoutdev/xattrbmp.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/svx/source/xoutdev/xattrbmp.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/svx/source/xoutdev/xattrbmp.cxx (original) +++ openoffice/branches/capstone2013/main/svx/source/xoutdev/xattrbmp.cxx Mon Nov 4 19:00:37 2013 @@ -129,10 +129,12 @@ bool SVX_DLLPUBLIC isHistorical8x8(const if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount()) { const BitmapPalette& rPalette = pRead->GetPalette(); - - o_rBack = rPalette[1]; - o_rFront = rPalette[0]; - + + // #123564# bachground and foregrund were exchanged; of course + // rPalette[0] is the background color + o_rFront = rPalette[1]; + o_rBack = rPalette[0]; + return true; } } Modified: openoffice/branches/capstone2013/main/sw/inc/ndgrf.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/inc/ndgrf.hxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/sw/inc/ndgrf.hxx (original) +++ openoffice/branches/capstone2013/main/sw/inc/ndgrf.hxx Mon Nov 4 19:00:37 2013 @@ -154,7 +154,6 @@ public: /// wrappers for non-const calls at GraphicObject void ReleaseGraphicFromCache() { maGrfObj.ReleaseFromCache(); } - void DrawGraphicWithPDFHandling(OutputDevice& rOutDev, const Point& rPt, const Size& rSz, const GraphicAttr* pGrfAttr = NULL, const sal_uLong nFlags = GRFMGR_DRAW_STANDARD) { maGrfObj.DrawWithPDFHandling(rOutDev, rPt, rSz, pGrfAttr, nFlags); } void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0, const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD, OutputDevice* pFirstFrameOutDev = NULL) { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pAttr, nFlags, pFirstFrameOutDev); } void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); } Modified: openoffice/branches/capstone2013/main/sw/source/core/doc/notxtfrm.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/doc/notxtfrm.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/sw/source/core/doc/notxtfrm.cxx (original) +++ openoffice/branches/capstone2013/main/sw/source/core/doc/notxtfrm.cxx Mon Nov 4 19:00:37 2013 @@ -76,7 +76,7 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/processor2d/processor2dtools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> -#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/graphicprimitive2d.hxx> using namespace com::sun::star; @@ -816,57 +816,19 @@ bool paintUsingPrimitivesHelper( OutputDevice& rOutputDevice, const drawinglayer::primitive2d::Primitive2DSequence& rSequence, const basegfx::B2DRange& rSourceRange, - const basegfx::B2DRange& rTargetRange, - const sal_Int32 nLeftCrop = 0, - const sal_Int32 nTopCrop = 0, - const sal_Int32 nRightCrop = 0, - const sal_Int32 nBottomCrop = 0, - const bool bMirrorX = false, - const bool bMirrorY = false) + const basegfx::B2DRange& rTargetRange) { - const double fSourceWidth(rSourceRange.getWidth()); - const double fSourceHeight(rSourceRange.getHeight()); - - if(rSequence.hasElements() && !basegfx::fTools::equalZero(fSourceWidth) && !basegfx::fTools::equalZero(fSourceHeight)) + if(rSequence.hasElements() && !basegfx::fTools::equalZero(rSourceRange.getWidth()) && !basegfx::fTools::equalZero(rSourceRange.getHeight())) { - // copy target range and apply evtl. cropping - basegfx::B2DRange aTargetRange(rTargetRange); - - if(nLeftCrop || nTopCrop || nRightCrop || nBottomCrop) + if(!basegfx::fTools::equalZero(rTargetRange.getWidth()) && !basegfx::fTools::equalZero(rTargetRange.getHeight())) { - // calculate original TargetRange - const double fFactor100thmmToTwips(72.0 / 127.0); - - aTargetRange = basegfx::B2DRange( - aTargetRange.getMinX() - (nLeftCrop * fFactor100thmmToTwips), - aTargetRange.getMinY() - (nTopCrop * fFactor100thmmToTwips), - aTargetRange.getMaxX() + (nRightCrop * fFactor100thmmToTwips), - aTargetRange.getMaxY() + (nBottomCrop * fFactor100thmmToTwips)); - } - - const double fTargetWidth(aTargetRange.getWidth()); - const double fTargetHeight(aTargetRange.getHeight()); - - if(!basegfx::fTools::equalZero(fTargetWidth) && !basegfx::fTools::equalZero(fTargetHeight)) - { - // map graphic range to target range. This will automatically include - // tme mapping from Svg 1/100th mm content to twips since the target - // range is twips already - basegfx::B2DHomMatrix aMappingTransform( - basegfx::tools::createTranslateB2DHomMatrix( - -rSourceRange.getMinX(), - -rSourceRange.getMinY())); - - aMappingTransform.scale(fTargetWidth / fSourceWidth, fTargetHeight / fSourceHeight); - aMappingTransform.translate(aTargetRange.getMinX(), aTargetRange.getMinY()); - - // apply mirrorings - if(bMirrorX || bMirrorY) - { - aMappingTransform.translate(-aTargetRange.getCenterX(), -aTargetRange.getCenterY()); - aMappingTransform.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0); // #119176# small typo with X/Y - aMappingTransform.translate(aTargetRange.getCenterX(), aTargetRange.getCenterY()); - } + // map graphic range to target range. This will e.g. automatically include + // tme mapping from 1/100th mm content to twips if needed when the target + // range is defined in twips + const basegfx::B2DHomMatrix aMappingTransform( + basegfx::tools::createSourceRangeTargetRangeTransform( + rSourceRange, + rTargetRange)); // Fill ViewInformation. Use MappingTransform here, so there is no need to // embed the primitives to it. Use original TargetRange here so there is also @@ -875,7 +837,7 @@ bool paintUsingPrimitivesHelper( const drawinglayer::geometry::ViewInformation2D aViewInformation2D( aMappingTransform, rOutputDevice.GetViewTransformation(), - aTargetRange, + rTargetRange, 0, 0.0, uno::Sequence< beans::PropertyValue >()); @@ -983,14 +945,6 @@ void SwNoTxtFrm::PaintPicture( OutputDev ::lcl_PaintReplacement( aAlignedGrfArea, aTxt, *pShell, this, sal_False ); bContinue = sal_False; } - else if( rGrfObj.IsCached( pOut, aAlignedGrfArea.Pos(), - aAlignedGrfArea.SSize(), &aGrfAttr )) - { - pGrfNd->DrawGraphicWithPDFHandling(*pOut, - aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), - &aGrfAttr ); - bContinue = sal_False; - } } if( bContinue ) @@ -1028,68 +982,30 @@ void SwNoTxtFrm::PaintPicture( OutputDev } else { - const SvgDataPtr& rSvgDataPtr = rGrfObj.GetGraphic().getSvgData(); - bool bDone(false); + // unify using GraphicPrimitive2D + // -> the primitive handles all crop and mirror stuff + // -> the primitive renderer will create the needed pdf export data + // -> if bitmap conent, it will be cached system-dependent + const basegfx::B2DRange aTargetRange( + aAlignedGrfArea.Left(), aAlignedGrfArea.Top(), + aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom()); + const basegfx::B2DHomMatrix aTargetTransform( + basegfx::tools::createScaleTranslateB2DHomMatrix( + aTargetRange.getRange(), + aTargetRange.getMinimum())); + drawinglayer::primitive2d::Primitive2DSequence aContent; + + aContent.realloc(1); + aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D( + aTargetTransform, + rGrfObj.GetGraphic(), + aGrfAttr); - if(rSvgDataPtr.get()) - { - // Graphic is Svg and can be painted as primitives (vector graphic) - const basegfx::B2DRange aTargetRange( - aAlignedGrfArea.Left(), aAlignedGrfArea.Top(), - aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom()); - const bool bCropped(aGrfAttr.IsCropped()); - drawinglayer::primitive2d::Primitive2DSequence aContent; - GraphicAttr aSuppressGraphicAttr(aGrfAttr); - - aSuppressGraphicAttr.SetCrop(0, 0, 0, 0); - aSuppressGraphicAttr.SetRotation(0); - aSuppressGraphicAttr.SetMirrorFlags(0); - - const bool bNeedTransformedGraphic( - aSuppressGraphicAttr.IsSpecialDrawMode() || - aSuppressGraphicAttr.IsAdjusted() || - aSuppressGraphicAttr.IsMirrored() || - aSuppressGraphicAttr.IsRotated() || - aSuppressGraphicAttr.IsTransparent()); - - if(bNeedTransformedGraphic) - { - // #122039# need to apply graphic transformation if GraphicAttr are used qwhich need this - const Graphic aTransformedGraphic(rGrfObj.GetTransformedGraphic(&aSuppressGraphicAttr)); - const basegfx::B2DRange aRange(rSvgDataPtr->getRange()); - const basegfx::B2DHomMatrix aTransform( - basegfx::tools::createScaleTranslateB2DHomMatrix( - aRange.getRange(), - aRange.getMinimum())); - - aContent.realloc(1); - aContent[0] = new drawinglayer::primitive2d::BitmapPrimitive2D( - aTransformedGraphic.GetBitmapEx(), - aTransform); - } - else - { - aContent = rSvgDataPtr->getPrimitive2DSequence(); - } - - bDone = paintUsingPrimitivesHelper( - *pOut, - aContent, - rSvgDataPtr->getRange(), - aTargetRange, - bCropped ? aGrfAttr.GetLeftCrop() : 0, - bCropped ? aGrfAttr.GetTopCrop() : 0, - bCropped ? aGrfAttr.GetRightCrop() : 0, - bCropped ? aGrfAttr.GetBottomCrop() : 0, - aGrfAttr.GetMirrorFlags() & BMP_MIRROR_HORZ, - aGrfAttr.GetMirrorFlags() & BMP_MIRROR_VERT); - } - - if(!bDone) - { - // fallback paint, uses replacement image - pGrfNd->DrawGraphicWithPDFHandling(*pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), &aGrfAttr); - } + paintUsingPrimitivesHelper( + *pOut, + aContent, + aTargetRange, + aTargetRange); } } else Modified: openoffice/branches/capstone2013/main/sw/source/filter/rtf/swparrtf.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/filter/rtf/swparrtf.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/sw/source/filter/rtf/swparrtf.cxx (original) +++ openoffice/branches/capstone2013/main/sw/source/filter/rtf/swparrtf.cxx Mon Nov 4 19:00:37 2013 @@ -2290,8 +2290,13 @@ void SwRTFParser::SetAttrInDoc( SvxRTFIt SwTxtNode* pTxtNd = pDoc->GetNodes()[ n ]->GetTxtNode(); if( pTxtNd ) { - pTxtNd->SetAttr( - *GetDfltAttr(RES_PARATR_NUMRULE)); + pTxtNd->SetAttr( *GetDfltAttr(RES_PARATR_NUMRULE) ); + // reset all list attributes + pTxtNd->ResetAttr( RES_PARATR_LIST_LEVEL ); + pTxtNd->ResetAttr( RES_PARATR_LIST_ISRESTART ); + pTxtNd->ResetAttr( RES_PARATR_LIST_RESTARTVALUE ); + pTxtNd->ResetAttr( RES_PARATR_LIST_ISCOUNTED ); + pTxtNd->ResetAttr( RES_PARATR_LIST_ID ); } } } Modified: openoffice/branches/capstone2013/main/tools/source/generic/toolsin.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/tools/source/generic/toolsin.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/tools/source/generic/toolsin.cxx (original) +++ openoffice/branches/capstone2013/main/tools/source/generic/toolsin.cxx Mon Nov 4 19:00:37 2013 @@ -31,7 +31,7 @@ #include <tools/debug.hxx> #include <toolsin.hxx> -#if defined WNT || defined OS2 +#if defined WNT #include <dll.hxx> #endif Modified: openoffice/branches/capstone2013/main/vcl/os2/source/gdi/salgdi3.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/vcl/os2/source/gdi/salgdi3.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/vcl/os2/source/gdi/salgdi3.cxx (original) +++ openoffice/branches/capstone2013/main/vcl/os2/source/gdi/salgdi3.cxx Mon Nov 4 19:00:37 2013 @@ -837,7 +837,7 @@ USHORT Os2SalGraphics::SetFont( ImplFont return 0; } -#if OSL_DEBUG_LEVEL>1 +#if OSL_DEBUG_LEVEL>10 debug_printf( "Os2SalGraphics::SetFont\n"); #endif Modified: openoffice/branches/capstone2013/main/xmloff/inc/xexptran.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/xmloff/inc/xexptran.hxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/xmloff/inc/xexptran.hxx (original) +++ openoffice/branches/capstone2013/main/xmloff/inc/xexptran.hxx Mon Nov 4 19:00:37 2013 @@ -115,83 +115,22 @@ public: class SdXMLImExViewBox { - rtl::OUString msString; - sal_Int32 mnX; - sal_Int32 mnY; - sal_Int32 mnW; - sal_Int32 mnH; + rtl::OUString msString; + double mfX; + double mfY; + double mfW; + double mfH; public: - SdXMLImExViewBox(sal_Int32 nX = 0L, sal_Int32 nY = 0L, sal_Int32 nW = 1000L, sal_Int32 nH = 1000L); - SdXMLImExViewBox(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv); + SdXMLImExViewBox(double fX = 0.0, double fY = 0.0, double fW = 1000.0, double fH = 1000.0); + SdXMLImExViewBox(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv); - sal_Int32 GetX() const { return mnX; } - sal_Int32 GetY() const { return mnY; } - sal_Int32 GetWidth() const { return mnW; } - sal_Int32 GetHeight() const { return mnH; } - const rtl::OUString& GetExportString(); + double GetX() const { return mfX; } + double GetY() const { return mfY; } + double GetWidth() const { return mfW; } + double GetHeight() const { return mfH; } + const rtl::OUString& GetExportString(); }; -////////////////////////////////////////////////////////////////////////////// - -class SdXMLImExPointsElement -{ - rtl::OUString msString; - com::sun::star::drawing::PointSequenceSequence maPoly; - -public: - SdXMLImExPointsElement(com::sun::star::drawing::PointSequence* pPoints, - const SdXMLImExViewBox& rViewBox, - const com::sun::star::awt::Point& rObjectPos, - const com::sun::star::awt::Size& rObjectSize, - // #96328# - const bool bClosed = true); - SdXMLImExPointsElement(const rtl::OUString& rNew, - const SdXMLImExViewBox& rViewBox, - const com::sun::star::awt::Point& rObjectPos, - const com::sun::star::awt::Size& rObjectSize, - const SvXMLUnitConverter& rConv); - - const rtl::OUString& GetExportString() const { return msString; } - const com::sun::star::drawing::PointSequenceSequence& GetPointSequenceSequence() const { return maPoly; } -}; - -////////////////////////////////////////////////////////////////////////////// - -class SdXMLImExSvgDElement -{ - rtl::OUString msString; - const SdXMLImExViewBox& mrViewBox; - bool mbIsClosed; - bool mbIsCurve; - - sal_Int32 mnLastX; - sal_Int32 mnLastY; - - com::sun::star::drawing::PointSequenceSequence maPoly; - com::sun::star::drawing::FlagSequenceSequence maFlag; - -public: - SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox); - SdXMLImExSvgDElement(const rtl::OUString& rNew, - const SdXMLImExViewBox& rViewBox, - const com::sun::star::awt::Point& rObjectPos, - const com::sun::star::awt::Size& rObjectSize, - const SvXMLUnitConverter& rConv); - - void AddPolygon( - com::sun::star::drawing::PointSequence* pPoints, - com::sun::star::drawing::FlagSequence* pFlags, - const com::sun::star::awt::Point& rObjectPos, - const com::sun::star::awt::Size& rObjectSize, - bool bClosed = false, bool bRelative = true); - - const rtl::OUString& GetExportString() const { return msString; } - bool IsClosed() const { return mbIsClosed; } - bool IsCurve() const { return mbIsCurve; } - const com::sun::star::drawing::PointSequenceSequence& GetPointSequenceSequence() const { return maPoly; } - const com::sun::star::drawing::FlagSequenceSequence& GetFlagSequenceSequence() const { return maFlag; } -}; - - #endif // _XEXPTRANSFORM_HXX +// eof Modified: openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapContext.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapContext.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapContext.cxx (original) +++ openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapContext.cxx Mon Nov 4 19:00:37 2013 @@ -19,25 +19,18 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" #include "XMLImageMapContext.hxx" #include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/beans/XPropertySet.hpp> -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP #include <com/sun/star/beans/XPropertySetInfo.hpp> -#endif #include <com/sun/star/xml/sax/XAttributeList.hpp> #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/drawing/PointSequenceSequence.hpp> - -#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP #include <com/sun/star/document/XEventsSupplier.hpp> -#endif #include <com/sun/star/awt/Rectangle.hpp> #include <xmloff/xmltoken.hxx> #include <xmloff/xmlimp.hxx> @@ -50,7 +43,8 @@ #include <xmloff/XMLEventsImportContext.hxx> #include "XMLStringBufferImportContext.hxx" #include <tools/debug.hxx> - +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> using namespace ::com::sun::star; using namespace ::xmloff::token; @@ -506,33 +500,30 @@ void XMLImageMapPolygonContext::ProcessA bValid = bViewBoxOK && bPointsOK; } -void XMLImageMapPolygonContext::Prepare( - Reference<XPropertySet> & rPropertySet) +void XMLImageMapPolygonContext::Prepare(Reference<XPropertySet> & rPropertySet) { - // process view box - SdXMLImExViewBox aViewBox(sViewBoxString, - GetImport().GetMM100UnitConverter()); - - // get polygon sequence - awt::Point aPoint(aViewBox.GetX(), aViewBox.GetY()); - awt::Size aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); - SdXMLImExPointsElement aPoints( sPointsString, aViewBox, aPoint, aSize, - GetImport().GetMM100UnitConverter() ); - PointSequenceSequence aPointSeqSeq = aPoints.GetPointSequenceSequence(); - - // only use first element of sequence-sequence - if (aPointSeqSeq.getLength() > 0) - { - Any aAny; - aAny <<= aPointSeqSeq[0]; - rPropertySet->setPropertyValue(sPolygon, aAny); - } + // process view box + SdXMLImExViewBox aViewBox(sViewBoxString, GetImport().GetMM100UnitConverter()); - // parent properties - XMLImageMapObjectContext::Prepare(rPropertySet); -} + // get polygon sequence + basegfx::B2DPolygon aPolygon; + if(basegfx::tools::importFromSvgPoints(aPolygon, sPointsString)) + { + if(aPolygon.count()) + { + com::sun::star::drawing::PointSequence aPointSequence; + uno::Any aAny; + + basegfx::tools::B2DPolygonToUnoPointSequence(aPolygon, aPointSequence); + aAny <<= aPointSequence; + rPropertySet->setPropertyValue(sPolygon, aAny); + } + } + // parent properties + XMLImageMapObjectContext::Prepare(rPropertySet); +} class XMLImageMapCircleContext : public XMLImageMapObjectContext { Modified: openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapExport.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapExport.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapExport.cxx (original) +++ openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapExport.cxx Mon Nov 4 19:00:37 2013 @@ -19,8 +19,6 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" #include "XMLImageMapExport.hxx" @@ -32,10 +30,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XIndexContainer.hpp> - -#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP #include <com/sun/star/document/XEventsSupplier.hpp> -#endif #include <com/sun/star/awt/Rectangle.hpp> #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> @@ -46,8 +41,8 @@ #include <xmloff/XMLEventExport.hxx> #include <xmloff/xmluconv.hxx> #include "xexptran.hxx" - - +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> using namespace ::com::sun::star; using namespace ::xmloff::token; @@ -322,61 +317,43 @@ void XMLImageMapExport::ExportCircle( aBuffer.makeStringAndClear() ); } -void XMLImageMapExport::ExportPolygon( - const Reference<XPropertySet> & rPropertySet) +void XMLImageMapExport::ExportPolygon(const Reference<XPropertySet> & rPropertySet) { - // polygons get exported as bounding box, viewbox, and coordinate - // pair sequence. The bounding box is always the entire image. - - // get polygon point sequence - Any aAny = rPropertySet->getPropertyValue(msPolygon); - PointSequence aPoly; - aAny >>= aPoly; - - // get bounding box (assume top-left to be 0,0) - sal_Int32 nWidth = 0; - sal_Int32 nHeight = 0; - sal_Int32 nLength = aPoly.getLength(); - const struct awt::Point* pPointPtr = aPoly.getConstArray(); - for ( sal_Int32 i = 0; i < nLength; i++ ) - { - sal_Int32 nPolyX = pPointPtr->X; - sal_Int32 nPolyY = pPointPtr->Y; - - if ( nPolyX > nWidth ) - nWidth = nPolyX; - if ( nPolyY > nHeight ) - nHeight = nPolyY; - - pPointPtr++; - } - DBG_ASSERT(nWidth > 0, "impossible Polygon found"); - DBG_ASSERT(nHeight > 0, "impossible Polygon found"); + // polygons get exported as bounding box, viewbox, and coordinate + // pair sequence. The bounding box is always the entire image. - // parameters svg:x, svg:y, svg:width, svg:height - OUStringBuffer aBuffer; - mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0); - mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_X, - aBuffer.makeStringAndClear() ); - mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0); - mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_Y, - aBuffer.makeStringAndClear() ); - mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nWidth); - mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, - aBuffer.makeStringAndClear() ); - mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nHeight); - mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, - aBuffer.makeStringAndClear() ); + // get polygon point sequence + Any aAny = rPropertySet->getPropertyValue(msPolygon); + PointSequence aPoly; + aAny >>= aPoly; + + const basegfx::B2DPolygon aPolygon( + basegfx::tools::UnoPointSequenceToB2DPolygon( + aPoly)); + const basegfx::B2DRange aPolygonRange(aPolygon.getB2DRange()); + + // parameters svg:x, svg:y, svg:width, svg:height + OUStringBuffer aBuffer; + + mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0); + mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_X, aBuffer.makeStringAndClear() ); + mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0); + mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_Y, aBuffer.makeStringAndClear() ); + mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, basegfx::fround(aPolygonRange.getWidth())); + mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, aBuffer.makeStringAndClear() ); + mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, basegfx::fround(aPolygonRange.getHeight())); + mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, aBuffer.makeStringAndClear() ); + + // svg:viewbox + SdXMLImExViewBox aViewBox(0.0, 0.0, aPolygonRange.getWidth(), aPolygonRange.getHeight()); + mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString()); + + // export point sequence + const ::rtl::OUString aPointString( + basegfx::tools::exportToSvgPoints( + aPolygon)); - // svg:viewbox - SdXMLImExViewBox aViewBox(0, 0, nWidth, nHeight); - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, - aViewBox.GetExportString()); - - // export point sequence - awt::Point aPoint(0, 0); - awt::Size aSize(nWidth, nHeight); - SdXMLImExPointsElement aPoints( &aPoly, aViewBox, aPoint, aSize ); - mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_POINTS, - aPoints.GetExportString()); + mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString); } + +// eof Modified: openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport2.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport2.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport2.cxx (original) +++ openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport2.cxx Mon Nov 4 19:00:37 2013 @@ -19,8 +19,6 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" #include "unointerfacetouniqueidentifiermapper.hxx" @@ -35,10 +33,7 @@ #include <com/sun/star/drawing/HomogenMatrix3.hpp> #include <com/sun/star/media/ZoomLevel.hpp> #include "anim.hxx" - -#ifndef _XMLOFF_SHAPEEXPORT_HXX #include <xmloff/shapeexport.hxx> -#endif #include "sdpropls.hxx" #include <tools/debug.hxx> #include <tools/urlobj.hxx> @@ -50,10 +45,14 @@ #include <tools/gen.hxx> // FRound #include <xmloff/xmltoken.hxx> #include <xmloff/nmspmap.hxx> - #include "xmloff/xmlnmspe.hxx" #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/tuple/b2dtuple.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -955,27 +954,27 @@ void XMLShapeExport::ImpExportEllipseSha sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210# - if(bCircle) - { - // write circle - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CIRCLE, bCreateNewline, sal_True); + // prepare name (with most used) + enum ::xmloff::token::XMLTokenEnum eName(XML_CIRCLE); - ImpExportDescription( xShape ); // #i68101# - ImpExportEvents( xShape ); - ImpExportGluePoints( xShape ); - ImpExportText( xShape ); - } - else - { - // write ellipse - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_ELLIPSE, bCreateNewline, sal_True); + if(bCircle) + { + // name already set + } + else + { + // set name + eName = XML_ELLIPSE; + } - ImpExportDescription( xShape ); // #i68101# - ImpExportEvents( xShape ); - ImpExportGluePoints( xShape ); - ImpExportText( xShape ); - } - } + // write ellipse or circle + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, eName, bCreateNewline, sal_True); + + ImpExportDescription( xShape ); // #i68101# + ImpExportEvents( xShape ); + ImpExportGluePoints( xShape ); + ImpExportText( xShape ); + } } ////////////////////////////////////////////////////////////////////////////// @@ -1014,116 +1013,79 @@ void XMLShapeExport::ImpExportPolygonSha sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210# - if(bBezier) - { - // get PolygonBezier - uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))) ); - drawing::PolyPolygonBezierCoords* pSourcePolyPolygon = - (drawing::PolyPolygonBezierCoords*)aAny.getValue(); - - if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength()) - { - sal_Int32 nOuterCnt(pSourcePolyPolygon->Coordinates.getLength()); - drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->Coordinates.getArray(); - drawing::FlagSequence* pOuterFlags = pSourcePolyPolygon->Flags.getArray(); - - if(pOuterSequence && pOuterFlags) - { - // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement(aViewBox); - - for(sal_Int32 a(0L); a < nOuterCnt; a++) - { - drawing::PointSequence* pSequence = pOuterSequence++; - drawing::FlagSequence* pFlags = pOuterFlags++; - - if(pSequence && pFlags) - { - aSvgDElement.AddPolygon(pSequence, pFlags, - aPoint, aSize, bClosed); - } - } - - // write point array - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString()); - } - - // write object now - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PATH, bCreateNewline, sal_True); + // prepare name (with most used) + enum ::xmloff::token::XMLTokenEnum eName(XML_PATH); - ImpExportDescription( xShape ); // #i68101# - ImpExportEvents( xShape ); - ImpExportGluePoints( xShape ); - ImpExportText( xShape ); - } - } - else - { - // get non-bezier polygon - uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))) ); - drawing::PointSequenceSequence* pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue(); + if(bBezier) + { + // get PolygonBezier + uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))) ); + const basegfx::B2DPolyPolygon aPolyPolygon( + basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*(drawing::PolyPolygonBezierCoords*)aAny.getValue())); - if(pSourcePolyPolygon && pSourcePolyPolygon->getLength()) - { - sal_Int32 nOuterCnt(pSourcePolyPolygon->getLength()); + if(aPolyPolygon.count()) + { + // complex polygon shape, write as svg:d + const ::rtl::OUString aPolygonString( + basegfx::tools::exportToSvgD( + aPolyPolygon, + true, // bUseRelativeCoordinates + false, // bDetectQuadraticBeziers: not used in old, but maybe activated now + true)); // bHandleRelativeNextPointCompatible - if(1L == nOuterCnt && !bBezier) - { - // simple polygon shape, can be written as svg:points sequence - drawing::PointSequence* pSequence = pSourcePolyPolygon->getArray(); - if(pSequence) - { - SdXMLImExPointsElement aPoints(pSequence, aViewBox, aPoint, aSize, - // #96328# - bClosed); + // write point array + mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); + } + } + else + { + // get non-bezier polygon + uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))) ); + const basegfx::B2DPolyPolygon aPolyPolygon( + basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(*(drawing::PointSequenceSequence*)aAny.getValue())); - // write point array - mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPoints.GetExportString()); - } + if(!aPolyPolygon.areControlPointsUsed() && 1 == aPolyPolygon.count()) + { + // simple polygon shape, can be written as svg:points sequence + const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(0)); + const ::rtl::OUString aPointString(basegfx::tools::exportToSvgPoints(aPolygon)); - // write object now - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, - bClosed ? XML_POLYGON : XML_POLYLINE , bCreateNewline, sal_True); - - ImpExportDescription( xShape ); // #i68101# - ImpExportEvents( xShape ); - ImpExportGluePoints( xShape ); - ImpExportText( xShape ); - } - else - { - // polypolygon or bezier, needs to be written as a svg:path sequence - drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray(); - if(pOuterSequence) - { - // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement(aViewBox); + // write point array + mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString); - for(sal_Int32 a(0L); a < nOuterCnt; a++) - { - drawing::PointSequence* pSequence = pOuterSequence++; - if(pSequence) - { - aSvgDElement.AddPolygon(pSequence, 0L, aPoint, - aSize, bClosed); - } - } + // set name + eName = aPolygon.isClosed() ? XML_POLYGON : XML_POLYLINE; + } + else + { + // complex polygon shape, write as svg:d + 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 - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString()); - } + // write point array + mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); + } + } - // write object now - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PATH, bCreateNewline, sal_True); + // write object, but after attributes are added since this call will + // consume all of these added attributes and the destructor will close the + // scope. Also before text is added; this may add sub-scopes as needed + SvXMLElementExport aOBJ( + mrExport, + XML_NAMESPACE_DRAW, + eName, + bCreateNewline, + sal_True); - ImpExportDescription( xShape ); // #i68101# - ImpExportEvents( xShape ); - ImpExportGluePoints( xShape ); - ImpExportText( xShape ); - } - } - } - } + ImpExportDescription( xShape ); // #i68101# + ImpExportEvents( xShape ); + ImpExportGluePoints( xShape ); + ImpExportText( xShape ); + } } ////////////////////////////////////////////////////////////////////////////// @@ -1463,43 +1425,27 @@ void XMLShapeExport::ImpExportConnectorS } } - if( xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ) ) >>= aAny ) - { - // get PolygonBezier - drawing::PolyPolygonBezierCoords* pSourcePolyPolygon = - (drawing::PolyPolygonBezierCoords*)aAny.getValue(); - - if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength()) - { - sal_Int32 nOuterCnt(pSourcePolyPolygon->Coordinates.getLength()); - drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->Coordinates.getArray(); - drawing::FlagSequence* pOuterFlags = pSourcePolyPolygon->Flags.getArray(); - - if(pOuterSequence && pOuterFlags) - { - // prepare svx:d element export - awt::Point aPoint( 0, 0 ); - awt::Size aSize( 1, 1 ); - SdXMLImExViewBox aViewBox( 0, 0, 1, 1 ); - SdXMLImExSvgDElement aSvgDElement(aViewBox); - - for(sal_Int32 a(0L); a < nOuterCnt; a++) - { - drawing::PointSequence* pSequence = pOuterSequence++; - drawing::FlagSequence* pFlags = pOuterFlags++; + if( xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ) ) >>= aAny ) + { + // get PolygonBezier + drawing::PolyPolygonBezierCoords* pSourcePolyPolygon = (drawing::PolyPolygonBezierCoords*)aAny.getValue(); - if(pSequence && pFlags) - { - aSvgDElement.AddPolygon(pSequence, pFlags, - aPoint, aSize, sal_False ); - } - } + if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength()) + { + const basegfx::B2DPolyPolygon aPolyPolygon( + basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( + *pSourcePolyPolygon)); + 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 - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString()); - } - } - } + // write point array + mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); + } + } // write connector shape. Add Export later. sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210# Modified: openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport3.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport3.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport3.cxx (original) +++ openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport3.cxx Mon Nov 4 19:00:37 2013 @@ -19,10 +19,9 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" + #include <com/sun/star/drawing/HomogenMatrix.hpp> #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> #include <com/sun/star/drawing/ProjectionMode.hpp> @@ -32,10 +31,7 @@ #include <com/sun/star/drawing/CameraGeometry.hpp> #include <com/sun/star/drawing/DoubleSequence.hpp> #include <tools/gen.hxx> - -#ifndef _XMLOFF_SHAPEEXPORT_HXX #include <xmloff/shapeexport.hxx> -#endif #include "sdpropls.hxx" #include <tools/debug.hxx> #include <rtl/ustrbuf.hxx> @@ -44,8 +40,12 @@ #include "xexptran.hxx" #include <xmloff/xmltoken.hxx> #include <basegfx/vector/b3dvector.hxx> - -#include "xmloff/xmlnmspe.hxx" +#include <xmloff/xmlnmspe.hxx> +#include <basegfx/polygon/b3dpolypolygon.hxx> +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -124,9 +124,6 @@ void XMLShapeExport::ImpExport3DShape( { case XmlShapeTypeDraw3DCubeObject: { - // write 3DCube shape - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_CUBE, sal_True, sal_True); - // minEdge aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition"))); drawing::Position3D aPosition3D; @@ -158,13 +155,15 @@ void XMLShapeExport::ImpExport3DShape( mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MAX_EDGE, aStr); } - break; + // write 3DCube shape + // #123542# Do this *after* the attributes are added, else these will be lost since opening + // the scope will clear the global attribute list at the exporter + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_CUBE, sal_True, sal_True); + + break; } case XmlShapeTypeDraw3DSphereObject: { - // write 3DSphere shape - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_SPHERE, sal_True, sal_True); - // Center aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition"))); drawing::Position3D aPosition3D; @@ -193,109 +192,55 @@ void XMLShapeExport::ImpExport3DShape( mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SIZE, aStr); } + // write 3DSphere shape + // #123542# Do this *after* the attributes are added, else these will be lost since opening + // the scope will clear the global attribute list at the exporter + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_SPHERE, sal_True, sal_True); + break; } case XmlShapeTypeDraw3DLatheObject: case XmlShapeTypeDraw3DExtrudeObject: { - // write special 3DLathe/3DExtrude attributes - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D"))); - drawing::PolyPolygonShape3D xPolyPolygon3D; - aAny >>= xPolyPolygon3D; - - // look for maximal values - double fXMin = 0; - double fXMax = 0; - double fYMin = 0; - double fYMax = 0; - sal_Bool bInit(sal_False); - sal_Int32 nOuterSequenceCount(xPolyPolygon3D.SequenceX.getLength()); - drawing::DoubleSequence* pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray(); - drawing::DoubleSequence* pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray(); - - sal_Int32 a; - for (a = 0; a < nOuterSequenceCount; a++) - { - sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength()); - double* pArrayX = pInnerSequenceX->getArray(); - double* pArrayY = pInnerSequenceY->getArray(); - - for(sal_Int32 b(0L); b < nInnerSequenceCount; b++) - { - double fX = *pArrayX++; - double fY = *pArrayY++; - - if(bInit) - { - if(fX > fXMax) - fXMax = fX; - - if(fX < fXMin) - fXMin = fX; - - if(fY > fYMax) - fYMax = fY; - - if(fY < fYMin) - fYMin = fY; - } - else - { - fXMin = fXMax = fX; - fYMin = fYMax = fY; - bInit = sal_True; - } - } - - pInnerSequenceX++; - pInnerSequenceY++; - } - - // export ViewBox - awt::Point aMinPoint(FRound(fXMin), FRound(fYMin)); - awt::Size aMaxSize(FRound(fXMax) - aMinPoint.X, FRound(fYMax) - aMinPoint.Y); - SdXMLImExViewBox aViewBox( - aMinPoint.X, aMinPoint.Y, aMaxSize.Width, aMaxSize.Height); - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, - aViewBox.GetExportString()); - - // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement(aViewBox); - pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray(); - pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray(); - - for (a = 0; a < nOuterSequenceCount; a++) - { - sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength()); - double* pArrayX = pInnerSequenceX->getArray(); - double* pArrayY = pInnerSequenceY->getArray(); - drawing::PointSequence aPoly(nInnerSequenceCount); - awt::Point* pInnerSequence = aPoly.getArray(); - - for(sal_Int32 b(0L); b < nInnerSequenceCount; b++) - { - double fX = *pArrayX++; - double fY = *pArrayY++; - - *pInnerSequence = awt::Point(FRound(fX), FRound(fY)); - pInnerSequence++; - } - - // calculate closed flag - awt::Point* pFirst = aPoly.getArray(); - awt::Point* pLast = pFirst + (nInnerSequenceCount - 1); - sal_Bool bClosed = (pFirst->X == pLast->X && pFirst->Y == pLast->Y); - - aSvgDElement.AddPolygon(&aPoly, 0L, aMinPoint, - aMaxSize, bClosed); - - // #80594# corrected error in PolyPolygon3D export for 3D XML - pInnerSequenceX++; - pInnerSequenceY++; - } + // write special 3DLathe/3DExtrude attributes, get 3D PolyPolygon as drawing::PolyPolygonShape3D + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D"))); + drawing::PolyPolygonShape3D xPolyPolygon3D; + aAny >>= xPolyPolygon3D; + + // convert to 3D PolyPolygon + const basegfx::B3DPolyPolygon aPolyPolygon3D( + basegfx::tools::UnoPolyPolygonShape3DToB3DPolyPolygon( + xPolyPolygon3D)); + + // convert to 2D PolyPolygon using identity 3D transformation (just grep X and Y) + const basegfx::B3DHomMatrix aB3DHomMatrixFor2DConversion; + const basegfx::B2DPolyPolygon aPolyPolygon( + basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon( + aPolyPolygon3D, + aB3DHomMatrixFor2DConversion)); + + // get 2D range of it + const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange()); + + // export ViewBox + SdXMLImExViewBox aViewBox( + aPolyPolygonRange.getMinX(), + aPolyPolygonRange.getMinY(), + aPolyPolygonRange.getWidth(), + aPolyPolygonRange.getHeight()); + + mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString()); + + // prepare svg:d string + const ::rtl::OUString aPolygonString( + basegfx::tools::exportToSvgD( + aPolyPolygon, + true, // bUseRelativeCoordinates + false, // bDetectQuadraticBeziers TTTT: not used in old, but maybe activated now + true)); // bHandleRelativeNextPointCompatible - // write point array - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString()); + // write point array + mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); if(eShapeType == XmlShapeTypeDraw3DLatheObject) {
