1cdf0e10cSrcweir /************************************************************************* 2cdf0e10cSrcweir * 3cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4cdf0e10cSrcweir * 5cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6cdf0e10cSrcweir * 7cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8cdf0e10cSrcweir * 9cdf0e10cSrcweir * This file is part of OpenOffice.org. 10cdf0e10cSrcweir * 11cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14cdf0e10cSrcweir * 15cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20cdf0e10cSrcweir * 21cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25cdf0e10cSrcweir * 26cdf0e10cSrcweir ************************************************************************/ 27cdf0e10cSrcweir 28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29cdf0e10cSrcweir #include "precompiled_svx.hxx" 30cdf0e10cSrcweir #include <svx/svdoashp.hxx> 31cdf0e10cSrcweir #include "svx/unoapi.hxx" 32cdf0e10cSrcweir #include <svx/unoshape.hxx> 33cdf0e10cSrcweir #include <ucbhelper/content.hxx> 34cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx> 35cdf0e10cSrcweir #include <unotools/datetime.hxx> 36cdf0e10cSrcweir #include <sfx2/lnkbase.hxx> 37cdf0e10cSrcweir #include <tools/urlobj.hxx> 38cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 39cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp> 40cdf0e10cSrcweir #include <com/sun/star/drawing/XCustomShapeEngine.hpp> 41cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> 42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 43cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 44cdf0e10cSrcweir #include "unopolyhelper.hxx" 45cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 46cdf0e10cSrcweir #include <svl/urihelper.hxx> 47cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h> 48cdf0e10cSrcweir #include <svx/svdogrp.hxx> 49cdf0e10cSrcweir #include <vcl/salbtype.hxx> // FRound 50cdf0e10cSrcweir #include <svx/svddrag.hxx> 51cdf0e10cSrcweir #include <svx/xpool.hxx> 52cdf0e10cSrcweir #include <svx/xpoly.hxx> 53cdf0e10cSrcweir #include <svx/svdmodel.hxx> 54cdf0e10cSrcweir #include <svx/svdpage.hxx> 55cdf0e10cSrcweir #include "svx/svditer.hxx" 56cdf0e10cSrcweir #include <svx/svdobj.hxx> 57cdf0e10cSrcweir #include <svx/svdtrans.hxx> 58cdf0e10cSrcweir #include <svx/svdetc.hxx> 59cdf0e10cSrcweir #include <svx/svdattrx.hxx> // NotPersistItems 60cdf0e10cSrcweir #include <svx/svdoedge.hxx> // #32383# Die Verbinder nach Move nochmal anbroadcasten 61cdf0e10cSrcweir #include "svx/svdglob.hxx" // StringCache 62cdf0e10cSrcweir #include "svx/svdstr.hrc" // Objektname 63cdf0e10cSrcweir #include <editeng/eeitem.hxx> 64cdf0e10cSrcweir #include "editeng/editstat.hxx" 65cdf0e10cSrcweir #include <svx/svdoutl.hxx> 66cdf0e10cSrcweir #include <editeng/outlobj.hxx> 67cdf0e10cSrcweir #include <svx/sdtfchim.hxx> 68cdf0e10cSrcweir #include "../svx/EnhancedCustomShapeGeometry.hxx" 69cdf0e10cSrcweir #include "../svx/EnhancedCustomShapeTypeNames.hxx" 70cdf0e10cSrcweir #include "../svx/EnhancedCustomShape2d.hxx" 71cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValues.hpp> 72cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> 73cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> 74cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> 75cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> 76cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> 77cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx> 78cdf0e10cSrcweir #include <svx/xlnclit.hxx> 79cdf0e10cSrcweir #include <svx/svxids.hrc> 80cdf0e10cSrcweir #include <svl/whiter.hxx> 81cdf0e10cSrcweir #include <svx/sdr/properties/customshapeproperties.hxx> 82cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrobjcustomshape.hxx> 83cdf0e10cSrcweir #include <svx/xlnclit.hxx> 84cdf0e10cSrcweir #include <svx/xlntrit.hxx> 85cdf0e10cSrcweir #include <svx/xfltrit.hxx> 86cdf0e10cSrcweir #include <svx/xflclit.hxx> 87cdf0e10cSrcweir #include <svx/xflgrit.hxx> 88cdf0e10cSrcweir #include <svx/xflhtit.hxx> 89cdf0e10cSrcweir #include <svx/xbtmpit.hxx> 90cdf0e10cSrcweir #include <vcl/bmpacc.hxx> 91cdf0e10cSrcweir #include <svx/svdview.hxx> 92cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 93cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 94cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 95cdf0e10cSrcweir 96cdf0e10cSrcweir // #104018# replace macros above with type-safe methods 97cdf0e10cSrcweir inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); } 98cdf0e10cSrcweir inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); } 99cdf0e10cSrcweir 100cdf0e10cSrcweir using namespace ::com::sun::star; 101cdf0e10cSrcweir using namespace ::com::sun::star::uno; 102cdf0e10cSrcweir using namespace ::com::sun::star::lang; 103cdf0e10cSrcweir using namespace ::com::sun::star::beans; 104cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 105cdf0e10cSrcweir 106cdf0e10cSrcweir static MSO_SPT ImpGetCustomShapeType( const SdrObjCustomShape& rCustoShape ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir MSO_SPT eRetValue = mso_sptNil; 109cdf0e10cSrcweir 110cdf0e10cSrcweir rtl::OUString aEngine( ( (SdrCustomShapeEngineItem&)rCustoShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE ) ).GetValue() ); 111cdf0e10cSrcweir if ( !aEngine.getLength() || aEngine.equalsAscii( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) ) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir rtl::OUString sShapeType; 114cdf0e10cSrcweir const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) ); 115cdf0e10cSrcweir SdrCustomShapeGeometryItem& rGeometryItem( (SdrCustomShapeGeometryItem&)rCustoShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 116cdf0e10cSrcweir Any* pAny = rGeometryItem.GetPropertyValueByName( sType ); 117cdf0e10cSrcweir if ( pAny && ( *pAny >>= sShapeType ) ) 118cdf0e10cSrcweir eRetValue = EnhancedCustomShapeTypeNames::Get( sShapeType ); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir return eRetValue; 121cdf0e10cSrcweir }; 122cdf0e10cSrcweir 123cdf0e10cSrcweir static sal_Bool ImpVerticalSwitch( const SdrObjCustomShape& rCustoShape ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir sal_Bool bRet = sal_False; 126cdf0e10cSrcweir MSO_SPT eShapeType( ImpGetCustomShapeType( rCustoShape ) ); 127cdf0e10cSrcweir switch( eShapeType ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir case mso_sptAccentBorderCallout90 : // 2 ortho 130cdf0e10cSrcweir case mso_sptBorderCallout1 : // 2 diag 131cdf0e10cSrcweir case mso_sptBorderCallout2 : // 3 132cdf0e10cSrcweir { 133cdf0e10cSrcweir bRet = sal_True; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir break; 136cdf0e10cSrcweir /* 137cdf0e10cSrcweir case mso_sptCallout1 : 138cdf0e10cSrcweir case mso_sptAccentCallout1 : 139cdf0e10cSrcweir case mso_sptAccentBorderCallout1 : 140cdf0e10cSrcweir case mso_sptBorderCallout90 : 141cdf0e10cSrcweir case mso_sptCallout90 : 142cdf0e10cSrcweir case mso_sptAccentCallout90 : 143cdf0e10cSrcweir case mso_sptCallout2 : 144cdf0e10cSrcweir case mso_sptCallout3 : 145cdf0e10cSrcweir case mso_sptAccentCallout2 : 146cdf0e10cSrcweir case mso_sptAccentCallout3 : 147cdf0e10cSrcweir case mso_sptBorderCallout3 : 148cdf0e10cSrcweir case mso_sptAccentBorderCallout2 : 149cdf0e10cSrcweir case mso_sptAccentBorderCallout3 : 150cdf0e10cSrcweir */ 151cdf0e10cSrcweir default: break; 152cdf0e10cSrcweir } 153cdf0e10cSrcweir return bRet; 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 157cdf0e10cSrcweir // #i37011# create a clone with all attributes changed to shadow attributes 158cdf0e10cSrcweir // and translation executed, too. 159cdf0e10cSrcweir SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemSet& rOriginalSet) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir SdrObject* pRetval = 0L; 162cdf0e10cSrcweir const sal_Bool bShadow(((SdrShadowItem&)rOriginalSet.Get(SDRATTR_SHADOW)).GetValue()); 163cdf0e10cSrcweir 164cdf0e10cSrcweir if(bShadow) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir // create a shadow representing object 167cdf0e10cSrcweir const sal_Int32 nXDist(((SdrShadowXDistItem&)(rOriginalSet.Get(SDRATTR_SHADOWXDIST))).GetValue()); 168cdf0e10cSrcweir const sal_Int32 nYDist(((SdrShadowYDistItem&)(rOriginalSet.Get(SDRATTR_SHADOWYDIST))).GetValue()); 169cdf0e10cSrcweir const ::Color aShadowColor(((SdrShadowColorItem&)(rOriginalSet.Get(SDRATTR_SHADOWCOLOR))).GetColorValue()); 170cdf0e10cSrcweir const sal_uInt16 nShadowTransparence(((SdrShadowTransparenceItem&)(rOriginalSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue()); 171cdf0e10cSrcweir pRetval = rOriginal.Clone(); 172cdf0e10cSrcweir DBG_ASSERT(pRetval, "ImpCreateShadowObjectClone: Could not clone object (!)"); 173cdf0e10cSrcweir 174cdf0e10cSrcweir // look for used stuff 175cdf0e10cSrcweir SdrObjListIter aIterator(rOriginal); 176cdf0e10cSrcweir sal_Bool bLineUsed(sal_False); 177cdf0e10cSrcweir sal_Bool bAllFillUsed(sal_False); 178cdf0e10cSrcweir sal_Bool bSolidFillUsed(sal_False); 179cdf0e10cSrcweir sal_Bool bGradientFillUsed(sal_False); 180cdf0e10cSrcweir sal_Bool bHatchFillUsed(sal_False); 181cdf0e10cSrcweir sal_Bool bBitmapFillUsed(sal_False); 182cdf0e10cSrcweir 183cdf0e10cSrcweir while(aIterator.IsMore()) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir SdrObject* pObj = aIterator.Next(); 186cdf0e10cSrcweir XFillStyle eFillStyle = ((XFillStyleItem&)(pObj->GetMergedItem(XATTR_FILLSTYLE))).GetValue(); 187cdf0e10cSrcweir 188cdf0e10cSrcweir if(!bLineUsed) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir XLineStyle eLineStyle = ((XLineStyleItem&)(pObj->GetMergedItem(XATTR_LINESTYLE))).GetValue(); 191cdf0e10cSrcweir 192cdf0e10cSrcweir if(XLINE_NONE != eLineStyle) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir bLineUsed = sal_True; 195cdf0e10cSrcweir } 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir if(!bAllFillUsed) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir if(!bSolidFillUsed && XFILL_SOLID == eFillStyle) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir bSolidFillUsed = sal_True; 203cdf0e10cSrcweir bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir if(!bGradientFillUsed && XFILL_GRADIENT == eFillStyle) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir bGradientFillUsed = sal_True; 208cdf0e10cSrcweir bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir if(!bHatchFillUsed && XFILL_HATCH == eFillStyle) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir bHatchFillUsed = sal_True; 213cdf0e10cSrcweir bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir if(!bBitmapFillUsed && XFILL_BITMAP == eFillStyle) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir bBitmapFillUsed = sal_True; 218cdf0e10cSrcweir bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir } 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir // translate to shadow coordinates 224cdf0e10cSrcweir pRetval->NbcMove(Size(nXDist, nYDist)); 225cdf0e10cSrcweir 226cdf0e10cSrcweir // set items as needed 227cdf0e10cSrcweir SfxItemSet aTempSet(rOriginalSet); 228cdf0e10cSrcweir 229cdf0e10cSrcweir // SJ: #40108# :-( if a SvxWritingModeItem (Top->Bottom) is set the text object 230cdf0e10cSrcweir // is creating a paraobject, but paraobjects can not be created without model. So 231cdf0e10cSrcweir // we are preventing the crash by setting the writing mode always left to right, 232cdf0e10cSrcweir // this is not bad since our shadow geometry does not contain text. 233cdf0e10cSrcweir aTempSet.Put( SvxWritingModeItem( com::sun::star::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION ) ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir // no shadow 236cdf0e10cSrcweir aTempSet.Put(SdrShadowItem(sal_False)); 237cdf0e10cSrcweir aTempSet.Put(SdrShadowXDistItem(0L)); 238cdf0e10cSrcweir aTempSet.Put(SdrShadowYDistItem(0L)); 239cdf0e10cSrcweir 240cdf0e10cSrcweir // line color and transparence like shadow 241cdf0e10cSrcweir if(bLineUsed) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir aTempSet.Put(XLineColorItem(String(), aShadowColor)); 244cdf0e10cSrcweir aTempSet.Put(XLineTransparenceItem(nShadowTransparence)); 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir // fill color and transparence like shadow 248cdf0e10cSrcweir if(bSolidFillUsed) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir aTempSet.Put(XFillColorItem(String(), aShadowColor)); 251cdf0e10cSrcweir aTempSet.Put(XFillTransparenceItem(nShadowTransparence)); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir // gradient and transparence like shadow 255cdf0e10cSrcweir if(bGradientFillUsed) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir XGradient aGradient(((XFillGradientItem&)(rOriginalSet.Get(XATTR_FILLGRADIENT))).GetGradientValue()); 258cdf0e10cSrcweir sal_uInt8 nStartLuminance(aGradient.GetStartColor().GetLuminance()); 259cdf0e10cSrcweir sal_uInt8 nEndLuminance(aGradient.GetEndColor().GetLuminance()); 260cdf0e10cSrcweir 261cdf0e10cSrcweir if(aGradient.GetStartIntens() != 100) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir nStartLuminance = (sal_uInt8)(nStartLuminance * ((double)aGradient.GetStartIntens() / 100.0)); 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir if(aGradient.GetEndIntens() != 100) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir nEndLuminance = (sal_uInt8)(nEndLuminance * ((double)aGradient.GetEndIntens() / 100.0)); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir ::Color aStartColor( 272cdf0e10cSrcweir (sal_uInt8)((nStartLuminance * aShadowColor.GetRed()) / 256), 273cdf0e10cSrcweir (sal_uInt8)((nStartLuminance * aShadowColor.GetGreen()) / 256), 274cdf0e10cSrcweir (sal_uInt8)((nStartLuminance * aShadowColor.GetBlue()) / 256)); 275cdf0e10cSrcweir 276cdf0e10cSrcweir ::Color aEndColor( 277cdf0e10cSrcweir (sal_uInt8)((nEndLuminance * aShadowColor.GetRed()) / 256), 278cdf0e10cSrcweir (sal_uInt8)((nEndLuminance * aShadowColor.GetGreen()) / 256), 279cdf0e10cSrcweir (sal_uInt8)((nEndLuminance * aShadowColor.GetBlue()) / 256)); 280cdf0e10cSrcweir 281cdf0e10cSrcweir aGradient.SetStartColor(aStartColor); 282cdf0e10cSrcweir aGradient.SetEndColor(aEndColor); 283cdf0e10cSrcweir aTempSet.Put(XFillGradientItem(aTempSet.GetPool(), aGradient)); 284cdf0e10cSrcweir aTempSet.Put(XFillTransparenceItem(nShadowTransparence)); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir // hatch and transparence like shadow 288cdf0e10cSrcweir if(bHatchFillUsed) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir XHatch aHatch(((XFillHatchItem&)(rOriginalSet.Get(XATTR_FILLHATCH))).GetHatchValue()); 291cdf0e10cSrcweir aHatch.SetColor(aShadowColor); 292cdf0e10cSrcweir aTempSet.Put(XFillHatchItem(aTempSet.GetPool(), aHatch)); 293cdf0e10cSrcweir aTempSet.Put(XFillTransparenceItem(nShadowTransparence)); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir // bitmap and transparence like shadow 297cdf0e10cSrcweir if(bBitmapFillUsed) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir XOBitmap aFillBitmap(((XFillBitmapItem&)(rOriginalSet.Get(XATTR_FILLBITMAP))).GetBitmapValue()); 300cdf0e10cSrcweir Bitmap aSourceBitmap(aFillBitmap.GetBitmap()); 301cdf0e10cSrcweir BitmapReadAccess* pReadAccess = aSourceBitmap.AcquireReadAccess(); 302cdf0e10cSrcweir 303cdf0e10cSrcweir if(!aSourceBitmap.IsEmpty()) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir if(pReadAccess) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir Bitmap aDestBitmap(aSourceBitmap.GetSizePixel(), 24L); 308cdf0e10cSrcweir BitmapWriteAccess* pWriteAccess = aDestBitmap.AcquireWriteAccess(); 309cdf0e10cSrcweir 310cdf0e10cSrcweir if(pWriteAccess) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir for(sal_Int32 y(0L); y < pReadAccess->Height(); y++) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir for(sal_Int32 x(0L); x < pReadAccess->Width(); x++) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir sal_uInt16 nLuminance((sal_uInt16)pReadAccess->GetLuminance(y, x) + 1); 317cdf0e10cSrcweir const BitmapColor aDestColor( 318cdf0e10cSrcweir (sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetRed()) >> 8L), 319cdf0e10cSrcweir (sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetGreen()) >> 8L), 320cdf0e10cSrcweir (sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetBlue()) >> 8L)); 321cdf0e10cSrcweir pWriteAccess->SetPixel(y, x, aDestColor); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir aDestBitmap.ReleaseAccess(pWriteAccess); 326cdf0e10cSrcweir aFillBitmap.SetBitmap(aDestBitmap); 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir aSourceBitmap.ReleaseAccess(pReadAccess); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir aTempSet.Put(XFillBitmapItem(aTempSet.GetPool(), aFillBitmap)); 334cdf0e10cSrcweir aTempSet.Put(XFillTransparenceItem(nShadowTransparence)); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir // set attributes and paint shadow object 338cdf0e10cSrcweir pRetval->SetMergedItemSet( aTempSet ); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir return pRetval; 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 344cdf0e10cSrcweir 345cdf0e10cSrcweir Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine( const SdrObjCustomShape* pCustomShape ) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir Reference< XCustomShapeEngine > xCustomShapeEngine; 348cdf0e10cSrcweir String aEngine(((SdrCustomShapeEngineItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE )).GetValue()); 349cdf0e10cSrcweir if ( !aEngine.Len() ) 350cdf0e10cSrcweir aEngine = String( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) ); 351cdf0e10cSrcweir 352cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 353cdf0e10cSrcweir 354cdf0e10cSrcweir Reference< XShape > aXShape = GetXShapeForSdrObject( (SdrObjCustomShape*)pCustomShape ); 355cdf0e10cSrcweir if ( aXShape.is() ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir if ( aEngine.Len() && xFactory.is() ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir Sequence< Any > aArgument( 1 ); 360cdf0e10cSrcweir Sequence< PropertyValue > aPropValues( 1 ); 361cdf0e10cSrcweir aPropValues[ 0 ].Name = rtl::OUString::createFromAscii( "CustomShape" ); 362cdf0e10cSrcweir aPropValues[ 0 ].Value <<= aXShape; 363cdf0e10cSrcweir aArgument[ 0 ] <<= aPropValues; 364cdf0e10cSrcweir Reference< XInterface > xInterface( xFactory->createInstanceWithArguments( aEngine, aArgument ) ); 365cdf0e10cSrcweir if ( xInterface.is() ) 366cdf0e10cSrcweir xCustomShapeEngine = Reference< XCustomShapeEngine >( xInterface, UNO_QUERY ); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir } 369cdf0e10cSrcweir return xCustomShapeEngine; 370cdf0e10cSrcweir } 371cdf0e10cSrcweir const SdrObject* SdrObjCustomShape::GetSdrObjectFromCustomShape() const 372cdf0e10cSrcweir { 373cdf0e10cSrcweir if ( !mXRenderedCustomShape.is() ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) ); 376cdf0e10cSrcweir if ( xCustomShapeEngine.is() ) 377cdf0e10cSrcweir ((SdrObjCustomShape*)this)->mXRenderedCustomShape = xCustomShapeEngine->render(); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir SdrObject* pRenderedCustomShape = mXRenderedCustomShape.is() 380cdf0e10cSrcweir ? GetSdrObjectFromXShape( mXRenderedCustomShape ) 381cdf0e10cSrcweir : NULL; 382cdf0e10cSrcweir return pRenderedCustomShape; 383cdf0e10cSrcweir } 384cdf0e10cSrcweir 385cdf0e10cSrcweir // #i37011# Shadow geometry creation 386cdf0e10cSrcweir const SdrObject* SdrObjCustomShape::GetSdrObjectShadowFromCustomShape() const 387cdf0e10cSrcweir { 388cdf0e10cSrcweir if(!mpLastShadowGeometry) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir const SdrObject* pSdrObject = GetSdrObjectFromCustomShape(); 391cdf0e10cSrcweir if(pSdrObject) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir const SfxItemSet& rOriginalSet = GetObjectItemSet(); 394cdf0e10cSrcweir const sal_Bool bShadow(((SdrShadowItem&)rOriginalSet.Get( SDRATTR_SHADOW )).GetValue()); 395cdf0e10cSrcweir 396cdf0e10cSrcweir if(bShadow) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir // create a clone with all attributes changed to shadow attributes 399cdf0e10cSrcweir // and translation executed, too. 400cdf0e10cSrcweir ((SdrObjCustomShape*)this)->mpLastShadowGeometry = ImpCreateShadowObjectClone(*pSdrObject, rOriginalSet); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir } 403cdf0e10cSrcweir } 404cdf0e10cSrcweir 405cdf0e10cSrcweir return mpLastShadowGeometry; 406cdf0e10cSrcweir } 407cdf0e10cSrcweir 408cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsTextPath() const 409cdf0e10cSrcweir { 410cdf0e10cSrcweir const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) ); 411cdf0e10cSrcweir sal_Bool bTextPathOn = sal_False; 412cdf0e10cSrcweir SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); 413cdf0e10cSrcweir Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sTextPath ); 414cdf0e10cSrcweir if ( pAny ) 415cdf0e10cSrcweir *pAny >>= bTextPathOn; 416cdf0e10cSrcweir return bTextPathOn; 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir sal_Bool SdrObjCustomShape::UseNoFillStyle() const 420cdf0e10cSrcweir { 421cdf0e10cSrcweir sal_Bool bRet = sal_False; 422cdf0e10cSrcweir rtl::OUString sShapeType; 423cdf0e10cSrcweir const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) ); 424cdf0e10cSrcweir SdrCustomShapeGeometryItem& rGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 425cdf0e10cSrcweir Any* pAny = rGeometryItem.GetPropertyValueByName( sType ); 426cdf0e10cSrcweir if ( pAny ) 427cdf0e10cSrcweir *pAny >>= sShapeType; 428cdf0e10cSrcweir bRet = IsCustomShapeFilledByDefault( EnhancedCustomShapeTypeNames::Get( sType ) ) == 0; 429cdf0e10cSrcweir 430cdf0e10cSrcweir return bRet; 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsMirroredX() const 434cdf0e10cSrcweir { 435cdf0e10cSrcweir sal_Bool bMirroredX = sal_False; 436cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 437cdf0e10cSrcweir const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) ); 438cdf0e10cSrcweir com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX ); 439cdf0e10cSrcweir if ( pAny ) 440cdf0e10cSrcweir *pAny >>= bMirroredX; 441cdf0e10cSrcweir return bMirroredX; 442cdf0e10cSrcweir } 443cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsMirroredY() const 444cdf0e10cSrcweir { 445cdf0e10cSrcweir sal_Bool bMirroredY = sal_False; 446cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 447cdf0e10cSrcweir const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) ); 448cdf0e10cSrcweir com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY ); 449cdf0e10cSrcweir if ( pAny ) 450cdf0e10cSrcweir *pAny >>= bMirroredY; 451cdf0e10cSrcweir return bMirroredY; 452cdf0e10cSrcweir } 453cdf0e10cSrcweir void SdrObjCustomShape::SetMirroredX( const sal_Bool bMirrorX ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 456cdf0e10cSrcweir const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) ); 457cdf0e10cSrcweir //com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX ); 458cdf0e10cSrcweir PropertyValue aPropVal; 459cdf0e10cSrcweir aPropVal.Name = sMirroredX; 460cdf0e10cSrcweir aPropVal.Value <<= bMirrorX; 461cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 462cdf0e10cSrcweir SetMergedItem( aGeometryItem ); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir void SdrObjCustomShape::SetMirroredY( const sal_Bool bMirrorY ) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 467cdf0e10cSrcweir const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) ); 468cdf0e10cSrcweir //com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY ); 469cdf0e10cSrcweir PropertyValue aPropVal; 470cdf0e10cSrcweir aPropVal.Name = sMirroredY; 471cdf0e10cSrcweir aPropVal.Value <<= bMirrorY; 472cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 473cdf0e10cSrcweir SetMergedItem( aGeometryItem ); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir double SdrObjCustomShape::GetObjectRotation() const 477cdf0e10cSrcweir { 478cdf0e10cSrcweir return fObjectRotation; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir double SdrObjCustomShape::GetExtraTextRotation() const 482cdf0e10cSrcweir { 483cdf0e10cSrcweir const com::sun::star::uno::Any* pAny; 484cdf0e10cSrcweir SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); 485cdf0e10cSrcweir const rtl::OUString sTextRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "TextRotateAngle" ) ); 486cdf0e10cSrcweir pAny = rGeometryItem.GetPropertyValueByName( sTextRotateAngle ); 487cdf0e10cSrcweir double fExtraTextRotateAngle = 0.0; 488cdf0e10cSrcweir if ( pAny ) 489cdf0e10cSrcweir *pAny >>= fExtraTextRotateAngle; 490cdf0e10cSrcweir return fExtraTextRotateAngle; 491cdf0e10cSrcweir } 492cdf0e10cSrcweir sal_Bool SdrObjCustomShape::GetTextBounds( Rectangle& rTextBound ) const 493cdf0e10cSrcweir { 494cdf0e10cSrcweir sal_Bool bRet = sal_False; 495cdf0e10cSrcweir Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) ); // a candidate for being cached 496cdf0e10cSrcweir if ( xCustomShapeEngine.is() ) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir awt::Rectangle aR( xCustomShapeEngine->getTextBounds() ); 499cdf0e10cSrcweir if ( aR.Width || aR.Height ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir rTextBound = Rectangle( Point( aR.X, aR.Y ), Size( aR.Width, aR.Height ) ); 502cdf0e10cSrcweir bRet = sal_True; 503cdf0e10cSrcweir } 504cdf0e10cSrcweir } 505cdf0e10cSrcweir return bRet; 506cdf0e10cSrcweir } 507cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::GetLineGeometry( const SdrObjCustomShape* pCustomShape, const sal_Bool bBezierAllowed ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir basegfx::B2DPolyPolygon aRetval; 510cdf0e10cSrcweir sal_Bool bRet = sal_False; 511cdf0e10cSrcweir Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( pCustomShape ) ); 512cdf0e10cSrcweir if ( xCustomShapeEngine.is() ) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir com::sun::star::drawing::PolyPolygonBezierCoords aBezierCoords = xCustomShapeEngine->getLineGeometry(); 515cdf0e10cSrcweir try 516cdf0e10cSrcweir { 517cdf0e10cSrcweir aRetval = SvxConvertPolyPolygonBezierToB2DPolyPolygon( &aBezierCoords ); 518cdf0e10cSrcweir if ( !bBezierAllowed && aRetval.areControlPointsUsed()) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir aRetval = basegfx::tools::adaptiveSubdivideByAngle(aRetval); 521cdf0e10cSrcweir } 522cdf0e10cSrcweir bRet = sal_True; 523cdf0e10cSrcweir } 524cdf0e10cSrcweir catch ( const com::sun::star::lang::IllegalArgumentException ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir } 527cdf0e10cSrcweir } 528cdf0e10cSrcweir return aRetval; 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > SdrObjCustomShape::GetInteractionHandles( const SdrObjCustomShape* pCustomShape ) const 532cdf0e10cSrcweir { 533cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > xRet; 534cdf0e10cSrcweir try 535cdf0e10cSrcweir { 536cdf0e10cSrcweir Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( pCustomShape ) ); 537cdf0e10cSrcweir if ( xCustomShapeEngine.is() ) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir int i; 540cdf0e10cSrcweir Sequence< Reference< XCustomShapeHandle > > xInteractionHandles( xCustomShapeEngine->getInteraction() ); 541cdf0e10cSrcweir for ( i = 0; i < xInteractionHandles.getLength(); i++ ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir if ( xInteractionHandles[ i ].is() ) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir SdrCustomShapeInteraction aSdrCustomShapeInteraction; 546cdf0e10cSrcweir aSdrCustomShapeInteraction.xInteraction = xInteractionHandles[ i ]; 547cdf0e10cSrcweir aSdrCustomShapeInteraction.aPosition = xInteractionHandles[ i ]->getPosition(); 548cdf0e10cSrcweir 549cdf0e10cSrcweir sal_Int32 nMode = 0; 550cdf0e10cSrcweir switch( ImpGetCustomShapeType( *this ) ) 551cdf0e10cSrcweir { 552cdf0e10cSrcweir case mso_sptAccentBorderCallout90 : // 2 ortho 553cdf0e10cSrcweir { 554cdf0e10cSrcweir if ( !i ) 555cdf0e10cSrcweir nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED; 556cdf0e10cSrcweir else if ( i == 1) 557cdf0e10cSrcweir nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE | CUSTOMSHAPE_HANDLE_ORTHO4; 558cdf0e10cSrcweir } 559cdf0e10cSrcweir break; 560cdf0e10cSrcweir 561cdf0e10cSrcweir case mso_sptWedgeRectCallout : 562cdf0e10cSrcweir case mso_sptWedgeRRectCallout : 563cdf0e10cSrcweir case mso_sptCloudCallout : 564cdf0e10cSrcweir case mso_sptWedgeEllipseCallout : 565cdf0e10cSrcweir { 566cdf0e10cSrcweir if ( !i ) 567cdf0e10cSrcweir nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED; 568cdf0e10cSrcweir } 569cdf0e10cSrcweir break; 570cdf0e10cSrcweir 571cdf0e10cSrcweir case mso_sptBorderCallout1 : // 2 diag 572cdf0e10cSrcweir { 573cdf0e10cSrcweir if ( !i ) 574cdf0e10cSrcweir nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED; 575cdf0e10cSrcweir else if ( i == 1 ) 576cdf0e10cSrcweir nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE; 577cdf0e10cSrcweir } 578cdf0e10cSrcweir break; 579cdf0e10cSrcweir case mso_sptBorderCallout2 : // 3 580cdf0e10cSrcweir { 581cdf0e10cSrcweir if ( !i ) 582cdf0e10cSrcweir nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED; 583cdf0e10cSrcweir else if ( i == 2 ) 584cdf0e10cSrcweir nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE; 585cdf0e10cSrcweir } 586cdf0e10cSrcweir break; 587cdf0e10cSrcweir case mso_sptCallout90 : 588cdf0e10cSrcweir case mso_sptAccentCallout90 : 589cdf0e10cSrcweir case mso_sptBorderCallout90 : 590cdf0e10cSrcweir case mso_sptCallout1 : 591cdf0e10cSrcweir case mso_sptCallout2 : 592cdf0e10cSrcweir case mso_sptCallout3 : 593cdf0e10cSrcweir case mso_sptAccentCallout1 : 594cdf0e10cSrcweir case mso_sptAccentCallout2 : 595cdf0e10cSrcweir case mso_sptAccentCallout3 : 596cdf0e10cSrcweir case mso_sptBorderCallout3 : 597cdf0e10cSrcweir case mso_sptAccentBorderCallout1 : 598cdf0e10cSrcweir case mso_sptAccentBorderCallout2 : 599cdf0e10cSrcweir case mso_sptAccentBorderCallout3 : 600cdf0e10cSrcweir { 601cdf0e10cSrcweir if ( !i ) 602cdf0e10cSrcweir nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED; 603cdf0e10cSrcweir } 604cdf0e10cSrcweir break; 605cdf0e10cSrcweir default: break; 606cdf0e10cSrcweir } 607cdf0e10cSrcweir aSdrCustomShapeInteraction.nMode = nMode; 608cdf0e10cSrcweir xRet.push_back( aSdrCustomShapeInteraction ); 609cdf0e10cSrcweir } 610cdf0e10cSrcweir } 611cdf0e10cSrcweir } 612cdf0e10cSrcweir } 613cdf0e10cSrcweir catch( const uno::RuntimeException& ) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir } 616cdf0e10cSrcweir return xRet; 617cdf0e10cSrcweir } 618cdf0e10cSrcweir 619cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 620cdf0e10cSrcweir // BaseProperties section 621cdf0e10cSrcweir #define DEFAULT_MINIMUM_SIGNED_COMPARE ((sal_Int32)0x80000000) 622cdf0e10cSrcweir #define DEFAULT_MAXIMUM_SIGNED_COMPARE ((sal_Int32)0x7fffffff) 623cdf0e10cSrcweir 624cdf0e10cSrcweir sdr::properties::BaseProperties* SdrObjCustomShape::CreateObjectSpecificProperties() 625cdf0e10cSrcweir { 626cdf0e10cSrcweir return new sdr::properties::CustomShapeProperties(*this); 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir TYPEINIT1(SdrObjCustomShape,SdrTextObj); 630cdf0e10cSrcweir SdrObjCustomShape::SdrObjCustomShape() : 631cdf0e10cSrcweir SdrTextObj(), 632cdf0e10cSrcweir fObjectRotation( 0.0 ), 633cdf0e10cSrcweir mpLastShadowGeometry(0L) 634cdf0e10cSrcweir { 635cdf0e10cSrcweir bTextFrame = sal_True; 636cdf0e10cSrcweir } 637cdf0e10cSrcweir 638cdf0e10cSrcweir SdrObjCustomShape::~SdrObjCustomShape() 639cdf0e10cSrcweir { 640cdf0e10cSrcweir // delete buffered display geometry 641cdf0e10cSrcweir InvalidateRenderGeometry(); 642cdf0e10cSrcweir } 643cdf0e10cSrcweir 644cdf0e10cSrcweir void SdrObjCustomShape::MergeDefaultAttributes( const rtl::OUString* pType ) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir PropertyValue aPropVal; 647cdf0e10cSrcweir rtl::OUString sShapeType; 648cdf0e10cSrcweir const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) ); 649cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 650cdf0e10cSrcweir if ( pType && pType->getLength() ) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir sal_Int32 nType = pType->toInt32(); 653cdf0e10cSrcweir if ( nType ) 654cdf0e10cSrcweir sShapeType = EnhancedCustomShapeTypeNames::Get( static_cast< MSO_SPT >( nType ) ); 655cdf0e10cSrcweir else 656cdf0e10cSrcweir sShapeType = *pType; 657cdf0e10cSrcweir 658cdf0e10cSrcweir aPropVal.Name = sType; 659cdf0e10cSrcweir aPropVal.Value <<= sShapeType; 660cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 661cdf0e10cSrcweir } 662cdf0e10cSrcweir else 663cdf0e10cSrcweir { 664cdf0e10cSrcweir Any *pAny = aGeometryItem.GetPropertyValueByName( sType ); 665cdf0e10cSrcweir if ( pAny ) 666cdf0e10cSrcweir *pAny >>= sShapeType; 667cdf0e10cSrcweir } 668cdf0e10cSrcweir MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType ); 669cdf0e10cSrcweir 670cdf0e10cSrcweir const sal_Int32* pDefData = NULL; 671cdf0e10cSrcweir const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType ); 672cdf0e10cSrcweir if ( pDefCustomShape ) 673cdf0e10cSrcweir pDefData = pDefCustomShape->pDefData; 674cdf0e10cSrcweir 675cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues; 676cdf0e10cSrcweir 677cdf0e10cSrcweir ////////////////////// 678cdf0e10cSrcweir // AdjustmentValues // 679cdf0e10cSrcweir ////////////////////// 680cdf0e10cSrcweir const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) ); 681cdf0e10cSrcweir const Any* pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sAdjustmentValues ); 682cdf0e10cSrcweir if ( pAny ) 683cdf0e10cSrcweir *pAny >>= seqAdjustmentValues; 684cdf0e10cSrcweir if ( pDefCustomShape && pDefData ) // now check if we have to default some adjustment values 685cdf0e10cSrcweir { 686cdf0e10cSrcweir // first check if there are adjustment values are to be appended 687cdf0e10cSrcweir sal_Int32 i, nAdjustmentValues = seqAdjustmentValues.getLength(); 688cdf0e10cSrcweir sal_Int32 nAdjustmentDefaults = *pDefData++; 689cdf0e10cSrcweir if ( nAdjustmentDefaults > nAdjustmentValues ) 690cdf0e10cSrcweir { 691cdf0e10cSrcweir seqAdjustmentValues.realloc( nAdjustmentDefaults ); 692cdf0e10cSrcweir for ( i = nAdjustmentValues; i < nAdjustmentDefaults; i++ ) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir seqAdjustmentValues[ i ].Value <<= pDefData[ i ]; 695cdf0e10cSrcweir seqAdjustmentValues[ i ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; // com::sun::star::beans::PropertyState_DEFAULT_VALUE; 696cdf0e10cSrcweir } 697cdf0e10cSrcweir } 698cdf0e10cSrcweir // check if there are defaulted adjustment values that should be filled the hard coded defaults (pDefValue) 699cdf0e10cSrcweir sal_Int32 nCount = nAdjustmentValues > nAdjustmentDefaults ? nAdjustmentDefaults : nAdjustmentValues; 700cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 701cdf0e10cSrcweir { 702cdf0e10cSrcweir if ( seqAdjustmentValues[ i ].State != com::sun::star::beans::PropertyState_DIRECT_VALUE ) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir seqAdjustmentValues[ i ].Value <<= pDefData[ i ]; 705cdf0e10cSrcweir seqAdjustmentValues[ i ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; 706cdf0e10cSrcweir } 707cdf0e10cSrcweir } 708cdf0e10cSrcweir } 709cdf0e10cSrcweir aPropVal.Name = sAdjustmentValues; 710cdf0e10cSrcweir aPropVal.Value <<= seqAdjustmentValues; 711cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 712cdf0e10cSrcweir 713cdf0e10cSrcweir /////////////// 714cdf0e10cSrcweir // Coordsize // 715cdf0e10cSrcweir /////////////// 716cdf0e10cSrcweir const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) ); 717cdf0e10cSrcweir const Any* pViewBox = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sViewBox ); 718cdf0e10cSrcweir com::sun::star::awt::Rectangle aViewBox; 719cdf0e10cSrcweir if ( !pViewBox || !(*pViewBox >>= aViewBox ) ) 720cdf0e10cSrcweir { 721cdf0e10cSrcweir if ( pDefCustomShape ) 722cdf0e10cSrcweir { 723cdf0e10cSrcweir aViewBox.X = 0; 724cdf0e10cSrcweir aViewBox.Y = 0; 725cdf0e10cSrcweir aViewBox.Width = pDefCustomShape->nCoordWidth; 726cdf0e10cSrcweir aViewBox.Height= pDefCustomShape->nCoordHeight; 727cdf0e10cSrcweir aPropVal.Name = sViewBox; 728cdf0e10cSrcweir aPropVal.Value <<= aViewBox; 729cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 730cdf0e10cSrcweir } 731cdf0e10cSrcweir } 732cdf0e10cSrcweir 733cdf0e10cSrcweir const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) ); 734cdf0e10cSrcweir 735cdf0e10cSrcweir ////////////////////// 736cdf0e10cSrcweir // Path/Coordinates // 737cdf0e10cSrcweir ////////////////////// 738cdf0e10cSrcweir const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) ); 739cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates ); 740cdf0e10cSrcweir if ( !pAny && pDefCustomShape && pDefCustomShape->nVertices && pDefCustomShape->pVertices ) 741cdf0e10cSrcweir { 742cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates; 743cdf0e10cSrcweir 744cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nVertices; 745cdf0e10cSrcweir seqCoordinates.realloc( nCount ); 746cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates[ i ].First, pDefCustomShape->pVertices[ i ].nValA ); 749cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates[ i ].Second, pDefCustomShape->pVertices[ i ].nValB ); 750cdf0e10cSrcweir } 751cdf0e10cSrcweir aPropVal.Name = sCoordinates; 752cdf0e10cSrcweir aPropVal.Value <<= seqCoordinates; 753cdf0e10cSrcweir aGeometryItem.SetPropertyValue( sPath, aPropVal ); 754cdf0e10cSrcweir } 755cdf0e10cSrcweir 756cdf0e10cSrcweir ///////////////////// 757cdf0e10cSrcweir // Path/GluePoints // 758cdf0e10cSrcweir ///////////////////// 759cdf0e10cSrcweir const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) ); 760cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sGluePoints ); 761cdf0e10cSrcweir if ( !pAny && pDefCustomShape && pDefCustomShape->nGluePoints && pDefCustomShape->pGluePoints ) 762cdf0e10cSrcweir { 763cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints; 764cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nGluePoints; 765cdf0e10cSrcweir seqGluePoints.realloc( nCount ); 766cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 767cdf0e10cSrcweir { 768cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints[ i ].First, pDefCustomShape->pGluePoints[ i ].nValA ); 769cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints[ i ].Second, pDefCustomShape->pGluePoints[ i ].nValB ); 770cdf0e10cSrcweir } 771cdf0e10cSrcweir aPropVal.Name = sGluePoints; 772cdf0e10cSrcweir aPropVal.Value <<= seqGluePoints; 773cdf0e10cSrcweir aGeometryItem.SetPropertyValue( sPath, aPropVal ); 774cdf0e10cSrcweir } 775cdf0e10cSrcweir 776cdf0e10cSrcweir /////////////////// 777cdf0e10cSrcweir // Path/Segments // 778cdf0e10cSrcweir /////////////////// 779cdf0e10cSrcweir const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) ); 780cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sSegments ); 781cdf0e10cSrcweir if ( !pAny && pDefCustomShape && pDefCustomShape->nElements && pDefCustomShape->pElements ) 782cdf0e10cSrcweir { 783cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments; 784cdf0e10cSrcweir 785cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nElements; 786cdf0e10cSrcweir seqSegments.realloc( nCount ); 787cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 788cdf0e10cSrcweir { 789cdf0e10cSrcweir EnhancedCustomShapeSegment& rSegInfo = seqSegments[ i ]; 790cdf0e10cSrcweir sal_uInt16 nSDat = pDefCustomShape->pElements[ i ]; 791cdf0e10cSrcweir switch( nSDat >> 8 ) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir case 0x00 : 794cdf0e10cSrcweir { 795cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO; 796cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 797cdf0e10cSrcweir if ( !rSegInfo.Count ) 798cdf0e10cSrcweir rSegInfo.Count = 1; 799cdf0e10cSrcweir } 800cdf0e10cSrcweir break; 801cdf0e10cSrcweir case 0x20 : 802cdf0e10cSrcweir { 803cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO; 804cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 805cdf0e10cSrcweir if ( !rSegInfo.Count ) 806cdf0e10cSrcweir rSegInfo.Count = 1; 807cdf0e10cSrcweir } 808cdf0e10cSrcweir break; 809cdf0e10cSrcweir case 0x40 : 810cdf0e10cSrcweir { 811cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO; 812cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 813cdf0e10cSrcweir if ( !rSegInfo.Count ) 814cdf0e10cSrcweir rSegInfo.Count = 1; 815cdf0e10cSrcweir } 816cdf0e10cSrcweir break; 817cdf0e10cSrcweir case 0x60 : 818cdf0e10cSrcweir { 819cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH; 820cdf0e10cSrcweir rSegInfo.Count = 0; 821cdf0e10cSrcweir } 822cdf0e10cSrcweir break; 823cdf0e10cSrcweir case 0x80 : 824cdf0e10cSrcweir { 825cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH; 826cdf0e10cSrcweir rSegInfo.Count = 0; 827cdf0e10cSrcweir } 828cdf0e10cSrcweir break; 829cdf0e10cSrcweir case 0xa1 : 830cdf0e10cSrcweir { 831cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO; 832cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) / 3; 833cdf0e10cSrcweir } 834cdf0e10cSrcweir break; 835cdf0e10cSrcweir case 0xa2 : 836cdf0e10cSrcweir { 837cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE; 838cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) / 3; 839cdf0e10cSrcweir } 840cdf0e10cSrcweir break; 841cdf0e10cSrcweir case 0xa3 : 842cdf0e10cSrcweir { 843cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO; 844cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) >> 2; 845cdf0e10cSrcweir } 846cdf0e10cSrcweir break; 847cdf0e10cSrcweir case 0xa4 : 848cdf0e10cSrcweir { 849cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC; 850cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) >> 2; 851cdf0e10cSrcweir } 852cdf0e10cSrcweir break; 853cdf0e10cSrcweir case 0xa5 : 854cdf0e10cSrcweir { 855cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO; 856cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) >> 2; 857cdf0e10cSrcweir } 858cdf0e10cSrcweir break; 859cdf0e10cSrcweir case 0xa6 : 860cdf0e10cSrcweir { 861cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC; 862cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) >> 2; 863cdf0e10cSrcweir } 864cdf0e10cSrcweir break; 865cdf0e10cSrcweir case 0xa7 : 866cdf0e10cSrcweir { 867cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX; 868cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 869cdf0e10cSrcweir } 870cdf0e10cSrcweir break; 871cdf0e10cSrcweir case 0xa8 : 872cdf0e10cSrcweir { 873cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY; 874cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 875cdf0e10cSrcweir } 876cdf0e10cSrcweir break; 877cdf0e10cSrcweir case 0xaa : 878cdf0e10cSrcweir { 879cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL; 880cdf0e10cSrcweir rSegInfo.Count = 0; 881cdf0e10cSrcweir } 882cdf0e10cSrcweir break; 883cdf0e10cSrcweir case 0xab : 884cdf0e10cSrcweir { 885cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE; 886cdf0e10cSrcweir rSegInfo.Count = 0; 887cdf0e10cSrcweir } 888cdf0e10cSrcweir break; 889cdf0e10cSrcweir default: 890cdf0e10cSrcweir case 0xf8 : 891cdf0e10cSrcweir { 892cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN; 893cdf0e10cSrcweir rSegInfo.Count = nSDat; 894cdf0e10cSrcweir } 895cdf0e10cSrcweir break; 896cdf0e10cSrcweir } 897cdf0e10cSrcweir } 898cdf0e10cSrcweir aPropVal.Name = sSegments; 899cdf0e10cSrcweir aPropVal.Value <<= seqSegments; 900cdf0e10cSrcweir aGeometryItem.SetPropertyValue( sPath, aPropVal ); 901cdf0e10cSrcweir } 902cdf0e10cSrcweir 903cdf0e10cSrcweir /////////////////// 904cdf0e10cSrcweir // Path/StretchX // 905cdf0e10cSrcweir /////////////////// 906cdf0e10cSrcweir const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) ); 907cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchX ); 908cdf0e10cSrcweir if ( !pAny && pDefCustomShape ) 909cdf0e10cSrcweir { 910cdf0e10cSrcweir sal_Int32 nXRef = pDefCustomShape->nXRef; 911cdf0e10cSrcweir if ( ( nXRef != DEFAULT_MINIMUM_SIGNED_COMPARE ) ) 912cdf0e10cSrcweir { 913cdf0e10cSrcweir aPropVal.Name = sStretchX; 914cdf0e10cSrcweir aPropVal.Value <<= nXRef; 915cdf0e10cSrcweir aGeometryItem.SetPropertyValue( sPath, aPropVal ); 916cdf0e10cSrcweir } 917cdf0e10cSrcweir } 918cdf0e10cSrcweir 919cdf0e10cSrcweir /////////////////// 920cdf0e10cSrcweir // Path/StretchY // 921cdf0e10cSrcweir /////////////////// 922cdf0e10cSrcweir const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) ); 923cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchY ); 924cdf0e10cSrcweir if ( !pAny && pDefCustomShape ) 925cdf0e10cSrcweir { 926cdf0e10cSrcweir sal_Int32 nYRef = pDefCustomShape->nYRef; 927cdf0e10cSrcweir if ( ( nYRef != DEFAULT_MINIMUM_SIGNED_COMPARE ) ) 928cdf0e10cSrcweir { 929cdf0e10cSrcweir aPropVal.Name = sStretchY; 930cdf0e10cSrcweir aPropVal.Value <<= nYRef; 931cdf0e10cSrcweir aGeometryItem.SetPropertyValue( sPath, aPropVal ); 932cdf0e10cSrcweir } 933cdf0e10cSrcweir } 934cdf0e10cSrcweir 935cdf0e10cSrcweir ///////////////////// 936cdf0e10cSrcweir // Path/TextFrames // 937cdf0e10cSrcweir ///////////////////// 938cdf0e10cSrcweir const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) ); 939cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sTextFrames ); 940cdf0e10cSrcweir if ( !pAny && pDefCustomShape && pDefCustomShape->nTextRect && pDefCustomShape->pTextRect ) 941cdf0e10cSrcweir { 942cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames; 943cdf0e10cSrcweir 944cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nTextRect; 945cdf0e10cSrcweir seqTextFrames.realloc( nCount ); 946cdf0e10cSrcweir const SvxMSDffTextRectangles* pRectangles = pDefCustomShape->pTextRect; 947cdf0e10cSrcweir for ( i = 0; i < nCount; i++, pRectangles++ ) 948cdf0e10cSrcweir { 949cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].TopLeft.First, pRectangles->nPairA.nValA ); 950cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].TopLeft.Second, pRectangles->nPairA.nValB ); 951cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].BottomRight.First, pRectangles->nPairB.nValA ); 952cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].BottomRight.Second, pRectangles->nPairB.nValB ); 953cdf0e10cSrcweir } 954cdf0e10cSrcweir aPropVal.Name = sTextFrames; 955cdf0e10cSrcweir aPropVal.Value <<= seqTextFrames; 956cdf0e10cSrcweir aGeometryItem.SetPropertyValue( sPath, aPropVal ); 957cdf0e10cSrcweir } 958cdf0e10cSrcweir 959cdf0e10cSrcweir /////////////// 960cdf0e10cSrcweir // Equations // 961cdf0e10cSrcweir /////////////// 962cdf0e10cSrcweir const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) ); 963cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sEquations ); 964cdf0e10cSrcweir if ( !pAny && pDefCustomShape && pDefCustomShape->nCalculation && pDefCustomShape->pCalculation ) 965cdf0e10cSrcweir { 966cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > seqEquations; 967cdf0e10cSrcweir 968cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nCalculation; 969cdf0e10cSrcweir seqEquations.realloc( nCount ); 970cdf0e10cSrcweir const SvxMSDffCalculationData* pData = pDefCustomShape->pCalculation; 971cdf0e10cSrcweir for ( i = 0; i < nCount; i++, pData++ ) 972cdf0e10cSrcweir seqEquations[ i ] = EnhancedCustomShape2d::GetEquation( pData->nFlags, pData->nVal[ 0 ], pData->nVal[ 1 ], pData->nVal[ 2 ] ); 973cdf0e10cSrcweir aPropVal.Name = sEquations; 974cdf0e10cSrcweir aPropVal.Value <<= seqEquations; 975cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 976cdf0e10cSrcweir } 977cdf0e10cSrcweir 978cdf0e10cSrcweir ///////////// 979cdf0e10cSrcweir // Handles // 980cdf0e10cSrcweir ///////////// 981cdf0e10cSrcweir const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) ); 982cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sHandles ); 983cdf0e10cSrcweir if ( !pAny && pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles ) 984cdf0e10cSrcweir { 985cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles; 986cdf0e10cSrcweir 987cdf0e10cSrcweir sal_Int32 i, n, nCount = pDefCustomShape->nHandles; 988cdf0e10cSrcweir const SvxMSDffHandle* pData = pDefCustomShape->pHandles; 989cdf0e10cSrcweir seqHandles.realloc( nCount ); 990cdf0e10cSrcweir for ( i = 0; i < nCount; i++, pData++ ) 991cdf0e10cSrcweir { 992cdf0e10cSrcweir sal_Int32 nPropertiesNeeded = 1; // position is always needed 993cdf0e10cSrcweir sal_Int32 nFlags = pData->nFlags; 994cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X ) 995cdf0e10cSrcweir nPropertiesNeeded++; 996cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y ) 997cdf0e10cSrcweir nPropertiesNeeded++; 998cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED ) 999cdf0e10cSrcweir nPropertiesNeeded++; 1000cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR ) 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir nPropertiesNeeded++; 1003cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE ) 1004cdf0e10cSrcweir { 1005cdf0e10cSrcweir if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1006cdf0e10cSrcweir nPropertiesNeeded++; 1007cdf0e10cSrcweir if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1008cdf0e10cSrcweir nPropertiesNeeded++; 1009cdf0e10cSrcweir } 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE ) 1012cdf0e10cSrcweir { 1013cdf0e10cSrcweir if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1014cdf0e10cSrcweir nPropertiesNeeded++; 1015cdf0e10cSrcweir if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1016cdf0e10cSrcweir nPropertiesNeeded++; 1017cdf0e10cSrcweir if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1018cdf0e10cSrcweir nPropertiesNeeded++; 1019cdf0e10cSrcweir if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1020cdf0e10cSrcweir nPropertiesNeeded++; 1021cdf0e10cSrcweir } 1022cdf0e10cSrcweir 1023cdf0e10cSrcweir n = 0; 1024cdf0e10cSrcweir com::sun::star::beans::PropertyValues& rPropValues = seqHandles[ i ]; 1025cdf0e10cSrcweir rPropValues.realloc( nPropertiesNeeded ); 1026cdf0e10cSrcweir 1027cdf0e10cSrcweir // POSITION 1028cdf0e10cSrcweir { 1029cdf0e10cSrcweir const rtl::OUString sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) ); 1030cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition; 1031cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First, pData->nPositionX, sal_True, sal_True ); 1032cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, pData->nPositionY, sal_True, sal_False ); 1033cdf0e10cSrcweir rPropValues[ n ].Name = sPosition; 1034cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aPosition; 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X ) 1037cdf0e10cSrcweir { 1038cdf0e10cSrcweir const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) ); 1039cdf0e10cSrcweir sal_Bool bMirroredX = sal_True; 1040cdf0e10cSrcweir rPropValues[ n ].Name = sMirroredX; 1041cdf0e10cSrcweir rPropValues[ n++ ].Value <<= bMirroredX; 1042cdf0e10cSrcweir } 1043cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y ) 1044cdf0e10cSrcweir { 1045cdf0e10cSrcweir const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) ); 1046cdf0e10cSrcweir sal_Bool bMirroredY = sal_True; 1047cdf0e10cSrcweir rPropValues[ n ].Name = sMirroredY; 1048cdf0e10cSrcweir rPropValues[ n++ ].Value <<= bMirroredY; 1049cdf0e10cSrcweir } 1050cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED ) 1051cdf0e10cSrcweir { 1052cdf0e10cSrcweir const rtl::OUString sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) ); 1053cdf0e10cSrcweir sal_Bool bSwitched = sal_True; 1054cdf0e10cSrcweir rPropValues[ n ].Name = sSwitched; 1055cdf0e10cSrcweir rPropValues[ n++ ].Value <<= bSwitched; 1056cdf0e10cSrcweir } 1057cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR ) 1058cdf0e10cSrcweir { 1059cdf0e10cSrcweir const rtl::OUString sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) ); 1060cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter; 1061cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First, pData->nCenterX, 1062cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True ); 1063cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second, pData->nCenterY, 1064cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False ); 1065cdf0e10cSrcweir rPropValues[ n ].Name = sPolar; 1066cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aCenter; 1067cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE ) 1068cdf0e10cSrcweir { 1069cdf0e10cSrcweir if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1070cdf0e10cSrcweir { 1071cdf0e10cSrcweir const rtl::OUString sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) ); 1072cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum; 1073cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, pData->nRangeXMin, 1074cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True ); 1075cdf0e10cSrcweir rPropValues[ n ].Name = sRadiusRangeMinimum; 1076cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRadiusRangeMinimum; 1077cdf0e10cSrcweir } 1078cdf0e10cSrcweir if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1079cdf0e10cSrcweir { 1080cdf0e10cSrcweir const rtl::OUString sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) ); 1081cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum; 1082cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, pData->nRangeXMax, 1083cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False ); 1084cdf0e10cSrcweir rPropValues[ n ].Name = sRadiusRangeMaximum; 1085cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRadiusRangeMaximum; 1086cdf0e10cSrcweir } 1087cdf0e10cSrcweir } 1088cdf0e10cSrcweir } 1089cdf0e10cSrcweir else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE ) 1090cdf0e10cSrcweir { 1091cdf0e10cSrcweir if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1092cdf0e10cSrcweir { 1093cdf0e10cSrcweir const rtl::OUString sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) ); 1094cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum; 1095cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum, pData->nRangeXMin, 1096cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True ); 1097cdf0e10cSrcweir rPropValues[ n ].Name = sRangeXMinimum; 1098cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRangeXMinimum; 1099cdf0e10cSrcweir } 1100cdf0e10cSrcweir if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1101cdf0e10cSrcweir { 1102cdf0e10cSrcweir const rtl::OUString sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) ); 1103cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum; 1104cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, pData->nRangeXMax, 1105cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False ); 1106cdf0e10cSrcweir rPropValues[ n ].Name = sRangeXMaximum; 1107cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRangeXMaximum; 1108cdf0e10cSrcweir } 1109cdf0e10cSrcweir if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1110cdf0e10cSrcweir { 1111cdf0e10cSrcweir const rtl::OUString sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) ); 1112cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum; 1113cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, pData->nRangeYMin, 1114cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True ); 1115cdf0e10cSrcweir rPropValues[ n ].Name = sRangeYMinimum; 1116cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRangeYMinimum; 1117cdf0e10cSrcweir } 1118cdf0e10cSrcweir if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1119cdf0e10cSrcweir { 1120cdf0e10cSrcweir const rtl::OUString sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) ); 1121cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum; 1122cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, pData->nRangeYMax, 1123cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False ); 1124cdf0e10cSrcweir rPropValues[ n ].Name = sRangeYMaximum; 1125cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRangeYMaximum; 1126cdf0e10cSrcweir } 1127cdf0e10cSrcweir } 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir aPropVal.Name = sHandles; 1130cdf0e10cSrcweir aPropVal.Value <<= seqHandles; 1131cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 1132cdf0e10cSrcweir } 1133cdf0e10cSrcweir SetMergedItem( aGeometryItem ); 1134cdf0e10cSrcweir } 1135cdf0e10cSrcweir 1136cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsDefaultGeometry( const DefaultType eDefaultType ) const 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir sal_Bool bIsDefaultGeometry = sal_False; 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir PropertyValue aPropVal; 1141cdf0e10cSrcweir rtl::OUString sShapeType; 1142cdf0e10cSrcweir const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) ); 1143cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 1144cdf0e10cSrcweir 1145cdf0e10cSrcweir Any *pAny = aGeometryItem.GetPropertyValueByName( sType ); 1146cdf0e10cSrcweir if ( pAny ) 1147cdf0e10cSrcweir *pAny >>= sShapeType; 1148cdf0e10cSrcweir 1149cdf0e10cSrcweir MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType ); 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType ); 1152cdf0e10cSrcweir const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) ); 1153cdf0e10cSrcweir switch( eDefaultType ) 1154cdf0e10cSrcweir { 1155cdf0e10cSrcweir case DEFAULT_VIEWBOX : 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) ); 1158cdf0e10cSrcweir const Any* pViewBox = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sViewBox ); 1159cdf0e10cSrcweir com::sun::star::awt::Rectangle aViewBox; 1160cdf0e10cSrcweir if ( pViewBox && ( *pViewBox >>= aViewBox ) ) 1161cdf0e10cSrcweir { 1162cdf0e10cSrcweir if ( ( aViewBox.Width == pDefCustomShape->nCoordWidth ) 1163cdf0e10cSrcweir && ( aViewBox.Height == pDefCustomShape->nCoordHeight ) ) 1164cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1165cdf0e10cSrcweir } 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir break; 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir case DEFAULT_PATH : 1170cdf0e10cSrcweir { 1171cdf0e10cSrcweir const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) ); 1172cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates ); 1173cdf0e10cSrcweir if ( pAny && pDefCustomShape && pDefCustomShape->nVertices && pDefCustomShape->pVertices ) 1174cdf0e10cSrcweir { 1175cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates1, seqCoordinates2; 1176cdf0e10cSrcweir if ( *pAny >>= seqCoordinates1 ) 1177cdf0e10cSrcweir { 1178cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nVertices; 1179cdf0e10cSrcweir seqCoordinates2.realloc( nCount ); 1180cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 1181cdf0e10cSrcweir { 1182cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ i ].First, pDefCustomShape->pVertices[ i ].nValA ); 1183cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ i ].Second, pDefCustomShape->pVertices[ i ].nValB ); 1184cdf0e10cSrcweir } 1185cdf0e10cSrcweir if ( seqCoordinates1 == seqCoordinates2 ) 1186cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1187cdf0e10cSrcweir } 1188cdf0e10cSrcweir } 1189cdf0e10cSrcweir else if ( pDefCustomShape && ( ( pDefCustomShape->nVertices == 0 ) || ( pDefCustomShape->pVertices == 0 ) ) ) 1190cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1191cdf0e10cSrcweir } 1192cdf0e10cSrcweir break; 1193cdf0e10cSrcweir 1194cdf0e10cSrcweir case DEFAULT_GLUEPOINTS : 1195cdf0e10cSrcweir { 1196cdf0e10cSrcweir const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) ); 1197cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sGluePoints ); 1198cdf0e10cSrcweir if ( pAny && pDefCustomShape && pDefCustomShape->nGluePoints && pDefCustomShape->pGluePoints ) 1199cdf0e10cSrcweir { 1200cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints1, seqGluePoints2; 1201cdf0e10cSrcweir if ( *pAny >>= seqGluePoints1 ) 1202cdf0e10cSrcweir { 1203cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nGluePoints; 1204cdf0e10cSrcweir seqGluePoints2.realloc( nCount ); 1205cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 1206cdf0e10cSrcweir { 1207cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints2[ i ].First, pDefCustomShape->pGluePoints[ i ].nValA ); 1208cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints2[ i ].Second, pDefCustomShape->pGluePoints[ i ].nValB ); 1209cdf0e10cSrcweir } 1210cdf0e10cSrcweir if ( seqGluePoints1 == seqGluePoints2 ) 1211cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1212cdf0e10cSrcweir } 1213cdf0e10cSrcweir } 1214cdf0e10cSrcweir else if ( pDefCustomShape && ( pDefCustomShape->nGluePoints == 0 ) ) 1215cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1216cdf0e10cSrcweir } 1217cdf0e10cSrcweir break; 1218cdf0e10cSrcweir 1219cdf0e10cSrcweir case DEFAULT_SEGMENTS : 1220cdf0e10cSrcweir { 1221cdf0e10cSrcweir /////////////////// 1222cdf0e10cSrcweir // Path/Segments // 1223cdf0e10cSrcweir /////////////////// 1224cdf0e10cSrcweir const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) ); 1225cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sSegments ); 1226cdf0e10cSrcweir if ( pAny ) 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments1, seqSegments2; 1229cdf0e10cSrcweir if ( *pAny >>= seqSegments1 ) 1230cdf0e10cSrcweir { 1231cdf0e10cSrcweir if ( pDefCustomShape && pDefCustomShape->nElements && pDefCustomShape->pElements ) 1232cdf0e10cSrcweir { 1233cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nElements; 1234cdf0e10cSrcweir if ( nCount ) 1235cdf0e10cSrcweir { 1236cdf0e10cSrcweir seqSegments2.realloc( nCount ); 1237cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 1238cdf0e10cSrcweir { 1239cdf0e10cSrcweir EnhancedCustomShapeSegment& rSegInfo = seqSegments2[ i ]; 1240cdf0e10cSrcweir sal_uInt16 nSDat = pDefCustomShape->pElements[ i ]; 1241cdf0e10cSrcweir switch( nSDat >> 8 ) 1242cdf0e10cSrcweir { 1243cdf0e10cSrcweir case 0x00 : 1244cdf0e10cSrcweir { 1245cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO; 1246cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 1247cdf0e10cSrcweir if ( !rSegInfo.Count ) 1248cdf0e10cSrcweir rSegInfo.Count = 1; 1249cdf0e10cSrcweir } 1250cdf0e10cSrcweir break; 1251cdf0e10cSrcweir case 0x20 : 1252cdf0e10cSrcweir { 1253cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO; 1254cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 1255cdf0e10cSrcweir if ( !rSegInfo.Count ) 1256cdf0e10cSrcweir rSegInfo.Count = 1; 1257cdf0e10cSrcweir } 1258cdf0e10cSrcweir break; 1259cdf0e10cSrcweir case 0x40 : 1260cdf0e10cSrcweir { 1261cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO; 1262cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 1263cdf0e10cSrcweir if ( !rSegInfo.Count ) 1264cdf0e10cSrcweir rSegInfo.Count = 1; 1265cdf0e10cSrcweir } 1266cdf0e10cSrcweir break; 1267cdf0e10cSrcweir case 0x60 : 1268cdf0e10cSrcweir { 1269cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH; 1270cdf0e10cSrcweir rSegInfo.Count = 0; 1271cdf0e10cSrcweir } 1272cdf0e10cSrcweir break; 1273cdf0e10cSrcweir case 0x80 : 1274cdf0e10cSrcweir { 1275cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH; 1276cdf0e10cSrcweir rSegInfo.Count = 0; 1277cdf0e10cSrcweir } 1278cdf0e10cSrcweir break; 1279cdf0e10cSrcweir case 0xa1 : 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO; 1282cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) / 3; 1283cdf0e10cSrcweir } 1284cdf0e10cSrcweir break; 1285cdf0e10cSrcweir case 0xa2 : 1286cdf0e10cSrcweir { 1287cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE; 1288cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) / 3; 1289cdf0e10cSrcweir } 1290cdf0e10cSrcweir break; 1291cdf0e10cSrcweir case 0xa3 : 1292cdf0e10cSrcweir { 1293cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO; 1294cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) >> 2; 1295cdf0e10cSrcweir } 1296cdf0e10cSrcweir break; 1297cdf0e10cSrcweir case 0xa4 : 1298cdf0e10cSrcweir { 1299cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC; 1300cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) >> 2; 1301cdf0e10cSrcweir } 1302cdf0e10cSrcweir break; 1303cdf0e10cSrcweir case 0xa5 : 1304cdf0e10cSrcweir { 1305cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO; 1306cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) >> 2; 1307cdf0e10cSrcweir } 1308cdf0e10cSrcweir break; 1309cdf0e10cSrcweir case 0xa6 : 1310cdf0e10cSrcweir { 1311cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC; 1312cdf0e10cSrcweir rSegInfo.Count = ( nSDat & 0xff ) >> 2; 1313cdf0e10cSrcweir } 1314cdf0e10cSrcweir break; 1315cdf0e10cSrcweir case 0xa7 : 1316cdf0e10cSrcweir { 1317cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX; 1318cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 1319cdf0e10cSrcweir } 1320cdf0e10cSrcweir break; 1321cdf0e10cSrcweir case 0xa8 : 1322cdf0e10cSrcweir { 1323cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY; 1324cdf0e10cSrcweir rSegInfo.Count = nSDat & 0xff; 1325cdf0e10cSrcweir } 1326cdf0e10cSrcweir break; 1327cdf0e10cSrcweir case 0xaa : 1328cdf0e10cSrcweir { 1329cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL; 1330cdf0e10cSrcweir rSegInfo.Count = 0; 1331cdf0e10cSrcweir } 1332cdf0e10cSrcweir break; 1333cdf0e10cSrcweir case 0xab : 1334cdf0e10cSrcweir { 1335cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE; 1336cdf0e10cSrcweir rSegInfo.Count = 0; 1337cdf0e10cSrcweir } 1338cdf0e10cSrcweir break; 1339cdf0e10cSrcweir default: 1340cdf0e10cSrcweir case 0xf8 : 1341cdf0e10cSrcweir { 1342cdf0e10cSrcweir rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN; 1343cdf0e10cSrcweir rSegInfo.Count = nSDat; 1344cdf0e10cSrcweir } 1345cdf0e10cSrcweir break; 1346cdf0e10cSrcweir } 1347cdf0e10cSrcweir } 1348cdf0e10cSrcweir if ( seqSegments1 == seqSegments2 ) 1349cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1350cdf0e10cSrcweir } 1351cdf0e10cSrcweir } 1352cdf0e10cSrcweir else 1353cdf0e10cSrcweir { 1354cdf0e10cSrcweir // check if its the default segment description ( M L Z N ) 1355cdf0e10cSrcweir if ( seqSegments1.getLength() == 4 ) 1356cdf0e10cSrcweir { 1357cdf0e10cSrcweir if ( ( seqSegments1[ 0 ].Command == EnhancedCustomShapeSegmentCommand::MOVETO ) 1358cdf0e10cSrcweir && ( seqSegments1[ 1 ].Command == EnhancedCustomShapeSegmentCommand::LINETO ) 1359cdf0e10cSrcweir && ( seqSegments1[ 2 ].Command == EnhancedCustomShapeSegmentCommand::CLOSESUBPATH ) 1360cdf0e10cSrcweir && ( seqSegments1[ 3 ].Command == EnhancedCustomShapeSegmentCommand::ENDSUBPATH ) ) 1361cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1362cdf0e10cSrcweir } 1363cdf0e10cSrcweir } 1364cdf0e10cSrcweir } 1365cdf0e10cSrcweir } 1366cdf0e10cSrcweir else if ( pDefCustomShape && ( ( pDefCustomShape->nElements == 0 ) || ( pDefCustomShape->pElements == 0 ) ) ) 1367cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1368cdf0e10cSrcweir } 1369cdf0e10cSrcweir break; 1370cdf0e10cSrcweir 1371cdf0e10cSrcweir case DEFAULT_STRETCHX : 1372cdf0e10cSrcweir { 1373cdf0e10cSrcweir const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) ); 1374cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchX ); 1375cdf0e10cSrcweir if ( pAny && pDefCustomShape ) 1376cdf0e10cSrcweir { 1377cdf0e10cSrcweir sal_Int32 nStretchX = 0; 1378cdf0e10cSrcweir if ( *pAny >>= nStretchX ) 1379cdf0e10cSrcweir { 1380cdf0e10cSrcweir if ( pDefCustomShape->nXRef == nStretchX ) 1381cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1382cdf0e10cSrcweir } 1383cdf0e10cSrcweir } 1384cdf0e10cSrcweir else if ( pDefCustomShape && ( pDefCustomShape->nXRef == DEFAULT_MINIMUM_SIGNED_COMPARE ) ) 1385cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1386cdf0e10cSrcweir } 1387cdf0e10cSrcweir break; 1388cdf0e10cSrcweir 1389cdf0e10cSrcweir case DEFAULT_STRETCHY : 1390cdf0e10cSrcweir { 1391cdf0e10cSrcweir const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) ); 1392cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchY ); 1393cdf0e10cSrcweir if ( pAny && pDefCustomShape ) 1394cdf0e10cSrcweir { 1395cdf0e10cSrcweir sal_Int32 nStretchY = 0; 1396cdf0e10cSrcweir if ( *pAny >>= nStretchY ) 1397cdf0e10cSrcweir { 1398cdf0e10cSrcweir if ( pDefCustomShape->nYRef == nStretchY ) 1399cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1400cdf0e10cSrcweir } 1401cdf0e10cSrcweir } 1402cdf0e10cSrcweir else if ( pDefCustomShape && ( pDefCustomShape->nYRef == DEFAULT_MINIMUM_SIGNED_COMPARE ) ) 1403cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1404cdf0e10cSrcweir } 1405cdf0e10cSrcweir break; 1406cdf0e10cSrcweir 1407cdf0e10cSrcweir case DEFAULT_EQUATIONS : 1408cdf0e10cSrcweir { 1409cdf0e10cSrcweir const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) ); 1410cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sEquations ); 1411cdf0e10cSrcweir if ( pAny && pDefCustomShape && pDefCustomShape->nCalculation && pDefCustomShape->pCalculation ) 1412cdf0e10cSrcweir { 1413cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > seqEquations1, seqEquations2; 1414cdf0e10cSrcweir if ( *pAny >>= seqEquations1 ) 1415cdf0e10cSrcweir { 1416cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nCalculation; 1417cdf0e10cSrcweir seqEquations2.realloc( nCount ); 1418cdf0e10cSrcweir 1419cdf0e10cSrcweir const SvxMSDffCalculationData* pData = pDefCustomShape->pCalculation; 1420cdf0e10cSrcweir for ( i = 0; i < nCount; i++, pData++ ) 1421cdf0e10cSrcweir seqEquations2[ i ] = EnhancedCustomShape2d::GetEquation( pData->nFlags, pData->nVal[ 0 ], pData->nVal[ 1 ], pData->nVal[ 2 ] ); 1422cdf0e10cSrcweir 1423cdf0e10cSrcweir if ( seqEquations1 == seqEquations2 ) 1424cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1425cdf0e10cSrcweir } 1426cdf0e10cSrcweir } 1427cdf0e10cSrcweir else if ( pDefCustomShape && ( ( pDefCustomShape->nCalculation == 0 ) || ( pDefCustomShape->pCalculation == 0 ) ) ) 1428cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1429cdf0e10cSrcweir } 1430cdf0e10cSrcweir break; 1431cdf0e10cSrcweir 1432cdf0e10cSrcweir case DEFAULT_TEXTFRAMES : 1433cdf0e10cSrcweir { 1434cdf0e10cSrcweir const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM( "TextFrames" ) ); 1435cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sTextFrames ); 1436cdf0e10cSrcweir if ( pAny && pDefCustomShape && pDefCustomShape->nTextRect && pDefCustomShape->pTextRect ) 1437cdf0e10cSrcweir { 1438cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames1, seqTextFrames2; 1439cdf0e10cSrcweir if ( *pAny >>= seqTextFrames1 ) 1440cdf0e10cSrcweir { 1441cdf0e10cSrcweir sal_Int32 i, nCount = pDefCustomShape->nTextRect; 1442cdf0e10cSrcweir seqTextFrames2.realloc( nCount ); 1443cdf0e10cSrcweir const SvxMSDffTextRectangles* pRectangles = pDefCustomShape->pTextRect; 1444cdf0e10cSrcweir for ( i = 0; i < nCount; i++, pRectangles++ ) 1445cdf0e10cSrcweir { 1446cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].TopLeft.First, pRectangles->nPairA.nValA ); 1447cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].TopLeft.Second, pRectangles->nPairA.nValB ); 1448cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].BottomRight.First, pRectangles->nPairB.nValA ); 1449cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].BottomRight.Second, pRectangles->nPairB.nValB ); 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir if ( seqTextFrames1 == seqTextFrames2 ) 1452cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1453cdf0e10cSrcweir } 1454cdf0e10cSrcweir } 1455cdf0e10cSrcweir else if ( pDefCustomShape && ( ( pDefCustomShape->nTextRect == 0 ) || ( pDefCustomShape->pTextRect == 0 ) ) ) 1456cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1457cdf0e10cSrcweir } 1458cdf0e10cSrcweir break; 1459cdf0e10cSrcweir 1460cdf0e10cSrcweir case DEFAULT_HANDLES : 1461cdf0e10cSrcweir { 1462cdf0e10cSrcweir const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) ); 1463cdf0e10cSrcweir pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sHandles ); 1464cdf0e10cSrcweir if ( pAny && pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles ) 1465cdf0e10cSrcweir { 1466cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles1, seqHandles2; 1467cdf0e10cSrcweir if ( *pAny >>= seqHandles1 ) 1468cdf0e10cSrcweir { 1469cdf0e10cSrcweir sal_Int32 i, n, nCount = pDefCustomShape->nHandles; 1470cdf0e10cSrcweir const SvxMSDffHandle* pData = pDefCustomShape->pHandles; 1471cdf0e10cSrcweir seqHandles2.realloc( nCount ); 1472cdf0e10cSrcweir for ( i = 0; i < nCount; i++, pData++ ) 1473cdf0e10cSrcweir { 1474cdf0e10cSrcweir sal_Int32 nPropertiesNeeded = 1; // position is always needed 1475cdf0e10cSrcweir sal_Int32 nFlags = pData->nFlags; 1476cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X ) 1477cdf0e10cSrcweir nPropertiesNeeded++; 1478cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y ) 1479cdf0e10cSrcweir nPropertiesNeeded++; 1480cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED ) 1481cdf0e10cSrcweir nPropertiesNeeded++; 1482cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR ) 1483cdf0e10cSrcweir { 1484cdf0e10cSrcweir nPropertiesNeeded++; 1485cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE ) 1486cdf0e10cSrcweir { 1487cdf0e10cSrcweir if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1488cdf0e10cSrcweir nPropertiesNeeded++; 1489cdf0e10cSrcweir if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1490cdf0e10cSrcweir nPropertiesNeeded++; 1491cdf0e10cSrcweir } 1492cdf0e10cSrcweir } 1493cdf0e10cSrcweir else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE ) 1494cdf0e10cSrcweir { 1495cdf0e10cSrcweir if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1496cdf0e10cSrcweir nPropertiesNeeded++; 1497cdf0e10cSrcweir if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1498cdf0e10cSrcweir nPropertiesNeeded++; 1499cdf0e10cSrcweir if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1500cdf0e10cSrcweir nPropertiesNeeded++; 1501cdf0e10cSrcweir if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1502cdf0e10cSrcweir nPropertiesNeeded++; 1503cdf0e10cSrcweir } 1504cdf0e10cSrcweir 1505cdf0e10cSrcweir n = 0; 1506cdf0e10cSrcweir com::sun::star::beans::PropertyValues& rPropValues = seqHandles2[ i ]; 1507cdf0e10cSrcweir rPropValues.realloc( nPropertiesNeeded ); 1508cdf0e10cSrcweir 1509cdf0e10cSrcweir // POSITION 1510cdf0e10cSrcweir { 1511cdf0e10cSrcweir const rtl::OUString sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) ); 1512cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition; 1513cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First, pData->nPositionX, sal_True, sal_True ); 1514cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, pData->nPositionY, sal_True, sal_False ); 1515cdf0e10cSrcweir rPropValues[ n ].Name = sPosition; 1516cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aPosition; 1517cdf0e10cSrcweir } 1518cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X ) 1519cdf0e10cSrcweir { 1520cdf0e10cSrcweir const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) ); 1521cdf0e10cSrcweir sal_Bool bMirroredX = sal_True; 1522cdf0e10cSrcweir rPropValues[ n ].Name = sMirroredX; 1523cdf0e10cSrcweir rPropValues[ n++ ].Value <<= bMirroredX; 1524cdf0e10cSrcweir } 1525cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y ) 1526cdf0e10cSrcweir { 1527cdf0e10cSrcweir const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) ); 1528cdf0e10cSrcweir sal_Bool bMirroredY = sal_True; 1529cdf0e10cSrcweir rPropValues[ n ].Name = sMirroredY; 1530cdf0e10cSrcweir rPropValues[ n++ ].Value <<= bMirroredY; 1531cdf0e10cSrcweir } 1532cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED ) 1533cdf0e10cSrcweir { 1534cdf0e10cSrcweir const rtl::OUString sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) ); 1535cdf0e10cSrcweir sal_Bool bSwitched = sal_True; 1536cdf0e10cSrcweir rPropValues[ n ].Name = sSwitched; 1537cdf0e10cSrcweir rPropValues[ n++ ].Value <<= bSwitched; 1538cdf0e10cSrcweir } 1539cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR ) 1540cdf0e10cSrcweir { 1541cdf0e10cSrcweir const rtl::OUString sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) ); 1542cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter; 1543cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First, pData->nCenterX, 1544cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True ); 1545cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second, pData->nCenterY, 1546cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False ); 1547cdf0e10cSrcweir rPropValues[ n ].Name = sPolar; 1548cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aCenter; 1549cdf0e10cSrcweir if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE ) 1550cdf0e10cSrcweir { 1551cdf0e10cSrcweir if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1552cdf0e10cSrcweir { 1553cdf0e10cSrcweir const rtl::OUString sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) ); 1554cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum; 1555cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, pData->nRangeXMin, 1556cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True ); 1557cdf0e10cSrcweir rPropValues[ n ].Name = sRadiusRangeMinimum; 1558cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRadiusRangeMinimum; 1559cdf0e10cSrcweir } 1560cdf0e10cSrcweir if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1561cdf0e10cSrcweir { 1562cdf0e10cSrcweir const rtl::OUString sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) ); 1563cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum; 1564cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, pData->nRangeXMax, 1565cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False ); 1566cdf0e10cSrcweir rPropValues[ n ].Name = sRadiusRangeMaximum; 1567cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRadiusRangeMaximum; 1568cdf0e10cSrcweir } 1569cdf0e10cSrcweir } 1570cdf0e10cSrcweir } 1571cdf0e10cSrcweir else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE ) 1572cdf0e10cSrcweir { 1573cdf0e10cSrcweir if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1574cdf0e10cSrcweir { 1575cdf0e10cSrcweir const rtl::OUString sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) ); 1576cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum; 1577cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum, pData->nRangeXMin, 1578cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True ); 1579cdf0e10cSrcweir rPropValues[ n ].Name = sRangeXMinimum; 1580cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRangeXMinimum; 1581cdf0e10cSrcweir } 1582cdf0e10cSrcweir if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1583cdf0e10cSrcweir { 1584cdf0e10cSrcweir const rtl::OUString sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) ); 1585cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum; 1586cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, pData->nRangeXMax, 1587cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False ); 1588cdf0e10cSrcweir rPropValues[ n ].Name = sRangeXMaximum; 1589cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRangeXMaximum; 1590cdf0e10cSrcweir } 1591cdf0e10cSrcweir if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) 1592cdf0e10cSrcweir { 1593cdf0e10cSrcweir const rtl::OUString sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) ); 1594cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum; 1595cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, pData->nRangeYMin, 1596cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True ); 1597cdf0e10cSrcweir rPropValues[ n ].Name = sRangeYMinimum; 1598cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRangeYMinimum; 1599cdf0e10cSrcweir } 1600cdf0e10cSrcweir if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) 1601cdf0e10cSrcweir { 1602cdf0e10cSrcweir const rtl::OUString sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) ); 1603cdf0e10cSrcweir ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum; 1604cdf0e10cSrcweir EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, pData->nRangeYMax, 1605cdf0e10cSrcweir ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False ); 1606cdf0e10cSrcweir rPropValues[ n ].Name = sRangeYMaximum; 1607cdf0e10cSrcweir rPropValues[ n++ ].Value <<= aRangeYMaximum; 1608cdf0e10cSrcweir } 1609cdf0e10cSrcweir } 1610cdf0e10cSrcweir } 1611cdf0e10cSrcweir if ( seqHandles1 == seqHandles2 ) 1612cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1613cdf0e10cSrcweir } 1614cdf0e10cSrcweir } 1615cdf0e10cSrcweir else if ( pDefCustomShape && ( ( pDefCustomShape->nHandles == 0 ) || ( pDefCustomShape->pHandles == 0 ) ) ) 1616cdf0e10cSrcweir bIsDefaultGeometry = sal_True; 1617cdf0e10cSrcweir } 1618cdf0e10cSrcweir break; 1619cdf0e10cSrcweir } 1620cdf0e10cSrcweir return bIsDefaultGeometry; 1621cdf0e10cSrcweir } 1622cdf0e10cSrcweir 1623cdf0e10cSrcweir void SdrObjCustomShape::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const 1624cdf0e10cSrcweir { 1625cdf0e10cSrcweir rInfo.bResizeFreeAllowed=fObjectRotation == 0.0; 1626cdf0e10cSrcweir rInfo.bResizePropAllowed=sal_True; 1627cdf0e10cSrcweir rInfo.bRotateFreeAllowed=sal_True; 1628cdf0e10cSrcweir rInfo.bRotate90Allowed =sal_True; 1629cdf0e10cSrcweir rInfo.bMirrorFreeAllowed=sal_True; 1630cdf0e10cSrcweir rInfo.bMirror45Allowed =sal_True; 1631cdf0e10cSrcweir rInfo.bMirror90Allowed =sal_True; 1632cdf0e10cSrcweir rInfo.bTransparenceAllowed = sal_False; 1633cdf0e10cSrcweir rInfo.bGradientAllowed = sal_False; 1634cdf0e10cSrcweir rInfo.bShearAllowed =sal_True; 1635cdf0e10cSrcweir rInfo.bEdgeRadiusAllowed=sal_False; 1636cdf0e10cSrcweir rInfo.bNoContortion =sal_True; 1637cdf0e10cSrcweir 1638cdf0e10cSrcweir // #i37011# 1639cdf0e10cSrcweir if ( mXRenderedCustomShape.is() ) 1640cdf0e10cSrcweir { 1641cdf0e10cSrcweir const SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape ); 1642cdf0e10cSrcweir if ( pRenderedCustomShape ) 1643cdf0e10cSrcweir { 1644cdf0e10cSrcweir // #i37262# 1645cdf0e10cSrcweir // Iterate self over the contained objects, since there are combinations of 1646cdf0e10cSrcweir // polygon and curve objects. In that case, aInfo.bCanConvToPath and 1647cdf0e10cSrcweir // aInfo.bCanConvToPoly would be false. What is needed here is an or, not an and. 1648cdf0e10cSrcweir SdrObjListIter aIterator(*pRenderedCustomShape); 1649cdf0e10cSrcweir while(aIterator.IsMore()) 1650cdf0e10cSrcweir { 1651cdf0e10cSrcweir SdrObject* pCandidate = aIterator.Next(); 1652cdf0e10cSrcweir SdrObjTransformInfoRec aInfo; 1653cdf0e10cSrcweir pCandidate->TakeObjInfo(aInfo); 1654cdf0e10cSrcweir 1655cdf0e10cSrcweir // set path and poly conversion if one is possible since 1656cdf0e10cSrcweir // this object will first be broken 1657cdf0e10cSrcweir const sal_Bool bCanConvToPathOrPoly(aInfo.bCanConvToPath || aInfo.bCanConvToPoly); 1658cdf0e10cSrcweir if(rInfo.bCanConvToPath != bCanConvToPathOrPoly) 1659cdf0e10cSrcweir { 1660cdf0e10cSrcweir rInfo.bCanConvToPath = bCanConvToPathOrPoly; 1661cdf0e10cSrcweir } 1662cdf0e10cSrcweir 1663cdf0e10cSrcweir if(rInfo.bCanConvToPoly != bCanConvToPathOrPoly) 1664cdf0e10cSrcweir { 1665cdf0e10cSrcweir rInfo.bCanConvToPoly = bCanConvToPathOrPoly; 1666cdf0e10cSrcweir } 1667cdf0e10cSrcweir 1668cdf0e10cSrcweir if(rInfo.bCanConvToContour != aInfo.bCanConvToContour) 1669cdf0e10cSrcweir { 1670cdf0e10cSrcweir rInfo.bCanConvToContour = aInfo.bCanConvToContour; 1671cdf0e10cSrcweir } 1672cdf0e10cSrcweir } 1673cdf0e10cSrcweir } 1674cdf0e10cSrcweir } 1675cdf0e10cSrcweir } 1676cdf0e10cSrcweir 1677cdf0e10cSrcweir void SdrObjCustomShape::SetModel(SdrModel* pNewModel) 1678cdf0e10cSrcweir { 1679cdf0e10cSrcweir SdrTextObj::SetModel(pNewModel); 1680cdf0e10cSrcweir mXRenderedCustomShape.clear(); 1681cdf0e10cSrcweir } 1682cdf0e10cSrcweir 1683cdf0e10cSrcweir sal_uInt16 SdrObjCustomShape::GetObjIdentifier() const 1684cdf0e10cSrcweir { 1685cdf0e10cSrcweir return sal_uInt16(OBJ_CUSTOMSHAPE); 1686cdf0e10cSrcweir } 1687cdf0e10cSrcweir 1688cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1689cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1690cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1691cdf0e10cSrcweir 1692cdf0e10cSrcweir void SdrObjCustomShape::RecalcSnapRect() 1693cdf0e10cSrcweir { 1694cdf0e10cSrcweir SdrTextObj::RecalcSnapRect(); 1695cdf0e10cSrcweir } 1696cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetSnapRect() const 1697cdf0e10cSrcweir { 1698cdf0e10cSrcweir return SdrTextObj::GetSnapRect(); 1699cdf0e10cSrcweir } 1700cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetCurrentBoundRect() const 1701cdf0e10cSrcweir { 1702cdf0e10cSrcweir return SdrTextObj::GetCurrentBoundRect(); 1703cdf0e10cSrcweir } 1704cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetLogicRect() const 1705cdf0e10cSrcweir { 1706cdf0e10cSrcweir return SdrTextObj::GetLogicRect(); 1707cdf0e10cSrcweir } 1708cdf0e10cSrcweir void SdrObjCustomShape::NbcSetSnapRect( const Rectangle& rRect ) 1709cdf0e10cSrcweir { 1710cdf0e10cSrcweir aRect=rRect; 1711cdf0e10cSrcweir ImpJustifyRect(aRect); 1712cdf0e10cSrcweir InvalidateRenderGeometry(); 1713cdf0e10cSrcweir Rectangle aTextBound( aRect ); 1714cdf0e10cSrcweir if ( GetTextBounds( aTextBound ) ) 1715cdf0e10cSrcweir { 1716cdf0e10cSrcweir if ( pModel==NULL || !pModel->IsPasteResize() ) 1717cdf0e10cSrcweir { 1718cdf0e10cSrcweir long nHDist=GetTextLeftDistance()+GetTextRightDistance(); 1719cdf0e10cSrcweir long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); 1720cdf0e10cSrcweir long nTWdt=aTextBound.GetWidth ()-1-nHDist; if (nTWdt<0) nTWdt=0; 1721cdf0e10cSrcweir long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0; 1722cdf0e10cSrcweir if ( IsAutoGrowWidth() ) 1723cdf0e10cSrcweir NbcSetMinTextFrameWidth( nTWdt ); 1724cdf0e10cSrcweir if ( IsAutoGrowHeight() ) 1725cdf0e10cSrcweir NbcSetMinTextFrameHeight( nTHgt ); 1726cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight(); 1727cdf0e10cSrcweir } 1728cdf0e10cSrcweir } 1729cdf0e10cSrcweir ImpCheckShear(); 1730cdf0e10cSrcweir SetRectsDirty(); 1731cdf0e10cSrcweir SetChanged(); 1732cdf0e10cSrcweir } 1733cdf0e10cSrcweir void SdrObjCustomShape::SetSnapRect( const Rectangle& rRect ) 1734cdf0e10cSrcweir { 1735cdf0e10cSrcweir Rectangle aBoundRect0; 1736cdf0e10cSrcweir if ( pUserCall ) 1737cdf0e10cSrcweir aBoundRect0 = GetLastBoundRect(); 1738cdf0e10cSrcweir NbcSetSnapRect( rRect ); 1739cdf0e10cSrcweir BroadcastObjectChange(); 1740cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 1741cdf0e10cSrcweir } 1742cdf0e10cSrcweir void SdrObjCustomShape::NbcSetLogicRect( const Rectangle& rRect ) 1743cdf0e10cSrcweir { 1744cdf0e10cSrcweir aRect = rRect; 1745cdf0e10cSrcweir ImpJustifyRect( aRect ); 1746cdf0e10cSrcweir InvalidateRenderGeometry(); 1747cdf0e10cSrcweir Rectangle aTextBound( aRect ); 1748cdf0e10cSrcweir if ( GetTextBounds( aTextBound ) ) 1749cdf0e10cSrcweir { 1750cdf0e10cSrcweir long nHDist=GetTextLeftDistance()+GetTextRightDistance(); 1751cdf0e10cSrcweir long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); 1752cdf0e10cSrcweir 1753cdf0e10cSrcweir long nTWdt=aTextBound.GetWidth()-1-nHDist; if (nTWdt<0) nTWdt=0; 1754cdf0e10cSrcweir long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0; 1755cdf0e10cSrcweir if ( IsAutoGrowWidth() ) 1756cdf0e10cSrcweir NbcSetMinTextFrameWidth( nTWdt ); 1757cdf0e10cSrcweir if ( IsAutoGrowHeight() ) 1758cdf0e10cSrcweir NbcSetMinTextFrameHeight( nTHgt ); 1759cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight(); 1760cdf0e10cSrcweir } 1761cdf0e10cSrcweir SetRectsDirty(); 1762cdf0e10cSrcweir SetChanged(); 1763cdf0e10cSrcweir } 1764cdf0e10cSrcweir void SdrObjCustomShape::SetLogicRect( const Rectangle& rRect ) 1765cdf0e10cSrcweir { 1766cdf0e10cSrcweir Rectangle aBoundRect0; 1767cdf0e10cSrcweir if ( pUserCall ) 1768cdf0e10cSrcweir aBoundRect0 = GetLastBoundRect(); 1769cdf0e10cSrcweir NbcSetLogicRect(rRect); 1770cdf0e10cSrcweir BroadcastObjectChange(); 1771cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 1772cdf0e10cSrcweir } 1773cdf0e10cSrcweir void SdrObjCustomShape::Move( const Size& rSiz ) 1774cdf0e10cSrcweir { 1775cdf0e10cSrcweir if ( rSiz.Width() || rSiz.Height() ) 1776cdf0e10cSrcweir { 1777cdf0e10cSrcweir Rectangle aBoundRect0; 1778cdf0e10cSrcweir if ( pUserCall ) 1779cdf0e10cSrcweir aBoundRect0 = GetLastBoundRect(); 1780cdf0e10cSrcweir // #110094#-14 SendRepaintBroadcast(); 1781cdf0e10cSrcweir NbcMove(rSiz); 1782cdf0e10cSrcweir SetChanged(); 1783cdf0e10cSrcweir BroadcastObjectChange(); 1784cdf0e10cSrcweir SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0); 1785cdf0e10cSrcweir } 1786cdf0e10cSrcweir } 1787cdf0e10cSrcweir void SdrObjCustomShape::NbcMove( const Size& rSiz ) 1788cdf0e10cSrcweir { 1789cdf0e10cSrcweir SdrTextObj::NbcMove( rSiz ); 1790cdf0e10cSrcweir if ( mXRenderedCustomShape.is() ) 1791cdf0e10cSrcweir { 1792cdf0e10cSrcweir SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape ); 1793cdf0e10cSrcweir if ( pRenderedCustomShape ) 1794cdf0e10cSrcweir { 1795cdf0e10cSrcweir // #i97149# the visualisation shape needs to be informed 1796cdf0e10cSrcweir // about change, too 1797cdf0e10cSrcweir pRenderedCustomShape->ActionChanged(); 1798cdf0e10cSrcweir pRenderedCustomShape->NbcMove( rSiz ); 1799cdf0e10cSrcweir } 1800cdf0e10cSrcweir } 1801cdf0e10cSrcweir 1802cdf0e10cSrcweir // #i37011# adapt geometry shadow 1803cdf0e10cSrcweir if(mpLastShadowGeometry) 1804cdf0e10cSrcweir { 1805cdf0e10cSrcweir mpLastShadowGeometry->NbcMove( rSiz ); 1806cdf0e10cSrcweir } 1807cdf0e10cSrcweir } 1808cdf0e10cSrcweir void SdrObjCustomShape::Resize( const Point& rRef, const Fraction& xFact, const Fraction& yFact ) 1809cdf0e10cSrcweir { 1810cdf0e10cSrcweir SdrTextObj::Resize( rRef, xFact, yFact ); 1811cdf0e10cSrcweir } 1812cdf0e10cSrcweir 1813cdf0e10cSrcweir void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, const Fraction& ryFact ) 1814cdf0e10cSrcweir { 1815cdf0e10cSrcweir Fraction xFact( rxFact ); 1816cdf0e10cSrcweir Fraction yFact( ryFact ); 1817cdf0e10cSrcweir 1818cdf0e10cSrcweir // taking care of handles that should not been changed 1819cdf0e10cSrcweir Rectangle aOld( aRect ); 1820cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) ); 1821cdf0e10cSrcweir 1822cdf0e10cSrcweir SdrTextObj::NbcResize( rRef, xFact, yFact ); 1823cdf0e10cSrcweir 1824cdf0e10cSrcweir if ( ( xFact.GetNumerator() != xFact.GetDenominator() ) 1825cdf0e10cSrcweir || ( yFact.GetNumerator()!= yFact.GetDenominator() ) ) 1826cdf0e10cSrcweir { 1827cdf0e10cSrcweir if ( ( ( xFact.GetNumerator() < 0 ) && ( xFact.GetDenominator() > 0 ) ) || 1828cdf0e10cSrcweir ( ( xFact.GetNumerator() > 0 ) && ( xFact.GetDenominator() < 0 ) ) ) 1829cdf0e10cSrcweir { 1830cdf0e10cSrcweir SetMirroredX( IsMirroredX() == sal_False ); 1831cdf0e10cSrcweir } 1832cdf0e10cSrcweir if ( ( ( yFact.GetNumerator() < 0 ) && ( yFact.GetDenominator() > 0 ) ) || 1833cdf0e10cSrcweir ( ( yFact.GetNumerator() > 0 ) && ( yFact.GetDenominator() < 0 ) ) ) 1834cdf0e10cSrcweir { 1835cdf0e10cSrcweir SetMirroredY( IsMirroredY() == sal_False ); 1836cdf0e10cSrcweir } 1837cdf0e10cSrcweir } 1838cdf0e10cSrcweir 1839cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() ); 1840cdf0e10cSrcweir while ( aIter != aInteractionHandles.end() ) 1841cdf0e10cSrcweir { 1842cdf0e10cSrcweir try 1843cdf0e10cSrcweir { 1844cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED ) 1845cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( aIter->aPosition ); 1846cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X ) 1847cdf0e10cSrcweir { 1848cdf0e10cSrcweir sal_Int32 nX = ( aIter->aPosition.X - aOld.Left() ) + aRect.Left(); 1849cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) ); 1850cdf0e10cSrcweir } 1851cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y ) 1852cdf0e10cSrcweir { 1853cdf0e10cSrcweir sal_Int32 nY = ( aIter->aPosition.Y - aOld.Top() ) + aRect.Top(); 1854cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) ); 1855cdf0e10cSrcweir } 1856cdf0e10cSrcweir } 1857cdf0e10cSrcweir catch ( const uno::RuntimeException& ) 1858cdf0e10cSrcweir { 1859cdf0e10cSrcweir } 1860cdf0e10cSrcweir aIter++; 1861cdf0e10cSrcweir } 1862cdf0e10cSrcweir InvalidateRenderGeometry(); 1863cdf0e10cSrcweir } 1864cdf0e10cSrcweir void SdrObjCustomShape::NbcRotate( const Point& rRef, long nWink, double sn, double cs ) 1865cdf0e10cSrcweir { 1866cdf0e10cSrcweir sal_Bool bMirroredX = IsMirroredX(); 1867cdf0e10cSrcweir sal_Bool bMirroredY = IsMirroredY(); 1868cdf0e10cSrcweir 1869cdf0e10cSrcweir fObjectRotation = fmod( fObjectRotation, 360.0 ); 1870cdf0e10cSrcweir if ( fObjectRotation < 0 ) 1871cdf0e10cSrcweir fObjectRotation = 360 + fObjectRotation; 1872cdf0e10cSrcweir 1873cdf0e10cSrcweir // the rotation angle for ashapes is stored in fObjectRotation, this rotation 1874cdf0e10cSrcweir // has to be applied to the text object (which is internally using aGeo.nWink). 1875cdf0e10cSrcweir SdrTextObj::NbcRotate( aRect.TopLeft(), -aGeo.nDrehWink, // retrieving the unrotated text object 1876cdf0e10cSrcweir sin( (-aGeo.nDrehWink) * F_PI18000 ), 1877cdf0e10cSrcweir cos( (-aGeo.nDrehWink) * F_PI18000 ) ); 1878cdf0e10cSrcweir aGeo.nDrehWink = 0; // resetting aGeo data 1879cdf0e10cSrcweir aGeo.RecalcSinCos(); 1880cdf0e10cSrcweir 1881cdf0e10cSrcweir long nW = (long)( fObjectRotation * 100 ); // applying our object rotation 1882cdf0e10cSrcweir if ( bMirroredX ) 1883cdf0e10cSrcweir nW = 36000 - nW; 1884cdf0e10cSrcweir if ( bMirroredY ) 1885cdf0e10cSrcweir nW = 18000 - nW; 1886cdf0e10cSrcweir nW = nW % 36000; 1887cdf0e10cSrcweir if ( nW < 0 ) 1888cdf0e10cSrcweir nW = 36000 + nW; 1889cdf0e10cSrcweir SdrTextObj::NbcRotate( aRect.TopLeft(), nW, // applying text rotation 1890cdf0e10cSrcweir sin( nW * F_PI18000 ), 1891cdf0e10cSrcweir cos( nW * F_PI18000 ) ); 1892cdf0e10cSrcweir 1893cdf0e10cSrcweir int nSwap = 0; 1894cdf0e10cSrcweir if ( bMirroredX ) 1895cdf0e10cSrcweir nSwap ^= 1; 1896cdf0e10cSrcweir if ( bMirroredY ) 1897cdf0e10cSrcweir nSwap ^= 1; 1898cdf0e10cSrcweir 1899cdf0e10cSrcweir double fWink = nWink; // updating to our new object rotation 1900cdf0e10cSrcweir fWink /= 100.0; 1901cdf0e10cSrcweir fObjectRotation = fmod( nSwap ? fObjectRotation - fWink : fObjectRotation + fWink, 360.0 ); 1902cdf0e10cSrcweir if ( fObjectRotation < 0 ) 1903cdf0e10cSrcweir fObjectRotation = 360 + fObjectRotation; 1904cdf0e10cSrcweir 1905cdf0e10cSrcweir SdrTextObj::NbcRotate( rRef, nWink, sn, cs ); // applying text rotation 1906cdf0e10cSrcweir InvalidateRenderGeometry(); 1907cdf0e10cSrcweir } 1908cdf0e10cSrcweir 1909cdf0e10cSrcweir void SdrObjCustomShape::NbcMirror( const Point& rRef1, const Point& rRef2 ) 1910cdf0e10cSrcweir { 1911cdf0e10cSrcweir // storing horizontal and vertical flipping without modifying the rotate angle 1912cdf0e10cSrcweir 1913cdf0e10cSrcweir sal_Bool bHorz = sal_False; 1914cdf0e10cSrcweir sal_Bool bVert = sal_False; 1915cdf0e10cSrcweir if ( rRef1.X() == rRef2.X() ) 1916cdf0e10cSrcweir bHorz = sal_True; 1917cdf0e10cSrcweir if ( rRef1.Y() == rRef2.Y() ) 1918cdf0e10cSrcweir bVert = sal_True; 1919cdf0e10cSrcweir if ( !bHorz && !bVert ) 1920cdf0e10cSrcweir bHorz = bVert = sal_True; 1921cdf0e10cSrcweir 1922cdf0e10cSrcweir if ( bHorz || bVert ) 1923cdf0e10cSrcweir { 1924cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 1925cdf0e10cSrcweir 1926cdf0e10cSrcweir ///////////////// 1927cdf0e10cSrcweir // "MirroredX" // 1928cdf0e10cSrcweir ///////////////// 1929cdf0e10cSrcweir if ( bHorz ) 1930cdf0e10cSrcweir { 1931cdf0e10cSrcweir const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) ); 1932cdf0e10cSrcweir com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX ); 1933cdf0e10cSrcweir if ( pAny ) 1934cdf0e10cSrcweir { 1935cdf0e10cSrcweir sal_Bool bFlip = sal_Bool(); 1936cdf0e10cSrcweir if ( *pAny >>= bFlip ) 1937cdf0e10cSrcweir { 1938cdf0e10cSrcweir if ( bFlip ) 1939cdf0e10cSrcweir bHorz = sal_False; 1940cdf0e10cSrcweir } 1941cdf0e10cSrcweir } 1942cdf0e10cSrcweir PropertyValue aPropVal; 1943cdf0e10cSrcweir aPropVal.Name = sMirroredX; 1944cdf0e10cSrcweir aPropVal.Value <<= bHorz; 1945cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 1946cdf0e10cSrcweir } 1947cdf0e10cSrcweir 1948cdf0e10cSrcweir ///////////////// 1949cdf0e10cSrcweir // "MirroredY" // 1950cdf0e10cSrcweir ///////////////// 1951cdf0e10cSrcweir if ( bVert ) 1952cdf0e10cSrcweir { 1953cdf0e10cSrcweir const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) ); 1954cdf0e10cSrcweir com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY ); 1955cdf0e10cSrcweir if ( pAny ) 1956cdf0e10cSrcweir { 1957cdf0e10cSrcweir sal_Bool bFlip = sal_Bool(); 1958cdf0e10cSrcweir if ( *pAny >>= bFlip ) 1959cdf0e10cSrcweir { 1960cdf0e10cSrcweir if ( bFlip ) 1961cdf0e10cSrcweir bVert = sal_False; 1962cdf0e10cSrcweir } 1963cdf0e10cSrcweir } 1964cdf0e10cSrcweir PropertyValue aPropVal; 1965cdf0e10cSrcweir aPropVal.Name = sMirroredY; 1966cdf0e10cSrcweir aPropVal.Value <<= bVert; 1967cdf0e10cSrcweir aGeometryItem.SetPropertyValue( aPropVal ); 1968cdf0e10cSrcweir } 1969cdf0e10cSrcweir SetMergedItem( aGeometryItem ); 1970cdf0e10cSrcweir } 1971cdf0e10cSrcweir SdrTextObj::NbcMirror( rRef1, rRef2 ); 1972cdf0e10cSrcweir InvalidateRenderGeometry(); 1973cdf0e10cSrcweir } 1974cdf0e10cSrcweir 1975cdf0e10cSrcweir void SdrObjCustomShape::Shear( const Point& rRef, long nWink, double tn, FASTBOOL bVShear ) 1976cdf0e10cSrcweir { 1977cdf0e10cSrcweir SdrTextObj::Shear( rRef, nWink, tn, bVShear ); 1978cdf0e10cSrcweir InvalidateRenderGeometry(); 1979cdf0e10cSrcweir } 1980cdf0e10cSrcweir void SdrObjCustomShape::NbcShear( const Point& rRef, long nWink, double tn, FASTBOOL bVShear ) 1981cdf0e10cSrcweir { 1982cdf0e10cSrcweir long nDrehWink = aGeo.nDrehWink; 1983cdf0e10cSrcweir if ( nDrehWink ) 1984cdf0e10cSrcweir { 1985cdf0e10cSrcweir aGeo.nDrehWink = -nDrehWink; 1986cdf0e10cSrcweir aGeo.RecalcSinCos(); 1987cdf0e10cSrcweir NbcRotate( rRef, aGeo.nDrehWink, aGeo.nSin, aGeo.nCos ); 1988cdf0e10cSrcweir } 1989cdf0e10cSrcweir SdrTextObj::NbcShear(rRef,nWink,tn,bVShear); 1990cdf0e10cSrcweir if ( nDrehWink ) 1991cdf0e10cSrcweir { 1992cdf0e10cSrcweir aGeo.nDrehWink = nDrehWink; 1993cdf0e10cSrcweir aGeo.RecalcSinCos(); 1994cdf0e10cSrcweir Rotate( rRef, aGeo.nDrehWink, aGeo.nSin, aGeo.nCos ); 1995cdf0e10cSrcweir } 1996cdf0e10cSrcweir InvalidateRenderGeometry(); 1997cdf0e10cSrcweir } 1998cdf0e10cSrcweir 1999cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2000cdf0e10cSrcweir 2001cdf0e10cSrcweir SdrGluePoint SdrObjCustomShape::GetVertexGluePoint(sal_uInt16 nPosNum) const 2002cdf0e10cSrcweir { 2003cdf0e10cSrcweir sal_Int32 nWdt = ImpGetLineWdt(); // #i25616# ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue(); 2004cdf0e10cSrcweir 2005cdf0e10cSrcweir // #i25616# 2006cdf0e10cSrcweir if(!LineIsOutsideGeometry()) 2007cdf0e10cSrcweir { 2008cdf0e10cSrcweir nWdt++; 2009cdf0e10cSrcweir nWdt /= 2; 2010cdf0e10cSrcweir } 2011cdf0e10cSrcweir 2012cdf0e10cSrcweir Point aPt; 2013cdf0e10cSrcweir switch (nPosNum) { 2014cdf0e10cSrcweir case 0: aPt=aRect.TopCenter(); aPt.Y()-=nWdt; break; 2015cdf0e10cSrcweir case 1: aPt=aRect.RightCenter(); aPt.X()+=nWdt; break; 2016cdf0e10cSrcweir case 2: aPt=aRect.BottomCenter(); aPt.Y()+=nWdt; break; 2017cdf0e10cSrcweir case 3: aPt=aRect.LeftCenter(); aPt.X()-=nWdt; break; 2018cdf0e10cSrcweir } 2019cdf0e10cSrcweir if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan); 2020cdf0e10cSrcweir if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); 2021cdf0e10cSrcweir aPt-=GetSnapRect().Center(); 2022cdf0e10cSrcweir SdrGluePoint aGP(aPt); 2023cdf0e10cSrcweir aGP.SetPercent(sal_False); 2024cdf0e10cSrcweir return aGP; 2025cdf0e10cSrcweir } 2026cdf0e10cSrcweir 2027cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2028cdf0e10cSrcweir 2029cdf0e10cSrcweir // #i38892# 2030cdf0e10cSrcweir void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded() 2031cdf0e10cSrcweir { 2032cdf0e10cSrcweir const SdrObject* pSdrObject = GetSdrObjectFromCustomShape(); 2033cdf0e10cSrcweir 2034cdf0e10cSrcweir if(pSdrObject) 2035cdf0e10cSrcweir { 2036cdf0e10cSrcweir const SdrGluePointList* pSource = pSdrObject->GetGluePointList(); 2037cdf0e10cSrcweir 2038cdf0e10cSrcweir if(pSource && pSource->GetCount()) 2039cdf0e10cSrcweir { 2040cdf0e10cSrcweir if(!SdrTextObj::GetGluePointList()) 2041cdf0e10cSrcweir { 2042cdf0e10cSrcweir SdrTextObj::ForceGluePointList(); 2043cdf0e10cSrcweir } 2044cdf0e10cSrcweir 2045cdf0e10cSrcweir const SdrGluePointList* pList = SdrTextObj::GetGluePointList(); 2046cdf0e10cSrcweir 2047cdf0e10cSrcweir if(pList) 2048cdf0e10cSrcweir { 2049cdf0e10cSrcweir SdrGluePointList aNewList; 2050cdf0e10cSrcweir sal_uInt16 a; 2051cdf0e10cSrcweir 2052cdf0e10cSrcweir for(a = 0; a < pSource->GetCount(); a++) 2053cdf0e10cSrcweir { 2054cdf0e10cSrcweir SdrGluePoint aCopy((*pSource)[a]); 2055cdf0e10cSrcweir aCopy.SetUserDefined(sal_False); 2056cdf0e10cSrcweir aNewList.Insert(aCopy); 2057cdf0e10cSrcweir } 2058cdf0e10cSrcweir 2059cdf0e10cSrcweir sal_Bool bMirroredX = IsMirroredX(); 2060cdf0e10cSrcweir sal_Bool bMirroredY = IsMirroredY(); 2061cdf0e10cSrcweir 2062cdf0e10cSrcweir long nShearWink = aGeo.nShearWink; 2063cdf0e10cSrcweir double fTan = aGeo.nTan; 2064cdf0e10cSrcweir 2065cdf0e10cSrcweir if ( aGeo.nDrehWink || nShearWink || bMirroredX || bMirroredY ) 2066cdf0e10cSrcweir { 2067cdf0e10cSrcweir Polygon aPoly( aRect ); 2068cdf0e10cSrcweir if( nShearWink ) 2069cdf0e10cSrcweir { 2070cdf0e10cSrcweir sal_uInt16 nPointCount=aPoly.GetSize(); 2071cdf0e10cSrcweir for (sal_uInt16 i=0; i<nPointCount; i++) 2072cdf0e10cSrcweir ShearPoint(aPoly[i],aRect.Center(), fTan, sal_False ); 2073cdf0e10cSrcweir } 2074cdf0e10cSrcweir if ( aGeo.nDrehWink ) 2075cdf0e10cSrcweir aPoly.Rotate( aRect.Center(), aGeo.nDrehWink / 10 ); 2076cdf0e10cSrcweir 2077cdf0e10cSrcweir Rectangle aBoundRect( aPoly.GetBoundRect() ); 2078cdf0e10cSrcweir sal_Int32 nXDiff = aBoundRect.Left() - aRect.Left(); 2079cdf0e10cSrcweir sal_Int32 nYDiff = aBoundRect.Top() - aRect.Top(); 2080cdf0e10cSrcweir 2081cdf0e10cSrcweir if (nShearWink&&((bMirroredX&&!bMirroredY)||(bMirroredY&&!bMirroredX))) 2082cdf0e10cSrcweir { 2083cdf0e10cSrcweir nShearWink = -nShearWink; 2084cdf0e10cSrcweir fTan = -fTan; 2085cdf0e10cSrcweir } 2086cdf0e10cSrcweir 2087cdf0e10cSrcweir Point aRef( aRect.GetWidth() / 2, aRect.GetHeight() / 2 ); 2088cdf0e10cSrcweir for ( a = 0; a < aNewList.GetCount(); a++ ) 2089cdf0e10cSrcweir { 2090cdf0e10cSrcweir SdrGluePoint& rPoint = aNewList[ a ]; 2091cdf0e10cSrcweir Point aGlue( rPoint.GetPos() ); 2092cdf0e10cSrcweir if ( nShearWink ) 2093cdf0e10cSrcweir ShearPoint( aGlue, aRef, fTan ); 2094cdf0e10cSrcweir 2095cdf0e10cSrcweir RotatePoint( aGlue, aRef, sin( fObjectRotation * F_PI180 ), cos( fObjectRotation * F_PI180 ) ); 2096cdf0e10cSrcweir if ( bMirroredX ) 2097cdf0e10cSrcweir aGlue.X() = aRect.GetWidth() - aGlue.X(); 2098cdf0e10cSrcweir if ( bMirroredY ) 2099cdf0e10cSrcweir aGlue.Y() = aRect.GetHeight() - aGlue.Y(); 2100cdf0e10cSrcweir aGlue.X() -= nXDiff; 2101cdf0e10cSrcweir aGlue.Y() -= nYDiff; 2102cdf0e10cSrcweir rPoint.SetPos( aGlue ); 2103cdf0e10cSrcweir } 2104cdf0e10cSrcweir } 2105cdf0e10cSrcweir 2106cdf0e10cSrcweir for(a = 0; a < pList->GetCount(); a++) 2107cdf0e10cSrcweir { 2108cdf0e10cSrcweir const SdrGluePoint& rCandidate = (*pList)[a]; 2109cdf0e10cSrcweir 2110cdf0e10cSrcweir if(rCandidate.IsUserDefined()) 2111cdf0e10cSrcweir { 2112cdf0e10cSrcweir aNewList.Insert(rCandidate); 2113cdf0e10cSrcweir } 2114cdf0e10cSrcweir } 2115cdf0e10cSrcweir 2116cdf0e10cSrcweir // copy new list to local. This is NOT very convenient behaviour, the local 2117cdf0e10cSrcweir // GluePointList should not be set, but be delivered by using GetGluePointList(), 2118cdf0e10cSrcweir // maybe on demand. Since the local object is changed here, this is assumed to 2119cdf0e10cSrcweir // be a result of GetGluePointList and thus the list is copied 2120cdf0e10cSrcweir if(pPlusData) 2121cdf0e10cSrcweir { 2122cdf0e10cSrcweir *pPlusData->pGluePoints = aNewList; 2123cdf0e10cSrcweir } 2124cdf0e10cSrcweir } 2125cdf0e10cSrcweir } 2126cdf0e10cSrcweir } 2127cdf0e10cSrcweir } 2128cdf0e10cSrcweir 2129cdf0e10cSrcweir // #i38892# 2130cdf0e10cSrcweir const SdrGluePointList* SdrObjCustomShape::GetGluePointList() const 2131cdf0e10cSrcweir { 2132cdf0e10cSrcweir ((SdrObjCustomShape*)this)->ImpCheckCustomGluePointsAreAdded(); 2133cdf0e10cSrcweir return SdrTextObj::GetGluePointList(); 2134cdf0e10cSrcweir } 2135cdf0e10cSrcweir 2136cdf0e10cSrcweir // #i38892# 2137cdf0e10cSrcweir //SdrGluePointList* SdrObjCustomShape::GetGluePointList() 2138cdf0e10cSrcweir //{ 2139cdf0e10cSrcweir // ImpCheckCustomGluePointsAreAdded(); 2140cdf0e10cSrcweir // return SdrTextObj::GetGluePointList(); 2141cdf0e10cSrcweir //} 2142cdf0e10cSrcweir 2143cdf0e10cSrcweir // #i38892# 2144cdf0e10cSrcweir SdrGluePointList* SdrObjCustomShape::ForceGluePointList() 2145cdf0e10cSrcweir { 2146cdf0e10cSrcweir if(SdrTextObj::ForceGluePointList()) 2147cdf0e10cSrcweir { 2148cdf0e10cSrcweir ImpCheckCustomGluePointsAreAdded(); 2149cdf0e10cSrcweir return SdrTextObj::ForceGluePointList(); 2150cdf0e10cSrcweir } 2151cdf0e10cSrcweir else 2152cdf0e10cSrcweir { 2153cdf0e10cSrcweir return 0L; 2154cdf0e10cSrcweir } 2155cdf0e10cSrcweir } 2156cdf0e10cSrcweir 2157cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2158cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2159cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2160cdf0e10cSrcweir 2161cdf0e10cSrcweir sal_uInt32 SdrObjCustomShape::GetHdlCount() const 2162cdf0e10cSrcweir { 2163cdf0e10cSrcweir const sal_uInt32 nBasicHdlCount(SdrTextObj::GetHdlCount()); 2164cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) ); 2165cdf0e10cSrcweir return ( aInteractionHandles.size() + nBasicHdlCount ); 2166cdf0e10cSrcweir } 2167cdf0e10cSrcweir 2168cdf0e10cSrcweir SdrHdl* SdrObjCustomShape::GetHdl( sal_uInt32 nHdlNum ) const 2169cdf0e10cSrcweir { 2170cdf0e10cSrcweir SdrHdl* pH = NULL; 2171cdf0e10cSrcweir const sal_uInt32 nBasicHdlCount(SdrTextObj::GetHdlCount()); 2172cdf0e10cSrcweir 2173cdf0e10cSrcweir if ( nHdlNum < nBasicHdlCount ) 2174cdf0e10cSrcweir pH = SdrTextObj::GetHdl( nHdlNum ); 2175cdf0e10cSrcweir else 2176cdf0e10cSrcweir { 2177cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) ); 2178cdf0e10cSrcweir const sal_uInt32 nCustomShapeHdlNum(nHdlNum - nBasicHdlCount); 2179cdf0e10cSrcweir 2180cdf0e10cSrcweir if ( nCustomShapeHdlNum < aInteractionHandles.size() ) 2181cdf0e10cSrcweir { 2182cdf0e10cSrcweir if ( aInteractionHandles[ nCustomShapeHdlNum ].xInteraction.is() ) 2183cdf0e10cSrcweir { 2184cdf0e10cSrcweir try 2185cdf0e10cSrcweir { 2186cdf0e10cSrcweir com::sun::star::awt::Point aPosition( aInteractionHandles[ nCustomShapeHdlNum ].xInteraction->getPosition() ); 2187cdf0e10cSrcweir pH = new SdrHdl( Point( aPosition.X, aPosition.Y ), HDL_CUSTOMSHAPE1 ); 2188cdf0e10cSrcweir pH->SetPointNum( nCustomShapeHdlNum ); 2189cdf0e10cSrcweir pH->SetObj( (SdrObject*)this ); 2190cdf0e10cSrcweir } 2191cdf0e10cSrcweir catch ( const uno::RuntimeException& ) 2192cdf0e10cSrcweir { 2193cdf0e10cSrcweir } 2194cdf0e10cSrcweir } 2195cdf0e10cSrcweir } 2196cdf0e10cSrcweir } 2197cdf0e10cSrcweir return pH; 2198cdf0e10cSrcweir } 2199cdf0e10cSrcweir 2200cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2201cdf0e10cSrcweir 2202cdf0e10cSrcweir bool SdrObjCustomShape::hasSpecialDrag() const 2203cdf0e10cSrcweir { 2204cdf0e10cSrcweir return true; 2205cdf0e10cSrcweir } 2206cdf0e10cSrcweir 2207cdf0e10cSrcweir bool SdrObjCustomShape::beginSpecialDrag(SdrDragStat& rDrag) const 2208cdf0e10cSrcweir { 2209cdf0e10cSrcweir const SdrHdl* pHdl = rDrag.GetHdl(); 2210cdf0e10cSrcweir 2211cdf0e10cSrcweir if(pHdl && HDL_CUSTOMSHAPE1 == pHdl->GetKind()) 2212cdf0e10cSrcweir { 2213cdf0e10cSrcweir rDrag.SetEndDragChangesAttributes(true); 2214cdf0e10cSrcweir rDrag.SetNoSnap(true); 2215cdf0e10cSrcweir } 2216cdf0e10cSrcweir else 2217cdf0e10cSrcweir { 2218cdf0e10cSrcweir const SdrHdl* pHdl2 = rDrag.GetHdl(); 2219cdf0e10cSrcweir const SdrHdlKind eHdl((pHdl2 == NULL) ? HDL_MOVE : pHdl2->GetKind()); 2220cdf0e10cSrcweir 2221cdf0e10cSrcweir switch( eHdl ) 2222cdf0e10cSrcweir { 2223cdf0e10cSrcweir case HDL_UPLFT : 2224cdf0e10cSrcweir case HDL_UPPER : 2225cdf0e10cSrcweir case HDL_UPRGT : 2226cdf0e10cSrcweir case HDL_LEFT : 2227cdf0e10cSrcweir case HDL_RIGHT : 2228cdf0e10cSrcweir case HDL_LWLFT : 2229cdf0e10cSrcweir case HDL_LOWER : 2230cdf0e10cSrcweir case HDL_LWRGT : 2231cdf0e10cSrcweir case HDL_MOVE : 2232cdf0e10cSrcweir { 2233cdf0e10cSrcweir break; 2234cdf0e10cSrcweir } 2235cdf0e10cSrcweir default: 2236cdf0e10cSrcweir { 2237cdf0e10cSrcweir return false; 2238cdf0e10cSrcweir } 2239cdf0e10cSrcweir } 2240cdf0e10cSrcweir } 2241cdf0e10cSrcweir 2242cdf0e10cSrcweir return true; 2243cdf0e10cSrcweir } 2244cdf0e10cSrcweir 2245cdf0e10cSrcweir void SdrObjCustomShape::DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const 2246cdf0e10cSrcweir { 2247cdf0e10cSrcweir Rectangle aOld( pObj->aRect ); 2248cdf0e10cSrcweir sal_Bool bOldMirroredX( pObj->IsMirroredX() ); 2249cdf0e10cSrcweir sal_Bool bOldMirroredY( pObj->IsMirroredY() ); 2250cdf0e10cSrcweir 2251cdf0e10cSrcweir Rectangle aNewRect( rNewRect ); 2252cdf0e10cSrcweir aNewRect.Justify(); 2253cdf0e10cSrcweir 2254cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) ); 2255cdf0e10cSrcweir 2256cdf0e10cSrcweir GeoStat aGeoStat( pObj->GetGeoStat() ); 2257cdf0e10cSrcweir if ( aNewRect.TopLeft()!= pObj->aRect.TopLeft() && 2258cdf0e10cSrcweir ( pObj->aGeo.nDrehWink || pObj->aGeo.nShearWink ) ) 2259cdf0e10cSrcweir { 2260cdf0e10cSrcweir Point aNewPos( aNewRect.TopLeft() ); 2261cdf0e10cSrcweir if ( pObj->aGeo.nShearWink ) ShearPoint( aNewPos, aOld.TopLeft(), aGeoStat.nTan ); 2262cdf0e10cSrcweir if ( pObj->aGeo.nDrehWink ) RotatePoint(aNewPos, aOld.TopLeft(), aGeoStat.nSin, aGeoStat.nCos ); 2263cdf0e10cSrcweir aNewRect.SetPos( aNewPos ); 2264cdf0e10cSrcweir } 2265cdf0e10cSrcweir if ( aNewRect != pObj->aRect ) 2266cdf0e10cSrcweir { 2267cdf0e10cSrcweir pObj->SetLogicRect( aNewRect ); 2268cdf0e10cSrcweir pObj->InvalidateRenderGeometry(); 2269cdf0e10cSrcweir 2270cdf0e10cSrcweir if ( rNewRect.Left() > rNewRect.Right() ) 2271cdf0e10cSrcweir { 2272cdf0e10cSrcweir Point aTop( ( pObj->GetSnapRect().Left() + pObj->GetSnapRect().Right() ) >> 1, pObj->GetSnapRect().Top() ); 2273cdf0e10cSrcweir Point aBottom( aTop.X(), aTop.Y() + 1000 ); 2274cdf0e10cSrcweir pObj->NbcMirror( aTop, aBottom ); 2275cdf0e10cSrcweir } 2276cdf0e10cSrcweir if ( rNewRect.Top() > rNewRect.Bottom() ) 2277cdf0e10cSrcweir { 2278cdf0e10cSrcweir Point aLeft( pObj->GetSnapRect().Left(), ( pObj->GetSnapRect().Top() + pObj->GetSnapRect().Bottom() ) >> 1 ); 2279cdf0e10cSrcweir Point aRight( aLeft.X() + 1000, aLeft.Y() ); 2280cdf0e10cSrcweir pObj->NbcMirror( aLeft, aRight ); 2281cdf0e10cSrcweir } 2282cdf0e10cSrcweir 2283cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() ); 2284cdf0e10cSrcweir while ( aIter != aInteractionHandles.end() ) 2285cdf0e10cSrcweir { 2286cdf0e10cSrcweir try 2287cdf0e10cSrcweir { 2288cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED ) 2289cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( aIter->aPosition ); 2290cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X ) 2291cdf0e10cSrcweir { 2292cdf0e10cSrcweir sal_Int32 nX; 2293cdf0e10cSrcweir if ( bOldMirroredX ) 2294cdf0e10cSrcweir { 2295cdf0e10cSrcweir nX = ( aIter->aPosition.X - aOld.Right() ); 2296cdf0e10cSrcweir if ( rNewRect.Left() > rNewRect.Right() ) 2297cdf0e10cSrcweir nX = pObj->aRect.Left() - nX; 2298cdf0e10cSrcweir else 2299cdf0e10cSrcweir nX += pObj->aRect.Right(); 2300cdf0e10cSrcweir } 2301cdf0e10cSrcweir else 2302cdf0e10cSrcweir { 2303cdf0e10cSrcweir nX = ( aIter->aPosition.X - aOld.Left() ); 2304cdf0e10cSrcweir if ( rNewRect.Left() > rNewRect.Right() ) 2305cdf0e10cSrcweir nX = pObj->aRect.Right() - nX; 2306cdf0e10cSrcweir else 2307cdf0e10cSrcweir nX += pObj->aRect.Left(); 2308cdf0e10cSrcweir } 2309cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) ); 2310cdf0e10cSrcweir } 2311cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y ) 2312cdf0e10cSrcweir { 2313cdf0e10cSrcweir sal_Int32 nY; 2314cdf0e10cSrcweir if ( bOldMirroredY ) 2315cdf0e10cSrcweir { 2316cdf0e10cSrcweir nY = ( aIter->aPosition.Y - aOld.Bottom() ); 2317cdf0e10cSrcweir if ( rNewRect.Top() > rNewRect.Bottom() ) 2318cdf0e10cSrcweir nY = pObj->aRect.Top() - nY; 2319cdf0e10cSrcweir else 2320cdf0e10cSrcweir nY += pObj->aRect.Bottom(); 2321cdf0e10cSrcweir } 2322cdf0e10cSrcweir else 2323cdf0e10cSrcweir { 2324cdf0e10cSrcweir nY = ( aIter->aPosition.Y - aOld.Top() ); 2325cdf0e10cSrcweir if ( rNewRect.Top() > rNewRect.Bottom() ) 2326cdf0e10cSrcweir nY = pObj->aRect.Bottom() - nY; 2327cdf0e10cSrcweir else 2328cdf0e10cSrcweir nY += pObj->aRect.Top(); 2329cdf0e10cSrcweir } 2330cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) ); 2331cdf0e10cSrcweir } 2332cdf0e10cSrcweir } 2333cdf0e10cSrcweir catch ( const uno::RuntimeException& ) 2334cdf0e10cSrcweir { 2335cdf0e10cSrcweir } 2336cdf0e10cSrcweir aIter++; 2337cdf0e10cSrcweir } 2338cdf0e10cSrcweir } 2339cdf0e10cSrcweir } 2340cdf0e10cSrcweir 2341cdf0e10cSrcweir void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point aDestination, const sal_uInt16 nCustomShapeHdlNum, SdrObjCustomShape* pObj ) const 2342cdf0e10cSrcweir { 2343cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) ); 2344cdf0e10cSrcweir if ( nCustomShapeHdlNum < aInteractionHandles.size() ) 2345cdf0e10cSrcweir { 2346cdf0e10cSrcweir SdrCustomShapeInteraction aInteractionHandle( aInteractionHandles[ nCustomShapeHdlNum ] ); 2347cdf0e10cSrcweir if ( aInteractionHandle.xInteraction.is() ) 2348cdf0e10cSrcweir { 2349cdf0e10cSrcweir try 2350cdf0e10cSrcweir { 2351cdf0e10cSrcweir com::sun::star::awt::Point aPt( aDestination.X(), aDestination.Y() ); 2352cdf0e10cSrcweir if ( aInteractionHandle.nMode & CUSTOMSHAPE_HANDLE_MOVE_SHAPE ) 2353cdf0e10cSrcweir { 2354cdf0e10cSrcweir sal_Int32 nXDiff = aPt.X - aInteractionHandle.aPosition.X; 2355cdf0e10cSrcweir sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y; 2356cdf0e10cSrcweir 2357cdf0e10cSrcweir pObj->aRect.Move( nXDiff, nYDiff ); 2358cdf0e10cSrcweir pObj->aOutRect.Move( nXDiff, nYDiff ); 2359cdf0e10cSrcweir pObj->maSnapRect.Move( nXDiff, nYDiff ); 2360cdf0e10cSrcweir pObj->SetRectsDirty(sal_True); 2361cdf0e10cSrcweir pObj->InvalidateRenderGeometry(); 2362cdf0e10cSrcweir 2363cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() ); 2364cdf0e10cSrcweir while ( aIter != aInteractionHandles.end() ) 2365cdf0e10cSrcweir { 2366cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED ) 2367cdf0e10cSrcweir { 2368cdf0e10cSrcweir if ( aIter->xInteraction.is() ) 2369cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( aIter->aPosition ); 2370cdf0e10cSrcweir } 2371cdf0e10cSrcweir aIter++; 2372cdf0e10cSrcweir } 2373cdf0e10cSrcweir } 2374cdf0e10cSrcweir aInteractionHandle.xInteraction->setControllerPosition( aPt ); 2375cdf0e10cSrcweir } 2376cdf0e10cSrcweir catch ( const uno::RuntimeException& ) 2377cdf0e10cSrcweir { 2378cdf0e10cSrcweir } 2379cdf0e10cSrcweir } 2380cdf0e10cSrcweir } 2381cdf0e10cSrcweir } 2382cdf0e10cSrcweir 2383cdf0e10cSrcweir bool SdrObjCustomShape::applySpecialDrag(SdrDragStat& rDrag) 2384cdf0e10cSrcweir { 2385cdf0e10cSrcweir const SdrHdl* pHdl = rDrag.GetHdl(); 2386cdf0e10cSrcweir const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind()); 2387cdf0e10cSrcweir 2388cdf0e10cSrcweir switch(eHdl) 2389cdf0e10cSrcweir { 2390cdf0e10cSrcweir case HDL_CUSTOMSHAPE1 : 2391cdf0e10cSrcweir { 2392cdf0e10cSrcweir rDrag.SetEndDragChangesGeoAndAttributes(true); 2393cdf0e10cSrcweir DragMoveCustomShapeHdl( rDrag.GetNow(), (sal_uInt16)pHdl->GetPointNum(), this ); 2394cdf0e10cSrcweir SetRectsDirty(); 2395cdf0e10cSrcweir InvalidateRenderGeometry(); 2396cdf0e10cSrcweir SetChanged(); 2397cdf0e10cSrcweir break; 2398cdf0e10cSrcweir } 2399cdf0e10cSrcweir 2400cdf0e10cSrcweir case HDL_UPLFT : 2401cdf0e10cSrcweir case HDL_UPPER : 2402cdf0e10cSrcweir case HDL_UPRGT : 2403cdf0e10cSrcweir case HDL_LEFT : 2404cdf0e10cSrcweir case HDL_RIGHT : 2405cdf0e10cSrcweir case HDL_LWLFT : 2406cdf0e10cSrcweir case HDL_LOWER : 2407cdf0e10cSrcweir case HDL_LWRGT : 2408cdf0e10cSrcweir { 2409cdf0e10cSrcweir DragResizeCustomShape(ImpDragCalcRect(rDrag), this); 2410cdf0e10cSrcweir break; 2411cdf0e10cSrcweir } 2412cdf0e10cSrcweir case HDL_MOVE : 2413cdf0e10cSrcweir { 2414cdf0e10cSrcweir Move(Size(rDrag.GetDX(), rDrag.GetDY())); 2415cdf0e10cSrcweir break; 2416cdf0e10cSrcweir } 2417cdf0e10cSrcweir default: break; 2418cdf0e10cSrcweir } 2419cdf0e10cSrcweir 2420cdf0e10cSrcweir return true; 2421cdf0e10cSrcweir } 2422cdf0e10cSrcweir 2423cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2424cdf0e10cSrcweir 2425cdf0e10cSrcweir void SdrObjCustomShape::DragCreateObject( SdrDragStat& rStat ) 2426cdf0e10cSrcweir { 2427cdf0e10cSrcweir Rectangle aRect1; 2428cdf0e10cSrcweir rStat.TakeCreateRect( aRect1 ); 2429cdf0e10cSrcweir 2430cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) ); 2431cdf0e10cSrcweir 2432cdf0e10cSrcweir sal_uInt32 nDefaultObjectSizeWidth = 3000; // default width from SDOptions ? 2433cdf0e10cSrcweir sal_uInt32 nDefaultObjectSizeHeight= 3000; 2434cdf0e10cSrcweir 2435cdf0e10cSrcweir if ( ImpVerticalSwitch( *this ) ) 2436cdf0e10cSrcweir { 2437cdf0e10cSrcweir SetMirroredX( aRect1.Left() > aRect1.Right() ); 2438cdf0e10cSrcweir 2439cdf0e10cSrcweir aRect1 = Rectangle( rStat.GetNow(), Size( nDefaultObjectSizeWidth, nDefaultObjectSizeHeight ) ); 2440cdf0e10cSrcweir // subtracting the horizontal difference of the latest handle from shape position 2441cdf0e10cSrcweir if ( !aInteractionHandles.empty() ) 2442cdf0e10cSrcweir { 2443cdf0e10cSrcweir sal_Int32 nHandlePos = aInteractionHandles[ aInteractionHandles.size() - 1 ].xInteraction->getPosition().X; 2444cdf0e10cSrcweir aRect1.Move( aRect.Left() - nHandlePos, 0 ); 2445cdf0e10cSrcweir } 2446cdf0e10cSrcweir } 2447cdf0e10cSrcweir ImpJustifyRect( aRect1 ); 2448cdf0e10cSrcweir rStat.SetActionRect( aRect1 ); 2449cdf0e10cSrcweir aRect = aRect1; 2450cdf0e10cSrcweir SetRectsDirty(); 2451cdf0e10cSrcweir 2452cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() ); 2453cdf0e10cSrcweir while ( aIter != aInteractionHandles.end() ) 2454cdf0e10cSrcweir { 2455cdf0e10cSrcweir try 2456cdf0e10cSrcweir { 2457cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_CREATE_FIXED ) 2458cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( awt::Point( rStat.GetStart().X(), rStat.GetStart().Y() ) ); 2459cdf0e10cSrcweir } 2460cdf0e10cSrcweir catch ( const uno::RuntimeException& ) 2461cdf0e10cSrcweir { 2462cdf0e10cSrcweir } 2463cdf0e10cSrcweir aIter++; 2464cdf0e10cSrcweir } 2465cdf0e10cSrcweir 2466cdf0e10cSrcweir SetBoundRectDirty(); 2467cdf0e10cSrcweir bSnapRectDirty=sal_True; 2468cdf0e10cSrcweir } 2469cdf0e10cSrcweir 2470cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::BegCreate( SdrDragStat& rDrag ) 2471cdf0e10cSrcweir { 2472cdf0e10cSrcweir return SdrTextObj::BegCreate( rDrag ); 2473cdf0e10cSrcweir } 2474cdf0e10cSrcweir 2475cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::MovCreate(SdrDragStat& rStat) 2476cdf0e10cSrcweir { 2477cdf0e10cSrcweir SdrView* pView = rStat.GetView(); // #i37448# 2478cdf0e10cSrcweir if( pView && pView->IsSolidDragging() ) 2479cdf0e10cSrcweir { 2480cdf0e10cSrcweir InvalidateRenderGeometry(); 2481cdf0e10cSrcweir } 2482cdf0e10cSrcweir DragCreateObject( rStat ); 2483cdf0e10cSrcweir SetRectsDirty(); 2484cdf0e10cSrcweir return sal_True; 2485cdf0e10cSrcweir } 2486cdf0e10cSrcweir 2487cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd ) 2488cdf0e10cSrcweir { 2489cdf0e10cSrcweir DragCreateObject( rStat ); 2490cdf0e10cSrcweir 2491cdf0e10cSrcweir if ( bTextFrame ) 2492cdf0e10cSrcweir { 2493cdf0e10cSrcweir if ( IsAutoGrowHeight() ) 2494cdf0e10cSrcweir { 2495cdf0e10cSrcweir // MinTextHeight 2496cdf0e10cSrcweir long nHgt=aRect.GetHeight()-1; 2497cdf0e10cSrcweir if (nHgt==1) nHgt=0; 2498cdf0e10cSrcweir NbcSetMinTextFrameHeight( nHgt ); 2499cdf0e10cSrcweir } 2500cdf0e10cSrcweir if ( IsAutoGrowWidth() ) 2501cdf0e10cSrcweir { 2502cdf0e10cSrcweir // MinTextWidth 2503cdf0e10cSrcweir long nWdt=aRect.GetWidth()-1; 2504cdf0e10cSrcweir if (nWdt==1) nWdt=0; 2505cdf0e10cSrcweir NbcSetMinTextFrameWidth( nWdt ); 2506cdf0e10cSrcweir } 2507cdf0e10cSrcweir // Textrahmen neu berechnen 2508cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight(); 2509cdf0e10cSrcweir } 2510cdf0e10cSrcweir SetRectsDirty(); 2511cdf0e10cSrcweir return ( eCmd == SDRCREATE_FORCEEND || rStat.GetPointAnz() >= 2 ); 2512cdf0e10cSrcweir } 2513cdf0e10cSrcweir 2514cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const 2515cdf0e10cSrcweir { 2516cdf0e10cSrcweir return GetLineGeometry( this, sal_False ); 2517cdf0e10cSrcweir } 2518cdf0e10cSrcweir 2519cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2520cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2521cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 2522cdf0e10cSrcweir 2523cdf0e10cSrcweir // in context with the SdrObjCustomShape the SdrTextAutoGrowHeightItem == true -> Resize Shape to fit text, 2524cdf0e10cSrcweir // the SdrTextAutoGrowWidthItem == true -> Word wrap text in Shape 2525cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::IsAutoGrowHeight() const 2526cdf0e10cSrcweir { 2527cdf0e10cSrcweir const SfxItemSet& rSet = GetMergedItemSet(); 2528cdf0e10cSrcweir FASTBOOL bIsAutoGrowHeight = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue(); 2529cdf0e10cSrcweir if ( bIsAutoGrowHeight && IsVerticalWriting() ) 2530cdf0e10cSrcweir bIsAutoGrowHeight = ((SdrTextWordWrapItem&)(rSet.Get(SDRATTR_TEXT_WORDWRAP))).GetValue() == sal_False; 2531cdf0e10cSrcweir return bIsAutoGrowHeight; 2532cdf0e10cSrcweir } 2533cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::IsAutoGrowWidth() const 2534cdf0e10cSrcweir { 2535cdf0e10cSrcweir const SfxItemSet& rSet = GetMergedItemSet(); 2536cdf0e10cSrcweir FASTBOOL bIsAutoGrowWidth = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue(); 2537cdf0e10cSrcweir if ( bIsAutoGrowWidth && !IsVerticalWriting() ) 2538cdf0e10cSrcweir bIsAutoGrowWidth = ((SdrTextWordWrapItem&)(rSet.Get(SDRATTR_TEXT_WORDWRAP))).GetValue() == sal_False; 2539cdf0e10cSrcweir return bIsAutoGrowWidth; 2540cdf0e10cSrcweir } 2541cdf0e10cSrcweir 2542cdf0e10cSrcweir /* The following method is identical to the SdrTextObj::SetVerticalWriting method, the only difference 2543cdf0e10cSrcweir is that the SdrAutoGrowWidthItem and SdrAutoGrowHeightItem are not exchanged if the vertical writing 2544cdf0e10cSrcweir mode has been changed */ 2545cdf0e10cSrcweir 2546cdf0e10cSrcweir void SdrObjCustomShape::SetVerticalWriting( sal_Bool bVertical ) 2547cdf0e10cSrcweir { 2548cdf0e10cSrcweir ForceOutlinerParaObject(); 2549cdf0e10cSrcweir 2550cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 2551cdf0e10cSrcweir 2552cdf0e10cSrcweir DBG_ASSERT( pOutlinerParaObject, "SdrTextObj::SetVerticalWriting() without OutlinerParaObject!" ); 2553cdf0e10cSrcweir 2554cdf0e10cSrcweir if( pOutlinerParaObject ) 2555cdf0e10cSrcweir { 2556cdf0e10cSrcweir if(pOutlinerParaObject->IsVertical() != (bool)bVertical) 2557cdf0e10cSrcweir { 2558cdf0e10cSrcweir // get item settings 2559cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet(); 2560cdf0e10cSrcweir 2561cdf0e10cSrcweir // #103516# Also exchange hor/ver adjust items 2562cdf0e10cSrcweir SdrTextHorzAdjust eHorz = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue(); 2563cdf0e10cSrcweir SdrTextVertAdjust eVert = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue(); 2564cdf0e10cSrcweir 2565cdf0e10cSrcweir // rescue object size 2566cdf0e10cSrcweir Rectangle aObjectRect = GetSnapRect(); 2567cdf0e10cSrcweir 2568cdf0e10cSrcweir // prepare ItemSet to set exchanged width and height items 2569cdf0e10cSrcweir SfxItemSet aNewSet(*rSet.GetPool(), 2570cdf0e10cSrcweir SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, 2571cdf0e10cSrcweir // #103516# Expanded item ranges to also support hor and ver adjust. 2572cdf0e10cSrcweir SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST, 2573cdf0e10cSrcweir SDRATTR_TEXT_AUTOGROWWIDTH, SDRATTR_TEXT_HORZADJUST, 2574cdf0e10cSrcweir 0, 0); 2575cdf0e10cSrcweir 2576cdf0e10cSrcweir aNewSet.Put(rSet); 2577cdf0e10cSrcweir 2578cdf0e10cSrcweir // #103516# Exchange horz and vert adjusts 2579cdf0e10cSrcweir switch(eVert) 2580cdf0e10cSrcweir { 2581cdf0e10cSrcweir case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break; 2582cdf0e10cSrcweir case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break; 2583cdf0e10cSrcweir case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break; 2584cdf0e10cSrcweir case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break; 2585cdf0e10cSrcweir } 2586cdf0e10cSrcweir switch(eHorz) 2587cdf0e10cSrcweir { 2588cdf0e10cSrcweir case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break; 2589cdf0e10cSrcweir case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break; 2590cdf0e10cSrcweir case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break; 2591cdf0e10cSrcweir case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break; 2592cdf0e10cSrcweir } 2593cdf0e10cSrcweir 2594cdf0e10cSrcweir SetObjectItemSet( aNewSet ); 2595cdf0e10cSrcweir pOutlinerParaObject = GetOutlinerParaObject(); 2596cdf0e10cSrcweir if ( pOutlinerParaObject ) 2597cdf0e10cSrcweir pOutlinerParaObject->SetVertical(bVertical); 2598cdf0e10cSrcweir 2599cdf0e10cSrcweir // restore object size 2600cdf0e10cSrcweir SetSnapRect(aObjectRect); 2601cdf0e10cSrcweir } 2602cdf0e10cSrcweir } 2603cdf0e10cSrcweir } 2604cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, FASTBOOL bHgt, FASTBOOL bWdt) const 2605cdf0e10cSrcweir { 2606cdf0e10cSrcweir if ( pModel && HasText() && !rR.IsEmpty() ) 2607cdf0e10cSrcweir { 2608cdf0e10cSrcweir FASTBOOL bWdtGrow=bWdt && IsAutoGrowWidth(); 2609cdf0e10cSrcweir FASTBOOL bHgtGrow=bHgt && IsAutoGrowHeight(); 2610cdf0e10cSrcweir if ( bWdtGrow || bHgtGrow ) 2611cdf0e10cSrcweir { 2612cdf0e10cSrcweir Rectangle aR0(rR); 2613cdf0e10cSrcweir long nHgt=0,nMinHgt=0,nMaxHgt=0; 2614cdf0e10cSrcweir long nWdt=0,nMinWdt=0,nMaxWdt=0; 2615cdf0e10cSrcweir Size aSiz(rR.GetSize()); aSiz.Width()--; aSiz.Height()--; 2616cdf0e10cSrcweir Size aMaxSiz(100000,100000); 2617cdf0e10cSrcweir Size aTmpSiz(pModel->GetMaxObjSize()); 2618cdf0e10cSrcweir if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width(); 2619cdf0e10cSrcweir if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height(); 2620cdf0e10cSrcweir if (bWdtGrow) 2621cdf0e10cSrcweir { 2622cdf0e10cSrcweir nMinWdt=GetMinTextFrameWidth(); 2623cdf0e10cSrcweir nMaxWdt=GetMaxTextFrameWidth(); 2624cdf0e10cSrcweir if (nMaxWdt==0 || nMaxWdt>aMaxSiz.Width()) nMaxWdt=aMaxSiz.Width(); 2625cdf0e10cSrcweir if (nMinWdt<=0) nMinWdt=1; 2626cdf0e10cSrcweir aSiz.Width()=nMaxWdt; 2627cdf0e10cSrcweir } 2628cdf0e10cSrcweir if (bHgtGrow) 2629cdf0e10cSrcweir { 2630cdf0e10cSrcweir nMinHgt=GetMinTextFrameHeight(); 2631cdf0e10cSrcweir nMaxHgt=GetMaxTextFrameHeight(); 2632cdf0e10cSrcweir if (nMaxHgt==0 || nMaxHgt>aMaxSiz.Height()) nMaxHgt=aMaxSiz.Height(); 2633cdf0e10cSrcweir if (nMinHgt<=0) nMinHgt=1; 2634cdf0e10cSrcweir aSiz.Height()=nMaxHgt; 2635cdf0e10cSrcweir } 2636cdf0e10cSrcweir long nHDist=GetTextLeftDistance()+GetTextRightDistance(); 2637cdf0e10cSrcweir long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); 2638cdf0e10cSrcweir aSiz.Width()-=nHDist; 2639cdf0e10cSrcweir aSiz.Height()-=nVDist; 2640cdf0e10cSrcweir if ( aSiz.Width() < 2 ) 2641cdf0e10cSrcweir aSiz.Width() = 2; // Mindestgroesse 2 2642cdf0e10cSrcweir if ( aSiz.Height() < 2 ) 2643cdf0e10cSrcweir aSiz.Height() = 2; // Mindestgroesse 2 2644cdf0e10cSrcweir 2645cdf0e10cSrcweir if(pEdtOutl) 2646cdf0e10cSrcweir { 2647cdf0e10cSrcweir pEdtOutl->SetMaxAutoPaperSize( aSiz ); 2648cdf0e10cSrcweir if (bWdtGrow) 2649cdf0e10cSrcweir { 2650cdf0e10cSrcweir Size aSiz2(pEdtOutl->CalcTextSize()); 2651cdf0e10cSrcweir nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz 2652cdf0e10cSrcweir if (bHgtGrow) nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz 2653cdf0e10cSrcweir } else 2654cdf0e10cSrcweir { 2655cdf0e10cSrcweir nHgt=pEdtOutl->GetTextHeight()+1; // lieber etwas Tolleranz 2656cdf0e10cSrcweir } 2657cdf0e10cSrcweir } 2658cdf0e10cSrcweir else 2659cdf0e10cSrcweir { 2660cdf0e10cSrcweir Outliner& rOutliner=ImpGetDrawOutliner(); 2661cdf0e10cSrcweir rOutliner.SetPaperSize(aSiz); 2662cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True); 2663cdf0e10cSrcweir // !!! hier sollte ich wohl auch noch mal die Optimierung mit 2664cdf0e10cSrcweir // bPortionInfoChecked usw einbauen 2665cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 2666cdf0e10cSrcweir if( pOutlinerParaObject != NULL ) 2667cdf0e10cSrcweir { 2668cdf0e10cSrcweir rOutliner.SetText(*pOutlinerParaObject); 2669cdf0e10cSrcweir rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue()); 2670cdf0e10cSrcweir } 2671cdf0e10cSrcweir if ( bWdtGrow ) 2672cdf0e10cSrcweir { 2673cdf0e10cSrcweir Size aSiz2(rOutliner.CalcTextSize()); 2674cdf0e10cSrcweir nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz 2675cdf0e10cSrcweir if ( bHgtGrow ) 2676cdf0e10cSrcweir nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz 2677cdf0e10cSrcweir } 2678cdf0e10cSrcweir else 2679cdf0e10cSrcweir nHgt = rOutliner.GetTextHeight()+1; // lieber etwas Tolleranz 2680cdf0e10cSrcweir rOutliner.Clear(); 2681cdf0e10cSrcweir } 2682cdf0e10cSrcweir if ( nWdt < nMinWdt ) 2683cdf0e10cSrcweir nWdt = nMinWdt; 2684cdf0e10cSrcweir if ( nWdt > nMaxWdt ) 2685cdf0e10cSrcweir nWdt = nMaxWdt; 2686cdf0e10cSrcweir nWdt += nHDist; 2687cdf0e10cSrcweir if ( nWdt < 1 ) 2688cdf0e10cSrcweir nWdt = 1; // nHDist kann auch negativ sein 2689cdf0e10cSrcweir if ( nHgt < nMinHgt ) 2690cdf0e10cSrcweir nHgt = nMinHgt; 2691cdf0e10cSrcweir if ( nHgt > nMaxHgt ) 2692cdf0e10cSrcweir nHgt = nMaxHgt; 2693cdf0e10cSrcweir nHgt+=nVDist; 2694cdf0e10cSrcweir if ( nHgt < 1 ) 2695cdf0e10cSrcweir nHgt = 1; // nVDist kann auch negativ sein 2696cdf0e10cSrcweir long nWdtGrow = nWdt-(rR.Right()-rR.Left()); 2697cdf0e10cSrcweir long nHgtGrow = nHgt-(rR.Bottom()-rR.Top()); 2698cdf0e10cSrcweir if ( nWdtGrow == 0 ) 2699cdf0e10cSrcweir bWdtGrow = sal_False; 2700cdf0e10cSrcweir if ( nHgtGrow == 0 ) 2701cdf0e10cSrcweir bHgtGrow=sal_False; 2702cdf0e10cSrcweir if ( bWdtGrow || bHgtGrow ) 2703cdf0e10cSrcweir { 2704cdf0e10cSrcweir if ( bWdtGrow ) 2705cdf0e10cSrcweir { 2706cdf0e10cSrcweir SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust(); 2707cdf0e10cSrcweir if ( eHAdj == SDRTEXTHORZADJUST_LEFT ) 2708cdf0e10cSrcweir rR.Right()+=nWdtGrow; 2709cdf0e10cSrcweir else if ( eHAdj == SDRTEXTHORZADJUST_RIGHT ) 2710cdf0e10cSrcweir rR.Left()-=nWdtGrow; 2711cdf0e10cSrcweir else 2712cdf0e10cSrcweir { 2713cdf0e10cSrcweir long nWdtGrow2=nWdtGrow/2; 2714cdf0e10cSrcweir rR.Left()-=nWdtGrow2; 2715cdf0e10cSrcweir rR.Right()=rR.Left()+nWdt; 2716cdf0e10cSrcweir } 2717cdf0e10cSrcweir } 2718cdf0e10cSrcweir if ( bHgtGrow ) 2719cdf0e10cSrcweir { 2720cdf0e10cSrcweir SdrTextVertAdjust eVAdj=GetTextVerticalAdjust(); 2721cdf0e10cSrcweir if ( eVAdj == SDRTEXTVERTADJUST_TOP ) 2722cdf0e10cSrcweir rR.Bottom()+=nHgtGrow; 2723cdf0e10cSrcweir else if ( eVAdj == SDRTEXTVERTADJUST_BOTTOM ) 2724cdf0e10cSrcweir rR.Top()-=nHgtGrow; 2725cdf0e10cSrcweir else 2726cdf0e10cSrcweir { 2727cdf0e10cSrcweir long nHgtGrow2=nHgtGrow/2; 2728cdf0e10cSrcweir rR.Top()-=nHgtGrow2; 2729cdf0e10cSrcweir rR.Bottom()=rR.Top()+nHgt; 2730cdf0e10cSrcweir } 2731cdf0e10cSrcweir } 2732cdf0e10cSrcweir if ( aGeo.nDrehWink ) 2733cdf0e10cSrcweir { 2734cdf0e10cSrcweir Point aD1(rR.TopLeft()); 2735cdf0e10cSrcweir aD1-=aR0.TopLeft(); 2736cdf0e10cSrcweir Point aD2(aD1); 2737cdf0e10cSrcweir RotatePoint(aD2,Point(),aGeo.nSin,aGeo.nCos); 2738cdf0e10cSrcweir aD2-=aD1; 2739cdf0e10cSrcweir rR.Move(aD2.X(),aD2.Y()); 2740cdf0e10cSrcweir } 2741cdf0e10cSrcweir return sal_True; 2742cdf0e10cSrcweir } 2743cdf0e10cSrcweir } 2744cdf0e10cSrcweir } 2745cdf0e10cSrcweir return sal_False; 2746cdf0e10cSrcweir } 2747cdf0e10cSrcweir 2748cdf0e10cSrcweir Rectangle SdrObjCustomShape::ImpCalculateTextFrame( const FASTBOOL bHgt, const FASTBOOL bWdt ) 2749cdf0e10cSrcweir { 2750cdf0e10cSrcweir Rectangle aReturnValue; 2751cdf0e10cSrcweir 2752cdf0e10cSrcweir Rectangle aOldTextRect( aRect ); // <- initial text rectangle 2753cdf0e10cSrcweir 2754cdf0e10cSrcweir Rectangle aNewTextRect( aRect ); // <- new text rectangle returned from the custom shape renderer, 2755cdf0e10cSrcweir GetTextBounds( aNewTextRect ); // it depends to the current logical shape size 2756cdf0e10cSrcweir 2757cdf0e10cSrcweir Rectangle aAdjustedTextRect( aNewTextRect ); // <- new text rectangle is being tested by AdjustTextFrameWidthAndHeight to ensure 2758cdf0e10cSrcweir if ( AdjustTextFrameWidthAndHeight( aAdjustedTextRect, bHgt, bWdt ) ) // that the new text rectangle is matching the current text size from the outliner 2759cdf0e10cSrcweir { 2760cdf0e10cSrcweir if ( ( aAdjustedTextRect != aNewTextRect ) && ( aOldTextRect != aAdjustedTextRect ) ) 2761cdf0e10cSrcweir { 2762cdf0e10cSrcweir aReturnValue = aRect; 2763cdf0e10cSrcweir double fXScale = (double)aOldTextRect.GetWidth() / (double)aNewTextRect.GetWidth(); 2764cdf0e10cSrcweir double fYScale = (double)aOldTextRect.GetHeight() / (double)aNewTextRect.GetHeight(); 2765cdf0e10cSrcweir double fRightDiff = (double)( aAdjustedTextRect.Right() - aNewTextRect.Right() ) * fXScale; 2766cdf0e10cSrcweir double fLeftDiff = (double)( aAdjustedTextRect.Left() - aNewTextRect.Left() ) * fXScale; 2767cdf0e10cSrcweir double fTopDiff = (double)( aAdjustedTextRect.Top() - aNewTextRect.Top() ) * fYScale; 2768cdf0e10cSrcweir double fBottomDiff= (double)( aAdjustedTextRect.Bottom()- aNewTextRect.Bottom()) * fYScale; 2769cdf0e10cSrcweir aReturnValue.Left() += (sal_Int32)fLeftDiff; 2770cdf0e10cSrcweir aReturnValue.Right() += (sal_Int32)fRightDiff; 2771cdf0e10cSrcweir aReturnValue.Top() += (sal_Int32)fTopDiff; 2772cdf0e10cSrcweir aReturnValue.Bottom() += (sal_Int32)fBottomDiff; 2773cdf0e10cSrcweir } 2774cdf0e10cSrcweir } 2775cdf0e10cSrcweir return aReturnValue; 2776cdf0e10cSrcweir } 2777cdf0e10cSrcweir 2778cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt) 2779cdf0e10cSrcweir { 2780cdf0e10cSrcweir Rectangle aNewTextRect = ImpCalculateTextFrame( bHgt, bWdt ); 2781cdf0e10cSrcweir sal_Bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != aRect ); 2782cdf0e10cSrcweir if ( bRet ) 2783cdf0e10cSrcweir { 2784cdf0e10cSrcweir // taking care of handles that should not been changed 2785cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) ); 2786cdf0e10cSrcweir 2787cdf0e10cSrcweir aRect = aNewTextRect; 2788cdf0e10cSrcweir SetRectsDirty(); 2789cdf0e10cSrcweir SetChanged(); 2790cdf0e10cSrcweir 2791cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() ); 2792cdf0e10cSrcweir while ( aIter != aInteractionHandles.end() ) 2793cdf0e10cSrcweir { 2794cdf0e10cSrcweir try 2795cdf0e10cSrcweir { 2796cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED ) 2797cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( aIter->aPosition ); 2798cdf0e10cSrcweir } 2799cdf0e10cSrcweir catch ( const uno::RuntimeException& ) 2800cdf0e10cSrcweir { 2801cdf0e10cSrcweir } 2802cdf0e10cSrcweir aIter++; 2803cdf0e10cSrcweir } 2804cdf0e10cSrcweir InvalidateRenderGeometry(); 2805cdf0e10cSrcweir } 2806cdf0e10cSrcweir return bRet; 2807cdf0e10cSrcweir } 2808cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::AdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt) 2809cdf0e10cSrcweir { 2810cdf0e10cSrcweir Rectangle aNewTextRect = ImpCalculateTextFrame( bHgt, bWdt ); 2811cdf0e10cSrcweir sal_Bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != aRect ); 2812cdf0e10cSrcweir if ( bRet ) 2813cdf0e10cSrcweir { 2814cdf0e10cSrcweir Rectangle aBoundRect0; 2815cdf0e10cSrcweir if ( pUserCall ) 2816cdf0e10cSrcweir aBoundRect0 = GetCurrentBoundRect(); 2817cdf0e10cSrcweir 2818cdf0e10cSrcweir // taking care of handles that should not been changed 2819cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) ); 2820cdf0e10cSrcweir 2821cdf0e10cSrcweir // SendRepaintBroadcast(); 2822cdf0e10cSrcweir aRect = aNewTextRect; 2823cdf0e10cSrcweir SetRectsDirty(); 2824cdf0e10cSrcweir 2825cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() ); 2826cdf0e10cSrcweir while ( aIter != aInteractionHandles.end() ) 2827cdf0e10cSrcweir { 2828cdf0e10cSrcweir try 2829cdf0e10cSrcweir { 2830cdf0e10cSrcweir if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED ) 2831cdf0e10cSrcweir aIter->xInteraction->setControllerPosition( aIter->aPosition ); 2832cdf0e10cSrcweir } 2833cdf0e10cSrcweir catch ( const uno::RuntimeException& ) 2834cdf0e10cSrcweir { 2835cdf0e10cSrcweir } 2836cdf0e10cSrcweir aIter++; 2837cdf0e10cSrcweir } 2838cdf0e10cSrcweir 2839cdf0e10cSrcweir InvalidateRenderGeometry(); 2840cdf0e10cSrcweir SetChanged(); 2841cdf0e10cSrcweir // SendRepaintBroadcast(); 2842cdf0e10cSrcweir BroadcastObjectChange(); 2843cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 2844cdf0e10cSrcweir } 2845cdf0e10cSrcweir return bRet; 2846cdf0e10cSrcweir } 2847cdf0e10cSrcweir sal_Bool SdrObjCustomShape::BegTextEdit( SdrOutliner& rOutl ) 2848cdf0e10cSrcweir { 2849cdf0e10cSrcweir return SdrTextObj::BegTextEdit( rOutl ); 2850cdf0e10cSrcweir } 2851cdf0e10cSrcweir void SdrObjCustomShape::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const 2852cdf0e10cSrcweir { 2853cdf0e10cSrcweir Size aPaperMin,aPaperMax; 2854cdf0e10cSrcweir Rectangle aViewInit; 2855cdf0e10cSrcweir TakeTextAnchorRect( aViewInit ); 2856cdf0e10cSrcweir if ( aGeo.nDrehWink ) 2857cdf0e10cSrcweir { 2858cdf0e10cSrcweir Point aCenter(aViewInit.Center()); 2859cdf0e10cSrcweir aCenter-=aViewInit.TopLeft(); 2860cdf0e10cSrcweir Point aCenter0(aCenter); 2861cdf0e10cSrcweir RotatePoint(aCenter,Point(),aGeo.nSin,aGeo.nCos); 2862cdf0e10cSrcweir aCenter-=aCenter0; 2863cdf0e10cSrcweir aViewInit.Move(aCenter.X(),aCenter.Y()); 2864cdf0e10cSrcweir } 2865cdf0e10cSrcweir Size aAnkSiz(aViewInit.GetSize()); 2866cdf0e10cSrcweir aAnkSiz.Width()--; aAnkSiz.Height()--; // weil GetSize() ein draufaddiert 2867cdf0e10cSrcweir Size aMaxSiz(1000000,1000000); 2868cdf0e10cSrcweir if (pModel!=NULL) { 2869cdf0e10cSrcweir Size aTmpSiz(pModel->GetMaxObjSize()); 2870cdf0e10cSrcweir if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width(); 2871cdf0e10cSrcweir if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height(); 2872cdf0e10cSrcweir } 2873cdf0e10cSrcweir SdrTextHorzAdjust eHAdj(GetTextHorizontalAdjust()); 2874cdf0e10cSrcweir SdrTextVertAdjust eVAdj(GetTextVerticalAdjust()); 2875cdf0e10cSrcweir 2876cdf0e10cSrcweir long nMinWdt = GetMinTextFrameWidth(); 2877cdf0e10cSrcweir long nMinHgt = GetMinTextFrameHeight(); 2878cdf0e10cSrcweir long nMaxWdt = GetMaxTextFrameWidth(); 2879cdf0e10cSrcweir long nMaxHgt = GetMaxTextFrameHeight(); 2880cdf0e10cSrcweir if (nMinWdt<1) nMinWdt=1; 2881cdf0e10cSrcweir if (nMinHgt<1) nMinHgt=1; 2882cdf0e10cSrcweir if ( nMaxWdt == 0 || nMaxWdt > aMaxSiz.Width() ) 2883cdf0e10cSrcweir nMaxWdt = aMaxSiz.Width(); 2884cdf0e10cSrcweir if ( nMaxHgt == 0 || nMaxHgt > aMaxSiz.Height() ) 2885cdf0e10cSrcweir nMaxHgt=aMaxSiz.Height(); 2886cdf0e10cSrcweir 2887cdf0e10cSrcweir if (((SdrTextWordWrapItem&)(GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue()) 2888cdf0e10cSrcweir { 2889cdf0e10cSrcweir if ( IsVerticalWriting() ) 2890cdf0e10cSrcweir { 2891cdf0e10cSrcweir nMaxHgt = aAnkSiz.Height(); 2892cdf0e10cSrcweir nMinHgt = nMaxHgt; 2893cdf0e10cSrcweir } 2894cdf0e10cSrcweir else 2895cdf0e10cSrcweir { 2896cdf0e10cSrcweir nMaxWdt = aAnkSiz.Width(); 2897cdf0e10cSrcweir nMinWdt = nMaxWdt; 2898cdf0e10cSrcweir } 2899cdf0e10cSrcweir } 2900cdf0e10cSrcweir aPaperMax.Width()=nMaxWdt; 2901cdf0e10cSrcweir aPaperMax.Height()=nMaxHgt; 2902cdf0e10cSrcweir 2903cdf0e10cSrcweir aPaperMin.Width()=nMinWdt; 2904cdf0e10cSrcweir aPaperMin.Height()=nMinHgt; 2905cdf0e10cSrcweir 2906cdf0e10cSrcweir if ( pViewMin ) 2907cdf0e10cSrcweir { 2908cdf0e10cSrcweir *pViewMin = aViewInit; 2909cdf0e10cSrcweir 2910cdf0e10cSrcweir long nXFree = aAnkSiz.Width() - aPaperMin.Width(); 2911cdf0e10cSrcweir if ( eHAdj == SDRTEXTHORZADJUST_LEFT ) 2912cdf0e10cSrcweir pViewMin->Right() -= nXFree; 2913cdf0e10cSrcweir else if ( eHAdj == SDRTEXTHORZADJUST_RIGHT ) 2914cdf0e10cSrcweir pViewMin->Left() += nXFree; 2915cdf0e10cSrcweir else { pViewMin->Left() += nXFree / 2; pViewMin->Right() = pViewMin->Left() + aPaperMin.Width(); } 2916cdf0e10cSrcweir 2917cdf0e10cSrcweir long nYFree = aAnkSiz.Height() - aPaperMin.Height(); 2918cdf0e10cSrcweir if ( eVAdj == SDRTEXTVERTADJUST_TOP ) 2919cdf0e10cSrcweir pViewMin->Bottom() -= nYFree; 2920cdf0e10cSrcweir else if ( eVAdj == SDRTEXTVERTADJUST_BOTTOM ) 2921cdf0e10cSrcweir pViewMin->Top() += nYFree; 2922cdf0e10cSrcweir else { pViewMin->Top() += nYFree / 2; pViewMin->Bottom() = pViewMin->Top() + aPaperMin.Height(); } 2923cdf0e10cSrcweir } 2924cdf0e10cSrcweir 2925cdf0e10cSrcweir if( IsVerticalWriting() ) 2926cdf0e10cSrcweir aPaperMin.Width() = 0; 2927cdf0e10cSrcweir else 2928cdf0e10cSrcweir aPaperMin.Height() = 0; // #33102# 2929cdf0e10cSrcweir 2930cdf0e10cSrcweir if( eHAdj != SDRTEXTHORZADJUST_BLOCK ) 2931cdf0e10cSrcweir aPaperMin.Width()=0; 2932cdf0e10cSrcweir 2933cdf0e10cSrcweir // #103516# For complete ver adjust support, set paper min height to 0, here. 2934cdf0e10cSrcweir if(SDRTEXTVERTADJUST_BLOCK != eVAdj ) 2935cdf0e10cSrcweir aPaperMin.Height() = 0; 2936cdf0e10cSrcweir 2937cdf0e10cSrcweir if (pPaperMin!=NULL) *pPaperMin=aPaperMin; 2938cdf0e10cSrcweir if (pPaperMax!=NULL) *pPaperMax=aPaperMax; 2939cdf0e10cSrcweir if (pViewInit!=NULL) *pViewInit=aViewInit; 2940cdf0e10cSrcweir } 2941cdf0e10cSrcweir void SdrObjCustomShape::EndTextEdit( SdrOutliner& rOutl ) 2942cdf0e10cSrcweir { 2943cdf0e10cSrcweir SdrTextObj::EndTextEdit( rOutl ); 2944cdf0e10cSrcweir InvalidateRenderGeometry(); 2945cdf0e10cSrcweir } 2946cdf0e10cSrcweir void SdrObjCustomShape::TakeTextAnchorRect( Rectangle& rAnchorRect ) const 2947cdf0e10cSrcweir { 2948cdf0e10cSrcweir if ( GetTextBounds( rAnchorRect ) ) 2949cdf0e10cSrcweir { 2950cdf0e10cSrcweir Point aRotateRef( maSnapRect.Center() ); 2951cdf0e10cSrcweir rAnchorRect.Left() += GetTextLeftDistance(); 2952cdf0e10cSrcweir rAnchorRect.Top() += GetTextUpperDistance(); 2953cdf0e10cSrcweir rAnchorRect.Right() -= GetTextRightDistance(); 2954cdf0e10cSrcweir rAnchorRect.Bottom() -= GetTextLowerDistance(); 2955cdf0e10cSrcweir ImpJustifyRect( rAnchorRect ); 2956cdf0e10cSrcweir 2957cdf0e10cSrcweir if ( rAnchorRect.GetWidth() < 2 ) 2958cdf0e10cSrcweir rAnchorRect.Right() = rAnchorRect.Left() + 1; // minimal width is 2 2959cdf0e10cSrcweir if ( rAnchorRect.GetHeight() < 2 ) 2960cdf0e10cSrcweir rAnchorRect.Bottom() = rAnchorRect.Top() + 1; // minimal height is 2 2961cdf0e10cSrcweir if ( aGeo.nDrehWink ) 2962cdf0e10cSrcweir { 2963cdf0e10cSrcweir Point aP( rAnchorRect.TopLeft() ); 2964cdf0e10cSrcweir RotatePoint( aP, aRotateRef, aGeo.nSin, aGeo. nCos ); 2965cdf0e10cSrcweir rAnchorRect.SetPos( aP ); 2966cdf0e10cSrcweir } 2967cdf0e10cSrcweir } 2968cdf0e10cSrcweir else 2969cdf0e10cSrcweir SdrTextObj::TakeTextAnchorRect( rAnchorRect ); 2970cdf0e10cSrcweir } 2971cdf0e10cSrcweir void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText, 2972cdf0e10cSrcweir Rectangle* pAnchorRect, sal_Bool /*bLineWidth*/) const 2973cdf0e10cSrcweir { 2974cdf0e10cSrcweir Rectangle aAnkRect; // Rect innerhalb dem geankert wird 2975cdf0e10cSrcweir TakeTextAnchorRect(aAnkRect); 2976cdf0e10cSrcweir SdrTextVertAdjust eVAdj=GetTextVerticalAdjust(); 2977cdf0e10cSrcweir SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust(); 2978cdf0e10cSrcweir sal_uIntPtr nStat0=rOutliner.GetControlWord(); 2979cdf0e10cSrcweir Size aNullSize; 2980cdf0e10cSrcweir 2981cdf0e10cSrcweir rOutliner.SetControlWord(nStat0|EE_CNTRL_AUTOPAGESIZE); 2982cdf0e10cSrcweir rOutliner.SetMinAutoPaperSize(aNullSize); 2983cdf0e10cSrcweir sal_Int32 nMaxAutoPaperWidth = 1000000; 2984cdf0e10cSrcweir sal_Int32 nMaxAutoPaperHeight= 1000000; 2985cdf0e10cSrcweir 2986cdf0e10cSrcweir long nAnkWdt=aAnkRect.GetWidth(); 2987cdf0e10cSrcweir long nAnkHgt=aAnkRect.GetHeight(); 2988cdf0e10cSrcweir 2989cdf0e10cSrcweir if (((SdrTextWordWrapItem&)(GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue()) 2990cdf0e10cSrcweir { 2991cdf0e10cSrcweir if ( IsVerticalWriting() ) 2992cdf0e10cSrcweir nMaxAutoPaperHeight = nAnkHgt; 2993cdf0e10cSrcweir else 2994cdf0e10cSrcweir nMaxAutoPaperWidth = nAnkWdt; 2995cdf0e10cSrcweir } 2996cdf0e10cSrcweir if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting()) 2997cdf0e10cSrcweir { 2998cdf0e10cSrcweir rOutliner.SetMinAutoPaperSize(Size(nAnkWdt, 0)); 2999cdf0e10cSrcweir } 3000cdf0e10cSrcweir 3001cdf0e10cSrcweir if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting()) 3002cdf0e10cSrcweir { 3003cdf0e10cSrcweir rOutliner.SetMinAutoPaperSize(Size(0, nAnkHgt)); 3004cdf0e10cSrcweir } 3005cdf0e10cSrcweir rOutliner.SetMaxAutoPaperSize( Size( nMaxAutoPaperWidth, nMaxAutoPaperHeight ) ); 3006cdf0e10cSrcweir rOutliner.SetPaperSize( aNullSize ); 3007cdf0e10cSrcweir 3008cdf0e10cSrcweir // Text in den Outliner stecken - ggf. den aus dem EditOutliner 3009cdf0e10cSrcweir OutlinerParaObject* pPara= GetOutlinerParaObject(); 3010cdf0e10cSrcweir if (pEdtOutl && !bNoEditText) 3011cdf0e10cSrcweir pPara=pEdtOutl->CreateParaObject(); 3012cdf0e10cSrcweir 3013cdf0e10cSrcweir if (pPara) 3014cdf0e10cSrcweir { 3015cdf0e10cSrcweir sal_Bool bHitTest = sal_False; 3016cdf0e10cSrcweir if( pModel ) 3017cdf0e10cSrcweir bHitTest = &pModel->GetHitTestOutliner() == &rOutliner; 3018cdf0e10cSrcweir 3019cdf0e10cSrcweir const SdrTextObj* pTestObj = rOutliner.GetTextObj(); 3020cdf0e10cSrcweir if( !pTestObj || !bHitTest || pTestObj != this || 3021cdf0e10cSrcweir pTestObj->GetOutlinerParaObject() != GetOutlinerParaObject() ) 3022cdf0e10cSrcweir { 3023cdf0e10cSrcweir if( bHitTest ) 3024cdf0e10cSrcweir rOutliner.SetTextObj( this ); 3025cdf0e10cSrcweir 3026cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True); 3027cdf0e10cSrcweir rOutliner.SetText(*pPara); 3028cdf0e10cSrcweir } 3029cdf0e10cSrcweir } 3030cdf0e10cSrcweir else 3031cdf0e10cSrcweir { 3032cdf0e10cSrcweir rOutliner.SetTextObj( NULL ); 3033cdf0e10cSrcweir } 3034cdf0e10cSrcweir if (pEdtOutl && !bNoEditText && pPara) 3035cdf0e10cSrcweir delete pPara; 3036cdf0e10cSrcweir 3037cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True); 3038cdf0e10cSrcweir rOutliner.SetControlWord(nStat0); 3039cdf0e10cSrcweir 3040cdf0e10cSrcweir SdrText* pText = getActiveText(); 3041cdf0e10cSrcweir if( pText ) 3042cdf0e10cSrcweir pText->CheckPortionInfo( rOutliner ); 3043cdf0e10cSrcweir 3044cdf0e10cSrcweir Point aTextPos(aAnkRect.TopLeft()); 3045cdf0e10cSrcweir Size aTextSiz(rOutliner.GetPaperSize()); // GetPaperSize() hat etwas Toleranz drauf, oder? 3046cdf0e10cSrcweir 3047cdf0e10cSrcweir // #106653# 3048cdf0e10cSrcweir // For draw objects containing text correct hor/ver alignment if text is bigger 3049cdf0e10cSrcweir // than the object itself. Without that correction, the text would always be 3050cdf0e10cSrcweir // formatted to the left edge (or top edge when vertical) of the draw object. 3051cdf0e10cSrcweir 3052cdf0e10cSrcweir if( !IsTextFrame() ) 3053cdf0e10cSrcweir { 3054cdf0e10cSrcweir if(aAnkRect.GetWidth() < aTextSiz.Width() && !IsVerticalWriting()) 3055cdf0e10cSrcweir { 3056cdf0e10cSrcweir // #110129# 3057cdf0e10cSrcweir // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK, 3058cdf0e10cSrcweir // else the alignment is wanted. 3059cdf0e10cSrcweir if(SDRTEXTHORZADJUST_BLOCK == eHAdj) 3060cdf0e10cSrcweir { 3061cdf0e10cSrcweir eHAdj = SDRTEXTHORZADJUST_CENTER; 3062cdf0e10cSrcweir } 3063cdf0e10cSrcweir } 3064cdf0e10cSrcweir 3065cdf0e10cSrcweir if(aAnkRect.GetHeight() < aTextSiz.Height() && IsVerticalWriting()) 3066cdf0e10cSrcweir { 3067cdf0e10cSrcweir // #110129# 3068cdf0e10cSrcweir // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK, 3069cdf0e10cSrcweir // else the alignment is wanted. 3070cdf0e10cSrcweir if(SDRTEXTVERTADJUST_BLOCK == eVAdj) 3071cdf0e10cSrcweir { 3072cdf0e10cSrcweir eVAdj = SDRTEXTVERTADJUST_CENTER; 3073cdf0e10cSrcweir } 3074cdf0e10cSrcweir } 3075cdf0e10cSrcweir } 3076cdf0e10cSrcweir 3077cdf0e10cSrcweir if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT) 3078cdf0e10cSrcweir { 3079cdf0e10cSrcweir long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width(); 3080cdf0e10cSrcweir if (eHAdj==SDRTEXTHORZADJUST_CENTER) 3081cdf0e10cSrcweir aTextPos.X()+=nFreeWdt/2; 3082cdf0e10cSrcweir if (eHAdj==SDRTEXTHORZADJUST_RIGHT) 3083cdf0e10cSrcweir aTextPos.X()+=nFreeWdt; 3084cdf0e10cSrcweir } 3085cdf0e10cSrcweir if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM) 3086cdf0e10cSrcweir { 3087cdf0e10cSrcweir long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height(); 3088cdf0e10cSrcweir if (eVAdj==SDRTEXTVERTADJUST_CENTER) 3089cdf0e10cSrcweir aTextPos.Y()+=nFreeHgt/2; 3090cdf0e10cSrcweir if (eVAdj==SDRTEXTVERTADJUST_BOTTOM) 3091cdf0e10cSrcweir aTextPos.Y()+=nFreeHgt; 3092cdf0e10cSrcweir } 3093cdf0e10cSrcweir if (aGeo.nDrehWink!=0) 3094cdf0e10cSrcweir RotatePoint(aTextPos,aAnkRect.TopLeft(),aGeo.nSin,aGeo.nCos); 3095cdf0e10cSrcweir 3096cdf0e10cSrcweir if (pAnchorRect) 3097cdf0e10cSrcweir *pAnchorRect=aAnkRect; 3098cdf0e10cSrcweir 3099cdf0e10cSrcweir // rTextRect ist bei ContourFrame in einigen Faellen nicht korrekt 3100cdf0e10cSrcweir rTextRect=Rectangle(aTextPos,aTextSiz); 3101cdf0e10cSrcweir } 3102cdf0e10cSrcweir 3103cdf0e10cSrcweir void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) 3104cdf0e10cSrcweir { 3105cdf0e10cSrcweir SdrTextObj::NbcSetOutlinerParaObject( pTextObject ); 3106cdf0e10cSrcweir SetBoundRectDirty(); 3107cdf0e10cSrcweir SetRectsDirty(sal_True); 3108cdf0e10cSrcweir InvalidateRenderGeometry(); 3109cdf0e10cSrcweir } 3110cdf0e10cSrcweir 3111cdf0e10cSrcweir void SdrObjCustomShape::operator=(const SdrObject& rObj) 3112cdf0e10cSrcweir { 3113cdf0e10cSrcweir SdrTextObj::operator=( rObj ); 3114cdf0e10cSrcweir aName =((SdrObjCustomShape&)rObj).aName; 3115cdf0e10cSrcweir fObjectRotation = ((SdrObjCustomShape&)rObj).fObjectRotation; 3116cdf0e10cSrcweir InvalidateRenderGeometry(); 3117cdf0e10cSrcweir } 3118cdf0e10cSrcweir 3119cdf0e10cSrcweir 3120cdf0e10cSrcweir void SdrObjCustomShape::TakeObjNameSingul(XubString& rName) const 3121cdf0e10cSrcweir { 3122cdf0e10cSrcweir rName = ImpGetResStr(STR_ObjNameSingulCUSTOMSHAPE); 3123cdf0e10cSrcweir String aNm( GetName() ); 3124cdf0e10cSrcweir if( aNm.Len() ) 3125cdf0e10cSrcweir { 3126cdf0e10cSrcweir rName += sal_Unicode(' '); 3127cdf0e10cSrcweir rName += sal_Unicode('\''); 3128cdf0e10cSrcweir rName += aNm; 3129cdf0e10cSrcweir rName += sal_Unicode('\''); 3130cdf0e10cSrcweir } 3131cdf0e10cSrcweir } 3132cdf0e10cSrcweir 3133cdf0e10cSrcweir void SdrObjCustomShape::TakeObjNamePlural(XubString& rName) const 3134cdf0e10cSrcweir { 3135cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNamePluralCUSTOMSHAPE); 3136cdf0e10cSrcweir } 3137cdf0e10cSrcweir 3138cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeXorPoly() const 3139cdf0e10cSrcweir { 3140cdf0e10cSrcweir return GetLineGeometry( (SdrObjCustomShape*)this, sal_False ); 3141cdf0e10cSrcweir } 3142cdf0e10cSrcweir 3143cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeContour() const 3144cdf0e10cSrcweir { 3145cdf0e10cSrcweir const SdrObject* pSdrObject = GetSdrObjectFromCustomShape(); 3146cdf0e10cSrcweir if ( pSdrObject ) 3147cdf0e10cSrcweir return pSdrObject->TakeContour(); 3148cdf0e10cSrcweir return basegfx::B2DPolyPolygon(); 3149cdf0e10cSrcweir } 3150cdf0e10cSrcweir 3151*a5258243SPedro Giffuni SdrObject* SdrObjCustomShape::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const 3152cdf0e10cSrcweir { 3153cdf0e10cSrcweir // #i37011# 3154cdf0e10cSrcweir SdrObject* pRetval = 0L; 3155cdf0e10cSrcweir SdrObject* pRenderedCustomShape = 0L; 3156cdf0e10cSrcweir 3157cdf0e10cSrcweir if ( !mXRenderedCustomShape.is() ) 3158cdf0e10cSrcweir { 3159cdf0e10cSrcweir // force CustomShape 3160cdf0e10cSrcweir ((SdrObjCustomShape*)this)->GetSdrObjectFromCustomShape(); 3161cdf0e10cSrcweir } 3162cdf0e10cSrcweir 3163cdf0e10cSrcweir if ( mXRenderedCustomShape.is() ) 3164cdf0e10cSrcweir { 3165cdf0e10cSrcweir pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape ); 3166cdf0e10cSrcweir } 3167cdf0e10cSrcweir 3168cdf0e10cSrcweir if ( pRenderedCustomShape ) 3169cdf0e10cSrcweir { 3170cdf0e10cSrcweir SdrObject* pCandidate = pRenderedCustomShape->Clone(); 3171cdf0e10cSrcweir DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)"); 3172cdf0e10cSrcweir pCandidate->SetModel(GetModel()); 3173*a5258243SPedro Giffuni pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText); 3174cdf0e10cSrcweir SdrObject::Free( pCandidate ); 3175cdf0e10cSrcweir 3176cdf0e10cSrcweir if(pRetval) 3177cdf0e10cSrcweir { 3178cdf0e10cSrcweir const sal_Bool bShadow(((SdrShadowItem&)GetMergedItem(SDRATTR_SHADOW)).GetValue()); 3179cdf0e10cSrcweir if(bShadow) 3180cdf0e10cSrcweir { 3181cdf0e10cSrcweir pRetval->SetMergedItem(SdrShadowItem(sal_True)); 3182cdf0e10cSrcweir } 3183cdf0e10cSrcweir } 3184cdf0e10cSrcweir 3185*a5258243SPedro Giffuni if(bAddText && HasText() && !IsTextPath()) 3186cdf0e10cSrcweir { 3187cdf0e10cSrcweir pRetval = ImpConvertAddText(pRetval, bBezier); 3188cdf0e10cSrcweir } 3189cdf0e10cSrcweir } 3190cdf0e10cSrcweir 3191cdf0e10cSrcweir return pRetval; 3192cdf0e10cSrcweir } 3193cdf0e10cSrcweir 3194cdf0e10cSrcweir void SdrObjCustomShape::NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr ) 3195cdf0e10cSrcweir { 3196cdf0e10cSrcweir // #i40944# 3197cdf0e10cSrcweir InvalidateRenderGeometry(); 3198cdf0e10cSrcweir SdrObject::NbcSetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr ); 3199cdf0e10cSrcweir } 3200cdf0e10cSrcweir 3201cdf0e10cSrcweir void SdrObjCustomShape::SetPage( SdrPage* pNewPage ) 3202cdf0e10cSrcweir { 3203cdf0e10cSrcweir SdrTextObj::SetPage( pNewPage ); 3204cdf0e10cSrcweir 3205cdf0e10cSrcweir if( pNewPage ) 3206cdf0e10cSrcweir { 3207cdf0e10cSrcweir // invalidating rectangles by SetRectsDirty is not sufficient, 3208cdf0e10cSrcweir // AdjustTextFrameWidthAndHeight() also has to be made, both 3209cdf0e10cSrcweir // actions are done by NbcSetSnapRect 3210cdf0e10cSrcweir Rectangle aTmp( aRect ); //creating temporary rectangle #i61108# 3211cdf0e10cSrcweir NbcSetSnapRect( aTmp ); 3212cdf0e10cSrcweir } 3213cdf0e10cSrcweir } 3214cdf0e10cSrcweir 3215cdf0e10cSrcweir SdrObjGeoData* SdrObjCustomShape::NewGeoData() const 3216cdf0e10cSrcweir { 3217cdf0e10cSrcweir return new SdrAShapeObjGeoData; 3218cdf0e10cSrcweir } 3219cdf0e10cSrcweir 3220cdf0e10cSrcweir void SdrObjCustomShape::SaveGeoData(SdrObjGeoData& rGeo) const 3221cdf0e10cSrcweir { 3222cdf0e10cSrcweir SdrTextObj::SaveGeoData( rGeo ); 3223cdf0e10cSrcweir SdrAShapeObjGeoData& rAGeo=(SdrAShapeObjGeoData&)rGeo; 3224cdf0e10cSrcweir rAGeo.fObjectRotation = fObjectRotation; 3225cdf0e10cSrcweir rAGeo.bMirroredX = IsMirroredX(); 3226cdf0e10cSrcweir rAGeo.bMirroredY = IsMirroredY(); 3227cdf0e10cSrcweir 3228cdf0e10cSrcweir const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) ); 3229cdf0e10cSrcweir Any* pAny( ( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ).GetPropertyValueByName( sAdjustmentValues ) ); 3230cdf0e10cSrcweir if ( pAny ) 3231cdf0e10cSrcweir *pAny >>= rAGeo.aAdjustmentSeq; 3232cdf0e10cSrcweir } 3233cdf0e10cSrcweir 3234cdf0e10cSrcweir void SdrObjCustomShape::RestGeoData(const SdrObjGeoData& rGeo) 3235cdf0e10cSrcweir { 3236cdf0e10cSrcweir SdrTextObj::RestGeoData( rGeo ); 3237cdf0e10cSrcweir SdrAShapeObjGeoData& rAGeo=(SdrAShapeObjGeoData&)rGeo; 3238cdf0e10cSrcweir fObjectRotation = rAGeo.fObjectRotation; 3239cdf0e10cSrcweir SetMirroredX( rAGeo.bMirroredX ); 3240cdf0e10cSrcweir SetMirroredY( rAGeo.bMirroredY ); 3241cdf0e10cSrcweir 3242cdf0e10cSrcweir SdrCustomShapeGeometryItem rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); 3243cdf0e10cSrcweir const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) ); 3244cdf0e10cSrcweir PropertyValue aPropVal; 3245cdf0e10cSrcweir aPropVal.Name = sAdjustmentValues; 3246cdf0e10cSrcweir aPropVal.Value <<= rAGeo.aAdjustmentSeq; 3247cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal ); 3248cdf0e10cSrcweir SetMergedItem( rGeometryItem ); 3249cdf0e10cSrcweir 3250cdf0e10cSrcweir InvalidateRenderGeometry(); 3251cdf0e10cSrcweir } 3252cdf0e10cSrcweir 3253cdf0e10cSrcweir void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/) 3254cdf0e10cSrcweir { 3255cdf0e10cSrcweir // break up matrix 3256cdf0e10cSrcweir basegfx::B2DTuple aScale; 3257cdf0e10cSrcweir basegfx::B2DTuple aTranslate; 3258cdf0e10cSrcweir double fRotate, fShearX; 3259cdf0e10cSrcweir rMatrix.decompose(aScale, aTranslate, fRotate, fShearX); 3260cdf0e10cSrcweir 3261cdf0e10cSrcweir // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings 3262cdf0e10cSrcweir // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly 3263cdf0e10cSrcweir if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0)) 3264cdf0e10cSrcweir { 3265cdf0e10cSrcweir aScale.setX(fabs(aScale.getX())); 3266cdf0e10cSrcweir aScale.setY(fabs(aScale.getY())); 3267cdf0e10cSrcweir fRotate = fmod(fRotate + F_PI, F_2PI); 3268cdf0e10cSrcweir } 3269cdf0e10cSrcweir 3270cdf0e10cSrcweir // reset object shear and rotations 3271cdf0e10cSrcweir aGeo.nDrehWink = 0; 3272cdf0e10cSrcweir aGeo.RecalcSinCos(); 3273cdf0e10cSrcweir aGeo.nShearWink = 0; 3274cdf0e10cSrcweir aGeo.RecalcTan(); 3275cdf0e10cSrcweir 3276cdf0e10cSrcweir // force metric to pool metric 3277cdf0e10cSrcweir SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); 3278cdf0e10cSrcweir if(eMapUnit != SFX_MAPUNIT_100TH_MM) 3279cdf0e10cSrcweir { 3280cdf0e10cSrcweir switch(eMapUnit) 3281cdf0e10cSrcweir { 3282cdf0e10cSrcweir case SFX_MAPUNIT_TWIP : 3283cdf0e10cSrcweir { 3284cdf0e10cSrcweir // position 3285cdf0e10cSrcweir aTranslate.setX(ImplMMToTwips(aTranslate.getX())); 3286cdf0e10cSrcweir aTranslate.setY(ImplMMToTwips(aTranslate.getY())); 3287cdf0e10cSrcweir 3288cdf0e10cSrcweir // size 3289cdf0e10cSrcweir aScale.setX(ImplMMToTwips(aScale.getX())); 3290cdf0e10cSrcweir aScale.setY(ImplMMToTwips(aScale.getY())); 3291cdf0e10cSrcweir 3292cdf0e10cSrcweir break; 3293cdf0e10cSrcweir } 3294cdf0e10cSrcweir default: 3295cdf0e10cSrcweir { 3296cdf0e10cSrcweir DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!"); 3297cdf0e10cSrcweir } 3298cdf0e10cSrcweir } 3299cdf0e10cSrcweir } 3300cdf0e10cSrcweir 3301cdf0e10cSrcweir // if anchor is used, make position relative to it 3302cdf0e10cSrcweir if( pModel && pModel->IsWriter() ) 3303cdf0e10cSrcweir { 3304cdf0e10cSrcweir if(GetAnchorPos().X() || GetAnchorPos().Y()) 3305cdf0e10cSrcweir { 3306cdf0e10cSrcweir aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y()); 3307cdf0e10cSrcweir } 3308cdf0e10cSrcweir } 3309cdf0e10cSrcweir 3310cdf0e10cSrcweir // build and set BaseRect (use scale) 3311cdf0e10cSrcweir Point aPoint = Point(); 3312cdf0e10cSrcweir Size aSize(FRound(aScale.getX()), FRound(aScale.getY())); 3313cdf0e10cSrcweir Rectangle aBaseRect(aPoint, aSize); 3314cdf0e10cSrcweir SetSnapRect(aBaseRect); 3315cdf0e10cSrcweir 3316cdf0e10cSrcweir // shear? 3317cdf0e10cSrcweir if(!basegfx::fTools::equalZero(fShearX)) 3318cdf0e10cSrcweir { 3319cdf0e10cSrcweir GeoStat aGeoStat; 3320cdf0e10cSrcweir aGeoStat.nShearWink = FRound((atan(fShearX) / F_PI180) * 100.0); 3321cdf0e10cSrcweir aGeoStat.RecalcTan(); 3322cdf0e10cSrcweir Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, sal_False); 3323cdf0e10cSrcweir } 3324cdf0e10cSrcweir 3325cdf0e10cSrcweir // rotation? 3326cdf0e10cSrcweir if(!basegfx::fTools::equalZero(fRotate)) 3327cdf0e10cSrcweir { 3328cdf0e10cSrcweir GeoStat aGeoStat; 3329cdf0e10cSrcweir 3330cdf0e10cSrcweir // #i78696# 3331cdf0e10cSrcweir // fRotate is mathematically correct, but aGeoStat.nDrehWink is 3332cdf0e10cSrcweir // mirrored -> mirror value here 3333cdf0e10cSrcweir aGeoStat.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000)); 3334cdf0e10cSrcweir aGeoStat.RecalcSinCos(); 3335cdf0e10cSrcweir Rotate(Point(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos); 3336cdf0e10cSrcweir } 3337cdf0e10cSrcweir 3338cdf0e10cSrcweir // translate? 3339cdf0e10cSrcweir if(!aTranslate.equalZero()) 3340cdf0e10cSrcweir { 3341cdf0e10cSrcweir Move(Size(FRound(aTranslate.getX()), FRound(aTranslate.getY()))); 3342cdf0e10cSrcweir } 3343cdf0e10cSrcweir } 3344cdf0e10cSrcweir 3345cdf0e10cSrcweir // taking fObjectRotation instead of aGeo.nWink 3346cdf0e10cSrcweir sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const 3347cdf0e10cSrcweir { 3348cdf0e10cSrcweir // get turn and shear 3349cdf0e10cSrcweir // double fRotate = (aGeo.nDrehWink / 100.0) * F_PI180; 3350cdf0e10cSrcweir double fRotate = fObjectRotation * F_PI180; 3351cdf0e10cSrcweir double fShearX = (aGeo.nShearWink / 100.0) * F_PI180; 3352cdf0e10cSrcweir 3353cdf0e10cSrcweir // get aRect, this is the unrotated snaprect 3354cdf0e10cSrcweir Rectangle aRectangle(aRect); 3355cdf0e10cSrcweir 3356cdf0e10cSrcweir sal_Bool bMirroredX = IsMirroredX(); 3357cdf0e10cSrcweir sal_Bool bMirroredY = IsMirroredY(); 3358cdf0e10cSrcweir if ( bMirroredX || bMirroredY ) 3359cdf0e10cSrcweir { // we have to retrieve the unmirrored rect 3360cdf0e10cSrcweir 3361cdf0e10cSrcweir GeoStat aNewGeo( aGeo ); 3362cdf0e10cSrcweir 3363cdf0e10cSrcweir if ( bMirroredX ) 3364cdf0e10cSrcweir { 3365cdf0e10cSrcweir Polygon aPol( Rect2Poly( aRect, aNewGeo ) ); 3366cdf0e10cSrcweir Rectangle aBoundRect( aPol.GetBoundRect() ); 3367cdf0e10cSrcweir 3368cdf0e10cSrcweir Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() ); 3369cdf0e10cSrcweir Point aRef2( aRef1.X(), aRef1.Y() + 1000 ); 3370cdf0e10cSrcweir sal_uInt16 i; 3371cdf0e10cSrcweir sal_uInt16 nPntAnz=aPol.GetSize(); 3372cdf0e10cSrcweir for (i=0; i<nPntAnz; i++) 3373cdf0e10cSrcweir { 3374cdf0e10cSrcweir MirrorPoint(aPol[i],aRef1,aRef2); 3375cdf0e10cSrcweir } 3376cdf0e10cSrcweir // Polygon wenden und etwas schieben 3377cdf0e10cSrcweir Polygon aPol0(aPol); 3378cdf0e10cSrcweir aPol[0]=aPol0[1]; 3379cdf0e10cSrcweir aPol[1]=aPol0[0]; 3380cdf0e10cSrcweir aPol[2]=aPol0[3]; 3381cdf0e10cSrcweir aPol[3]=aPol0[2]; 3382cdf0e10cSrcweir aPol[4]=aPol0[1]; 3383cdf0e10cSrcweir Poly2Rect(aPol,aRectangle,aNewGeo); 3384cdf0e10cSrcweir } 3385cdf0e10cSrcweir if ( bMirroredY ) 3386cdf0e10cSrcweir { 3387cdf0e10cSrcweir Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) ); 3388cdf0e10cSrcweir Rectangle aBoundRect( aPol.GetBoundRect() ); 3389cdf0e10cSrcweir 3390cdf0e10cSrcweir Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 ); 3391cdf0e10cSrcweir Point aRef2( aRef1.X() + 1000, aRef1.Y() ); 3392cdf0e10cSrcweir sal_uInt16 i; 3393cdf0e10cSrcweir sal_uInt16 nPntAnz=aPol.GetSize(); 3394cdf0e10cSrcweir for (i=0; i<nPntAnz; i++) 3395cdf0e10cSrcweir { 3396cdf0e10cSrcweir MirrorPoint(aPol[i],aRef1,aRef2); 3397cdf0e10cSrcweir } 3398cdf0e10cSrcweir // Polygon wenden und etwas schieben 3399cdf0e10cSrcweir Polygon aPol0(aPol); 3400cdf0e10cSrcweir aPol[0]=aPol0[1]; 3401cdf0e10cSrcweir aPol[1]=aPol0[0]; 3402cdf0e10cSrcweir aPol[2]=aPol0[3]; 3403cdf0e10cSrcweir aPol[3]=aPol0[2]; 3404cdf0e10cSrcweir aPol[4]=aPol0[1]; 3405cdf0e10cSrcweir Poly2Rect(aPol,aRectangle,aNewGeo); 3406cdf0e10cSrcweir } 3407cdf0e10cSrcweir } 3408cdf0e10cSrcweir 3409cdf0e10cSrcweir // fill other values 3410cdf0e10cSrcweir basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight()); 3411cdf0e10cSrcweir basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top()); 3412cdf0e10cSrcweir 3413cdf0e10cSrcweir // position maybe relative to anchorpos, convert 3414cdf0e10cSrcweir if( pModel && pModel->IsWriter() ) 3415cdf0e10cSrcweir { 3416cdf0e10cSrcweir if(GetAnchorPos().X() || GetAnchorPos().Y()) 3417cdf0e10cSrcweir { 3418cdf0e10cSrcweir aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y()); 3419cdf0e10cSrcweir } 3420cdf0e10cSrcweir } 3421cdf0e10cSrcweir 3422cdf0e10cSrcweir // force MapUnit to 100th mm 3423cdf0e10cSrcweir SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); 3424cdf0e10cSrcweir if(eMapUnit != SFX_MAPUNIT_100TH_MM) 3425cdf0e10cSrcweir { 3426cdf0e10cSrcweir switch(eMapUnit) 3427cdf0e10cSrcweir { 3428cdf0e10cSrcweir case SFX_MAPUNIT_TWIP : 3429cdf0e10cSrcweir { 3430cdf0e10cSrcweir // postion 3431cdf0e10cSrcweir aTranslate.setX(ImplTwipsToMM(aTranslate.getX())); 3432cdf0e10cSrcweir aTranslate.setY(ImplTwipsToMM(aTranslate.getY())); 3433cdf0e10cSrcweir 3434cdf0e10cSrcweir // size 3435cdf0e10cSrcweir aScale.setX(ImplTwipsToMM(aScale.getX())); 3436cdf0e10cSrcweir aScale.setY(ImplTwipsToMM(aScale.getY())); 3437cdf0e10cSrcweir 3438cdf0e10cSrcweir break; 3439cdf0e10cSrcweir } 3440cdf0e10cSrcweir default: 3441cdf0e10cSrcweir { 3442cdf0e10cSrcweir DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!"); 3443cdf0e10cSrcweir } 3444cdf0e10cSrcweir } 3445cdf0e10cSrcweir } 3446cdf0e10cSrcweir 3447cdf0e10cSrcweir // build matrix 3448cdf0e10cSrcweir rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 3449cdf0e10cSrcweir aScale, 3450cdf0e10cSrcweir basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX), 3451cdf0e10cSrcweir basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate, 3452cdf0e10cSrcweir aTranslate); 3453cdf0e10cSrcweir 3454cdf0e10cSrcweir return sal_False; 3455cdf0e10cSrcweir } 3456cdf0e10cSrcweir 3457cdf0e10cSrcweir sdr::contact::ViewContact* SdrObjCustomShape::CreateObjectSpecificViewContact() 3458cdf0e10cSrcweir { 3459cdf0e10cSrcweir return new sdr::contact::ViewContactOfSdrObjCustomShape(*this); 3460cdf0e10cSrcweir } 3461cdf0e10cSrcweir 3462cdf0e10cSrcweir // #i33136# 3463cdf0e10cSrcweir bool SdrObjCustomShape::doConstructOrthogonal(const ::rtl::OUString& rName) 3464cdf0e10cSrcweir { 3465cdf0e10cSrcweir bool bRetval(false); 3466cdf0e10cSrcweir static ::rtl::OUString Imps_sNameASOrtho_quadrat( RTL_CONSTASCII_USTRINGPARAM( "quadrat" ) ); 3467cdf0e10cSrcweir static ::rtl::OUString Imps_sNameASOrtho_round_quadrat( RTL_CONSTASCII_USTRINGPARAM( "round-quadrat" ) ); 3468cdf0e10cSrcweir static ::rtl::OUString Imps_sNameASOrtho_circle( RTL_CONSTASCII_USTRINGPARAM( "circle" ) ); 3469cdf0e10cSrcweir static ::rtl::OUString Imps_sNameASOrtho_circle_pie( RTL_CONSTASCII_USTRINGPARAM( "circle-pie" ) ); 3470cdf0e10cSrcweir static ::rtl::OUString Imps_sNameASOrtho_ring( RTL_CONSTASCII_USTRINGPARAM( "ring" ) ); 3471cdf0e10cSrcweir 3472cdf0e10cSrcweir if(Imps_sNameASOrtho_quadrat.equalsIgnoreAsciiCase(rName)) 3473cdf0e10cSrcweir { 3474cdf0e10cSrcweir bRetval = true; 3475cdf0e10cSrcweir } 3476cdf0e10cSrcweir else if(Imps_sNameASOrtho_round_quadrat.equalsIgnoreAsciiCase(rName)) 3477cdf0e10cSrcweir { 3478cdf0e10cSrcweir bRetval = true; 3479cdf0e10cSrcweir } 3480cdf0e10cSrcweir else if(Imps_sNameASOrtho_circle.equalsIgnoreAsciiCase(rName)) 3481cdf0e10cSrcweir { 3482cdf0e10cSrcweir bRetval = true; 3483cdf0e10cSrcweir } 3484cdf0e10cSrcweir else if(Imps_sNameASOrtho_circle_pie.equalsIgnoreAsciiCase(rName)) 3485cdf0e10cSrcweir { 3486cdf0e10cSrcweir bRetval = true; 3487cdf0e10cSrcweir } 3488cdf0e10cSrcweir else if(Imps_sNameASOrtho_ring.equalsIgnoreAsciiCase(rName)) 3489cdf0e10cSrcweir { 3490cdf0e10cSrcweir bRetval = true; 3491cdf0e10cSrcweir } 3492cdf0e10cSrcweir 3493cdf0e10cSrcweir return bRetval; 3494cdf0e10cSrcweir } 3495cdf0e10cSrcweir 3496cdf0e10cSrcweir // #i37011# centralize throw-away of render geometry 3497cdf0e10cSrcweir void SdrObjCustomShape::InvalidateRenderGeometry() 3498cdf0e10cSrcweir { 3499cdf0e10cSrcweir mXRenderedCustomShape = 0L; 3500cdf0e10cSrcweir SdrObject::Free( mpLastShadowGeometry ); 3501cdf0e10cSrcweir mpLastShadowGeometry = 0L; 3502cdf0e10cSrcweir } 3503cdf0e10cSrcweir 3504cdf0e10cSrcweir // eof 3505