diff options
author | Zhe Wang <wangzcdl@apache.org> | 2012-06-20 05:54:57 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-04-13 09:03:09 +0100 |
commit | fbc42f30bc0fbca4d12f34059f2b2b821921d849 (patch) | |
tree | e90b891694565b19998468185b1a27e99cefcb65 | |
parent | 5cd3da2246bba2e2902010e023922ece2fffbd1e (diff) |
Resolves: #i119974# Ellipse shape too large in MS office ppt
(cherry picked from commit 1330e0eed32d5d6fee532a0538efada306822810)
Conflicts:
svx/source/customshapes/EnhancedCustomShape2d.cxx
Change-Id: If0b17bf110306b500cd7142a6a7fa4c343db68ff
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index b5d2d61f1fe1..c37e17b013d7 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -1578,10 +1578,77 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ ) { // create a circle - Point _aCenter( GetPoint( seqCoordinates[ rSrcPt ], true, true ) ); + Point _aCenter; double fWidth, fHeight; - GetParameter( fWidth, seqCoordinates[ rSrcPt + 1 ].First, true, false ); - GetParameter( fHeight, seqCoordinates[ rSrcPt + 1 ].Second, false, true ); + const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( mso_sptEllipse ); + bool bIsDefaultViewBox = false; + bool bIsDefaultPath = false; + bool bIsMSEllipse = false; + + if( ( nCoordWidth == pDefCustomShape->nCoordWidth ) + && ( nCoordHeight == pDefCustomShape->nCoordHeight ) ) + bIsDefaultViewBox = true; + sal_Int32 j, nCount = pDefCustomShape->nVertices;//==3 + com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates1, seqCoordinates2; + + seqCoordinates1.realloc( nCount ); + for ( j = 0; j < nCount; j++ ) + { + seqCoordinates1[j] = seqCoordinates[ rSrcPt + j]; + } + + seqCoordinates2.realloc( nCount ); + for ( j = 0; j < nCount; j++ ) + { + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ j ].First, pDefCustomShape->pVertices[ j ].nValA ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ j ].Second, pDefCustomShape->pVertices[ j ].nValB ); + } + if(seqCoordinates1 == seqCoordinates2) + bIsDefaultPath = true; + + const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) ); + rtl::OUString sShpType; + SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); + Any* pAny = rGeometryItem.GetPropertyValueByName( sType ); + if ( pAny ) + *pAny >>= sShpType; + if( sShpType.getLength() > 3 && + sShpType.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "mso" ))){ + bIsMSEllipse = true; + } + if( (! bIsDefaultPath && ! bIsDefaultViewBox) || (bIsDefaultViewBox && bIsMSEllipse) /*&& (nGeneratorVersion == SfxObjectShell::Sym_L2)*/ ) + { + _aCenter = GetPoint( seqCoordinates[ rSrcPt ], true, true ); + GetParameter( fWidth, seqCoordinates[ rSrcPt + 1 ].First, true, false ); + GetParameter( fHeight, seqCoordinates[ rSrcPt + 1 ].Second, false, true ); + fWidth /= 2; + fHeight /= 2; + }else if( bIsDefaultPath && !bIsDefaultViewBox /*&& (nGeneratorVersion == SfxObjectShell::Sym_L2)*/ ) + { + _aCenter.X() = nCoordWidth/2 * fXScale; + _aCenter.Y() = nCoordHeight/2 * fYScale; + fWidth = nCoordWidth/2; + fHeight = nCoordHeight/2; + + const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) ); + const Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sViewBox ); + com::sun::star::awt::Rectangle aViewBox; + if ( pViewBox && (*pViewBox >>= aViewBox ) ) + { + aViewBox.Width = pDefCustomShape->nCoordWidth; + aViewBox.Height = pDefCustomShape->nCoordHeight; + } + com::sun::star::beans::PropertyValue aPropVal; + aPropVal.Name = sViewBox; + aPropVal.Value <<= aViewBox; + rGeometryItem.SetPropertyValue( aPropVal ); + pCustomShapeObj->SetMergedItem( rGeometryItem ); + }else{ + _aCenter = GetPoint( seqCoordinates[ rSrcPt ], true, true ); + GetParameter( fWidth, seqCoordinates[ rSrcPt + 1 ].First, true, false); + GetParameter( fHeight, seqCoordinates[ rSrcPt + 1 ].Second, false, true ); + } + fWidth *= fXScale; fHeight*= fYScale; Point aP( (sal_Int32)( _aCenter.X() - fWidth ), (sal_Int32)( _aCenter.Y() - fHeight ) ); |