diff options
author | Radek Doulik <rodo@novell.com> | 2012-01-19 09:43:41 +0100 |
---|---|---|
committer | Radek Doulik <rodo@novell.com> | 2012-01-19 09:48:53 +0100 |
commit | d281af514546b18cb429cfb4f68128e60980adb8 (patch) | |
tree | 7a2d3f7b9ade87f04d7a7cb9ea1546695b2519f7 /svx | |
parent | fccfa941b206e530449516432a6396376d948336 (diff) |
implemented SubViewSize property for EnhancedCustomShapePath
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/svx/EnhancedCustomShape2d.hxx | 9 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 117 |
2 files changed, 84 insertions, 42 deletions
diff --git a/svx/inc/svx/EnhancedCustomShape2d.hxx b/svx/inc/svx/EnhancedCustomShape2d.hxx index fa2a07970f18..415385cea83f 100644 --- a/svx/inc/svx/EnhancedCustomShape2d.hxx +++ b/svx/inc/svx/EnhancedCustomShape2d.hxx @@ -34,6 +34,7 @@ #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/beans/PropertyValues.hpp> #include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> #include <svl/itemset.hxx> #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> @@ -86,6 +87,8 @@ class EnhancedCustomShape2d : public SfxItemSet sal_Int32 nCoordLeft; sal_Int32 nCoordTop; + sal_Int32 nCoordWidthG; + sal_Int32 nCoordHeightG; sal_Int32 nCoordWidth; sal_Int32 nCoordHeight; Rectangle aLogicRect; @@ -119,6 +122,7 @@ class EnhancedCustomShape2d : public SfxItemSet com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints; com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues; com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles; + com::sun::star::uno::Sequence< com::sun::star::awt::Size > seqSubViewSize; sal_Bool bTextFlow : 1; sal_Bool bFilled : 1; @@ -139,10 +143,13 @@ class EnhancedCustomShape2d : public SfxItemSet const sal_Bool bScale = sal_True, const sal_Bool bReplaceGeoSize = sal_False ) const; void CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList, - sal_Bool bLineGeometryNeededOnly, sal_Bool bSortFilledObjectsToBack ); + sal_Bool bLineGeometryNeededOnly, sal_Bool bSortFilledObjectsToBack, + sal_Int32 nIndex ); SdrObject* CreatePathObj( sal_Bool bLineGeometryNeededOnly ); const sal_Int32* ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem ); + void SetPathSize( sal_Int32 nIndex = 0 ); + public : struct Handle diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index ee8a365a46c2..3e5f340802df 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -600,10 +600,10 @@ const sal_Int32* EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomSha com::sun::star::awt::Rectangle aViewBox; if ( pViewBox && (*pViewBox >>= aViewBox ) ) { - nCoordLeft = aViewBox.X; - nCoordTop = aViewBox.Y; - nCoordWidth = labs( aViewBox.Width ); - nCoordHeight= labs( aViewBox.Height); + nCoordLeft = aViewBox.X; + nCoordTop = aViewBox.Y; + nCoordWidthG = labs( aViewBox.Width ); + nCoordHeightG = labs( aViewBox.Height); } const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) ); @@ -631,6 +631,14 @@ const sal_Int32* EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomSha if ( pAny ) *pAny >>= seqSegments; + ////////////////////// + // Path/SubViewSize // + ////////////////////// + const rtl::OUString sSubViewSize( RTL_CONSTASCII_USTRINGPARAM ( "SubViewSize" ) ); + pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sSubViewSize ); + if ( pAny ) + *pAny >>= seqSubViewSize; + /////////////////// // Path/StretchX // /////////////////// @@ -686,14 +694,65 @@ EnhancedCustomShape2d::~EnhancedCustomShape2d() { } +void EnhancedCustomShape2d::SetPathSize( sal_Int32 nIndex ) +{ + sal_Int32 nWidth = 0; + sal_Int32 nHeight = 0; + + if ( seqSubViewSize.getLength() && nIndex < seqSubViewSize.getLength() ) { + nWidth = seqSubViewSize[ nIndex ].Width; + nHeight = seqSubViewSize[ nIndex ].Height; + OSL_TRACE("set subpath %d size: %d x %d", nIndex, nWidth, nHeight); + } + + if ( nWidth && nHeight ) { + nCoordWidth = nWidth; + nCoordHeight = nHeight; + } else { + nCoordWidth = nCoordWidthG; + nCoordHeight = nCoordHeightG; + } + + fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth; + fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight; + if ( bOOXMLShape ) + { + OSL_TRACE("ooxml shape, path width: %d height: %d", nCoordWidth, nCoordHeight); + if ( nCoordWidth == 0 ) + fXScale = 1.0; + if ( nCoordHeight == 0 ) + fYScale = 1.0; + } + if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() ) + { + fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight(); + if ( fXRatio > 1 ) + fXScale /= fXRatio; + else + fXRatio = 1.0; + } + else + fXRatio = 1.0; + if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() ) + { + fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth(); + if ( fYRatio > 1 ) + fYScale /= fYRatio; + else + fYRatio = 1.0; + } + else + fYRatio = 1.0; +} + EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : SfxItemSet ( pAObj->GetMergedItemSet() ), pCustomShapeObj ( pAObj ), eSpType ( mso_sptNil ), nCoordLeft ( 0 ), nCoordTop ( 0 ), - nCoordWidth ( 21600 ), - nCoordHeight ( 21600 ), + nCoordWidthG ( 21600 ), + nCoordHeightG ( 21600 ), bOOXMLShape ( sal_False ), nXRef ( 0x80000000 ), nYRef ( 0x80000000 ), @@ -754,6 +813,8 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : nRotateAngle = pCustomShapeObj->GetRotateAngle(); /*const sal_Int32* pDefData =*/ ApplyShapeAttributes( rGeometryItem ); + SetPathSize(); + switch( eSpType ) { case mso_sptCan : nColorData = 0x20400000; break; @@ -798,40 +859,8 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : break; } - fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth; - fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight; - if ( bOOXMLShape ) - { - OSL_TRACE("ooxml shape, path width: %d height: %d", nCoordWidth, nCoordHeight); - if ( nCoordWidth == 0 ) - fXScale = 1.0; - if ( nCoordHeight == 0 ) - fYScale = 1.0; - } - if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() ) - { - fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight(); - if ( fXRatio > 1 ) - fXScale /= fXRatio; - else - fXRatio = 1.0; - } - else - fXRatio = 1.0; - if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() ) - { - fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth(); - if ( fYRatio > 1 ) - fYScale /= fYRatio; - else - fYRatio = 1.0; - } - else - fYRatio = 1.0; - sal_Int32 i, nLength = seqEquations.getLength(); - if ( nLength ) { vNodesSharedPtr.resize( nLength ); @@ -1452,8 +1481,9 @@ basegfx::B2DPolygon CreateArc( const Rectangle& rRect, const Point& rStart, cons } void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList, - const sal_Bool bLineGeometryNeededOnly, - const sal_Bool bSortFilledObjectsToBack ) + const sal_Bool bLineGeometryNeededOnly, + const sal_Bool bSortFilledObjectsToBack, + sal_Int32 nIndex ) { sal_Bool bNoFill = sal_False; sal_Bool bNoStroke = sal_False; @@ -1462,6 +1492,8 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm basegfx::B2DPolyPolygon aNewB2DPolyPolygon; basegfx::B2DPolygon aNewB2DPolygon; + SetPathSize( nIndex ); + sal_Int32 nCoordSize = seqCoordinates.getLength(); sal_Int32 nSegInfoSize = seqSegments.getLength(); if ( !nSegInfoSize ) @@ -2132,9 +2164,12 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnl std::vector< SdrPathObj* > vObjectList; sal_Bool bSortFilledObjectsToBack = SortFilledObjectsToBackByDefault( eSpType ); + sal_Int32 nSubPathIndex = 0; + while( nSegmentInd <= seqSegments.getLength() ) { - CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack ); + CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack, nSubPathIndex ); + nSubPathIndex ++; } SdrObject* pRet = NULL; |