LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/svdraw - svdoashp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 926 1808 51.2 %
Date: 2013-07-09 Functions: 66 100 66.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10