xref: /trunk/main/svx/source/customshapes/EnhancedCustomShape2d.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include "svx/EnhancedCustomShape2d.hxx"
27cdf0e10cSrcweir #include "svx/EnhancedCustomShapeGeometry.hxx"
28cdf0e10cSrcweir #include "svx/EnhancedCustomShapeTypeNames.hxx"
29cdf0e10cSrcweir #include <svx/svdoashp.hxx>
30cdf0e10cSrcweir #include <svx/svdtrans.hxx>
31cdf0e10cSrcweir #include <svx/svdocirc.hxx>
32cdf0e10cSrcweir #include <svx/svdogrp.hxx>
33cdf0e10cSrcweir #include <svx/svdopath.hxx>
34cdf0e10cSrcweir #ifndef _SVDOCAPT_HXX
35cdf0e10cSrcweir #include <svx/svdocapt.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <svx/svdpage.hxx>
38cdf0e10cSrcweir #include <svx/xflclit.hxx>
39cdf0e10cSrcweir #include <svx/sdasaitm.hxx>
40cdf0e10cSrcweir #include <svx/svdmodel.hxx>
41cdf0e10cSrcweir #include <rtl/crc.h>
42cdf0e10cSrcweir #include <rtl/math.hxx>
43cdf0e10cSrcweir #include <svx/xfillit0.hxx>
44cdf0e10cSrcweir #include <svx/xlnstit.hxx>
45cdf0e10cSrcweir #include <svx/xlnedit.hxx>
46cdf0e10cSrcweir #include <svx/xlnstwit.hxx>
47cdf0e10cSrcweir #include <svx/xlnedwit.hxx>
48cdf0e10cSrcweir #include <svx/xlnstcit.hxx>
49cdf0e10cSrcweir #include <svx/xlnedcit.hxx>
50cdf0e10cSrcweir #include <svx/xflgrit.hxx>
51cdf0e10cSrcweir #include <svx/xflhtit.hxx>
52cdf0e10cSrcweir #include <svx/xbtmpit.hxx>
53cdf0e10cSrcweir #include <svx/xgrad.hxx>
54cdf0e10cSrcweir #include <svx/xhatch.hxx>
55cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
56cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
57cdf0e10cSrcweir #ifndef __COM_SUN_STAR_DRAWING_ENHANCEDCUSTOMSHAPESEGMENTCOMMAND_HPP__
58cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
61cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
64cdf0e10cSrcweir #include <basegfx/color/bcolortools.hxx>
65cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // #i76201#
68cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #include <math.h>
71cdf0e10cSrcweir 
72cdf0e10cSrcweir using namespace ::com::sun::star::uno;
73cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
74cdf0e10cSrcweir using namespace ::com::sun::star::drawing::EnhancedCustomShapeSegmentCommand;
75cdf0e10cSrcweir 
SetEnhancedCustomShapeParameter(EnhancedCustomShapeParameter & rParameter,const sal_Int32 nValue)76cdf0e10cSrcweir void EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nValue )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir     sal_uInt32 nDat = (sal_uInt32)nValue;
79cdf0e10cSrcweir     sal_Int32  nNewValue = nValue;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     // check if this is a special point
82cdf0e10cSrcweir     if ( ( nDat >> 16 ) == 0x8000 )
83cdf0e10cSrcweir     {
84cdf0e10cSrcweir         nNewValue = (sal_uInt16)nDat;
85cdf0e10cSrcweir         rParameter.Type = EnhancedCustomShapeParameterType::EQUATION;
86cdf0e10cSrcweir     }
87cdf0e10cSrcweir     else
88cdf0e10cSrcweir         rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
89cdf0e10cSrcweir     rParameter.Value <<= nNewValue;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
GetEquation(const sal_uInt16 nFlags,sal_Int32 nP1,sal_Int32 nP2,sal_Int32 nP3)924d2151e5SArmin Le Grand rtl::OUString EnhancedCustomShape2d::GetEquation( const sal_uInt16 nFlags, sal_Int32 nP1, sal_Int32 nP2, sal_Int32 nP3 )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     rtl::OUString aEquation;
95cdf0e10cSrcweir     sal_Bool b1Special = ( nFlags & 0x2000 ) != 0;
96cdf0e10cSrcweir     sal_Bool b2Special = ( nFlags & 0x4000 ) != 0;
97cdf0e10cSrcweir     sal_Bool b3Special = ( nFlags & 0x8000 ) != 0;
98cdf0e10cSrcweir     switch( nFlags & 0xff )
99cdf0e10cSrcweir     {
100cdf0e10cSrcweir         case 0 :
101cdf0e10cSrcweir         case 14 :
102cdf0e10cSrcweir         {
103cdf0e10cSrcweir             sal_Int32 nOptimize = 0;
104cdf0e10cSrcweir             if ( nP1 )
105cdf0e10cSrcweir                 nOptimize |= 1;
106cdf0e10cSrcweir             if ( nP2 )
107cdf0e10cSrcweir                 nOptimize |= 2;
108cdf0e10cSrcweir             if ( b1Special )
109cdf0e10cSrcweir                 nOptimize |= 4;
110cdf0e10cSrcweir             if ( b2Special )
111cdf0e10cSrcweir                 nOptimize |= 8;
112cdf0e10cSrcweir             switch( nOptimize )
113cdf0e10cSrcweir             {
114cdf0e10cSrcweir                 case 0 :
115cdf0e10cSrcweir                 break;
116cdf0e10cSrcweir                 case 1 :
117cdf0e10cSrcweir                 case 4 :
118cdf0e10cSrcweir                 case 5 :
119cdf0e10cSrcweir                     EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
120cdf0e10cSrcweir                 break;
121cdf0e10cSrcweir                 case 2 :
122cdf0e10cSrcweir                 case 8 :
123cdf0e10cSrcweir                 case 10:
124cdf0e10cSrcweir                     EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
125cdf0e10cSrcweir                 break;
126cdf0e10cSrcweir                 default :
127cdf0e10cSrcweir                 {
128cdf0e10cSrcweir                     EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
129cdf0e10cSrcweir                     aEquation += rtl::OUString( (sal_Unicode)'+' );
130cdf0e10cSrcweir                     EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
131cdf0e10cSrcweir                 }
132cdf0e10cSrcweir                 break;
133cdf0e10cSrcweir             }
134cdf0e10cSrcweir             if ( b3Special || nP3 )
135cdf0e10cSrcweir             {
136cdf0e10cSrcweir                 aEquation += rtl::OUString( (sal_Unicode)'-' );
137cdf0e10cSrcweir                 EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
138cdf0e10cSrcweir             }
139cdf0e10cSrcweir         }
140cdf0e10cSrcweir         break;
141cdf0e10cSrcweir         case 1 :
142cdf0e10cSrcweir         {
143cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
144cdf0e10cSrcweir             if ( b2Special || ( nP2 != 1 ) )
145cdf0e10cSrcweir             {
146cdf0e10cSrcweir                 aEquation += rtl::OUString( (sal_Unicode)'*' );
147cdf0e10cSrcweir                 EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
148cdf0e10cSrcweir             }
149cdf0e10cSrcweir             if ( b3Special || ( ( nP3 != 1 ) && ( nP3 != 0 ) ) )
150cdf0e10cSrcweir             {
151cdf0e10cSrcweir                 aEquation += rtl::OUString( (sal_Unicode)'/' );
152cdf0e10cSrcweir                 EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
153cdf0e10cSrcweir             }
154cdf0e10cSrcweir         }
155cdf0e10cSrcweir         break;
156cdf0e10cSrcweir         case 2 :
157cdf0e10cSrcweir         {
158cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(" ) );
159cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
160cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
161cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
162cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/2" ) );
163cdf0e10cSrcweir         }
164cdf0e10cSrcweir         break;
165cdf0e10cSrcweir         case 3 :
166cdf0e10cSrcweir         {
167cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "abs(" ) );
168cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
169cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
170cdf0e10cSrcweir         }
171cdf0e10cSrcweir         break;
172cdf0e10cSrcweir         case 4 :
173cdf0e10cSrcweir         {
174cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "min(" ) );
175cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
176cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
177cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
178cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
179cdf0e10cSrcweir         }
180cdf0e10cSrcweir         break;
181cdf0e10cSrcweir         case 5 :
182cdf0e10cSrcweir         {
183cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "max(" ) );
184cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
185cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
186cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
187cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
188cdf0e10cSrcweir         }
189cdf0e10cSrcweir         break;
190cdf0e10cSrcweir         case 6 :
191cdf0e10cSrcweir         {
192cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "if(" ) );
193cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
194cdf0e10cSrcweir             aEquation += rtl::OUString( (sal_Unicode)',' );
195cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
196cdf0e10cSrcweir             aEquation += rtl::OUString( (sal_Unicode)',' );
197cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
198cdf0e10cSrcweir             aEquation += rtl::OUString( (sal_Unicode)')' );
199cdf0e10cSrcweir         }
200cdf0e10cSrcweir         break;
201cdf0e10cSrcweir         case 7 :
202cdf0e10cSrcweir         {
203cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
204cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
205cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
206cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
207cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
208cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
209cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
210cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
211cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
212cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
213cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
214cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
215cdf0e10cSrcweir             aEquation += rtl::OUString( (sal_Unicode)')' );
216cdf0e10cSrcweir         }
217cdf0e10cSrcweir         break;
218cdf0e10cSrcweir         case 8 :
219cdf0e10cSrcweir         {
220cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "atan2(" ) );
221cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
222cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
223cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
224cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/(pi/180)" ) );
225cdf0e10cSrcweir         }
226cdf0e10cSrcweir         break;
227cdf0e10cSrcweir         case 9 :
228cdf0e10cSrcweir         {
229cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
230cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sin(" ) );
231cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
232cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) );
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir         break;
235cdf0e10cSrcweir         case 10 :
236cdf0e10cSrcweir         {
237cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
238cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*cos(" ) );
239cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
240cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) );
241cdf0e10cSrcweir         }
242cdf0e10cSrcweir         break;
243cdf0e10cSrcweir         case 11 :
244cdf0e10cSrcweir         {
245cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
246cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
247cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "cos(atan2(" ) );
248cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
249cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
250cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
251cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
252cdf0e10cSrcweir         }
253cdf0e10cSrcweir         break;
254cdf0e10cSrcweir         case 12 :
255cdf0e10cSrcweir         {
256cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
257cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
258cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sin(atan2(" ) );
259cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
260cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
261cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
262cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
263cdf0e10cSrcweir         }
264cdf0e10cSrcweir         break;
265cdf0e10cSrcweir         case 13 :
266cdf0e10cSrcweir         {
267cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
268cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
269cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
270cdf0e10cSrcweir         }
271cdf0e10cSrcweir         break;
272cdf0e10cSrcweir         case 15 :
273cdf0e10cSrcweir         {
274cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
275cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sqrt(1-(" ) );
276cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
277cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
278cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
279cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
280cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(" ) );
281cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
282cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
283cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
284cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
285cdf0e10cSrcweir         }
286cdf0e10cSrcweir         break;
287cdf0e10cSrcweir         case 16 :
288cdf0e10cSrcweir         {
289cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
290cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*tan(" ) );
291cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
292cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
293cdf0e10cSrcweir         }
294cdf0e10cSrcweir         break;
295cdf0e10cSrcweir         case 0x80 :
296cdf0e10cSrcweir         {
297cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
298cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
299cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
300cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
301cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-" ) );
302cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
303cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
304cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
305cdf0e10cSrcweir             aEquation += rtl::OUString( (sal_Unicode)')' );
306cdf0e10cSrcweir         }
307cdf0e10cSrcweir         break;
308cdf0e10cSrcweir         case 0x81 :
309cdf0e10cSrcweir         {
310cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(cos(" ) );
311cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
312cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
313cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
314cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)+sin(" ) );
315cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
316cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
317cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
318cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) );
319cdf0e10cSrcweir         }
320cdf0e10cSrcweir         break;
321cdf0e10cSrcweir         case 0x82 :
322cdf0e10cSrcweir         {
323cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-(sin(" ) );
324cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
325cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
326cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
327cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)-cos(" ) );
328cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
329cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
330cdf0e10cSrcweir             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
331cdf0e10cSrcweir             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) );
332cdf0e10cSrcweir         }
333cdf0e10cSrcweir         break;
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir     return aEquation;
336cdf0e10cSrcweir }
337cdf0e10cSrcweir 
AppendEnhancedCustomShapeEquationParameter(rtl::OUString & rParameter,const sal_Int32 nPara,const sal_Bool bIsSpecialValue)3384d2151e5SArmin Le Grand void EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir     if ( bIsSpecialValue )
341cdf0e10cSrcweir     {
342cdf0e10cSrcweir         if ( nPara & 0x400 )
343cdf0e10cSrcweir         {
344cdf0e10cSrcweir             rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "?" ) );
345cdf0e10cSrcweir             rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara & 0xff ) );
346cdf0e10cSrcweir             rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
347cdf0e10cSrcweir         }
348cdf0e10cSrcweir         else
349cdf0e10cSrcweir         {
350cdf0e10cSrcweir             switch( nPara )
351cdf0e10cSrcweir             {
352cdf0e10cSrcweir                 case DFF_Prop_adjustValue :
353cdf0e10cSrcweir                 case DFF_Prop_adjust2Value :
354cdf0e10cSrcweir                 case DFF_Prop_adjust3Value :
355cdf0e10cSrcweir                 case DFF_Prop_adjust4Value :
356cdf0e10cSrcweir                 case DFF_Prop_adjust5Value :
357cdf0e10cSrcweir                 case DFF_Prop_adjust6Value :
358cdf0e10cSrcweir                 case DFF_Prop_adjust7Value :
359cdf0e10cSrcweir                 case DFF_Prop_adjust8Value :
360cdf0e10cSrcweir                 case DFF_Prop_adjust9Value :
361cdf0e10cSrcweir                 case DFF_Prop_adjust10Value :
362cdf0e10cSrcweir                 {
363cdf0e10cSrcweir                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "$" ) );
364cdf0e10cSrcweir                     rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara - DFF_Prop_adjustValue ) );
365cdf0e10cSrcweir                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
366cdf0e10cSrcweir                 }
367cdf0e10cSrcweir                 break;
368cdf0e10cSrcweir                 case DFF_Prop_geoLeft :
369cdf0e10cSrcweir                 {
370cdf0e10cSrcweir                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "left" ) );
371cdf0e10cSrcweir                 }
372cdf0e10cSrcweir                 break;
373cdf0e10cSrcweir                 case DFF_Prop_geoTop :
374cdf0e10cSrcweir                 {
375cdf0e10cSrcweir                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "top" ) );
376cdf0e10cSrcweir                 }
377cdf0e10cSrcweir                 break;
378cdf0e10cSrcweir                 case DFF_Prop_geoRight :
379cdf0e10cSrcweir                 {
380cdf0e10cSrcweir                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "right" ) );
381cdf0e10cSrcweir                 }
382cdf0e10cSrcweir                 break;
383cdf0e10cSrcweir                 case DFF_Prop_geoBottom :
384cdf0e10cSrcweir                 {
385cdf0e10cSrcweir                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "bottom" ) );
386cdf0e10cSrcweir                 }
387cdf0e10cSrcweir                 break;
388cdf0e10cSrcweir             }
389cdf0e10cSrcweir         }
390cdf0e10cSrcweir     }
391cdf0e10cSrcweir     else
392cdf0e10cSrcweir     {
393cdf0e10cSrcweir         rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara ) );
394cdf0e10cSrcweir     }
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
SetEnhancedCustomShapeHandleParameter(EnhancedCustomShapeParameter & rParameter,const sal_Int32 nPara,const sal_Bool bIsSpecialValue,sal_Bool bHorz)397cdf0e10cSrcweir void EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz )
398cdf0e10cSrcweir {
399cdf0e10cSrcweir     sal_Int32 nValue = 0;
400cdf0e10cSrcweir     if ( bIsSpecialValue )
401cdf0e10cSrcweir     {
402cdf0e10cSrcweir         if ( ( nPara >= 0x100 ) && ( nPara <= 0x107 ) )
403cdf0e10cSrcweir         {
404cdf0e10cSrcweir             nValue = nPara & 0xff;
405cdf0e10cSrcweir             rParameter.Type = EnhancedCustomShapeParameterType::ADJUSTMENT;
406cdf0e10cSrcweir         }
407cdf0e10cSrcweir         else if ( ( nPara >= 3 ) && ( nPara <= 0x82 ) )
408cdf0e10cSrcweir         {
409cdf0e10cSrcweir             nValue = nPara - 3;
410cdf0e10cSrcweir             rParameter.Type = EnhancedCustomShapeParameterType::EQUATION;
411cdf0e10cSrcweir         }
412cdf0e10cSrcweir         else if ( nPara == 0 )
413cdf0e10cSrcweir         {
414cdf0e10cSrcweir             nValue = 0;
415cdf0e10cSrcweir             if ( bHorz )
416cdf0e10cSrcweir                 rParameter.Type = EnhancedCustomShapeParameterType::LEFT;
417cdf0e10cSrcweir             else
418cdf0e10cSrcweir                 rParameter.Type = EnhancedCustomShapeParameterType::TOP;
419cdf0e10cSrcweir         }
420cdf0e10cSrcweir         else if ( nPara == 1 )
421cdf0e10cSrcweir         {
422cdf0e10cSrcweir             nValue = 0;
423cdf0e10cSrcweir             if ( bHorz )
424cdf0e10cSrcweir                 rParameter.Type = EnhancedCustomShapeParameterType::RIGHT;
425cdf0e10cSrcweir             else
426cdf0e10cSrcweir                 rParameter.Type = EnhancedCustomShapeParameterType::BOTTOM;
427cdf0e10cSrcweir         }
428cdf0e10cSrcweir         else if ( nPara == 2 )  // means to be centered, but should not be
429cdf0e10cSrcweir         {                       // used in our implementation
430cdf0e10cSrcweir             nValue = 5600;
431cdf0e10cSrcweir             rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
432cdf0e10cSrcweir         }
433cdf0e10cSrcweir         else
434cdf0e10cSrcweir         {
435cdf0e10cSrcweir             nValue = nPara;
436cdf0e10cSrcweir             rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
437cdf0e10cSrcweir         }
438cdf0e10cSrcweir     }
439cdf0e10cSrcweir     else
440cdf0e10cSrcweir     {
441cdf0e10cSrcweir         nValue = nPara;
442cdf0e10cSrcweir         rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
443cdf0e10cSrcweir     }
444cdf0e10cSrcweir     rParameter.Value <<= nValue;
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
ConvertSequenceToEnhancedCustomShape2dHandle(const com::sun::star::beans::PropertyValues & rHandleProperties,EnhancedCustomShape2d::Handle & rDestinationHandle)447cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle(
448cdf0e10cSrcweir     const com::sun::star::beans::PropertyValues& rHandleProperties,
449cdf0e10cSrcweir         EnhancedCustomShape2d::Handle& rDestinationHandle )
450cdf0e10cSrcweir {
451cdf0e10cSrcweir     sal_Bool bRetValue = sal_False;
452cdf0e10cSrcweir     sal_uInt32 i, nProperties = rHandleProperties.getLength();
453cdf0e10cSrcweir     if ( nProperties )
454cdf0e10cSrcweir     {
455cdf0e10cSrcweir         rDestinationHandle.nFlags = 0;
456cdf0e10cSrcweir         for ( i = 0; i < nProperties; i++ )
457cdf0e10cSrcweir         {
458cdf0e10cSrcweir             const com::sun::star::beans::PropertyValue& rPropVal = rHandleProperties[ i ];
459cdf0e10cSrcweir 
460cdf0e10cSrcweir             const rtl::OUString sPosition           ( RTL_CONSTASCII_USTRINGPARAM( "Position" ) );
461cdf0e10cSrcweir             const rtl::OUString sMirroredX          ( RTL_CONSTASCII_USTRINGPARAM( "MirroredX" ) );
462cdf0e10cSrcweir             const rtl::OUString sMirroredY          ( RTL_CONSTASCII_USTRINGPARAM( "MirroredY" ) );
463cdf0e10cSrcweir             const rtl::OUString sSwitched           ( RTL_CONSTASCII_USTRINGPARAM( "Switched" ) );
464cdf0e10cSrcweir             const rtl::OUString sPolar              ( RTL_CONSTASCII_USTRINGPARAM( "Polar" ) );
465cdf0e10cSrcweir //          const rtl::OUString sMap                ( RTL_CONSTASCII_USTRINGPARAM( "Map" ) );
466cdf0e10cSrcweir             const rtl::OUString sRefX               ( RTL_CONSTASCII_USTRINGPARAM( "RefX" ) );
467cdf0e10cSrcweir             const rtl::OUString sRefY               ( RTL_CONSTASCII_USTRINGPARAM( "RefY" ) );
468cdf0e10cSrcweir             const rtl::OUString sRefAngle           ( RTL_CONSTASCII_USTRINGPARAM( "RefAngle" ) );
469cdf0e10cSrcweir             const rtl::OUString sRefR               ( RTL_CONSTASCII_USTRINGPARAM( "RefR" ) );
470cdf0e10cSrcweir             const rtl::OUString sRadiusRangeMinimum ( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMinimum" ) );
471cdf0e10cSrcweir             const rtl::OUString sRadiusRangeMaximum ( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMaximum" ) );
472cdf0e10cSrcweir             const rtl::OUString sRangeXMinimum      ( RTL_CONSTASCII_USTRINGPARAM( "RangeXMinimum" ) );
473cdf0e10cSrcweir             const rtl::OUString sRangeXMaximum      ( RTL_CONSTASCII_USTRINGPARAM( "RangeXMaximum" ) );
474cdf0e10cSrcweir             const rtl::OUString sRangeYMinimum      ( RTL_CONSTASCII_USTRINGPARAM( "RangeYMinimum" ) );
475cdf0e10cSrcweir             const rtl::OUString sRangeYMaximum      ( RTL_CONSTASCII_USTRINGPARAM( "RangeYMaximum" ) );
476cdf0e10cSrcweir 
477cdf0e10cSrcweir             if ( rPropVal.Name.equals( sPosition ) )
478cdf0e10cSrcweir             {
479cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.aPosition )
480cdf0e10cSrcweir                     bRetValue = sal_True;
481cdf0e10cSrcweir             }
482cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sMirroredX ) )
483cdf0e10cSrcweir             {
484cdf0e10cSrcweir                 sal_Bool bMirroredX = sal_Bool();
485cdf0e10cSrcweir                 if ( rPropVal.Value >>= bMirroredX )
486cdf0e10cSrcweir                 {
487cdf0e10cSrcweir                     if ( bMirroredX )
488cdf0e10cSrcweir                         rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_X;
489cdf0e10cSrcweir                 }
490cdf0e10cSrcweir             }
491cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sMirroredY ) )
492cdf0e10cSrcweir             {
493cdf0e10cSrcweir                 sal_Bool bMirroredY = sal_Bool();
494cdf0e10cSrcweir                 if ( rPropVal.Value >>= bMirroredY )
495cdf0e10cSrcweir                 {
496cdf0e10cSrcweir                     if ( bMirroredY )
497cdf0e10cSrcweir                         rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_Y;
498cdf0e10cSrcweir                 }
499cdf0e10cSrcweir             }
500cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sSwitched ) )
501cdf0e10cSrcweir             {
502cdf0e10cSrcweir                 sal_Bool bSwitched = sal_Bool();
503cdf0e10cSrcweir                 if ( rPropVal.Value >>= bSwitched )
504cdf0e10cSrcweir                 {
505cdf0e10cSrcweir                     if ( bSwitched )
506cdf0e10cSrcweir                         rDestinationHandle.nFlags |= HANDLE_FLAGS_SWITCHED;
507cdf0e10cSrcweir                 }
508cdf0e10cSrcweir             }
509cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sPolar ) )
510cdf0e10cSrcweir             {
511cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.aPolar )
512cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_POLAR;
513cdf0e10cSrcweir             }
514cdf0e10cSrcweir /* seems not to be used.
515cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sMap ) )
516cdf0e10cSrcweir             {
517cdf0e10cSrcweir                 com::sun::star::drawing::EnhancedCustomShapeParameterPair aMap;
518cdf0e10cSrcweir                 if ( rPropVal.Value >>= aMap )
519cdf0e10cSrcweir                 {
520cdf0e10cSrcweir                     if ( GetValueForEnhancedCustomShapeHandleParameter( nXMap, aMap.First ) )
521cdf0e10cSrcweir                         rDestinationHandle.Flags |= 0x800;
522cdf0e10cSrcweir                     if ( GetValueForEnhancedCustomShapeHandleParameter( nYMap, aMap.Second ) )
523cdf0e10cSrcweir                         rDestinationHandle.Flags |= 0x1000;
524cdf0e10cSrcweir                     rDestinationHandle.Flags |= 0x10;
525cdf0e10cSrcweir                 }
526cdf0e10cSrcweir             }
527cdf0e10cSrcweir */
528cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRefX ) )
529cdf0e10cSrcweir             {
530cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.nRefX )
531cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_REFX;
532cdf0e10cSrcweir             }
533cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRefY ) )
534cdf0e10cSrcweir             {
535cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.nRefY )
536cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_REFY;
537cdf0e10cSrcweir             }
538cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRefAngle ) )
539cdf0e10cSrcweir             {
540cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.nRefAngle )
541cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_REFANGLE;
542cdf0e10cSrcweir             }
543cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRefR ) )
544cdf0e10cSrcweir             {
545cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.nRefR )
546cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_REFR;
547cdf0e10cSrcweir             }
548cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRadiusRangeMinimum ) )
549cdf0e10cSrcweir             {
550cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMinimum )
551cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MINIMUM;
552cdf0e10cSrcweir             }
553cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRadiusRangeMaximum ) )
554cdf0e10cSrcweir             {
555cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMaximum )
556cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM;
557cdf0e10cSrcweir             }
558cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRangeXMinimum ) )
559cdf0e10cSrcweir             {
560cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.aXRangeMinimum )
561cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MINIMUM;
562cdf0e10cSrcweir             }
563cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRangeXMaximum ) )
564cdf0e10cSrcweir             {
565cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.aXRangeMaximum )
566cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MAXIMUM;
567cdf0e10cSrcweir             }
568cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRangeYMinimum ) )
569cdf0e10cSrcweir             {
570cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.aYRangeMinimum )
571cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MINIMUM;
572cdf0e10cSrcweir             }
573cdf0e10cSrcweir             else if ( rPropVal.Name.equals( sRangeYMaximum ) )
574cdf0e10cSrcweir             {
575cdf0e10cSrcweir                 if ( rPropVal.Value >>= rDestinationHandle.aYRangeMaximum )
576cdf0e10cSrcweir                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MAXIMUM;
577cdf0e10cSrcweir             }
578cdf0e10cSrcweir         }
579cdf0e10cSrcweir     }
580cdf0e10cSrcweir     return bRetValue;
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
ApplyShapeAttributes(const SdrCustomShapeGeometryItem & rGeometryItem)583cdf0e10cSrcweir const sal_Int32* EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rGeometryItem )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir     const sal_Int32* pDefData = NULL;
586cdf0e10cSrcweir     const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
587cdf0e10cSrcweir     if ( pDefCustomShape )
588cdf0e10cSrcweir         pDefData = pDefCustomShape->pDefData;
589cdf0e10cSrcweir 
590cdf0e10cSrcweir     //////////////////////
591cdf0e10cSrcweir     // AdjustmentValues //
592cdf0e10cSrcweir     //////////////////////
593cdf0e10cSrcweir     const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
594cdf0e10cSrcweir     const Any* pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sAdjustmentValues );
595cdf0e10cSrcweir     if ( pAny )
596cdf0e10cSrcweir         *pAny >>= seqAdjustmentValues;
597cdf0e10cSrcweir 
598cdf0e10cSrcweir     ///////////////
599cdf0e10cSrcweir     // Coordsize //
600cdf0e10cSrcweir     ///////////////
601cdf0e10cSrcweir     const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
602cdf0e10cSrcweir     const Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sViewBox );
603cdf0e10cSrcweir     com::sun::star::awt::Rectangle aViewBox;
604cdf0e10cSrcweir     if ( pViewBox && (*pViewBox >>= aViewBox ) )
605cdf0e10cSrcweir     {
606cdf0e10cSrcweir         nCoordLeft  = aViewBox.X;
607cdf0e10cSrcweir         nCoordTop   = aViewBox.Y;
608cdf0e10cSrcweir         nCoordWidth = labs( aViewBox.Width );
609cdf0e10cSrcweir         nCoordHeight= labs( aViewBox.Height);
610cdf0e10cSrcweir     }
611cdf0e10cSrcweir     const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir     //////////////////////
614cdf0e10cSrcweir     // Path/Coordinates //
615cdf0e10cSrcweir     //////////////////////
616cdf0e10cSrcweir     const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
617cdf0e10cSrcweir     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
618cdf0e10cSrcweir     if ( pAny )
619cdf0e10cSrcweir         *pAny >>= seqCoordinates;
620cdf0e10cSrcweir 
621cdf0e10cSrcweir     /////////////////////
622cdf0e10cSrcweir     // Path/GluePoints //
623cdf0e10cSrcweir     /////////////////////
624cdf0e10cSrcweir     const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
625cdf0e10cSrcweir     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
626cdf0e10cSrcweir     if ( pAny )
627cdf0e10cSrcweir         *pAny >>= seqGluePoints;
628cdf0e10cSrcweir 
629cdf0e10cSrcweir     ///////////////////
630cdf0e10cSrcweir     // Path/Segments //
631cdf0e10cSrcweir     ///////////////////
632cdf0e10cSrcweir     const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
633cdf0e10cSrcweir     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sSegments );
634cdf0e10cSrcweir     if ( pAny )
635cdf0e10cSrcweir         *pAny >>= seqSegments;
636cdf0e10cSrcweir 
637cdf0e10cSrcweir     ///////////////////
638cdf0e10cSrcweir     // Path/StretchX //
639cdf0e10cSrcweir     ///////////////////
640cdf0e10cSrcweir     const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
641cdf0e10cSrcweir     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchX );
642cdf0e10cSrcweir     if ( pAny )
643cdf0e10cSrcweir     {
644cdf0e10cSrcweir         sal_Int32 nStretchX = 0;
645cdf0e10cSrcweir         if ( *pAny >>= nStretchX )
646cdf0e10cSrcweir             nXRef = nStretchX;
647cdf0e10cSrcweir     }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir     ///////////////////
650cdf0e10cSrcweir     // Path/StretchY //
651cdf0e10cSrcweir     ///////////////////
652cdf0e10cSrcweir     const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
653cdf0e10cSrcweir     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchY );
654cdf0e10cSrcweir     if ( pAny )
655cdf0e10cSrcweir     {
656cdf0e10cSrcweir         sal_Int32 nStretchY = 0;
657cdf0e10cSrcweir         if ( *pAny >>= nStretchY )
658cdf0e10cSrcweir             nYRef = nStretchY;
659cdf0e10cSrcweir     }
660cdf0e10cSrcweir 
661cdf0e10cSrcweir     /////////////////////
662cdf0e10cSrcweir     // Path/TextFrames //
663cdf0e10cSrcweir     /////////////////////
664cdf0e10cSrcweir     const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
665cdf0e10cSrcweir     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
666cdf0e10cSrcweir     if ( pAny )
667cdf0e10cSrcweir         *pAny >>= seqTextFrames;
668cdf0e10cSrcweir 
669cdf0e10cSrcweir     ///////////////
670cdf0e10cSrcweir     // Equations //
671cdf0e10cSrcweir     ///////////////
672cdf0e10cSrcweir     const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
673cdf0e10cSrcweir     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sEquations );
674cdf0e10cSrcweir     if ( pAny )
675cdf0e10cSrcweir         *pAny >>= seqEquations;
676cdf0e10cSrcweir 
677cdf0e10cSrcweir     /////////////
678cdf0e10cSrcweir     // Handles //
679cdf0e10cSrcweir     /////////////
680cdf0e10cSrcweir     const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
681cdf0e10cSrcweir     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sHandles );
682cdf0e10cSrcweir     if ( pAny )
683cdf0e10cSrcweir         *pAny >>= seqHandles;
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     return pDefData;
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
~EnhancedCustomShape2d()688cdf0e10cSrcweir EnhancedCustomShape2d::~EnhancedCustomShape2d()
689cdf0e10cSrcweir {
690cdf0e10cSrcweir }
691cdf0e10cSrcweir 
EnhancedCustomShape2d(SdrObject * pAObj)692cdf0e10cSrcweir EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
693cdf0e10cSrcweir     SfxItemSet          ( pAObj->GetMergedItemSet() ),
694cdf0e10cSrcweir     pCustomShapeObj     ( pAObj ),
695cdf0e10cSrcweir     eSpType             ( mso_sptNil ),
696cdf0e10cSrcweir     nCoordLeft          ( 0 ),
697cdf0e10cSrcweir     nCoordTop           ( 0 ),
698cdf0e10cSrcweir     nCoordWidth         ( 21600 ),
699cdf0e10cSrcweir     nCoordHeight        ( 21600 ),
700e5cfc9caSHerbert Dürr     nXRef               ( Mx80000000 ),
701e5cfc9caSHerbert Dürr     nYRef               ( Mx80000000 ),
702cdf0e10cSrcweir     nFlags              ( 0 ),
703cdf0e10cSrcweir     nColorData          ( 0 ),
704cdf0e10cSrcweir     bTextFlow           ( sal_False ),
705cdf0e10cSrcweir     bFilled             ( ((const XFillStyleItem&)pAObj->GetMergedItem( XATTR_FILLSTYLE )).GetValue() != XFILL_NONE ),
706cdf0e10cSrcweir     bStroked            ( ((const XLineStyleItem&)pAObj->GetMergedItem( XATTR_LINESTYLE )).GetValue() != XLINE_NONE ),
707cdf0e10cSrcweir     bFlipH              ( sal_False ),
708cdf0e10cSrcweir     bFlipV              ( sal_False )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir     // bTextFlow needs to be set before clearing the TextDirection Item
711cdf0e10cSrcweir 
712cdf0e10cSrcweir     ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created
713cdf0e10cSrcweir 
714*67f7bfb1SJohn Bampton     // #i105323# For 2D AtoShapes, the shadow attribute does not need to be applied to any
715*67f7bfb1SJohn Bampton     // of the constructed helper SdrObjects. This would lead to problems since the shadow
716cdf0e10cSrcweir     // of one helper object would fall on one helper object behind it (e.g. with the
717cdf0e10cSrcweir     // eyes of the smiley shape). This is not wanted; instead a single shadow 'behind'
718*67f7bfb1SJohn Bampton     // the AutoShape visualisation is wanted. This is done with primitive functionality
719cdf0e10cSrcweir     // now in SdrCustomShapePrimitive2D::create2DDecomposition, but only for 2D objects
720cdf0e10cSrcweir     // (see there and in EnhancedCustomShape3d::Create3DObject to read more).
721cdf0e10cSrcweir     // This exception may be removed later when AutoShapes will create primitives directly.
722cdf0e10cSrcweir     // So, currently remove the ShadowAttribute from the ItemSet to not apply it to any
723cdf0e10cSrcweir     // 2D helper shape.
724cdf0e10cSrcweir     ClearItem(SDRATTR_SHADOW);
725cdf0e10cSrcweir 
726cdf0e10cSrcweir     Point aP( pCustomShapeObj->GetSnapRect().Center() );
727cdf0e10cSrcweir     Size aS( pCustomShapeObj->GetLogicRect().GetSize() );
728cdf0e10cSrcweir     aP.X() -= aS.Width() / 2;
729cdf0e10cSrcweir     aP.Y() -= aS.Height() / 2;
730cdf0e10cSrcweir     aLogicRect = Rectangle( aP, aS );
731cdf0e10cSrcweir 
732cdf0e10cSrcweir     const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
733cdf0e10cSrcweir     const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
734cdf0e10cSrcweir     const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
735cdf0e10cSrcweir 
736cdf0e10cSrcweir     rtl::OUString sShapeType;
737cdf0e10cSrcweir     SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
738cdf0e10cSrcweir     Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
739cdf0e10cSrcweir     if ( pAny )
740cdf0e10cSrcweir         *pAny >>= sShapeType;
741cdf0e10cSrcweir     eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
742cdf0e10cSrcweir 
743cdf0e10cSrcweir     pAny = rGeometryItem.GetPropertyValueByName( sMirroredX );
744cdf0e10cSrcweir     if ( pAny )
745cdf0e10cSrcweir         *pAny >>= bFlipH;
746cdf0e10cSrcweir     pAny = rGeometryItem.GetPropertyValueByName( sMirroredY );
747cdf0e10cSrcweir     if ( pAny )
748cdf0e10cSrcweir         *pAny >>= bFlipV;
749cdf0e10cSrcweir 
750cdf0e10cSrcweir     if ( pCustomShapeObj->ISA( SdrObjCustomShape ) )    // should always be a SdrObjCustomShape, but you don't know
751cdf0e10cSrcweir         nRotateAngle = (sal_Int32)(((SdrObjCustomShape*)pCustomShapeObj)->GetObjectRotation() * 100.0);
752cdf0e10cSrcweir     else
753cdf0e10cSrcweir         nRotateAngle = pCustomShapeObj->GetRotateAngle();
754cdf0e10cSrcweir 
755cdf0e10cSrcweir     /*const sal_Int32* pDefData =*/ ApplyShapeAttributes( rGeometryItem );
756cdf0e10cSrcweir     switch( eSpType )
757cdf0e10cSrcweir     {
758cdf0e10cSrcweir         case mso_sptCan :                       nColorData = 0x20400000; break;
759cdf0e10cSrcweir         case mso_sptCube :                      nColorData = 0x302e0000; break;
760cdf0e10cSrcweir         case mso_sptActionButtonBlank :         nColorData = 0x502ce400; break;
761cdf0e10cSrcweir         case mso_sptActionButtonHome :          nColorData = 0x702ce4ce; break;
762cdf0e10cSrcweir         case mso_sptActionButtonHelp :          nColorData = 0x602ce4c0; break;
763cdf0e10cSrcweir         case mso_sptActionButtonInformation :   nColorData = 0x702ce4c5; break;
764cdf0e10cSrcweir         case mso_sptActionButtonBackPrevious :  nColorData = 0x602ce4c0; break;
765cdf0e10cSrcweir         case mso_sptActionButtonForwardNext :   nColorData = 0x602ce4c0; break;
766cdf0e10cSrcweir         case mso_sptActionButtonBeginning :     nColorData = 0x602ce4c0; break;
767cdf0e10cSrcweir         case mso_sptActionButtonEnd :           nColorData = 0x602ce4c0; break;
768cdf0e10cSrcweir         case mso_sptActionButtonReturn :        nColorData = 0x602ce4c0; break;
769cdf0e10cSrcweir         case mso_sptActionButtonDocument :      nColorData = 0x702ce4ec; break;
770cdf0e10cSrcweir         case mso_sptActionButtonSound :         nColorData = 0x602ce4c0; break;
771cdf0e10cSrcweir         case mso_sptActionButtonMovie :         nColorData = 0x602ce4c0; break;
772cdf0e10cSrcweir         case mso_sptBevel :                     nColorData = 0x502ce400; break;
773cdf0e10cSrcweir         case mso_sptFoldedCorner :              nColorData = 0x20e00000; break;
774cdf0e10cSrcweir         case mso_sptSmileyFace :                nColorData = 0x20e00000; break;
775cdf0e10cSrcweir         case mso_sptNil :
776cdf0e10cSrcweir         {
777cdf0e10cSrcweir             if( sShapeType.getLength() > 4 &&
778cdf0e10cSrcweir                 sShapeType.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "col-" )))
779cdf0e10cSrcweir             {
780cdf0e10cSrcweir                 nColorData = sShapeType.copy( 4 ).toInt32( 16 );
781cdf0e10cSrcweir             }
782cdf0e10cSrcweir         }
783cdf0e10cSrcweir         break;
784cdf0e10cSrcweir         case mso_sptCurvedLeftArrow :
785cdf0e10cSrcweir         case mso_sptCurvedRightArrow :
786cdf0e10cSrcweir         case mso_sptCurvedUpArrow :
787cdf0e10cSrcweir         case mso_sptCurvedDownArrow :           nColorData = 0x20d00000; break;
788cdf0e10cSrcweir         case mso_sptRibbon2 :                   nColorData = 0x30ee0000; break;
789cdf0e10cSrcweir         case mso_sptRibbon :                    nColorData = 0x30ee0000; break;
790cdf0e10cSrcweir 
791cdf0e10cSrcweir         case mso_sptEllipseRibbon2 :            nColorData = 0x30ee0000; break;
792cdf0e10cSrcweir         case mso_sptEllipseRibbon :             nColorData = 0x30ee0000; break;
793cdf0e10cSrcweir 
794cdf0e10cSrcweir         case mso_sptVerticalScroll :            nColorData = 0x30ee0000; break;
795cdf0e10cSrcweir         case mso_sptHorizontalScroll :          nColorData = 0x30ee0000; break;
796cdf0e10cSrcweir         default:
797cdf0e10cSrcweir             break;
798cdf0e10cSrcweir     }
799cdf0e10cSrcweir     fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth;
800cdf0e10cSrcweir     fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight;
801e5cfc9caSHerbert Dürr     if( (nXRef != Mx80000000) && aLogicRect.GetHeight() )
802cdf0e10cSrcweir     {
803cdf0e10cSrcweir         fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight();
804cdf0e10cSrcweir         if ( fXRatio > 1 )
805cdf0e10cSrcweir             fXScale /= fXRatio;
806cdf0e10cSrcweir         else
807cdf0e10cSrcweir             fXRatio = 1.0;
808cdf0e10cSrcweir     }
809cdf0e10cSrcweir     else
810cdf0e10cSrcweir         fXRatio = 1.0;
811e5cfc9caSHerbert Dürr     if( (nYRef != Mx80000000) && aLogicRect.GetWidth() )
812cdf0e10cSrcweir     {
813cdf0e10cSrcweir         fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth();
814cdf0e10cSrcweir         if ( fYRatio > 1 )
815cdf0e10cSrcweir             fYScale /= fYRatio;
816cdf0e10cSrcweir         else
817cdf0e10cSrcweir             fYRatio = 1.0;
818cdf0e10cSrcweir     }
819cdf0e10cSrcweir     else
820cdf0e10cSrcweir         fYRatio = 1.0;
821cdf0e10cSrcweir 
822cdf0e10cSrcweir     sal_Int32 i, nLength = seqEquations.getLength();
823cdf0e10cSrcweir 
824cdf0e10cSrcweir 
825cdf0e10cSrcweir     if ( nLength )
826cdf0e10cSrcweir     {
827cdf0e10cSrcweir         vNodesSharedPtr.resize( nLength );
828cdf0e10cSrcweir         for ( i = 0; i < seqEquations.getLength(); i++ )
829cdf0e10cSrcweir         {
830cdf0e10cSrcweir             try
831cdf0e10cSrcweir             {
832cdf0e10cSrcweir                 vNodesSharedPtr[ i ] = EnhancedCustomShape::FunctionParser::parseFunction( seqEquations[ i ], *this );
833cdf0e10cSrcweir             }
834cdf0e10cSrcweir             catch ( EnhancedCustomShape::ParseError& )
835cdf0e10cSrcweir             {
836cdf0e10cSrcweir             }
837cdf0e10cSrcweir         }
838cdf0e10cSrcweir     }
839cdf0e10cSrcweir }
GetEnumFunc(const EnumFunc eFunc) const840cdf0e10cSrcweir double EnhancedCustomShape2d::GetEnumFunc( const EnumFunc eFunc ) const
841cdf0e10cSrcweir {
842cdf0e10cSrcweir     double fRet = 0.0;
843cdf0e10cSrcweir     switch( eFunc )
844cdf0e10cSrcweir     {
845cdf0e10cSrcweir         case ENUM_FUNC_PI :         fRet = F_PI; break;
846cdf0e10cSrcweir         case ENUM_FUNC_LEFT :       fRet = 0.0; break;
847cdf0e10cSrcweir         case ENUM_FUNC_TOP :        fRet = 0.0; break;
848cdf0e10cSrcweir         case ENUM_FUNC_RIGHT :      fRet = (double)nCoordWidth * fXRatio;   break;
849cdf0e10cSrcweir         case ENUM_FUNC_BOTTOM :     fRet = (double)nCoordHeight * fYRatio; break;
850cdf0e10cSrcweir         case ENUM_FUNC_XSTRETCH :   fRet = nXRef; break;
851cdf0e10cSrcweir         case ENUM_FUNC_YSTRETCH :   fRet = nYRef; break;
852cdf0e10cSrcweir         case ENUM_FUNC_HASSTROKE :  fRet = bStroked ? 1.0 : 0.0; break;
853cdf0e10cSrcweir         case ENUM_FUNC_HASFILL :    fRet = bFilled ? 1.0 : 0.0; break;
854cdf0e10cSrcweir         case ENUM_FUNC_WIDTH :      fRet = nCoordWidth; break;
855cdf0e10cSrcweir         case ENUM_FUNC_HEIGHT :     fRet = nCoordHeight; break;
856cdf0e10cSrcweir         case ENUM_FUNC_LOGWIDTH :   fRet = aLogicRect.GetWidth(); break;
857cdf0e10cSrcweir         case ENUM_FUNC_LOGHEIGHT :  fRet = aLogicRect.GetHeight(); break;
858cdf0e10cSrcweir     }
859cdf0e10cSrcweir     return fRet;
860cdf0e10cSrcweir }
GetAdjustValueAsDouble(const sal_Int32 nIndex) const861cdf0e10cSrcweir double EnhancedCustomShape2d::GetAdjustValueAsDouble( const sal_Int32 nIndex ) const
862cdf0e10cSrcweir {
863cdf0e10cSrcweir     double fNumber = 0.0;
864cdf0e10cSrcweir     if ( nIndex < seqAdjustmentValues.getLength() )
865cdf0e10cSrcweir     {
866cdf0e10cSrcweir         if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE )
867cdf0e10cSrcweir             seqAdjustmentValues[ nIndex ].Value >>= fNumber;
868cdf0e10cSrcweir         else
869cdf0e10cSrcweir         {
870cdf0e10cSrcweir             sal_Int32 nNumber = 0;
871cdf0e10cSrcweir             seqAdjustmentValues[ nIndex ].Value >>= nNumber;
872cdf0e10cSrcweir             fNumber = (double)nNumber;
873cdf0e10cSrcweir         }
874cdf0e10cSrcweir     }
875cdf0e10cSrcweir     return fNumber;
876cdf0e10cSrcweir }
GetEquationValueAsDouble(const sal_Int32 nIndex) const877cdf0e10cSrcweir double EnhancedCustomShape2d::GetEquationValueAsDouble( const sal_Int32 nIndex ) const
878cdf0e10cSrcweir {
879cdf0e10cSrcweir     double fNumber = 0.0;
880cdf0e10cSrcweir     if ( nIndex < (sal_Int32)vNodesSharedPtr.size() )
881cdf0e10cSrcweir     {
882cdf0e10cSrcweir         if ( vNodesSharedPtr[ nIndex ].get() )
883cdf0e10cSrcweir         try
884cdf0e10cSrcweir         {
885cdf0e10cSrcweir             fNumber = (*vNodesSharedPtr[ nIndex ])();
886cdf0e10cSrcweir             if ( !rtl::math::isFinite( fNumber ) )
887cdf0e10cSrcweir                 fNumber = 0.0;
888cdf0e10cSrcweir         }
889cdf0e10cSrcweir         catch ( ... )
890cdf0e10cSrcweir         {
891cdf0e10cSrcweir             /* sal_Bool bUps = sal_True; */
892cdf0e10cSrcweir         }
893cdf0e10cSrcweir     }
894cdf0e10cSrcweir     return fNumber;
895cdf0e10cSrcweir }
GetAdjustValueAsInteger(const sal_Int32 nIndex,const sal_Int32 nDefault) const896cdf0e10cSrcweir sal_Int32 EnhancedCustomShape2d::GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault ) const
897cdf0e10cSrcweir {
898cdf0e10cSrcweir     sal_Int32 nNumber = nDefault;
899cdf0e10cSrcweir     if ( nIndex < seqAdjustmentValues.getLength() )
900cdf0e10cSrcweir     {
901cdf0e10cSrcweir         if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE )
902cdf0e10cSrcweir         {
903cdf0e10cSrcweir             double fNumber = 0;
904cdf0e10cSrcweir             seqAdjustmentValues[ nIndex ].Value >>= fNumber;
905cdf0e10cSrcweir             nNumber = (sal_Int32)fNumber;
906cdf0e10cSrcweir         }
907cdf0e10cSrcweir         else
908cdf0e10cSrcweir             seqAdjustmentValues[ nIndex ].Value >>= nNumber;
909cdf0e10cSrcweir     }
910cdf0e10cSrcweir     return nNumber;
911cdf0e10cSrcweir }
SetAdjustValueAsDouble(const double & rValue,const sal_Int32 nIndex)912cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex )
913cdf0e10cSrcweir {
914cdf0e10cSrcweir     sal_Bool bRetValue = sal_False;
915cdf0e10cSrcweir     if ( nIndex < seqAdjustmentValues.getLength() )
916cdf0e10cSrcweir     {
917cdf0e10cSrcweir         // updating our local adjustment sequence
918cdf0e10cSrcweir         seqAdjustmentValues[ nIndex ].Value <<= rValue;
919cdf0e10cSrcweir         seqAdjustmentValues[ nIndex ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
920cdf0e10cSrcweir         bRetValue = sal_True;
921cdf0e10cSrcweir     }
922cdf0e10cSrcweir     return bRetValue;
923cdf0e10cSrcweir }
924cdf0e10cSrcweir 
GetPoint(const com::sun::star::drawing::EnhancedCustomShapeParameterPair & rPair,const sal_Bool bScale,const sal_Bool bReplaceGeoSize) const925cdf0e10cSrcweir Point EnhancedCustomShape2d::GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair& rPair,
926cdf0e10cSrcweir                                         const sal_Bool bScale, const sal_Bool bReplaceGeoSize ) const
927cdf0e10cSrcweir {
928cdf0e10cSrcweir     Point       aRetValue;
929cdf0e10cSrcweir     sal_Bool    bExchange = ( nFlags & DFF_CUSTOMSHAPE_EXCH ) != 0; // x <-> y
930cdf0e10cSrcweir     sal_uInt32  nPass = 0;
931cdf0e10cSrcweir     do
932cdf0e10cSrcweir     {
933cdf0e10cSrcweir         sal_uInt32  nIndex = nPass;
934cdf0e10cSrcweir 
935cdf0e10cSrcweir         if ( bExchange )
936cdf0e10cSrcweir             nIndex ^= 1;
937cdf0e10cSrcweir 
938cdf0e10cSrcweir         double      fVal;
939cdf0e10cSrcweir         const EnhancedCustomShapeParameter& rParameter = nIndex ? rPair.Second : rPair.First;
940cdf0e10cSrcweir         if ( nPass )    // height
941cdf0e10cSrcweir         {
942cdf0e10cSrcweir             GetParameter( fVal, rParameter, sal_False, bReplaceGeoSize );
943cdf0e10cSrcweir             fVal -= nCoordTop;
944cdf0e10cSrcweir             if ( bScale )
945cdf0e10cSrcweir             {
946cdf0e10cSrcweir                 fVal *= fYScale;
947cdf0e10cSrcweir 
948cdf0e10cSrcweir                 if ( nFlags & DFF_CUSTOMSHAPE_FLIP_V )
949cdf0e10cSrcweir                     fVal = aLogicRect.GetHeight() - fVal;
950cdf0e10cSrcweir             }
951cdf0e10cSrcweir             aRetValue.Y() = (sal_Int32)fVal;
952cdf0e10cSrcweir         }
953cdf0e10cSrcweir         else            // width
954cdf0e10cSrcweir         {
955cdf0e10cSrcweir             GetParameter( fVal, rParameter, bReplaceGeoSize, sal_False );
956cdf0e10cSrcweir             fVal -= nCoordLeft;
957cdf0e10cSrcweir             if ( bScale )
958cdf0e10cSrcweir             {
959cdf0e10cSrcweir                 fVal *= fXScale;
960cdf0e10cSrcweir 
961cdf0e10cSrcweir                 if ( nFlags & DFF_CUSTOMSHAPE_FLIP_H )
962cdf0e10cSrcweir                     fVal = aLogicRect.GetWidth() - fVal;
963cdf0e10cSrcweir             }
964cdf0e10cSrcweir             aRetValue.X() = (sal_Int32)fVal;
965cdf0e10cSrcweir         }
966cdf0e10cSrcweir     }
967cdf0e10cSrcweir     while ( ++nPass < 2 );
968cdf0e10cSrcweir     return aRetValue;
969cdf0e10cSrcweir }
970cdf0e10cSrcweir 
GetParameter(double & rRetValue,const EnhancedCustomShapeParameter & rParameter,const sal_Bool bReplaceGeoWidth,const sal_Bool bReplaceGeoHeight) const971cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::GetParameter( double& rRetValue, const EnhancedCustomShapeParameter& rParameter,
972cdf0e10cSrcweir                                                 const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const
973cdf0e10cSrcweir {
974cdf0e10cSrcweir     rRetValue = 0.0;
975cdf0e10cSrcweir     sal_Bool bRetValue = sal_False;
976cdf0e10cSrcweir     switch ( rParameter.Type )
977cdf0e10cSrcweir     {
978cdf0e10cSrcweir         case EnhancedCustomShapeParameterType::ADJUSTMENT :
979cdf0e10cSrcweir         {
980cdf0e10cSrcweir             sal_Int32 nAdjustmentIndex = 0;
981cdf0e10cSrcweir             if ( rParameter.Value >>= nAdjustmentIndex )
982cdf0e10cSrcweir             {
983cdf0e10cSrcweir                 rRetValue = GetAdjustValueAsDouble( nAdjustmentIndex );
984cdf0e10cSrcweir                 bRetValue = sal_True;
985cdf0e10cSrcweir             }
986cdf0e10cSrcweir         }
987cdf0e10cSrcweir         break;
988cdf0e10cSrcweir         case EnhancedCustomShapeParameterType::EQUATION :
989cdf0e10cSrcweir         {
990cdf0e10cSrcweir             sal_Int32 nEquationIndex = 0;
991cdf0e10cSrcweir             if ( rParameter.Value >>= nEquationIndex )
992cdf0e10cSrcweir             {
993cdf0e10cSrcweir                 rRetValue = GetEquationValueAsDouble( nEquationIndex );
994cdf0e10cSrcweir                 bRetValue = sal_True;
995cdf0e10cSrcweir             }
996cdf0e10cSrcweir         }
997cdf0e10cSrcweir         break;
998cdf0e10cSrcweir         case EnhancedCustomShapeParameterType::NORMAL :
999cdf0e10cSrcweir         {
1000cdf0e10cSrcweir             if ( rParameter.Value.getValueTypeClass() == TypeClass_DOUBLE )
1001cdf0e10cSrcweir             {
1002cdf0e10cSrcweir                 double fValue;
1003cdf0e10cSrcweir                 if ( rParameter.Value >>= fValue )
1004cdf0e10cSrcweir                 {
1005cdf0e10cSrcweir                     rRetValue = fValue;
1006cdf0e10cSrcweir                     bRetValue = sal_True;
1007cdf0e10cSrcweir                 }
1008cdf0e10cSrcweir             }
1009cdf0e10cSrcweir             else
1010cdf0e10cSrcweir             {
1011cdf0e10cSrcweir                 sal_Int32 nValue = 0;
1012cdf0e10cSrcweir                 if ( rParameter.Value >>= nValue )
1013cdf0e10cSrcweir                 {
1014cdf0e10cSrcweir                     rRetValue = nValue;
1015cdf0e10cSrcweir                     bRetValue = sal_True;
1016cdf0e10cSrcweir                     if ( bReplaceGeoWidth && ( nValue == nCoordWidth ) )
1017cdf0e10cSrcweir                         rRetValue *= fXRatio;
1018cdf0e10cSrcweir                     else if ( bReplaceGeoHeight && ( nValue == nCoordHeight ) )
1019cdf0e10cSrcweir                         rRetValue *= fYRatio;
1020cdf0e10cSrcweir                 }
1021cdf0e10cSrcweir             }
1022cdf0e10cSrcweir         }
1023cdf0e10cSrcweir         break;
1024cdf0e10cSrcweir         case EnhancedCustomShapeParameterType::LEFT :
1025cdf0e10cSrcweir         {
1026cdf0e10cSrcweir             rRetValue  = 0.0;
1027cdf0e10cSrcweir             bRetValue = sal_True;
1028cdf0e10cSrcweir         }
1029cdf0e10cSrcweir         break;
1030cdf0e10cSrcweir         case EnhancedCustomShapeParameterType::TOP :
1031cdf0e10cSrcweir         {
1032cdf0e10cSrcweir             rRetValue  = 0.0;
1033cdf0e10cSrcweir             bRetValue = sal_True;
1034cdf0e10cSrcweir         }
1035cdf0e10cSrcweir         break;
1036cdf0e10cSrcweir         case EnhancedCustomShapeParameterType::RIGHT :
1037cdf0e10cSrcweir         {
1038cdf0e10cSrcweir             rRetValue = nCoordWidth;
1039cdf0e10cSrcweir             bRetValue = sal_True;
1040cdf0e10cSrcweir         }
1041cdf0e10cSrcweir         break;
1042cdf0e10cSrcweir         case EnhancedCustomShapeParameterType::BOTTOM :
1043cdf0e10cSrcweir         {
1044cdf0e10cSrcweir             rRetValue = nCoordHeight;
1045cdf0e10cSrcweir             bRetValue = sal_True;
1046cdf0e10cSrcweir         }
1047cdf0e10cSrcweir         break;
1048cdf0e10cSrcweir     }
1049cdf0e10cSrcweir     return bRetValue;
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir // nLumDat 28-31 = number of luminance entries in nLumDat
1053cdf0e10cSrcweir // nLumDat 27-24 = nLumDatEntry 0
1054cdf0e10cSrcweir // nLumDat 23-20 = nLumDatEntry 1 ...
1055cdf0e10cSrcweir // each 4bit entry is to be interpreted as a 10 percent signed luminance changing
GetLuminanceChange(sal_uInt32 nIndex) const1056cdf0e10cSrcweir sal_Int32 EnhancedCustomShape2d::GetLuminanceChange( sal_uInt32 nIndex ) const
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir     const sal_uInt32 nCount = nColorData >> 28;
1059cdf0e10cSrcweir     if ( !nCount )
1060cdf0e10cSrcweir         return 0;
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir     if ( nIndex >= nCount )
1063cdf0e10cSrcweir         nIndex = nCount - 1;
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir     const sal_Int32 nLumDat = nColorData << ( ( 1 + nIndex ) << 2 );
1066cdf0e10cSrcweir     return ( nLumDat >> 28 ) * 10;
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir 
GetColorData(const Color & rFillColor,sal_uInt32 nIndex) const1069cdf0e10cSrcweir Color EnhancedCustomShape2d::GetColorData( const Color& rFillColor, sal_uInt32 nIndex ) const
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir     const sal_Int32 nLuminance = GetLuminanceChange(nIndex);
1072cdf0e10cSrcweir     if( !nLuminance )
1073cdf0e10cSrcweir         return rFillColor;
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir     basegfx::BColor aHSVColor=
1076cdf0e10cSrcweir         basegfx::tools::rgb2hsv(
1077cdf0e10cSrcweir             basegfx::BColor(rFillColor.GetRed()/255.0,
1078cdf0e10cSrcweir                             rFillColor.GetGreen()/255.0,
1079cdf0e10cSrcweir                             rFillColor.GetBlue()/255.0));
1080cdf0e10cSrcweir     if( nLuminance > 0 )
1081cdf0e10cSrcweir     {
1082cdf0e10cSrcweir         aHSVColor.setGreen(
1083cdf0e10cSrcweir             aHSVColor.getGreen() * (1.0-nLuminance/100.0));
1084cdf0e10cSrcweir         aHSVColor.setBlue(
1085cdf0e10cSrcweir             nLuminance/100.0 +
1086cdf0e10cSrcweir             (1.0-nLuminance/100.0)*aHSVColor.getBlue());
1087cdf0e10cSrcweir     }
1088cdf0e10cSrcweir     else if( nLuminance < 0 )
1089cdf0e10cSrcweir     {
1090cdf0e10cSrcweir         aHSVColor.setBlue(
1091cdf0e10cSrcweir             (1.0+nLuminance/100.0)*aHSVColor.getBlue());
1092cdf0e10cSrcweir     }
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir     aHSVColor = basegfx::tools::hsv2rgb(aHSVColor);
1095cdf0e10cSrcweir     return Color( (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getRed(),0.0,1.0) * 255.0 + 0.5 ),
1096cdf0e10cSrcweir                   (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getGreen(),0.0,1.0) * 255.0 + 0.5 ),
1097cdf0e10cSrcweir                   (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getBlue(),0.0,1.0) * 255.0 + 0.5 ) );
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir 
GetTextRect() const1100cdf0e10cSrcweir Rectangle EnhancedCustomShape2d::GetTextRect() const
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir     sal_Int32 nIndex, nSize = seqTextFrames.getLength();
1103cdf0e10cSrcweir     if ( !nSize )
1104cdf0e10cSrcweir         return aLogicRect;
1105cdf0e10cSrcweir     nIndex = 0;
1106cdf0e10cSrcweir     if ( bTextFlow && ( nSize > 1 ) )
1107cdf0e10cSrcweir         nIndex++;
1108cdf0e10cSrcweir     Point aTopLeft( GetPoint( seqTextFrames[ nIndex ].TopLeft, sal_True, sal_True ) );
1109cdf0e10cSrcweir     Point aBottomRight( GetPoint( seqTextFrames[ nIndex ].BottomRight, sal_True, sal_True ) );
1110cdf0e10cSrcweir     if ( bFlipH )
1111cdf0e10cSrcweir     {
1112cdf0e10cSrcweir         aTopLeft.X() = aLogicRect.GetWidth() - aTopLeft.X();
1113cdf0e10cSrcweir         aBottomRight.X() = aLogicRect.GetWidth() - aBottomRight.X();
1114cdf0e10cSrcweir     }
1115cdf0e10cSrcweir     if ( bFlipV )
1116cdf0e10cSrcweir     {
1117cdf0e10cSrcweir         aTopLeft.Y() = aLogicRect.GetHeight() - aTopLeft.Y();
1118cdf0e10cSrcweir         aBottomRight.Y() = aLogicRect.GetHeight() - aBottomRight.Y();
1119cdf0e10cSrcweir     }
1120cdf0e10cSrcweir     Rectangle aRect( aTopLeft, aBottomRight );
1121cdf0e10cSrcweir     aRect.Move( aLogicRect.Left(), aLogicRect.Top() );
1122cdf0e10cSrcweir     aRect.Justify();
1123cdf0e10cSrcweir     return aRect;
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir 
GetHdlCount() const1126cdf0e10cSrcweir sal_uInt32 EnhancedCustomShape2d::GetHdlCount() const
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir     return seqHandles.getLength();
1129cdf0e10cSrcweir }
1130cdf0e10cSrcweir 
GetHandlePosition(const sal_uInt32 nIndex,Point & rReturnPosition) const1131cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const
1132cdf0e10cSrcweir {
1133cdf0e10cSrcweir     sal_Bool bRetValue = sal_False;
1134cdf0e10cSrcweir     if ( nIndex < GetHdlCount() )
1135cdf0e10cSrcweir     {
1136cdf0e10cSrcweir         Handle aHandle;
1137cdf0e10cSrcweir         if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
1138cdf0e10cSrcweir         {
1139cdf0e10cSrcweir             if ( aHandle.nFlags & HANDLE_FLAGS_POLAR )
1140cdf0e10cSrcweir             {
1141cdf0e10cSrcweir                 Point aReferencePoint( GetPoint( aHandle.aPolar, sal_True, sal_False ) );
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir                 double      fAngle;
1144cdf0e10cSrcweir                 double      fRadius;
1145cdf0e10cSrcweir                 GetParameter( fRadius, aHandle.aPosition.First, sal_False, sal_False );
1146cdf0e10cSrcweir                 GetParameter( fAngle,  aHandle.aPosition.Second, sal_False, sal_False );
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir                 double a = ( 360.0 - fAngle ) * F_PI180;
1149cdf0e10cSrcweir                 double dx = fRadius * fXScale;
1150cdf0e10cSrcweir                 double fX = dx * cos( a );
1151cdf0e10cSrcweir                 double fY =-dx * sin( a );
1152cdf0e10cSrcweir                 rReturnPosition =
1153cdf0e10cSrcweir                     Point(
1154cdf0e10cSrcweir                         Round( fX + aReferencePoint.X() ),
1155cdf0e10cSrcweir                         basegfx::fTools::equalZero(fXScale) ? aReferencePoint.Y() :
1156cdf0e10cSrcweir                         Round( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) );
1157cdf0e10cSrcweir             }
1158cdf0e10cSrcweir             else
1159cdf0e10cSrcweir             {
1160cdf0e10cSrcweir                 if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED )
1161cdf0e10cSrcweir                 {
1162cdf0e10cSrcweir                     if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
1163cdf0e10cSrcweir                     {
1164cdf0e10cSrcweir                         com::sun::star::drawing::EnhancedCustomShapeParameter aFirst = aHandle.aPosition.First;
1165cdf0e10cSrcweir                         com::sun::star::drawing::EnhancedCustomShapeParameter aSecond = aHandle.aPosition.Second;
1166cdf0e10cSrcweir                         aHandle.aPosition.First = aSecond;
1167cdf0e10cSrcweir                         aHandle.aPosition.Second = aFirst;
1168cdf0e10cSrcweir                     }
1169cdf0e10cSrcweir                 }
1170cdf0e10cSrcweir                 rReturnPosition = GetPoint( aHandle.aPosition, sal_True, sal_False );
1171cdf0e10cSrcweir             }
1172cdf0e10cSrcweir             const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() );
1173cdf0e10cSrcweir             if ( aGeoStat.nShearWink )
1174cdf0e10cSrcweir             {
1175cdf0e10cSrcweir                 double nTan = aGeoStat.nTan;
1176cdf0e10cSrcweir                 if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
1177cdf0e10cSrcweir                     nTan = -nTan;
1178cdf0e10cSrcweir                 ShearPoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
1179cdf0e10cSrcweir             }
1180cdf0e10cSrcweir             if ( nRotateAngle )
1181cdf0e10cSrcweir             {
1182cdf0e10cSrcweir                 double a = nRotateAngle * F_PI18000;
1183cdf0e10cSrcweir                 RotatePoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
1184cdf0e10cSrcweir             }
1185cdf0e10cSrcweir             if ( bFlipH )
1186cdf0e10cSrcweir                 rReturnPosition.X() = aLogicRect.GetWidth() - rReturnPosition.X();
1187cdf0e10cSrcweir             if ( bFlipV )
1188cdf0e10cSrcweir                 rReturnPosition.Y() = aLogicRect.GetHeight() - rReturnPosition.Y();
1189cdf0e10cSrcweir             rReturnPosition.Move( aLogicRect.Left(), aLogicRect.Top() );
1190cdf0e10cSrcweir             bRetValue = sal_True;
1191cdf0e10cSrcweir         }
1192cdf0e10cSrcweir     }
1193cdf0e10cSrcweir     return bRetValue;
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir 
SetHandleControllerPosition(const sal_uInt32 nIndex,const com::sun::star::awt::Point & rPosition)1196cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition )
1197cdf0e10cSrcweir {
1198cdf0e10cSrcweir     sal_Bool bRetValue = sal_False;
1199cdf0e10cSrcweir     if ( nIndex < GetHdlCount() )
1200cdf0e10cSrcweir     {
1201cdf0e10cSrcweir         Handle aHandle;
1202cdf0e10cSrcweir         if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
1203cdf0e10cSrcweir         {
1204cdf0e10cSrcweir             Point aP( rPosition.X, rPosition.Y );
1205cdf0e10cSrcweir             // apply the negative object rotation to the controller position
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir             aP.Move( -aLogicRect.Left(), -aLogicRect.Top() );
1208cdf0e10cSrcweir             if ( bFlipH )
1209cdf0e10cSrcweir                 aP.X() = aLogicRect.GetWidth() - aP.X();
1210cdf0e10cSrcweir             if ( bFlipV )
1211cdf0e10cSrcweir                 aP.Y() = aLogicRect.GetHeight() - aP.Y();
1212cdf0e10cSrcweir             if ( nRotateAngle )
1213cdf0e10cSrcweir             {
1214cdf0e10cSrcweir                 double a = -nRotateAngle * F_PI18000;
1215cdf0e10cSrcweir                 RotatePoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
1216cdf0e10cSrcweir             }
1217cdf0e10cSrcweir             const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() );
1218cdf0e10cSrcweir             if ( aGeoStat.nShearWink )
1219cdf0e10cSrcweir             {
1220cdf0e10cSrcweir                 double nTan = -aGeoStat.nTan;
1221cdf0e10cSrcweir                 if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
1222cdf0e10cSrcweir                     nTan = -nTan;
1223cdf0e10cSrcweir                 ShearPoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
1224cdf0e10cSrcweir             }
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir             double fPos1 = aP.X();  //( bFlipH ) ? aLogicRect.GetWidth() - aP.X() : aP.X();
1227cdf0e10cSrcweir             double fPos2 = aP.Y();  //( bFlipV ) ? aLogicRect.GetHeight() -aP.Y() : aP.Y();
1228cdf0e10cSrcweir             fPos1 /= fXScale;
1229cdf0e10cSrcweir             fPos2 /= fYScale;
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir             if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED )
1232cdf0e10cSrcweir             {
1233cdf0e10cSrcweir                 if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
1234cdf0e10cSrcweir                 {
1235cdf0e10cSrcweir                     double fX = fPos1;
1236cdf0e10cSrcweir                     double fY = fPos2;
1237cdf0e10cSrcweir                     fPos1 = fY;
1238cdf0e10cSrcweir                     fPos2 = fX;
1239cdf0e10cSrcweir                 }
1240cdf0e10cSrcweir             }
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir             sal_Int32 nFirstAdjustmentValue = -1, nSecondAdjustmentValue = -1;
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir             if ( aHandle.aPosition.First.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
1245cdf0e10cSrcweir                 aHandle.aPosition.First.Value >>= nFirstAdjustmentValue;
1246cdf0e10cSrcweir             if ( aHandle.aPosition.Second.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
1247cdf0e10cSrcweir                 aHandle.aPosition.Second.Value>>= nSecondAdjustmentValue;
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir             if ( aHandle.nFlags & HANDLE_FLAGS_POLAR )
1250cdf0e10cSrcweir             {
1251cdf0e10cSrcweir                 double fXRef, fYRef, fAngle;
1252cdf0e10cSrcweir                 GetParameter( fXRef, aHandle.aPolar.First, sal_False, sal_False );
1253cdf0e10cSrcweir                 GetParameter( fYRef, aHandle.aPolar.Second, sal_False, sal_False );
1254cdf0e10cSrcweir                 const double fDX = fPos1 - fXRef;
1255cdf0e10cSrcweir                 fAngle = -( atan2( -fPos2 + fYRef, ( ( fDX == 0.0L ) ? 0.000000001 : fDX ) ) / F_PI180 );
1256cdf0e10cSrcweir                 double fX = ( fPos1 - fXRef );
1257cdf0e10cSrcweir                 double fY = ( fPos2 - fYRef );
1258cdf0e10cSrcweir                 double fRadius = sqrt( fX * fX + fY * fY );
1259cdf0e10cSrcweir                 if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MINIMUM )
1260cdf0e10cSrcweir                 {
1261cdf0e10cSrcweir                     double fMin;
1262cdf0e10cSrcweir                     GetParameter( fMin,  aHandle.aRadiusRangeMinimum, sal_False, sal_False );
1263cdf0e10cSrcweir                     if ( fRadius < fMin )
1264cdf0e10cSrcweir                         fRadius = fMin;
1265cdf0e10cSrcweir                 }
1266cdf0e10cSrcweir                 if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM )
1267cdf0e10cSrcweir                 {
1268cdf0e10cSrcweir                     double fMax;
1269cdf0e10cSrcweir                     GetParameter( fMax, aHandle.aRadiusRangeMaximum, sal_False, sal_False );
1270cdf0e10cSrcweir                     if ( fRadius > fMax )
1271cdf0e10cSrcweir                         fRadius = fMax;
1272cdf0e10cSrcweir                 }
1273cdf0e10cSrcweir                 if ( nFirstAdjustmentValue >= 0 )
1274cdf0e10cSrcweir                     SetAdjustValueAsDouble( fRadius, nFirstAdjustmentValue );
1275cdf0e10cSrcweir                 if ( nSecondAdjustmentValue >= 0 )
1276cdf0e10cSrcweir                     SetAdjustValueAsDouble( fAngle,  nSecondAdjustmentValue );
1277cdf0e10cSrcweir             }
1278cdf0e10cSrcweir             else
1279cdf0e10cSrcweir             {
1280cdf0e10cSrcweir                 if ( aHandle.nFlags & HANDLE_FLAGS_REFX )
1281cdf0e10cSrcweir                 {
1282cdf0e10cSrcweir                     nFirstAdjustmentValue = aHandle.nRefX;
1283cdf0e10cSrcweir                     fPos1 *= 100000.0;
1284cdf0e10cSrcweir                     fPos1 /= nCoordWidth;
1285cdf0e10cSrcweir                 }
1286cdf0e10cSrcweir                 if ( aHandle.nFlags & HANDLE_FLAGS_REFY )
1287cdf0e10cSrcweir                 {
1288cdf0e10cSrcweir                     nSecondAdjustmentValue = aHandle.nRefY;
1289cdf0e10cSrcweir                     fPos2 *= 100000.0;
1290cdf0e10cSrcweir                     fPos2 /= nCoordHeight;
1291cdf0e10cSrcweir                 }
1292cdf0e10cSrcweir                 if ( nFirstAdjustmentValue >= 0 )
1293cdf0e10cSrcweir                 {
1294cdf0e10cSrcweir                     if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MINIMUM )        // check if horizontal handle needs to be within a range
1295cdf0e10cSrcweir                     {
1296cdf0e10cSrcweir                         double fXMin;
1297cdf0e10cSrcweir                         GetParameter( fXMin, aHandle.aXRangeMinimum, sal_False, sal_False );
1298cdf0e10cSrcweir                         if ( fPos1 < fXMin )
1299cdf0e10cSrcweir                             fPos1 = fXMin;
1300cdf0e10cSrcweir                     }
1301cdf0e10cSrcweir                     if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MAXIMUM )        // check if horizontal handle needs to be within a range
1302cdf0e10cSrcweir                     {
1303cdf0e10cSrcweir                         double fXMax;
1304cdf0e10cSrcweir                         GetParameter( fXMax, aHandle.aXRangeMaximum, sal_False, sal_False );
1305cdf0e10cSrcweir                         if ( fPos1 > fXMax )
1306cdf0e10cSrcweir                             fPos1 = fXMax;
1307cdf0e10cSrcweir                     }
1308cdf0e10cSrcweir                     SetAdjustValueAsDouble( fPos1, nFirstAdjustmentValue );
1309cdf0e10cSrcweir                 }
1310cdf0e10cSrcweir                 if ( nSecondAdjustmentValue >= 0 )
1311cdf0e10cSrcweir                 {
1312cdf0e10cSrcweir                     if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MINIMUM )        // check if vertical handle needs to be within a range
1313cdf0e10cSrcweir                     {
1314cdf0e10cSrcweir                         double fYMin;
1315cdf0e10cSrcweir                         GetParameter( fYMin, aHandle.aYRangeMinimum, sal_False, sal_False );
1316cdf0e10cSrcweir                         if ( fPos2 < fYMin )
1317cdf0e10cSrcweir                             fPos2 = fYMin;
1318cdf0e10cSrcweir                     }
1319cdf0e10cSrcweir                     if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MAXIMUM )        // check if vertical handle needs to be within a range
1320cdf0e10cSrcweir                     {
1321cdf0e10cSrcweir                         double fYMax;
1322cdf0e10cSrcweir                         GetParameter( fYMax, aHandle.aYRangeMaximum, sal_False, sal_False );
1323cdf0e10cSrcweir                         if ( fPos2 > fYMax )
1324cdf0e10cSrcweir                             fPos2 = fYMax;
1325cdf0e10cSrcweir                     }
1326cdf0e10cSrcweir                     SetAdjustValueAsDouble( fPos2, nSecondAdjustmentValue );
1327cdf0e10cSrcweir                 }
1328cdf0e10cSrcweir             }
1329cdf0e10cSrcweir             // and writing them back into the GeometryItem
1330cdf0e10cSrcweir             SdrCustomShapeGeometryItem aGeometryItem((SdrCustomShapeGeometryItem&)
1331cdf0e10cSrcweir                 (const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
1332cdf0e10cSrcweir             const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
1333cdf0e10cSrcweir             com::sun::star::beans::PropertyValue aPropVal;
1334cdf0e10cSrcweir             aPropVal.Name = sAdjustmentValues;
1335cdf0e10cSrcweir             aPropVal.Value <<= seqAdjustmentValues;
1336cdf0e10cSrcweir             aGeometryItem.SetPropertyValue( aPropVal );
1337cdf0e10cSrcweir             pCustomShapeObj->SetMergedItem( aGeometryItem );
1338cdf0e10cSrcweir             bRetValue = sal_True;
1339cdf0e10cSrcweir         }
1340cdf0e10cSrcweir     }
1341cdf0e10cSrcweir     return bRetValue;
1342cdf0e10cSrcweir }
1343cdf0e10cSrcweir 
SwapStartAndEndArrow(SdrObject * pObj)1344cdf0e10cSrcweir void EnhancedCustomShape2d::SwapStartAndEndArrow( SdrObject* pObj ) //#108274
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir     XLineStartItem       aLineStart;
1347cdf0e10cSrcweir     aLineStart.SetLineStartValue(((XLineStartItem&)pObj->GetMergedItem( XATTR_LINEEND )).GetLineStartValue());
1348cdf0e10cSrcweir     XLineStartWidthItem  aLineStartWidth(((XLineStartWidthItem&)pObj->GetMergedItem( XATTR_LINEENDWIDTH )).GetValue());
1349cdf0e10cSrcweir     XLineStartCenterItem aLineStartCenter(((XLineStartCenterItem&)pObj->GetMergedItem( XATTR_LINEENDCENTER )).GetValue());
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir     XLineEndItem         aLineEnd;
1352cdf0e10cSrcweir     aLineEnd.SetLineEndValue(((XLineEndItem&)pObj->GetMergedItem( XATTR_LINESTART )).GetLineEndValue());
1353cdf0e10cSrcweir     XLineEndWidthItem    aLineEndWidth(((XLineEndWidthItem&)pObj->GetMergedItem( XATTR_LINESTARTWIDTH )).GetValue());
1354cdf0e10cSrcweir     XLineEndCenterItem   aLineEndCenter(((XLineEndCenterItem&)pObj->GetMergedItem( XATTR_LINESTARTCENTER )).GetValue());
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir     pObj->SetMergedItem( aLineStart );
1357cdf0e10cSrcweir     pObj->SetMergedItem( aLineStartWidth );
1358cdf0e10cSrcweir     pObj->SetMergedItem( aLineStartCenter );
1359cdf0e10cSrcweir     pObj->SetMergedItem( aLineEnd );
1360cdf0e10cSrcweir     pObj->SetMergedItem( aLineEndWidth );
1361cdf0e10cSrcweir     pObj->SetMergedItem( aLineEndCenter );
1362cdf0e10cSrcweir }
1363cdf0e10cSrcweir 
CreateArc(const Rectangle & rRect,const Point & rStart,const Point & rEnd,const sal_Bool bClockwise)1364cdf0e10cSrcweir basegfx::B2DPolygon CreateArc( const Rectangle& rRect, const Point& rStart, const Point& rEnd, const sal_Bool bClockwise )
1365cdf0e10cSrcweir {
1366cdf0e10cSrcweir     Rectangle aRect( rRect );
1367cdf0e10cSrcweir     Point aStart( rStart );
1368cdf0e10cSrcweir     Point aEnd( rEnd );
1369cdf0e10cSrcweir 
1370cdf0e10cSrcweir     sal_Int32 bSwapStartEndAngle = 0;
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir     if ( aRect.Left() > aRect.Right() )
1373cdf0e10cSrcweir         bSwapStartEndAngle ^= 0x01;
1374cdf0e10cSrcweir     if ( aRect.Top() > aRect.Bottom() )
1375cdf0e10cSrcweir         bSwapStartEndAngle ^= 0x11;
1376cdf0e10cSrcweir     if ( bSwapStartEndAngle )
1377cdf0e10cSrcweir     {
1378cdf0e10cSrcweir         aRect.Justify();
1379cdf0e10cSrcweir         if ( bSwapStartEndAngle & 1 )
1380cdf0e10cSrcweir         {
1381cdf0e10cSrcweir             Point aTmp( aStart );
1382cdf0e10cSrcweir             aStart = aEnd;
1383cdf0e10cSrcweir             aEnd = aTmp;
1384cdf0e10cSrcweir         }
1385cdf0e10cSrcweir     }
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir     Polygon aTempPoly( aRect, aStart, aEnd, POLY_ARC );
1388cdf0e10cSrcweir     basegfx::B2DPolygon aRetval;
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir     if ( bClockwise )
1391cdf0e10cSrcweir     {
1392cdf0e10cSrcweir         for ( sal_uInt16 j = aTempPoly.GetSize(); j--; )
1393cdf0e10cSrcweir         {
1394cdf0e10cSrcweir             aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y()));
1395cdf0e10cSrcweir         }
1396cdf0e10cSrcweir     }
1397cdf0e10cSrcweir     else
1398cdf0e10cSrcweir     {
1399cdf0e10cSrcweir         for ( sal_uInt16 j = 0; j < aTempPoly.GetSize(); j++ )
1400cdf0e10cSrcweir         {
1401cdf0e10cSrcweir             aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y()));
1402cdf0e10cSrcweir         }
1403cdf0e10cSrcweir     }
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir     return aRetval;
1406cdf0e10cSrcweir }
1407cdf0e10cSrcweir 
CreateSubPath(sal_uInt16 & rSrcPt,sal_uInt16 & rSegmentInd,std::vector<SdrPathObj * > & rObjectList,const sal_Bool bLineGeometryNeededOnly,const sal_Bool bSortFilledObjectsToBack)1408cdf0e10cSrcweir void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
1409cdf0e10cSrcweir                                                                                         const sal_Bool bLineGeometryNeededOnly,
1410cdf0e10cSrcweir                                                                                         const sal_Bool bSortFilledObjectsToBack )
1411cdf0e10cSrcweir {
1412cdf0e10cSrcweir     sal_Bool bNoFill = sal_False;
1413cdf0e10cSrcweir     sal_Bool bNoStroke = sal_False;
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir     basegfx::B2DPolyPolygon aNewB2DPolyPolygon;
1416cdf0e10cSrcweir     basegfx::B2DPolygon aNewB2DPolygon;
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir     sal_Int32 nCoordSize = seqCoordinates.getLength();
1419cdf0e10cSrcweir     sal_Int32 nSegInfoSize = seqSegments.getLength();
1420cdf0e10cSrcweir     if ( !nSegInfoSize )
1421cdf0e10cSrcweir     {
1422cdf0e10cSrcweir         const EnhancedCustomShapeParameterPair* pTmp = seqCoordinates.getArray();
1423cdf0e10cSrcweir 
1424cdf0e10cSrcweir         for ( sal_Int32 nPtNum(0L); nPtNum < nCoordSize; nPtNum++ )
1425cdf0e10cSrcweir         {
1426cdf0e10cSrcweir             const Point aTempPoint(GetPoint( *pTmp++, sal_True, sal_True ));
1427cdf0e10cSrcweir             aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
1428cdf0e10cSrcweir         }
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir         aNewB2DPolygon.setClosed(true);
1431cdf0e10cSrcweir     }
1432cdf0e10cSrcweir     else
1433cdf0e10cSrcweir     {
1434cdf0e10cSrcweir         for ( ;rSegmentInd < nSegInfoSize; )
1435cdf0e10cSrcweir         {
1436cdf0e10cSrcweir             sal_Int16 nCommand = seqSegments[ rSegmentInd ].Command;
1437cdf0e10cSrcweir             sal_Int16 nPntCount= seqSegments[ rSegmentInd++ ].Count;
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir             switch ( nCommand )
1440cdf0e10cSrcweir             {
1441cdf0e10cSrcweir                 case NOFILL :
1442cdf0e10cSrcweir                     bNoFill = sal_True;
1443cdf0e10cSrcweir                 break;
1444cdf0e10cSrcweir                 case NOSTROKE :
1445cdf0e10cSrcweir                     bNoStroke = sal_True;
1446cdf0e10cSrcweir                 break;
1447cdf0e10cSrcweir                 case MOVETO :
1448cdf0e10cSrcweir                 {
1449cdf0e10cSrcweir                     if(aNewB2DPolygon.count() > 1L)
1450cdf0e10cSrcweir                     {
1451cdf0e10cSrcweir                         // #i76201# Add conversion to closed polygon when first and last points are equal
1452cdf0e10cSrcweir                         basegfx::tools::checkClosed(aNewB2DPolygon);
1453cdf0e10cSrcweir                         aNewB2DPolyPolygon.append(aNewB2DPolygon);
1454cdf0e10cSrcweir                     }
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir                     aNewB2DPolygon.clear();
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir                     if ( rSrcPt < nCoordSize )
1459cdf0e10cSrcweir                     {
1460cdf0e10cSrcweir                         const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1461cdf0e10cSrcweir                         aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
1462cdf0e10cSrcweir                     }
1463cdf0e10cSrcweir                 }
1464cdf0e10cSrcweir                 break;
1465cdf0e10cSrcweir                 case ENDSUBPATH :
1466cdf0e10cSrcweir                 break;
1467cdf0e10cSrcweir                 case CLOSESUBPATH :
1468cdf0e10cSrcweir                 {
1469cdf0e10cSrcweir                     if(aNewB2DPolygon.count())
1470cdf0e10cSrcweir                     {
1471cdf0e10cSrcweir                         if(aNewB2DPolygon.count() > 1L)
1472cdf0e10cSrcweir                         {
1473cdf0e10cSrcweir                             aNewB2DPolygon.setClosed(true);
1474cdf0e10cSrcweir                             aNewB2DPolyPolygon.append(aNewB2DPolygon);
1475cdf0e10cSrcweir                         }
1476cdf0e10cSrcweir 
1477cdf0e10cSrcweir                         aNewB2DPolygon.clear();
1478cdf0e10cSrcweir                     }
1479cdf0e10cSrcweir                 }
1480cdf0e10cSrcweir                 break;
1481cdf0e10cSrcweir                 case CURVETO :
1482cdf0e10cSrcweir                 {
1483cdf0e10cSrcweir                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ )
1484cdf0e10cSrcweir                     {
1485cdf0e10cSrcweir                         const Point aControlA(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1486cdf0e10cSrcweir                         const Point aControlB(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1487cdf0e10cSrcweir                         const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir                         DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding control point (!)");
1490cdf0e10cSrcweir                         aNewB2DPolygon.appendBezierSegment(
1491cdf0e10cSrcweir                             basegfx::B2DPoint(aControlA.X(), aControlA.Y()),
1492cdf0e10cSrcweir                             basegfx::B2DPoint(aControlB.X(), aControlB.Y()),
1493cdf0e10cSrcweir                             basegfx::B2DPoint(aEnd.X(), aEnd.Y()));
1494cdf0e10cSrcweir                     }
1495cdf0e10cSrcweir                 }
1496cdf0e10cSrcweir                 break;
1497cdf0e10cSrcweir 
1498bfc23b67SArmin Le Grand                 case QUADRATICCURVETO :
1499bfc23b67SArmin Le Grand                 {
1500bfc23b67SArmin Le Grand                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 1 ) < nCoordSize ); i++ )
1501bfc23b67SArmin Le Grand                     {
1502bfc23b67SArmin Le Grand                         if ( rSrcPt )
1503bfc23b67SArmin Le Grand                         {
1504bfc23b67SArmin Le Grand                             const Point aPreviousEndPoint(GetPoint( seqCoordinates[ rSrcPt - 1 ], sal_True, sal_True));
1505bfc23b67SArmin Le Grand                             const Point aControlQ(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1506bfc23b67SArmin Le Grand                             const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1507bfc23b67SArmin Le Grand                             const Point aControlA((aPreviousEndPoint + (aControlQ * 2)) / 3);
1508bfc23b67SArmin Le Grand                             const Point aControlB(((aControlQ * 2) + aEnd) / 3);
1509bfc23b67SArmin Le Grand 
1510bfc23b67SArmin Le Grand                             DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding Q control point (!)");
1511bfc23b67SArmin Le Grand                             aNewB2DPolygon.appendBezierSegment(
1512bfc23b67SArmin Le Grand                                 basegfx::B2DPoint(aControlA.X(), aControlA.Y()),
1513bfc23b67SArmin Le Grand                                 basegfx::B2DPoint(aControlB.X(), aControlB.Y()),
1514bfc23b67SArmin Le Grand                                 basegfx::B2DPoint(aEnd.X(), aEnd.Y()));
1515bfc23b67SArmin Le Grand                         }
1516bfc23b67SArmin Le Grand                         else // no previous point , do a moveto
1517bfc23b67SArmin Le Grand                         {
1518bfc23b67SArmin Le Grand                             rSrcPt++; // skip control point
1519bfc23b67SArmin Le Grand                             const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1520bfc23b67SArmin Le Grand 
1521bfc23b67SArmin Le Grand                             DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding Q control point (!)");
1522bfc23b67SArmin Le Grand                             aNewB2DPolygon.append(basegfx::B2DPoint(aEnd.X(), aEnd.Y()));
1523bfc23b67SArmin Le Grand                         }
1524bfc23b67SArmin Le Grand                     }
1525bfc23b67SArmin Le Grand                 }
1526bfc23b67SArmin Le Grand                 break;
1527bfc23b67SArmin Le Grand 
1528cdf0e10cSrcweir                 case ANGLEELLIPSE :
1529cdf0e10cSrcweir                 {
1530f566f36cSAndre Fischer                     if ( nPntCount )
1531f566f36cSAndre Fischer                     {
1532cdf0e10cSrcweir                         if(aNewB2DPolygon.count() > 1L)
1533cdf0e10cSrcweir                         {
1534cdf0e10cSrcweir                             // #i76201# Add conversion to closed polygon when first and last points are equal
1535cdf0e10cSrcweir                             basegfx::tools::checkClosed(aNewB2DPolygon);
1536cdf0e10cSrcweir                             aNewB2DPolyPolygon.append(aNewB2DPolygon);
1537cdf0e10cSrcweir                         }
1538cdf0e10cSrcweir                         aNewB2DPolygon.clear();
1539cdf0e10cSrcweir                     }
1540f566f36cSAndre Fischer                 }
1541cdf0e10cSrcweir                 case ANGLEELLIPSETO :
1542cdf0e10cSrcweir                 {
1543cdf0e10cSrcweir                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ )
1544cdf0e10cSrcweir                     {
1545cdf0e10cSrcweir                         // create a circle
15469dfab63dSZhe Wang                         Point _aCenter;
1547cdf0e10cSrcweir                         double fWidth, fHeight;
15489dfab63dSZhe Wang                         MSO_SPT eSpType = mso_sptEllipse;
15499dfab63dSZhe Wang                         const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
15509dfab63dSZhe Wang                         sal_Bool bIsDefaultViewBox = sal_False;
15519dfab63dSZhe Wang                         sal_Bool bIsDefaultPath = sal_False;
15529dfab63dSZhe Wang                         sal_Bool bIsMSEllipse = sal_False;
15539dfab63dSZhe Wang 
15549dfab63dSZhe Wang                         if( ( nCoordWidth == pDefCustomShape->nCoordWidth )
15559dfab63dSZhe Wang                             && ( nCoordHeight == pDefCustomShape->nCoordHeight ) )
15569dfab63dSZhe Wang                             bIsDefaultViewBox = sal_True;
15579dfab63dSZhe Wang                         sal_Int32 j, nCount = pDefCustomShape->nVertices;//==3
15589dfab63dSZhe Wang                         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates1, seqCoordinates2;
15599dfab63dSZhe Wang 
15609dfab63dSZhe Wang                         seqCoordinates1.realloc( nCount );
15619dfab63dSZhe Wang                         for ( j = 0; j < nCount; j++ )
15629dfab63dSZhe Wang                         {
15639dfab63dSZhe Wang                             seqCoordinates1[j] = seqCoordinates[ rSrcPt + j];
15649dfab63dSZhe Wang                         }
15659dfab63dSZhe Wang 
15669dfab63dSZhe Wang                         seqCoordinates2.realloc( nCount );
15679dfab63dSZhe Wang                         for ( j = 0; j < nCount; j++ )
15689dfab63dSZhe Wang                         {
15699dfab63dSZhe Wang                             EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ j ].First, pDefCustomShape->pVertices[ j ].nValA );
15709dfab63dSZhe Wang                             EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ j ].Second, pDefCustomShape->pVertices[ j ].nValB );
15719dfab63dSZhe Wang                         }
15729dfab63dSZhe Wang                         if(seqCoordinates1 == seqCoordinates2)
15739dfab63dSZhe Wang                             bIsDefaultPath = sal_True;
15749dfab63dSZhe Wang 
15759dfab63dSZhe Wang                         const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
15769dfab63dSZhe Wang                         rtl::OUString sShpType;
15779dfab63dSZhe Wang                         SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
15789dfab63dSZhe Wang                         Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
15799dfab63dSZhe Wang                         if ( pAny )
15809dfab63dSZhe Wang                             *pAny >>= sShpType;
15819dfab63dSZhe Wang                         if( sShpType.getLength() > 3 &&
15829dfab63dSZhe Wang                             sShpType.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "mso" ))){
15839dfab63dSZhe Wang                                 bIsMSEllipse = sal_True;
15849dfab63dSZhe Wang                         }
15859dfab63dSZhe Wang                         if( (! bIsDefaultPath   && ! bIsDefaultViewBox) || (bIsDefaultViewBox && bIsMSEllipse) /*&& (nGeneratorVersion == SfxObjectShell::Sym_L2)*/ )
15869dfab63dSZhe Wang                         {
15879dfab63dSZhe Wang                             _aCenter = GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True );
1588cdf0e10cSrcweir                             GetParameter( fWidth,  seqCoordinates[ rSrcPt + 1 ].First, sal_True, sal_False  );
1589cdf0e10cSrcweir                             GetParameter( fHeight,  seqCoordinates[ rSrcPt + 1 ].Second, sal_False, sal_True );
15909dfab63dSZhe Wang                             fWidth /= 2;
15919dfab63dSZhe Wang                             fHeight /= 2;
15929dfab63dSZhe Wang                         }else if( bIsDefaultPath && !bIsDefaultViewBox /*&& (nGeneratorVersion == SfxObjectShell::Sym_L2)*/ )
15939dfab63dSZhe Wang                         {
15949dfab63dSZhe Wang                             _aCenter.X() = nCoordWidth/2 * fXScale;
15959dfab63dSZhe Wang                             _aCenter.Y() = nCoordHeight/2 * fYScale;
15969dfab63dSZhe Wang                             fWidth = nCoordWidth/2;
15979dfab63dSZhe Wang                             fHeight = nCoordHeight/2;
15989dfab63dSZhe Wang 
15999dfab63dSZhe Wang                             const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
16009dfab63dSZhe Wang                             const Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sViewBox );
16019dfab63dSZhe Wang                             com::sun::star::awt::Rectangle aViewBox;
16029dfab63dSZhe Wang                             if ( pViewBox && (*pViewBox >>= aViewBox ) )
16039dfab63dSZhe Wang                             {
16049dfab63dSZhe Wang                                 aViewBox.Width = pDefCustomShape->nCoordWidth;
16059dfab63dSZhe Wang                                 aViewBox.Height = pDefCustomShape->nCoordHeight;
16069dfab63dSZhe Wang                             }
16079dfab63dSZhe Wang                             com::sun::star::beans::PropertyValue aPropVal;
16089dfab63dSZhe Wang                             aPropVal.Name = sViewBox;
16099dfab63dSZhe Wang                             aPropVal.Value <<= aViewBox;
16109dfab63dSZhe Wang                             rGeometryItem.SetPropertyValue( aPropVal );
16119dfab63dSZhe Wang                             pCustomShapeObj->SetMergedItem( rGeometryItem );
16129dfab63dSZhe Wang                         }else{
16139dfab63dSZhe Wang                             _aCenter = GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True );
16149dfab63dSZhe Wang                             GetParameter( fWidth,  seqCoordinates[ rSrcPt + 1 ].First, sal_True, sal_False  );
16159dfab63dSZhe Wang                             GetParameter( fHeight,  seqCoordinates[ rSrcPt + 1 ].Second, sal_False, sal_True );
16169dfab63dSZhe Wang                         }
16179dfab63dSZhe Wang 
1618cdf0e10cSrcweir                         fWidth *= fXScale;
1619cdf0e10cSrcweir                         fHeight*= fYScale;
1620cdf0e10cSrcweir                         Point aP( (sal_Int32)( _aCenter.X() - fWidth ), (sal_Int32)( _aCenter.Y() - fHeight ) );
1621cdf0e10cSrcweir                         Size  aS( (sal_Int32)( fWidth * 2.0 ), (sal_Int32)( fHeight * 2.0 ) );
1622cdf0e10cSrcweir                         Rectangle aRect( aP, aS );
1623cdf0e10cSrcweir                         if ( aRect.GetWidth() && aRect.GetHeight() )
1624cdf0e10cSrcweir                         {
1625cdf0e10cSrcweir                             double fStartAngle, fEndAngle;
1626cdf0e10cSrcweir                             GetParameter( fStartAngle, seqCoordinates[ rSrcPt + 2 ].First,  sal_False, sal_False );
1627cdf0e10cSrcweir                             GetParameter( fEndAngle  , seqCoordinates[ rSrcPt + 2 ].Second, sal_False, sal_False );
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir                             if ( ((sal_Int32)fStartAngle % 360) != ((sal_Int32)fEndAngle % 360) )
1630cdf0e10cSrcweir                             {
1631cdf0e10cSrcweir                                 if ( (sal_Int32)fStartAngle & 0x7fff0000 )  // SJ: if the angle was imported from our escher import, then the
1632cdf0e10cSrcweir                                     fStartAngle /= 65536.0;                 // value is shifted by 16. TODO: already change the fixed float to a
1633cdf0e10cSrcweir                                 if ( (sal_Int32)fEndAngle & 0x7fff0000 )    // double in the import filter
1634cdf0e10cSrcweir                                 {
1635cdf0e10cSrcweir                                     fEndAngle /= 65536.0;
1636cdf0e10cSrcweir                                     fEndAngle = fEndAngle + fStartAngle;
1637cdf0e10cSrcweir                                     if ( fEndAngle < 0 )
1638cdf0e10cSrcweir                                     {   // in the binary filter the endangle is the amount
1639cdf0e10cSrcweir                                         double fTemp = fStartAngle;
1640cdf0e10cSrcweir                                         fStartAngle = fEndAngle;
1641cdf0e10cSrcweir                                         fEndAngle = fTemp;
1642cdf0e10cSrcweir                                     }
1643cdf0e10cSrcweir                                 }
1644cdf0e10cSrcweir                                 double fCenterX = aRect.Center().X();
1645cdf0e10cSrcweir                                 double fCenterY = aRect.Center().Y();
1646cdf0e10cSrcweir                                 double fx1 = ( cos( fStartAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX;
1647cdf0e10cSrcweir                                 double fy1 = ( -sin( fStartAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY;
1648cdf0e10cSrcweir                                 double fx2 = ( cos( fEndAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX;
1649cdf0e10cSrcweir                                 double fy2 = ( -sin( fEndAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY;
1650cdf0e10cSrcweir                                 aNewB2DPolygon.append(CreateArc( aRect, Point( (sal_Int32)fx1, (sal_Int32)fy1 ), Point( (sal_Int32)fx2, (sal_Int32)fy2 ), sal_False));
1651cdf0e10cSrcweir                             }
1652cdf0e10cSrcweir                             else
1653cdf0e10cSrcweir                             {   /* SJ: TODO: this block should be replaced sometimes, because the current point
1654cdf0e10cSrcweir                                    is not set correct, it also does not use the correct moveto
1655cdf0e10cSrcweir                                    point if ANGLEELLIPSETO was used, but the method CreateArc
1656cdf0e10cSrcweir                                    is at the moment not able to draw full circles (if startangle is 0
1657cdf0e10cSrcweir                                    and endangle 360 nothing is painted :-( */
1658cdf0e10cSrcweir                                 sal_Int32 nXControl = (sal_Int32)((double)aRect.GetWidth() * 0.2835 );
1659cdf0e10cSrcweir                                 sal_Int32 nYControl = (sal_Int32)((double)aRect.GetHeight() * 0.2835 );
1660cdf0e10cSrcweir                                 Point aCenter( aRect.Center() );
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir                                 // append start point
1663cdf0e10cSrcweir                                 aNewB2DPolygon.append(basegfx::B2DPoint(aCenter.X(), aRect.Top()));
1664cdf0e10cSrcweir 
1665cdf0e10cSrcweir                                 // append four bezier segments
1666cdf0e10cSrcweir                                 aNewB2DPolygon.appendBezierSegment(
1667cdf0e10cSrcweir                                     basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Top()),
1668cdf0e10cSrcweir                                     basegfx::B2DPoint(aRect.Right(), aCenter.Y() - nYControl),
1669cdf0e10cSrcweir                                     basegfx::B2DPoint(aRect.Right(), aCenter.Y()));
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir                                 aNewB2DPolygon.appendBezierSegment(
1672cdf0e10cSrcweir                                     basegfx::B2DPoint(aRect.Right(), aCenter.Y() + nYControl),
1673cdf0e10cSrcweir                                     basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Bottom()),
1674cdf0e10cSrcweir                                     basegfx::B2DPoint(aCenter.X(), aRect.Bottom()));
1675cdf0e10cSrcweir 
1676cdf0e10cSrcweir                                 aNewB2DPolygon.appendBezierSegment(
1677cdf0e10cSrcweir                                     basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Bottom()),
1678cdf0e10cSrcweir                                     basegfx::B2DPoint(aRect.Left(), aCenter.Y() + nYControl),
1679cdf0e10cSrcweir                                     basegfx::B2DPoint(aRect.Left(), aCenter.Y()));
1680cdf0e10cSrcweir 
1681cdf0e10cSrcweir                                 aNewB2DPolygon.appendBezierSegment(
1682cdf0e10cSrcweir                                     basegfx::B2DPoint(aRect.Left(), aCenter.Y() - nYControl),
1683cdf0e10cSrcweir                                     basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Top()),
1684cdf0e10cSrcweir                                     basegfx::B2DPoint(aCenter.X(), aRect.Top()));
1685cdf0e10cSrcweir 
1686cdf0e10cSrcweir                                 // close, rescue last controlpoint, remove double last point
1687cdf0e10cSrcweir                                 basegfx::tools::closeWithGeometryChange(aNewB2DPolygon);
1688cdf0e10cSrcweir                             }
1689cdf0e10cSrcweir                         }
1690cdf0e10cSrcweir                         rSrcPt += 3;
1691cdf0e10cSrcweir                     }
1692cdf0e10cSrcweir                 }
1693cdf0e10cSrcweir                 break;
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir                 case LINETO :
1696cdf0e10cSrcweir                 {
1697cdf0e10cSrcweir                     for ( sal_Int32 i(0L); ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ )
1698cdf0e10cSrcweir                     {
1699cdf0e10cSrcweir                         const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1700cdf0e10cSrcweir                         aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
1701cdf0e10cSrcweir                     }
1702cdf0e10cSrcweir                 }
1703cdf0e10cSrcweir                 break;
1704cdf0e10cSrcweir 
1705cdf0e10cSrcweir                 case ARC :
1706cdf0e10cSrcweir                 case CLOCKWISEARC :
1707cdf0e10cSrcweir                 {
1708cdf0e10cSrcweir                     if(aNewB2DPolygon.count() > 1L)
1709cdf0e10cSrcweir                     {
1710cdf0e10cSrcweir                         // #i76201# Add conversion to closed polygon when first and last points are equal
1711cdf0e10cSrcweir                         basegfx::tools::checkClosed(aNewB2DPolygon);
1712cdf0e10cSrcweir                         aNewB2DPolyPolygon.append(aNewB2DPolygon);
1713cdf0e10cSrcweir                     }
1714cdf0e10cSrcweir 
1715cdf0e10cSrcweir                     aNewB2DPolygon.clear();
1716cdf0e10cSrcweir                 }
1717cdf0e10cSrcweir                 case ARCTO :
1718cdf0e10cSrcweir                 case CLOCKWISEARCTO :
1719cdf0e10cSrcweir                 {
1720cdf0e10cSrcweir                     sal_Bool bClockwise = ( nCommand == CLOCKWISEARC ) || ( nCommand == CLOCKWISEARCTO );
1721cdf0e10cSrcweir                     sal_uInt32 nXor = bClockwise ? 3 : 2;
1722cdf0e10cSrcweir                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 3 ) < nCoordSize ); i++ )
1723cdf0e10cSrcweir                     {
1724cdf0e10cSrcweir                         Rectangle aRect( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ), GetPoint( seqCoordinates[ rSrcPt + 1 ], sal_True, sal_True ) );
1725cdf0e10cSrcweir                         if ( aRect.GetWidth() && aRect.GetHeight() )
1726cdf0e10cSrcweir                         {
1727cdf0e10cSrcweir                             Point aCenter( aRect.Center() );
1728cdf0e10cSrcweir                             Point aStart( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + nXor ) ], sal_True, sal_True ) );
1729cdf0e10cSrcweir                             Point aEnd( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + ( nXor ^ 1 ) ) ], sal_True, sal_True ) );
1730cdf0e10cSrcweir                             double fRatio = (double)aRect.GetHeight() / (double)aRect.GetWidth();
1731cdf0e10cSrcweir                             aStart.X() = (sal_Int32)( ( (double)( aStart.X() - aCenter.X() ) ) * fRatio ) + aCenter.X();
1732cdf0e10cSrcweir                             aStart.Y() = (sal_Int32)( ( (double)( aStart.Y() - aCenter.Y() ) ) ) + aCenter.Y();
1733cdf0e10cSrcweir                             aEnd.X() = (sal_Int32)( ( (double)( aEnd.X() - aCenter.X() ) ) * fRatio ) + aCenter.X();
1734cdf0e10cSrcweir                             aEnd.Y() = (sal_Int32)( ( (double)( aEnd.Y() - aCenter.Y() ) ) ) + aCenter.Y();
1735cdf0e10cSrcweir                             aNewB2DPolygon.append(CreateArc( aRect, aStart, aEnd, bClockwise));
1736cdf0e10cSrcweir                         }
1737cdf0e10cSrcweir                         rSrcPt += 4;
1738cdf0e10cSrcweir                     }
1739cdf0e10cSrcweir                 }
1740cdf0e10cSrcweir                 break;
1741cdf0e10cSrcweir 
1742cdf0e10cSrcweir                 case ELLIPTICALQUADRANTX :
1743cdf0e10cSrcweir                 case ELLIPTICALQUADRANTY :
1744cdf0e10cSrcweir                 {
1745cdf0e10cSrcweir                     bool bFirstDirection(true);
1746cdf0e10cSrcweir                     basegfx::B2DPoint aControlPointA;
1747cdf0e10cSrcweir                     basegfx::B2DPoint aControlPointB;
1748cdf0e10cSrcweir 
1749cdf0e10cSrcweir                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ )
1750cdf0e10cSrcweir                     {
1751cdf0e10cSrcweir                         sal_uInt32 nModT = ( nCommand == ELLIPTICALQUADRANTX ) ? 1 : 0;
1752cdf0e10cSrcweir                         Point aCurrent( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) );
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir                         if ( rSrcPt )   // we need a previous point
1755cdf0e10cSrcweir                         {
1756cdf0e10cSrcweir                             Point aPrev( GetPoint( seqCoordinates[ rSrcPt - 1 ], sal_True, sal_True ) );
1757cdf0e10cSrcweir                             sal_Int32 nX, nY;
1758cdf0e10cSrcweir                             nX = aCurrent.X() - aPrev.X();
1759cdf0e10cSrcweir                             nY = aCurrent.Y() - aPrev.Y();
1760cdf0e10cSrcweir                             if ( ( nY ^ nX ) & 0x80000000 )
1761cdf0e10cSrcweir                             {
1762cdf0e10cSrcweir                                 if ( !i )
1763cdf0e10cSrcweir                                     bFirstDirection = true;
1764cdf0e10cSrcweir                                 else if ( !bFirstDirection )
1765cdf0e10cSrcweir                                     nModT ^= 1;
1766cdf0e10cSrcweir                             }
1767cdf0e10cSrcweir                             else
1768cdf0e10cSrcweir                             {
1769cdf0e10cSrcweir                                 if ( !i )
1770cdf0e10cSrcweir                                     bFirstDirection = false;
1771cdf0e10cSrcweir                                 else if ( bFirstDirection )
1772cdf0e10cSrcweir                                     nModT ^= 1;
1773cdf0e10cSrcweir                             }
1774cdf0e10cSrcweir                             if ( nModT )            // get the right corner
1775cdf0e10cSrcweir                             {
1776cdf0e10cSrcweir                                 nX = aCurrent.X();
1777cdf0e10cSrcweir                                 nY = aPrev.Y();
1778cdf0e10cSrcweir                             }
1779cdf0e10cSrcweir                             else
1780cdf0e10cSrcweir                             {
1781cdf0e10cSrcweir                                 nX = aPrev.X();
1782cdf0e10cSrcweir                                 nY = aCurrent.Y();
1783cdf0e10cSrcweir                             }
1784cdf0e10cSrcweir                             sal_Int32 nXVec = ( nX - aPrev.X() ) >> 1;
1785cdf0e10cSrcweir                             sal_Int32 nYVec = ( nY - aPrev.Y() ) >> 1;
1786cdf0e10cSrcweir                             Point aControl1( aPrev.X() + nXVec, aPrev.Y() + nYVec );
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir                             aControlPointA = basegfx::B2DPoint(aControl1.X(), aControl1.Y());
1789cdf0e10cSrcweir 
1790cdf0e10cSrcweir                             nXVec = ( nX - aCurrent.X() ) >> 1;
1791cdf0e10cSrcweir                             nYVec = ( nY - aCurrent.Y() ) >> 1;
1792cdf0e10cSrcweir                             Point aControl2( aCurrent.X() + nXVec, aCurrent.Y() + nYVec );
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir                             aControlPointB = basegfx::B2DPoint(aControl2.X(), aControl2.Y());
1795cdf0e10cSrcweir 
1796cdf0e10cSrcweir                             aNewB2DPolygon.appendBezierSegment(
1797cdf0e10cSrcweir                                 aControlPointA,
1798cdf0e10cSrcweir                                 aControlPointB,
1799cdf0e10cSrcweir                                 basegfx::B2DPoint(aCurrent.X(), aCurrent.Y()));
1800cdf0e10cSrcweir                         }
1801cdf0e10cSrcweir                         else
1802cdf0e10cSrcweir                         {
1803cdf0e10cSrcweir                             aNewB2DPolygon.append(basegfx::B2DPoint(aCurrent.X(), aCurrent.Y()));
1804cdf0e10cSrcweir                         }
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir                         rSrcPt++;
1807cdf0e10cSrcweir                     }
1808cdf0e10cSrcweir                 }
1809cdf0e10cSrcweir                 break;
1810cdf0e10cSrcweir 
1811cdf0e10cSrcweir #ifdef DBG_CUSTOMSHAPE
1812cdf0e10cSrcweir                 case UNKNOWN :
1813cdf0e10cSrcweir                 default :
1814cdf0e10cSrcweir                 {
1815cdf0e10cSrcweir                     ByteString aString( "CustomShapes::unknown PolyFlagValue :" );
1816cdf0e10cSrcweir                     aString.Append( ByteString::CreateFromInt32( nCommand ) );
1817cdf0e10cSrcweir                     DBG_ERROR( aString.GetBuffer() );
1818cdf0e10cSrcweir                 }
1819cdf0e10cSrcweir                 break;
1820cdf0e10cSrcweir #endif
1821cdf0e10cSrcweir             }
1822cdf0e10cSrcweir             if ( nCommand == ENDSUBPATH )
1823cdf0e10cSrcweir                 break;
1824cdf0e10cSrcweir         }
1825cdf0e10cSrcweir     }
1826cdf0e10cSrcweir     if ( rSegmentInd == nSegInfoSize )
1827cdf0e10cSrcweir         rSegmentInd++;
1828cdf0e10cSrcweir 
1829cdf0e10cSrcweir     if(aNewB2DPolygon.count() > 1L)
1830cdf0e10cSrcweir     {
1831cdf0e10cSrcweir         // #i76201# Add conversion to closed polygon when first and last points are equal
1832cdf0e10cSrcweir         basegfx::tools::checkClosed(aNewB2DPolygon);
1833cdf0e10cSrcweir         aNewB2DPolyPolygon.append(aNewB2DPolygon);
1834cdf0e10cSrcweir     }
1835cdf0e10cSrcweir 
1836cdf0e10cSrcweir     if(aNewB2DPolyPolygon.count())
1837cdf0e10cSrcweir     {
1838cdf0e10cSrcweir         // #i37011#
1839cdf0e10cSrcweir         bool bForceCreateTwoObjects(false);
1840cdf0e10cSrcweir 
1841cdf0e10cSrcweir         if(!bSortFilledObjectsToBack && !aNewB2DPolyPolygon.isClosed() && !bNoStroke)
1842cdf0e10cSrcweir         {
1843cdf0e10cSrcweir             bForceCreateTwoObjects = true;
1844cdf0e10cSrcweir         }
1845cdf0e10cSrcweir 
1846cdf0e10cSrcweir         if(bLineGeometryNeededOnly)
1847cdf0e10cSrcweir         {
1848cdf0e10cSrcweir             bForceCreateTwoObjects = true;
1849cdf0e10cSrcweir             bNoFill = true;
1850cdf0e10cSrcweir             bNoStroke = false;
1851cdf0e10cSrcweir         }
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir         if(bForceCreateTwoObjects || bSortFilledObjectsToBack)
1854cdf0e10cSrcweir         {
1855cdf0e10cSrcweir             if(bFilled && !bNoFill)
1856cdf0e10cSrcweir             {
1857cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon);
1858cdf0e10cSrcweir                 aClosedPolyPolygon.setClosed(true);
1859cdf0e10cSrcweir                 SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon);
1860cdf0e10cSrcweir                 SfxItemSet aTempSet(*this);
1861cdf0e10cSrcweir                 aTempSet.Put(SdrShadowItem(sal_False));
1862cdf0e10cSrcweir                 aTempSet.Put(XLineStyleItem(XLINE_NONE));
1863cdf0e10cSrcweir                 pFill->SetMergedItemSet(aTempSet);
1864cdf0e10cSrcweir                 rObjectList.push_back(pFill);
1865cdf0e10cSrcweir             }
1866cdf0e10cSrcweir 
1867cdf0e10cSrcweir             if(!bNoStroke)
1868cdf0e10cSrcweir             {
1869cdf0e10cSrcweir                 // there is no reason to use OBJ_PLIN here when the polygon is actually closed,
1870cdf0e10cSrcweir                 // the non-fill is defined by XFILL_NONE. Since SdrPathObj::ImpForceKind() needs
1871cdf0e10cSrcweir                 // to correct the polygon (here: open it) using the type, the last edge may get lost.
1872cdf0e10cSrcweir                 // Thus, use a type that fits the polygon
1873cdf0e10cSrcweir                 SdrPathObj* pStroke = new SdrPathObj(
1874cdf0e10cSrcweir                     aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
1875cdf0e10cSrcweir                     aNewB2DPolyPolygon);
1876cdf0e10cSrcweir                 SfxItemSet aTempSet(*this);
1877cdf0e10cSrcweir                 aTempSet.Put(SdrShadowItem(sal_False));
1878cdf0e10cSrcweir                 aTempSet.Put(XFillStyleItem(XFILL_NONE));
1879cdf0e10cSrcweir                 pStroke->SetMergedItemSet(aTempSet);
1880cdf0e10cSrcweir                 rObjectList.push_back(pStroke);
1881cdf0e10cSrcweir             }
1882cdf0e10cSrcweir         }
1883cdf0e10cSrcweir         else
1884cdf0e10cSrcweir         {
1885cdf0e10cSrcweir             SdrPathObj* pObj = 0;
1886cdf0e10cSrcweir             SfxItemSet aTempSet(*this);
1887cdf0e10cSrcweir             aTempSet.Put(SdrShadowItem(sal_False));
1888cdf0e10cSrcweir 
1889cdf0e10cSrcweir             if(bNoFill)
1890cdf0e10cSrcweir             {
1891cdf0e10cSrcweir                 // see comment above about OBJ_PLIN
1892cdf0e10cSrcweir                 pObj = new SdrPathObj(
1893cdf0e10cSrcweir                     aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
1894cdf0e10cSrcweir                     aNewB2DPolyPolygon);
1895cdf0e10cSrcweir                 aTempSet.Put(XFillStyleItem(XFILL_NONE));
1896cdf0e10cSrcweir             }
1897cdf0e10cSrcweir             else
1898cdf0e10cSrcweir             {
1899cdf0e10cSrcweir                 aNewB2DPolyPolygon.setClosed(true);
1900cdf0e10cSrcweir                 pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon);
1901cdf0e10cSrcweir             }
1902cdf0e10cSrcweir 
1903cdf0e10cSrcweir             if(bNoStroke)
1904cdf0e10cSrcweir             {
1905cdf0e10cSrcweir                 aTempSet.Put(XLineStyleItem(XLINE_NONE));
1906cdf0e10cSrcweir             }
1907cdf0e10cSrcweir 
1908cdf0e10cSrcweir             if(pObj)
1909cdf0e10cSrcweir             {
1910cdf0e10cSrcweir                 pObj->SetMergedItemSet(aTempSet);
1911cdf0e10cSrcweir                 rObjectList.push_back(pObj);
1912cdf0e10cSrcweir             }
1913cdf0e10cSrcweir         }
1914cdf0e10cSrcweir     }
1915cdf0e10cSrcweir }
1916cdf0e10cSrcweir 
CorrectCalloutArrows(MSO_SPT eSpType,sal_uInt32 nLineObjectCount,std::vector<SdrPathObj * > & vObjectList)1917cdf0e10cSrcweir void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::vector< SdrPathObj* >& vObjectList )
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir     sal_Bool bAccent = sal_False;
1920cdf0e10cSrcweir     switch( eSpType )
1921cdf0e10cSrcweir     {
1922cdf0e10cSrcweir         case mso_sptCallout1 :
1923cdf0e10cSrcweir         case mso_sptBorderCallout1 :
1924cdf0e10cSrcweir         case mso_sptCallout90 :
1925cdf0e10cSrcweir         case mso_sptBorderCallout90 :
1926cdf0e10cSrcweir         default:
1927cdf0e10cSrcweir         break;
1928cdf0e10cSrcweir 
1929cdf0e10cSrcweir         case mso_sptAccentCallout1 :
1930cdf0e10cSrcweir         case mso_sptAccentBorderCallout1 :
1931cdf0e10cSrcweir         case mso_sptAccentCallout90 :
1932cdf0e10cSrcweir         case mso_sptAccentBorderCallout90 :
1933cdf0e10cSrcweir         {
1934cdf0e10cSrcweir             sal_uInt32 i, nLine = 0;
1935cdf0e10cSrcweir             for ( i = 0; i < vObjectList.size(); i++ )
1936cdf0e10cSrcweir             {
1937cdf0e10cSrcweir                 SdrPathObj* pObj( vObjectList[ i ] );
1938cdf0e10cSrcweir                 if(pObj->IsLine())
1939cdf0e10cSrcweir                 {
1940cdf0e10cSrcweir                     nLine++;
1941cdf0e10cSrcweir                     if ( nLine == nLineObjectCount )
1942cdf0e10cSrcweir                     {
1943cdf0e10cSrcweir                         pObj->ClearMergedItem( XATTR_LINESTART );
1944cdf0e10cSrcweir                         pObj->ClearMergedItem( XATTR_LINEEND );
1945cdf0e10cSrcweir                     }
1946cdf0e10cSrcweir                 }
1947cdf0e10cSrcweir             }
1948cdf0e10cSrcweir         }
1949cdf0e10cSrcweir         break;
1950cdf0e10cSrcweir 
1951cdf0e10cSrcweir         // switch start & end
1952cdf0e10cSrcweir         case mso_sptAccentCallout2 :
1953cdf0e10cSrcweir         case mso_sptAccentBorderCallout2 :
1954cdf0e10cSrcweir             bAccent = sal_True;
1955cdf0e10cSrcweir         case mso_sptCallout2 :
1956cdf0e10cSrcweir         case mso_sptBorderCallout2 :
1957cdf0e10cSrcweir         {
1958cdf0e10cSrcweir             sal_uInt32 i, nLine = 0;
1959cdf0e10cSrcweir             for ( i = 0; i < vObjectList.size(); i++ )
1960cdf0e10cSrcweir             {
1961cdf0e10cSrcweir                 SdrPathObj* pObj( vObjectList[ i ] );
1962cdf0e10cSrcweir                 if(pObj->IsLine())
1963cdf0e10cSrcweir                 {
1964cdf0e10cSrcweir                     nLine++;
1965cdf0e10cSrcweir                     if ( nLine == 1 )
1966cdf0e10cSrcweir                         pObj->ClearMergedItem( XATTR_LINEEND );
1967cdf0e10cSrcweir                     else if ( ( bAccent && ( nLine == nLineObjectCount - 1 ) ) || ( !bAccent && ( nLine == nLineObjectCount ) ) )
1968cdf0e10cSrcweir                         pObj->ClearMergedItem( XATTR_LINESTART );
1969cdf0e10cSrcweir                     else
1970cdf0e10cSrcweir                     {
1971cdf0e10cSrcweir                         pObj->ClearMergedItem( XATTR_LINESTART );
1972cdf0e10cSrcweir                         pObj->ClearMergedItem( XATTR_LINEEND );
1973cdf0e10cSrcweir                     }
1974cdf0e10cSrcweir                 }
1975cdf0e10cSrcweir             }
1976cdf0e10cSrcweir         }
1977cdf0e10cSrcweir         break;
1978cdf0e10cSrcweir 
1979cdf0e10cSrcweir         case mso_sptAccentCallout3 :
1980cdf0e10cSrcweir         case mso_sptAccentBorderCallout3 :
1981cdf0e10cSrcweir             bAccent = sal_False;
1982cdf0e10cSrcweir         case mso_sptCallout3 :
1983cdf0e10cSrcweir         case mso_sptBorderCallout3 :
1984cdf0e10cSrcweir         {
1985cdf0e10cSrcweir             sal_uInt32 i, nLine = 0;
1986cdf0e10cSrcweir             for ( i = 0; i < vObjectList.size(); i++ )
1987cdf0e10cSrcweir             {
1988cdf0e10cSrcweir                 SdrPathObj* pObj( vObjectList[ i ] );
1989cdf0e10cSrcweir                 if(pObj->IsLine())
1990cdf0e10cSrcweir                 {
1991cdf0e10cSrcweir                     if ( nLine )
1992cdf0e10cSrcweir                     {
1993cdf0e10cSrcweir                         pObj->ClearMergedItem( XATTR_LINESTART );
1994cdf0e10cSrcweir                         pObj->ClearMergedItem( XATTR_LINEEND );
1995cdf0e10cSrcweir                     }
1996cdf0e10cSrcweir                     else
1997cdf0e10cSrcweir                         EnhancedCustomShape2d::SwapStartAndEndArrow( pObj );
1998cdf0e10cSrcweir 
1999cdf0e10cSrcweir                     nLine++;
2000cdf0e10cSrcweir                 }
2001cdf0e10cSrcweir             }
2002cdf0e10cSrcweir         }
2003cdf0e10cSrcweir         break;
2004cdf0e10cSrcweir     }
2005cdf0e10cSrcweir }
2006cdf0e10cSrcweir 
AdaptObjColor(SdrPathObj & rObj,const SfxItemSet & rCustomShapeSet,sal_uInt32 & nColorIndex,sal_uInt32 nColorCount)2007cdf0e10cSrcweir void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
2008cdf0e10cSrcweir                                           sal_uInt32& nColorIndex, sal_uInt32 nColorCount)
2009cdf0e10cSrcweir {
2010cdf0e10cSrcweir     if ( !rObj.IsLine() )
2011cdf0e10cSrcweir     {
2012cdf0e10cSrcweir         const XFillStyle eFillStyle = ((const XFillStyleItem&)rObj.GetMergedItem(XATTR_FILLSTYLE)).GetValue();
2013cdf0e10cSrcweir         switch( eFillStyle )
2014cdf0e10cSrcweir         {
2015cdf0e10cSrcweir             default:
2016cdf0e10cSrcweir             case XFILL_SOLID:
2017cdf0e10cSrcweir             {
2018cdf0e10cSrcweir                 Color aFillColor;
2019cdf0e10cSrcweir                 if ( nColorCount )
2020cdf0e10cSrcweir                 {
2021cdf0e10cSrcweir                     aFillColor = GetColorData(
2022cdf0e10cSrcweir                         ((XFillColorItem&)rCustomShapeSet.Get( XATTR_FILLCOLOR )).GetColorValue(),
2023cdf0e10cSrcweir                         std::min(nColorIndex, nColorCount-1) );
2024cdf0e10cSrcweir                     rObj.SetMergedItem( XFillColorItem( String(), aFillColor ) );
2025cdf0e10cSrcweir                 }
2026cdf0e10cSrcweir                 break;
2027cdf0e10cSrcweir             }
2028cdf0e10cSrcweir             case XFILL_GRADIENT:
2029cdf0e10cSrcweir             {
2030cdf0e10cSrcweir                 XGradient aXGradient(((const XFillGradientItem&)rObj.GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue());
2031cdf0e10cSrcweir                 if ( nColorCount )
2032cdf0e10cSrcweir                 {
2033cdf0e10cSrcweir                     aXGradient.SetStartColor(
2034cdf0e10cSrcweir                         GetColorData(
2035cdf0e10cSrcweir                             aXGradient.GetStartColor(),
2036cdf0e10cSrcweir                             std::min(nColorIndex, nColorCount-1) ));
2037cdf0e10cSrcweir                     aXGradient.SetEndColor(
2038cdf0e10cSrcweir                         GetColorData(
2039cdf0e10cSrcweir                             aXGradient.GetEndColor(),
2040cdf0e10cSrcweir                             std::min(nColorIndex, nColorCount-1) ));
2041cdf0e10cSrcweir                 }
2042cdf0e10cSrcweir 
2043cdf0e10cSrcweir                 rObj.SetMergedItem( XFillGradientItem( String(), aXGradient ) );
2044cdf0e10cSrcweir                 break;
2045cdf0e10cSrcweir             }
2046cdf0e10cSrcweir             case XFILL_HATCH:
2047cdf0e10cSrcweir             {
2048cdf0e10cSrcweir                 XHatch aXHatch(((const XFillHatchItem&)rObj.GetMergedItem(XATTR_FILLHATCH)).GetHatchValue());
2049cdf0e10cSrcweir                 if ( nColorCount )
2050cdf0e10cSrcweir                 {
2051cdf0e10cSrcweir                     aXHatch.SetColor(
2052cdf0e10cSrcweir                         GetColorData(
2053cdf0e10cSrcweir                             aXHatch.GetColor(),
2054cdf0e10cSrcweir                             std::min(nColorIndex, nColorCount-1) ));
2055cdf0e10cSrcweir                 }
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir                 rObj.SetMergedItem( XFillHatchItem( String(), aXHatch ) );
2058cdf0e10cSrcweir                 break;
2059cdf0e10cSrcweir             }
2060cdf0e10cSrcweir             case XFILL_BITMAP:
2061cdf0e10cSrcweir             {
2062cdf0e10cSrcweir                 if ( nColorCount )
2063cdf0e10cSrcweir                 {
206470d3707aSArmin Le Grand                     Bitmap aBitmap(((const XFillBitmapItem&)rObj.GetMergedItem(XATTR_FILLBITMAP)).GetGraphicObject().GetGraphic().GetBitmapEx().GetBitmap());
206570d3707aSArmin Le Grand 
2066cdf0e10cSrcweir                     aBitmap.Adjust(
2067cdf0e10cSrcweir                         static_cast< short > ( GetLuminanceChange(
2068cdf0e10cSrcweir                             std::min(nColorIndex, nColorCount-1))));
206970d3707aSArmin Le Grand 
207070d3707aSArmin Le Grand                     rObj.SetMergedItem(XFillBitmapItem(String(), Graphic(aBitmap)));
2071cdf0e10cSrcweir                 }
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir                 break;
2074cdf0e10cSrcweir             }
2075cdf0e10cSrcweir         }
2076cdf0e10cSrcweir 
2077cdf0e10cSrcweir         if ( nColorIndex < nColorCount )
2078cdf0e10cSrcweir             nColorIndex++;
2079cdf0e10cSrcweir     }
2080cdf0e10cSrcweir }
2081cdf0e10cSrcweir 
CreatePathObj(sal_Bool bLineGeometryNeededOnly)2082cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnly )
2083cdf0e10cSrcweir {
2084cdf0e10cSrcweir     sal_Int32 nCoordSize = seqCoordinates.getLength();
2085cdf0e10cSrcweir     if ( !nCoordSize )
2086cdf0e10cSrcweir         return NULL;
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir     sal_uInt16 nSrcPt = 0;
2089cdf0e10cSrcweir     sal_uInt16 nSegmentInd = 0;
2090cdf0e10cSrcweir 
2091cdf0e10cSrcweir     std::vector< SdrPathObj* > vObjectList;
2092cdf0e10cSrcweir     sal_Bool bSortFilledObjectsToBack = SortFilledObjectsToBackByDefault( eSpType );
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir     while( nSegmentInd <= seqSegments.getLength() )
2095cdf0e10cSrcweir     {
2096cdf0e10cSrcweir         CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack );
2097cdf0e10cSrcweir     }
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir     SdrObject* pRet = NULL;
2100cdf0e10cSrcweir     sal_uInt32 i;
2101cdf0e10cSrcweir 
2102cdf0e10cSrcweir     if ( !vObjectList.empty() )
2103cdf0e10cSrcweir     {
2104cdf0e10cSrcweir         const SfxItemSet& rCustomShapeSet = pCustomShapeObj->GetMergedItemSet();
2105cdf0e10cSrcweir         Color           aFillColor;
2106cdf0e10cSrcweir         sal_uInt32      nColorCount = nColorData >> 28;
2107cdf0e10cSrcweir         sal_uInt32      nColorIndex = 0;
2108cdf0e10cSrcweir 
2109cdf0e10cSrcweir         // #i37011# remove invisible objects
2110cdf0e10cSrcweir         if(!vObjectList.empty())
2111cdf0e10cSrcweir         {
2112cdf0e10cSrcweir             std::vector< SdrPathObj* > vTempList;
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir             for(i = 0L; i < vObjectList.size(); i++)
2115cdf0e10cSrcweir             {
2116cdf0e10cSrcweir                 SdrPathObj* pObj(vObjectList[i]);
2117cdf0e10cSrcweir                 const XLineStyle eLineStyle = ((const XLineStyleItem&)pObj->GetMergedItem(XATTR_LINESTYLE)).GetValue();
2118cdf0e10cSrcweir                 const XFillStyle eFillStyle = ((const XFillStyleItem&)pObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue();
2119cdf0e10cSrcweir 
2120cdf0e10cSrcweir                 //SJ: #i40600# if bLineGeometryNeededOnly is set linystyle does not matter
2121cdf0e10cSrcweir                 if( !bLineGeometryNeededOnly && ( XLINE_NONE == eLineStyle ) && ( XFILL_NONE == eFillStyle ) )
2122cdf0e10cSrcweir                     delete pObj;
2123cdf0e10cSrcweir                 else
2124cdf0e10cSrcweir                     vTempList.push_back(pObj);
2125cdf0e10cSrcweir             }
2126cdf0e10cSrcweir 
2127cdf0e10cSrcweir             vObjectList = vTempList;
2128cdf0e10cSrcweir         }
2129cdf0e10cSrcweir 
2130cdf0e10cSrcweir         if(1L == vObjectList.size())
2131cdf0e10cSrcweir         {
2132cdf0e10cSrcweir             // a single object, correct some values
2133cdf0e10cSrcweir             AdaptObjColor(*vObjectList[0L],rCustomShapeSet,nColorIndex,nColorCount);
2134cdf0e10cSrcweir         }
2135cdf0e10cSrcweir         else
2136cdf0e10cSrcweir         {
2137cdf0e10cSrcweir             sal_Int32 nLineObjectCount = 0;
2138cdf0e10cSrcweir             sal_Int32 nAreaObjectCount = 0;
2139cdf0e10cSrcweir 
2140cdf0e10cSrcweir             // correct some values and collect content data
2141cdf0e10cSrcweir             for ( i = 0; i < vObjectList.size(); i++ )
2142cdf0e10cSrcweir             {
2143cdf0e10cSrcweir                 SdrPathObj* pObj( vObjectList[ i ] );
2144cdf0e10cSrcweir 
2145cdf0e10cSrcweir                 if(pObj->IsLine())
2146cdf0e10cSrcweir                 {
2147cdf0e10cSrcweir                     nLineObjectCount++;
2148cdf0e10cSrcweir                 }
2149cdf0e10cSrcweir                 else
2150cdf0e10cSrcweir                 {
2151cdf0e10cSrcweir                     nAreaObjectCount++;
2152cdf0e10cSrcweir                     AdaptObjColor(*pObj,rCustomShapeSet,nColorIndex,nColorCount);
2153cdf0e10cSrcweir                 }
2154cdf0e10cSrcweir             }
2155cdf0e10cSrcweir 
2156cdf0e10cSrcweir             // #i88870# correct line arrows for callouts
2157cdf0e10cSrcweir             if ( nLineObjectCount )
2158cdf0e10cSrcweir                 CorrectCalloutArrows( eSpType, nLineObjectCount, vObjectList );
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir             // sort objects so that filled ones are in front. Necessary
2161cdf0e10cSrcweir             // for some strange objects
2162cdf0e10cSrcweir             if ( bSortFilledObjectsToBack )
2163cdf0e10cSrcweir             {
2164cdf0e10cSrcweir                 std::vector< SdrPathObj* > vTempList;
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir                 for ( i = 0; i < vObjectList.size(); i++ )
2167cdf0e10cSrcweir                 {
2168cdf0e10cSrcweir                     SdrPathObj* pObj( vObjectList[ i ] );
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir                     if ( !pObj->IsLine() )
2171cdf0e10cSrcweir                     {
2172cdf0e10cSrcweir                         vTempList.push_back(pObj);
2173cdf0e10cSrcweir                     }
2174cdf0e10cSrcweir                 }
2175cdf0e10cSrcweir 
2176cdf0e10cSrcweir                 for ( i = 0; i < vObjectList.size(); i++ )
2177cdf0e10cSrcweir                 {
2178cdf0e10cSrcweir                     SdrPathObj* pObj( vObjectList[ i ] );
2179cdf0e10cSrcweir 
2180cdf0e10cSrcweir                     if ( pObj->IsLine() )
2181cdf0e10cSrcweir                     {
2182cdf0e10cSrcweir                         vTempList.push_back(pObj);
2183cdf0e10cSrcweir                     }
2184cdf0e10cSrcweir                 }
2185cdf0e10cSrcweir 
2186cdf0e10cSrcweir                 vObjectList = vTempList;
2187cdf0e10cSrcweir             }
2188cdf0e10cSrcweir         }
2189cdf0e10cSrcweir     }
2190cdf0e10cSrcweir 
2191cdf0e10cSrcweir     // #i37011#
2192cdf0e10cSrcweir     if(!vObjectList.empty())
2193cdf0e10cSrcweir     {
2194cdf0e10cSrcweir         // copy remaining objects to pRet
2195cdf0e10cSrcweir         if(vObjectList.size() > 1L)
2196cdf0e10cSrcweir         {
2197cdf0e10cSrcweir             pRet = new SdrObjGroup;
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir             for (i = 0L; i < vObjectList.size(); i++)
2200cdf0e10cSrcweir             {
2201cdf0e10cSrcweir                 SdrObject* pObj(vObjectList[i]);
2202cdf0e10cSrcweir                 pRet->GetSubList()->NbcInsertObject(pObj);
2203cdf0e10cSrcweir             }
2204cdf0e10cSrcweir         }
2205cdf0e10cSrcweir         else if(1L == vObjectList.size())
2206cdf0e10cSrcweir         {
2207cdf0e10cSrcweir             pRet = vObjectList[0L];
2208cdf0e10cSrcweir         }
2209cdf0e10cSrcweir 
2210cdf0e10cSrcweir         if(pRet)
2211cdf0e10cSrcweir         {
2212cdf0e10cSrcweir             // move to target position
2213cdf0e10cSrcweir             Rectangle aCurRect(pRet->GetSnapRect());
2214cdf0e10cSrcweir             aCurRect.Move(aLogicRect.Left(), aLogicRect.Top());
2215cdf0e10cSrcweir             pRet->NbcSetSnapRect(aCurRect);
2216cdf0e10cSrcweir         }
2217cdf0e10cSrcweir     }
2218cdf0e10cSrcweir 
2219cdf0e10cSrcweir     return pRet;
2220cdf0e10cSrcweir }
2221cdf0e10cSrcweir 
CreateObject(sal_Bool bLineGeometryNeededOnly)2222cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreateObject( sal_Bool bLineGeometryNeededOnly )
2223cdf0e10cSrcweir {
2224cdf0e10cSrcweir     SdrObject* pRet = NULL;
2225cdf0e10cSrcweir 
2226cdf0e10cSrcweir     if ( eSpType == mso_sptRectangle )
2227cdf0e10cSrcweir     {
2228cdf0e10cSrcweir         pRet = new SdrRectObj( aLogicRect );
2229cdf0e10cSrcweir // SJ: not setting model, so we save a lot of broadcasting and the model is not modified any longer
2230cdf0e10cSrcweir //      pRet->SetModel( pCustomShapeObj->GetModel() );
2231cdf0e10cSrcweir         pRet->SetMergedItemSet( *this );
2232cdf0e10cSrcweir     }
2233cdf0e10cSrcweir     if ( !pRet )
2234cdf0e10cSrcweir         pRet = CreatePathObj( bLineGeometryNeededOnly );
2235cdf0e10cSrcweir 
2236cdf0e10cSrcweir     return pRet;
2237cdf0e10cSrcweir }
2238cdf0e10cSrcweir 
ApplyGluePoints(SdrObject * pObj)2239cdf0e10cSrcweir void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj )
2240cdf0e10cSrcweir {
2241cdf0e10cSrcweir     if ( pObj && seqGluePoints.getLength() )
2242cdf0e10cSrcweir     {
2243cdf0e10cSrcweir         sal_uInt32 i, nCount = seqGluePoints.getLength();
2244cdf0e10cSrcweir         for ( i = 0; i < nCount; i++ )
2245cdf0e10cSrcweir         {
2246cdf0e10cSrcweir             SdrGluePoint aGluePoint;
2247cdf0e10cSrcweir 
2248cdf0e10cSrcweir             aGluePoint.SetPos( GetPoint( seqGluePoints[ i ], sal_True, sal_True ) );
2249cdf0e10cSrcweir             aGluePoint.SetPercent( sal_False );
2250cdf0e10cSrcweir 
2251cdf0e10cSrcweir //          const Point& rPoint = GetPoint( seqGluePoints[ i ], sal_True, sal_True );
2252cdf0e10cSrcweir //          double fXRel = rPoint.X();
2253cdf0e10cSrcweir //          double fYRel = rPoint.Y();
2254cdf0e10cSrcweir //          fXRel = aLogicRect.GetWidth() == 0 ? 0.0 : fXRel / aLogicRect.GetWidth() * 10000;
2255cdf0e10cSrcweir //          fYRel = aLogicRect.GetHeight() == 0 ? 0.0 : fYRel / aLogicRect.GetHeight() * 10000;
2256cdf0e10cSrcweir //          aGluePoint.SetPos( Point( (sal_Int32)fXRel, (sal_Int32)fYRel ) );
2257cdf0e10cSrcweir //          aGluePoint.SetPercent( sal_True );
2258cdf0e10cSrcweir             aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT );
2259cdf0e10cSrcweir             aGluePoint.SetEscDir( SDRESC_SMART );
2260cdf0e10cSrcweir             SdrGluePointList* pList = pObj->ForceGluePointList();
2261cdf0e10cSrcweir             if( pList )
2262cdf0e10cSrcweir                 /* sal_uInt16 nId = */ pList->Insert( aGluePoint );
2263cdf0e10cSrcweir         }
2264cdf0e10cSrcweir     }
2265cdf0e10cSrcweir }
2266cdf0e10cSrcweir 
CreateLineGeometry()2267cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreateLineGeometry()
2268cdf0e10cSrcweir {
2269cdf0e10cSrcweir     return CreateObject( sal_True );
2270cdf0e10cSrcweir }
2271