xref: /trunk/main/svx/source/customshapes/EnhancedCustomShapeEngine.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include "EnhancedCustomShapeEngine.hxx"
27cdf0e10cSrcweir #include "svx/EnhancedCustomShape2d.hxx"
28cdf0e10cSrcweir #include "EnhancedCustomShape3d.hxx"
29cdf0e10cSrcweir #include "EnhancedCustomShapeFontWork.hxx"
30cdf0e10cSrcweir #include "EnhancedCustomShapeHandle.hxx"
31cdf0e10cSrcweir #include "svx/EnhancedCustomShapeGeometry.hxx"
32cdf0e10cSrcweir #include <svx/unoshape.hxx>
33cdf0e10cSrcweir #ifndef _SVX_UNOPAGE_HXX
34cdf0e10cSrcweir #include "svx/unopage.hxx"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include "svx/unoapi.hxx"
37cdf0e10cSrcweir #include <svx/svdobj.hxx>
38cdf0e10cSrcweir #include <svx/svdoashp.hxx>
39cdf0e10cSrcweir #include <svx/svdogrp.hxx>
40cdf0e10cSrcweir #include <svx/svdorect.hxx>
41cdf0e10cSrcweir #include <editeng/outlobj.hxx>
42cdf0e10cSrcweir #include <editeng/outliner.hxx>
43cdf0e10cSrcweir #include <svx/svdoutl.hxx>
44cdf0e10cSrcweir #include <svl/itemset.hxx>
45cdf0e10cSrcweir #include <svx/svdopath.hxx>
46cdf0e10cSrcweir #include <svx/svdpage.hxx>
47cdf0e10cSrcweir #include <svx/svdmodel.hxx>
48cdf0e10cSrcweir #include "svx/svditer.hxx"
49cdf0e10cSrcweir #include "unopolyhelper.hxx"
50cdf0e10cSrcweir #include <uno/mapping.hxx>
51cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
52cdf0e10cSrcweir #include <com/sun/star/document/XActionLockable.hpp>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // ---------------------------
55cdf0e10cSrcweir // - EnhancedCustomShapeEngine -
56cdf0e10cSrcweir // ---------------------------
57cdf0e10cSrcweir 
EnhancedCustomShapeEngine_getImplementationName()58cdf0e10cSrcweir rtl::OUString EnhancedCustomShapeEngine_getImplementationName()
59cdf0e10cSrcweir     throw( NMSP_UNO::RuntimeException )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     return B2UCONST( "com.sun.star.drawing.EnhancedCustomShapeEngine" );
62cdf0e10cSrcweir }
EnhancedCustomShapeEngine_supportsService(const rtl::OUString & ServiceName)63cdf0e10cSrcweir sal_Bool SAL_CALL EnhancedCustomShapeEngine_supportsService( const rtl::OUString& ServiceName )
64cdf0e10cSrcweir     throw( NMSP_UNO::RuntimeException )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.CustomShapeEngine" ) );
67cdf0e10cSrcweir }
SEQ(rtl::OUString)68cdf0e10cSrcweir SEQ( rtl::OUString ) SAL_CALL EnhancedCustomShapeEngine_getSupportedServiceNames()
69cdf0e10cSrcweir     throw( NMSP_UNO::RuntimeException )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir     SEQ( rtl::OUString ) aRet(1);
72cdf0e10cSrcweir     rtl::OUString* pArray = aRet.getArray();
73cdf0e10cSrcweir     pArray[0] = B2UCONST( "com.sun.star.drawing.CustomShapeEngine" );
74cdf0e10cSrcweir     return aRet;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir // -----------------------------------------------------------------------------
78cdf0e10cSrcweir 
EnhancedCustomShapeEngine(const REF (NMSP_LANG::XMultiServiceFactory)& rxMgr)79cdf0e10cSrcweir EnhancedCustomShapeEngine::EnhancedCustomShapeEngine( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) :
80cdf0e10cSrcweir     mxFact                  ( rxMgr ),
81cdf0e10cSrcweir     mbForceGroupWithText    ( sal_False )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
~EnhancedCustomShapeEngine()84cdf0e10cSrcweir EnhancedCustomShapeEngine::~EnhancedCustomShapeEngine()
85cdf0e10cSrcweir {
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir // XInterface -----------------------------------------------------------------
89cdf0e10cSrcweir 
acquire()90cdf0e10cSrcweir void SAL_CALL EnhancedCustomShapeEngine::acquire() throw()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     OWeakObject::acquire();
93cdf0e10cSrcweir }
release()94cdf0e10cSrcweir void SAL_CALL EnhancedCustomShapeEngine::release() throw()
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     OWeakObject::release();
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir // XInitialization ------------------------------------------------------------
100cdf0e10cSrcweir 
initialize(const SEQ (NMSP_UNO::Any)& aArguments)101cdf0e10cSrcweir void SAL_CALL EnhancedCustomShapeEngine::initialize( const SEQ( NMSP_UNO::Any )& aArguments )
102cdf0e10cSrcweir     throw ( NMSP_UNO::Exception, NMSP_UNO::RuntimeException )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     sal_Int32 i;
105cdf0e10cSrcweir     SEQ( NMSP_BEANS::PropertyValue ) aParameter;
106cdf0e10cSrcweir     for ( i = 0; i < aArguments.getLength(); i++ )
107cdf0e10cSrcweir     {
108cdf0e10cSrcweir         if ( aArguments[ i ] >>= aParameter )
109cdf0e10cSrcweir             break;
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir     for ( i = 0; i < aParameter.getLength(); i++ )
112cdf0e10cSrcweir     {
113cdf0e10cSrcweir         const NMSP_BEANS::PropertyValue& rProp = aParameter[ i ];
114cdf0e10cSrcweir         if ( rProp.Name.equalsAscii( "CustomShape" ) )
115cdf0e10cSrcweir             rProp.Value >>= mxShape;
116cdf0e10cSrcweir         else if ( rProp.Name.equalsAscii( "ForceGroupWithText" ) )
117cdf0e10cSrcweir             rProp.Value >>= mbForceGroupWithText;
118cdf0e10cSrcweir     }
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir // XServiceInfo ---------------------------------------------------------------
122cdf0e10cSrcweir 
getImplementationName()123cdf0e10cSrcweir rtl::OUString SAL_CALL EnhancedCustomShapeEngine::getImplementationName()
124cdf0e10cSrcweir     throw( NMSP_UNO::RuntimeException )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     return EnhancedCustomShapeEngine_getImplementationName();
127cdf0e10cSrcweir }
supportsService(const rtl::OUString & rServiceName)128cdf0e10cSrcweir sal_Bool SAL_CALL EnhancedCustomShapeEngine::supportsService( const rtl::OUString& rServiceName )
129cdf0e10cSrcweir     throw( NMSP_UNO::RuntimeException )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     return EnhancedCustomShapeEngine_supportsService( rServiceName );
132cdf0e10cSrcweir }
SEQ(rtl::OUString)133cdf0e10cSrcweir SEQ( rtl::OUString ) SAL_CALL EnhancedCustomShapeEngine::getSupportedServiceNames()
134cdf0e10cSrcweir     throw ( NMSP_UNO::RuntimeException )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     return EnhancedCustomShapeEngine_getSupportedServiceNames();
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir // XCustomShapeEngine -----------------------------------------------------------
140cdf0e10cSrcweir 
ImplForceGroupWithText(const SdrObjCustomShape * pCustoObj,SdrObject * pRenderedShape)141cdf0e10cSrcweir SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( const SdrObjCustomShape* pCustoObj, SdrObject* pRenderedShape )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     bool bHasText = pCustoObj->HasText();
144cdf0e10cSrcweir     if ( pRenderedShape || bHasText )
145cdf0e10cSrcweir     {
146cdf0e10cSrcweir         // applying shadow
147cdf0e10cSrcweir         const SdrObject* pShadowGeometry = pCustoObj->GetSdrObjectShadowFromCustomShape();
148cdf0e10cSrcweir         if ( pShadowGeometry )
149cdf0e10cSrcweir         {
150cdf0e10cSrcweir             if ( pRenderedShape )
151cdf0e10cSrcweir             {
152cdf0e10cSrcweir                 if ( !pRenderedShape->ISA( SdrObjGroup ) )
153cdf0e10cSrcweir                 {
154cdf0e10cSrcweir                     SdrObject* pTmp = pRenderedShape;
155cdf0e10cSrcweir                     pRenderedShape = new SdrObjGroup();
156cdf0e10cSrcweir                     ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
157cdf0e10cSrcweir                 }
158cdf0e10cSrcweir                 ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pShadowGeometry->Clone(), 0 );
159cdf0e10cSrcweir             }
160cdf0e10cSrcweir             else
161cdf0e10cSrcweir                 pRenderedShape = pShadowGeometry->Clone();
162cdf0e10cSrcweir         }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         // apply text
165cdf0e10cSrcweir         if ( bHasText )
166cdf0e10cSrcweir         {
167cdf0e10cSrcweir             // #i37011# also create a text object and add at rPos + 1
168cdf0e10cSrcweir             SdrTextObj* pTextObj = (SdrTextObj*)SdrObjFactory::MakeNewObject(
169cdf0e10cSrcweir                 pCustoObj->GetObjInventor(), OBJ_TEXT, 0L, pCustoObj->GetModel());
170cdf0e10cSrcweir 
171cdf0e10cSrcweir             // Copy text content
172cdf0e10cSrcweir             OutlinerParaObject* pParaObj = pCustoObj->GetOutlinerParaObject();
173cdf0e10cSrcweir             if( pParaObj )
174cdf0e10cSrcweir                 pTextObj->NbcSetOutlinerParaObject( new OutlinerParaObject(*pParaObj) );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir             // copy all attributes
177cdf0e10cSrcweir             SfxItemSet aTargetItemSet( pCustoObj->GetMergedItemSet() );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir             // clear fill and line style
180cdf0e10cSrcweir             aTargetItemSet.Put(XLineStyleItem(XLINE_NONE));
181cdf0e10cSrcweir             aTargetItemSet.Put(XFillStyleItem(XFILL_NONE));
182cdf0e10cSrcweir 
183cdf0e10cSrcweir             // get the text bounds and set at text object
184cdf0e10cSrcweir             Rectangle aTextBounds = pCustoObj->GetSnapRect();
185cdf0e10cSrcweir             SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
186cdf0e10cSrcweir             if ( pSdrObjCustomShape )
187cdf0e10cSrcweir             {
188cdf0e10cSrcweir                 EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
189cdf0e10cSrcweir                 aTextBounds = aCustomShape2d.GetTextRect();
190cdf0e10cSrcweir             }
191cdf0e10cSrcweir             pTextObj->SetSnapRect( aTextBounds );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir             // if rotated, copy GeoStat, too.
194cdf0e10cSrcweir             const GeoStat& rSourceGeo = pCustoObj->GetGeoStat();
195cdf0e10cSrcweir             if ( rSourceGeo.nDrehWink )
196cdf0e10cSrcweir             {
197cdf0e10cSrcweir                 pTextObj->NbcRotate(
198cdf0e10cSrcweir                     pCustoObj->GetSnapRect().Center(), rSourceGeo.nDrehWink,
199cdf0e10cSrcweir                     rSourceGeo.nSin, rSourceGeo.nCos);
200cdf0e10cSrcweir             }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir             // set modified ItemSet at text object
203cdf0e10cSrcweir             pTextObj->SetMergedItemSet(aTargetItemSet);
204cdf0e10cSrcweir 
205cdf0e10cSrcweir             if ( pRenderedShape )
206cdf0e10cSrcweir             {
207cdf0e10cSrcweir                 if ( !pRenderedShape->ISA( SdrObjGroup ) )
208cdf0e10cSrcweir                 {
209cdf0e10cSrcweir                     SdrObject* pTmp = pRenderedShape;
210cdf0e10cSrcweir                     pRenderedShape = new SdrObjGroup();
211cdf0e10cSrcweir                     ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
212cdf0e10cSrcweir                 }
213cdf0e10cSrcweir                 ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pTextObj, LIST_APPEND );
214cdf0e10cSrcweir             }
215cdf0e10cSrcweir             else
216cdf0e10cSrcweir                 pRenderedShape = pTextObj;
217cdf0e10cSrcweir         }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir         // force group
220cdf0e10cSrcweir         if ( pRenderedShape )
221cdf0e10cSrcweir         {
222cdf0e10cSrcweir             if ( !pRenderedShape->ISA( SdrObjGroup ) )
223cdf0e10cSrcweir             {
224cdf0e10cSrcweir                 SdrObject* pTmp = pRenderedShape;
225cdf0e10cSrcweir                 pRenderedShape = new SdrObjGroup();
226cdf0e10cSrcweir                 ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
227cdf0e10cSrcweir             }
228cdf0e10cSrcweir             pRenderedShape->SetPage( pCustoObj->GetPage() );
229cdf0e10cSrcweir             pRenderedShape->SetModel( pCustoObj->GetModel() );
230cdf0e10cSrcweir         }
231cdf0e10cSrcweir     }
232cdf0e10cSrcweir     return pRenderedShape;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
SetTemporary(::com::sun::star::uno::Reference<::com::sun::star::drawing::XShape> & xShape)235cdf0e10cSrcweir void SetTemporary( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir     if ( xShape.is() )
238cdf0e10cSrcweir     {
239cdf0e10cSrcweir         SvxShape* pShape = SvxShape::getImplementation( xShape );
240cdf0e10cSrcweir         if ( pShape )
241cdf0e10cSrcweir             pShape->TakeSdrObjectOwnership();
242cdf0e10cSrcweir /*
243cdf0e10cSrcweir         ::com::sun::star::uno::Reference<
244cdf0e10cSrcweir             ::com::sun::star::drawing::XShapes > xShapes( xShape, ::com::sun::star::uno::UNO_QUERY );
245cdf0e10cSrcweir         if ( xShapes.is() )
246cdf0e10cSrcweir         {
247cdf0e10cSrcweir             sal_Int32 i;
248cdf0e10cSrcweir             for ( i = 0; i < xShapes->getCount(); i++ )
249cdf0e10cSrcweir             {
250cdf0e10cSrcweir                 ::com::sun::star::uno::Any aAny( xShapes->getByIndex( i ) );
251cdf0e10cSrcweir                 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape;
252cdf0e10cSrcweir                 if ( aAny >>= xShape )
253cdf0e10cSrcweir                     SetTemporary( xShape );
254cdf0e10cSrcweir             }
255cdf0e10cSrcweir         }
256cdf0e10cSrcweir */
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
REF(com::sun::star::drawing::XShape)260cdf0e10cSrcweir REF( com::sun::star::drawing::XShape ) SAL_CALL EnhancedCustomShapeEngine::render()
261cdf0e10cSrcweir     throw ( NMSP_UNO::RuntimeException )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     REF( com::sun::star::drawing::XShape ) xShape;
264cdf0e10cSrcweir     SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
265cdf0e10cSrcweir     if ( pSdrObjCustomShape )
266cdf0e10cSrcweir     {
267cdf0e10cSrcweir         // retrieving the TextPath property to check if feature is enabled
268cdf0e10cSrcweir         SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)
269cdf0e10cSrcweir             pSdrObjCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
270cdf0e10cSrcweir         sal_Bool bTextPathOn = sal_False;
271cdf0e10cSrcweir         const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
272cdf0e10cSrcweir         com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sTextPath );
273cdf0e10cSrcweir         if ( pAny )
274cdf0e10cSrcweir             *pAny >>= bTextPathOn;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir         EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
277cdf0e10cSrcweir         sal_Int32 nRotateAngle = aCustomShape2d.GetRotateAngle();
278cdf0e10cSrcweir 
279cdf0e10cSrcweir         sal_Bool bFlipV = aCustomShape2d.IsFlipVert();
280cdf0e10cSrcweir         sal_Bool bFlipH = aCustomShape2d.IsFlipHorz();
281cdf0e10cSrcweir         sal_Bool bLineGeometryNeededOnly = bTextPathOn;
282cdf0e10cSrcweir 
283cdf0e10cSrcweir         SdrObject* pRenderedShape = aCustomShape2d.CreateObject( bLineGeometryNeededOnly );
284cdf0e10cSrcweir         if ( pRenderedShape )
285cdf0e10cSrcweir         {
286cdf0e10cSrcweir             if ( bTextPathOn )
287cdf0e10cSrcweir             {
288cdf0e10cSrcweir                 SdrObject* pRenderedFontWork = EnhancedCustomShapeFontWork::CreateFontWork( pRenderedShape, pSdrObjCustomShape );
289cdf0e10cSrcweir                 if ( pRenderedFontWork )
290cdf0e10cSrcweir                 {
291cdf0e10cSrcweir                     SdrObject::Free( pRenderedShape );
292cdf0e10cSrcweir                     pRenderedShape = pRenderedFontWork;
293cdf0e10cSrcweir                 }
294cdf0e10cSrcweir             }
295cdf0e10cSrcweir             SdrObject* pRenderedShape3d = EnhancedCustomShape3d::Create3DObject( pRenderedShape, pSdrObjCustomShape );
296cdf0e10cSrcweir             if ( pRenderedShape3d )
297cdf0e10cSrcweir             {
298cdf0e10cSrcweir                 bFlipV = bFlipH = sal_False;
299cdf0e10cSrcweir                 nRotateAngle = 0;
300cdf0e10cSrcweir                 SdrObject::Free( pRenderedShape );
301cdf0e10cSrcweir                 pRenderedShape = pRenderedShape3d;
302cdf0e10cSrcweir             }
303cdf0e10cSrcweir             Rectangle aRect( pSdrObjCustomShape->GetSnapRect() );
304cdf0e10cSrcweir 
305cdf0e10cSrcweir             const GeoStat& rGeoStat = ((SdrObjCustomShape*)pSdrObjCustomShape)->GetGeoStat();
306cdf0e10cSrcweir             if ( rGeoStat.nShearWink )
307cdf0e10cSrcweir             {
308cdf0e10cSrcweir                 long nShearWink = rGeoStat.nShearWink;
309cdf0e10cSrcweir                 double nTan = rGeoStat.nTan;
310cdf0e10cSrcweir                 if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
311cdf0e10cSrcweir                 {
312cdf0e10cSrcweir                     nShearWink = -nShearWink;
313cdf0e10cSrcweir                     nTan = -nTan;
314cdf0e10cSrcweir                 }
315cdf0e10cSrcweir                 pRenderedShape->Shear( pSdrObjCustomShape->GetSnapRect().Center(), nShearWink, nTan, sal_False);
316cdf0e10cSrcweir             }
317cdf0e10cSrcweir             if( nRotateAngle )
318cdf0e10cSrcweir             {
319cdf0e10cSrcweir                 double a = nRotateAngle * F_PI18000;
320cdf0e10cSrcweir                 pRenderedShape->NbcRotate( pSdrObjCustomShape->GetSnapRect().Center(), nRotateAngle, sin( a ), cos( a ) );
321cdf0e10cSrcweir             }
322cdf0e10cSrcweir             if ( bFlipV )
323cdf0e10cSrcweir             {
324cdf0e10cSrcweir                 Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
325cdf0e10cSrcweir                 Point aRight( aLeft.X() + 1000, aLeft.Y() );
326cdf0e10cSrcweir                 pRenderedShape->NbcMirror( aLeft, aRight );
327cdf0e10cSrcweir             }
328cdf0e10cSrcweir             if ( bFlipH )
329cdf0e10cSrcweir             {
330cdf0e10cSrcweir                 Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
331cdf0e10cSrcweir                 Point aBottom( aTop.X(), aTop.Y() + 1000 );
332cdf0e10cSrcweir                 pRenderedShape->NbcMirror( aTop, aBottom );
333cdf0e10cSrcweir             }
334cdf0e10cSrcweir             pRenderedShape->NbcSetStyleSheet( pSdrObjCustomShape->GetStyleSheet(), sal_True );
335cdf0e10cSrcweir             pRenderedShape->RecalcSnapRect();
336cdf0e10cSrcweir         }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir         if ( mbForceGroupWithText )
339cdf0e10cSrcweir             pRenderedShape = ImplForceGroupWithText( (SdrObjCustomShape*)pSdrObjCustomShape, pRenderedShape );
340cdf0e10cSrcweir 
341cdf0e10cSrcweir         if ( pRenderedShape )
342cdf0e10cSrcweir         {
343cdf0e10cSrcweir             aCustomShape2d.ApplyGluePoints( pRenderedShape );
344cdf0e10cSrcweir             xShape = SvxDrawPage::CreateShapeByTypeAndInventor( pRenderedShape->GetObjIdentifier(),
345cdf0e10cSrcweir                 pRenderedShape->GetObjInventor(), pRenderedShape, NULL );
346cdf0e10cSrcweir         }
347cdf0e10cSrcweir         SetTemporary( xShape );
348cdf0e10cSrcweir     }
349cdf0e10cSrcweir     return xShape;
350cdf0e10cSrcweir }
351cdf0e10cSrcweir 
getTextBounds()352cdf0e10cSrcweir com::sun::star::awt::Rectangle SAL_CALL EnhancedCustomShapeEngine::getTextBounds()
353cdf0e10cSrcweir     throw ( NMSP_UNO::RuntimeException )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir     com::sun::star::awt::Rectangle aTextRect;
356cdf0e10cSrcweir     SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
357cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::document::XActionLockable > xLockable( mxShape, ::com::sun::star::uno::UNO_QUERY );
358cdf0e10cSrcweir     if ( pSdrObjCustomShape && pSdrObjCustomShape->GetModel() && xLockable.is() && !xLockable->isActionLocked() )
359cdf0e10cSrcweir     {
360cdf0e10cSrcweir         if ( pSdrObjCustomShape )
361cdf0e10cSrcweir         {
362cdf0e10cSrcweir             EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
363cdf0e10cSrcweir             Rectangle aRect( aCustomShape2d.GetTextRect() );
364cdf0e10cSrcweir             aTextRect.X = aRect.Left();
365cdf0e10cSrcweir             aTextRect.Y = aRect.Top();
366cdf0e10cSrcweir             aTextRect.Width = aRect.GetWidth();
367cdf0e10cSrcweir             aTextRect.Height = aRect.GetHeight();
368cdf0e10cSrcweir         }
369cdf0e10cSrcweir     }
370cdf0e10cSrcweir     return aTextRect;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir 
getLineGeometry()373cdf0e10cSrcweir com::sun::star::drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeometry()
374cdf0e10cSrcweir     throw ( NMSP_UNO::RuntimeException )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir     com::sun::star::drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords;
377cdf0e10cSrcweir     SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
378cdf0e10cSrcweir     if ( pSdrObjCustomShape )
379cdf0e10cSrcweir     {
380cdf0e10cSrcweir         EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
381cdf0e10cSrcweir         SdrObject* pObj = aCustomShape2d.CreateLineGeometry();
382cdf0e10cSrcweir         if ( pObj )
383cdf0e10cSrcweir         {
384cdf0e10cSrcweir             Rectangle aRect( pSdrObjCustomShape->GetSnapRect() );
385cdf0e10cSrcweir             sal_Bool bFlipV = aCustomShape2d.IsFlipVert();
386cdf0e10cSrcweir             sal_Bool bFlipH = aCustomShape2d.IsFlipHorz();
387cdf0e10cSrcweir 
388cdf0e10cSrcweir             const GeoStat& rGeoStat = ((SdrObjCustomShape*)pSdrObjCustomShape)->GetGeoStat();
389cdf0e10cSrcweir             if ( rGeoStat.nShearWink )
390cdf0e10cSrcweir             {
391cdf0e10cSrcweir                 long nShearWink = rGeoStat.nShearWink;
392cdf0e10cSrcweir                 double nTan = rGeoStat.nTan;
393cdf0e10cSrcweir                 if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
394cdf0e10cSrcweir                 {
395cdf0e10cSrcweir                     nShearWink = -nShearWink;
396cdf0e10cSrcweir                     nTan = -nTan;
397cdf0e10cSrcweir                 }
398cdf0e10cSrcweir                 pObj->Shear( aRect.Center(), nShearWink, nTan, sal_False);
399cdf0e10cSrcweir             }
400cdf0e10cSrcweir             sal_Int32 nRotateAngle = aCustomShape2d.GetRotateAngle();
401cdf0e10cSrcweir             if( nRotateAngle )
402cdf0e10cSrcweir             {
403cdf0e10cSrcweir                 double a = nRotateAngle * F_PI18000;
404cdf0e10cSrcweir                 pObj->NbcRotate( aRect.Center(), nRotateAngle, sin( a ), cos( a ) );
405cdf0e10cSrcweir             }
406cdf0e10cSrcweir             if ( bFlipH )
407cdf0e10cSrcweir             {
408cdf0e10cSrcweir                 Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
409cdf0e10cSrcweir                 Point aBottom( aTop.X(), aTop.Y() + 1000 );
410cdf0e10cSrcweir                 pObj->NbcMirror( aTop, aBottom );
411cdf0e10cSrcweir             }
412cdf0e10cSrcweir             if ( bFlipV )
413cdf0e10cSrcweir             {
414cdf0e10cSrcweir                 Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
415cdf0e10cSrcweir                 Point aRight( aLeft.X() + 1000, aLeft.Y() );
416cdf0e10cSrcweir                 pObj->NbcMirror( aLeft, aRight );
417cdf0e10cSrcweir             }
418cdf0e10cSrcweir 
419cdf0e10cSrcweir             basegfx::B2DPolyPolygon aPolyPolygon;
420cdf0e10cSrcweir             SdrObjListIter aIter( *pObj, IM_DEEPWITHGROUPS );
421cdf0e10cSrcweir 
422cdf0e10cSrcweir             while ( aIter.IsMore() )
423cdf0e10cSrcweir             {
424cdf0e10cSrcweir                 SdrObject* pNewObj = NULL;
425cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aPP;
426cdf0e10cSrcweir                 const SdrObject* pNext = aIter.Next();
427cdf0e10cSrcweir 
428cdf0e10cSrcweir                 if ( pNext->ISA( SdrPathObj ) )
429cdf0e10cSrcweir                 {
430cdf0e10cSrcweir                     aPP = ((SdrPathObj*)pNext)->GetPathPoly();
431cdf0e10cSrcweir                 }
432cdf0e10cSrcweir                 else
433cdf0e10cSrcweir                 {
434cdf0e10cSrcweir                     pNewObj = pNext->ConvertToPolyObj( sal_False, sal_False );
435cdf0e10cSrcweir                     SdrPathObj* pPath = PTR_CAST( SdrPathObj, pNewObj );
436cdf0e10cSrcweir                     if ( pPath )
437cdf0e10cSrcweir                         aPP = pPath->GetPathPoly();
438cdf0e10cSrcweir                 }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir                 if ( aPP.count() )
441cdf0e10cSrcweir                     aPolyPolygon.append(aPP);
442cdf0e10cSrcweir 
443cdf0e10cSrcweir                 SdrObject::Free( pNewObj );
444cdf0e10cSrcweir             }
445cdf0e10cSrcweir             SdrObject::Free( pObj );
446cdf0e10cSrcweir             SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPolygon, aPolyPolygonBezierCoords );
447cdf0e10cSrcweir         }
448cdf0e10cSrcweir     }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir     return aPolyPolygonBezierCoords;
451cdf0e10cSrcweir }
452cdf0e10cSrcweir 
SEQ(REF (com::sun::star::drawing::XCustomShapeHandle))453cdf0e10cSrcweir SEQ( REF( com::sun::star::drawing::XCustomShapeHandle ) ) SAL_CALL EnhancedCustomShapeEngine::getInteraction()
454cdf0e10cSrcweir     throw ( NMSP_UNO::RuntimeException )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir     sal_uInt32 i, nHdlCount = 0;
457cdf0e10cSrcweir     SdrObject* pSdrObjCustomShape = GetSdrObjectFromXShape( mxShape );
458cdf0e10cSrcweir     if ( pSdrObjCustomShape )
459cdf0e10cSrcweir     {
460cdf0e10cSrcweir         EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
461cdf0e10cSrcweir         nHdlCount = aCustomShape2d.GetHdlCount();
462cdf0e10cSrcweir     }
463cdf0e10cSrcweir     SEQ( REF( com::sun::star::drawing::XCustomShapeHandle ) ) aSeq( nHdlCount );
464cdf0e10cSrcweir     for ( i = 0; i < nHdlCount; i++ )
465cdf0e10cSrcweir         aSeq[ i ] = new EnhancedCustomShapeHandle( mxShape, i );
466cdf0e10cSrcweir     return aSeq;
467cdf0e10cSrcweir }
468