Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <main.hxx>
22 : #include <chart.hxx>
23 : #include <outact.hxx>
24 : #include <math.h>
25 : #include <boost/scoped_array.hpp>
26 :
27 : using namespace ::com::sun::star;
28 :
29 9 : double CGM::ImplGetOrientation( FloatPoint& rCenter, FloatPoint& rPoint )
30 : {
31 : double fOrientation;
32 :
33 9 : double nX = rPoint.X - rCenter.X;
34 9 : double nY = rPoint.Y - rCenter.Y;
35 :
36 9 : fOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
37 9 : if ( nY > 0 )
38 3 : fOrientation = 360 - fOrientation;
39 :
40 9 : return fOrientation;
41 : }
42 :
43 :
44 :
45 6 : void CGM::ImplSwitchStartEndAngle( double& rStartAngle, double& rEndAngle )
46 : {
47 : double nTemp;
48 6 : nTemp = rStartAngle;
49 6 : rStartAngle = rEndAngle;
50 6 : rEndAngle = nTemp;
51 6 : }
52 :
53 :
54 :
55 35 : void CGM::ImplGetVector( double* pVector )
56 : {
57 35 : if ( pElement->eVDCType == VDC_REAL )
58 : {
59 175 : for ( sal_uInt32 i = 0; i < 4; i++ )
60 : {
61 140 : pVector[ i ] = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
62 : }
63 : }
64 : else
65 : {
66 0 : for ( sal_uInt32 i = 0; i < 4; i++ )
67 : {
68 0 : pVector[ i ] = (double)ImplGetI( pElement->nVDCIntegerPrecision );
69 : }
70 : }
71 35 : pVector[ 0 ] *= mnVDCXmul;
72 35 : pVector[ 2 ] *= mnVDCXmul;
73 35 : pVector[ 1 ] *= mnVDCYmul;
74 35 : pVector[ 3 ] *= mnVDCYmul;
75 35 : }
76 :
77 :
78 1 : bool CGM::ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rAngle )
79 : {
80 1 : FloatPoint aPoint1, aPoint2;
81 : double fRot1, fRot2;
82 1 : ImplGetPoint( rCenter, true );
83 1 : ImplGetPoint( aPoint1, true );
84 0 : ImplGetPoint( aPoint2, true );
85 0 : fRot1 = ImplGetOrientation( rCenter, aPoint1 );
86 0 : fRot2 = ImplGetOrientation( rCenter, aPoint2 );
87 0 : rAngle = ImplGetOrientation( rCenter, aPoint1 );
88 0 : aPoint1.X -= rCenter.X;
89 0 : aPoint1.Y -= rCenter.Y;
90 0 : rRadius.X = sqrt( aPoint1.X * aPoint1.X + aPoint1.Y * aPoint1.Y );
91 0 : aPoint2.X -= rCenter.X;
92 0 : aPoint2.Y -= rCenter.Y;
93 0 : rRadius.Y = sqrt( aPoint2.X * aPoint2.X + aPoint2.Y * aPoint2.Y );
94 :
95 0 : if ( fRot1 > fRot2 )
96 : {
97 0 : if ( ( fRot1 - fRot2 ) < 180 )
98 0 : return false;
99 : }
100 : else
101 : {
102 0 : if ( ( fRot2 - fRot1 ) > 180 )
103 0 : return false;
104 : }
105 0 : return true;
106 : }
107 :
108 103 : void CGM::ImplDoClass4()
109 : {
110 103 : if ( mbFirstOutPut )
111 14 : mpOutAct->FirstOutPut();
112 :
113 103 : if ( mpBitmapInUse && ( mnElementID != 9 ) ) // process existend graphic
114 : { // because there are now no pending bitmap actions
115 0 : CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
116 : // do anything with the bitmap
117 0 : mpOutAct->DrawBitmap( pBmpDesc );
118 0 : delete mpBitmapInUse;
119 0 : mpBitmapInUse = NULL;
120 : }
121 :
122 103 : if ( ( mpChart == NULL ) || mpChart->IsAnnotation() )
123 : {
124 103 : switch ( mnElementID )
125 : {
126 : case 0x01 : /*PolyLine*/
127 : {
128 14 : sal_uInt32 nPoints = mnElementSize / ImplGetPointSize();
129 14 : Polygon aPolygon( (sal_uInt16)nPoints );
130 84 : for ( sal_uInt32 i = 0; i < nPoints; i++)
131 : {
132 70 : FloatPoint aFloatPoint;
133 70 : ImplGetPoint( aFloatPoint, true );
134 70 : aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), i );
135 : }
136 14 : if ( mbFigure )
137 0 : mpOutAct->RegPolyLine( aPolygon );
138 : else
139 14 : mpOutAct->DrawPolyLine( aPolygon );
140 : }
141 14 : break;
142 :
143 : case 0x02 : /*Disjoint PolyLine*/
144 : {
145 : sal_uInt16 nPoints = sal::static_int_cast< sal_uInt16 >(
146 14 : mnElementSize / ImplGetPointSize());
147 14 : if ( ! ( nPoints & 1 ) )
148 : {
149 14 : nPoints >>= 1;
150 14 : FloatPoint aFloatPoint;
151 14 : if ( mbFigure )
152 : {
153 0 : Polygon aPolygon( nPoints );
154 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
155 : {
156 0 : ImplGetPoint( aFloatPoint, true );
157 0 : aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
158 : }
159 0 : mpOutAct->RegPolyLine( aPolygon );
160 : }
161 : else
162 : {
163 14 : mpOutAct->BeginGroup();
164 14 : Polygon aPolygon( (sal_uInt16)2 );
165 56 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
166 : {
167 42 : ImplGetPoint( aFloatPoint, true );
168 42 : aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
169 42 : ImplGetPoint( aFloatPoint, true );
170 42 : aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 1);
171 42 : mpOutAct->DrawPolyLine( aPolygon );
172 : }
173 14 : mpOutAct->EndGroup();
174 : }
175 : }
176 : }
177 14 : break;
178 :
179 0 : case 0x03 : /*PolyMarker*/ break;
180 : case 0x04 : /*Text*/
181 : {
182 0 : FloatPoint aFloatPoint;
183 : sal_uInt32 nType, nSize;
184 :
185 0 : if ( mbFigure )
186 0 : mpOutAct->CloseRegion();
187 :
188 0 : ImplGetPoint ( aFloatPoint, true );
189 0 : nType = ImplGetUI16( 4 );
190 0 : nSize = ImplGetUI( 1 );
191 0 : mpSource[ mnParaSize + nSize ] = 0;
192 :
193 0 : awt::Size aSize;
194 0 : awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
195 : mpOutAct->DrawText( aPoint, aSize,
196 0 : reinterpret_cast<char*>(mpSource) + mnParaSize, nSize, (FinalFlag)nType );
197 0 : mnParaSize = mnElementSize;
198 : }
199 0 : break;
200 :
201 : case 0x05 : /*Restricted Text*/
202 : {
203 : double dx, dy;
204 0 : FloatPoint aFloatPoint;
205 : sal_uInt32 nType, nSize;
206 :
207 0 : if ( mbFigure )
208 0 : mpOutAct->CloseRegion();
209 :
210 0 : if ( pElement->eVDCType == VDC_REAL )
211 : {
212 0 : dx = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
213 0 : dy = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
214 : }
215 : else
216 : {
217 0 : dx = (double)ImplGetI( pElement->nVDCIntegerPrecision );
218 0 : dy = (double)ImplGetI( pElement->nVDCIntegerPrecision );
219 : }
220 0 : ImplMapDouble( dx );
221 0 : ImplMapDouble( dy );
222 :
223 0 : ImplGetPoint ( aFloatPoint, true );
224 0 : nType = ImplGetUI16( 4 );
225 0 : nSize = ImplGetUI( 1 );
226 :
227 0 : mpSource[ mnParaSize + nSize ] = 0;
228 :
229 0 : awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
230 0 : awt::Size aSize((long)dx, (long)dy);
231 : mpOutAct->DrawText( aPoint, aSize ,
232 0 : reinterpret_cast<char*>(mpSource) + mnParaSize, nSize, (FinalFlag)nType );
233 0 : mnParaSize = mnElementSize;
234 : }
235 0 : break;
236 :
237 : case 0x06 : /*Append Text*/
238 : {
239 : sal_uInt32 nSize;
240 0 : sal_uInt32 nType = ImplGetUI16( 4 );
241 :
242 0 : nSize = ImplGetUI( 1 );
243 0 : mpSource[ mnParaSize + nSize ] = 0;
244 :
245 0 : mpOutAct->AppendText( reinterpret_cast<char*>(mpSource) + mnParaSize, nSize, (FinalFlag)nType );
246 0 : mnParaSize = mnElementSize;
247 : }
248 0 : break;
249 :
250 : case 0x07 : /*Polygon*/
251 : {
252 0 : if ( mbFigure )
253 0 : mpOutAct->CloseRegion();
254 :
255 : sal_uInt16 nPoints = sal::static_int_cast< sal_uInt16 >(
256 0 : mnElementSize / ImplGetPointSize());
257 0 : Polygon aPolygon( nPoints );
258 0 : for ( sal_uInt16 i = 0; i < nPoints; i++)
259 : {
260 0 : FloatPoint aFloatPoint;
261 0 : ImplGetPoint( aFloatPoint, true );
262 0 : aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
263 : }
264 0 : mpOutAct->DrawPolygon( aPolygon );
265 : }
266 0 : break;
267 :
268 : case 0x08 : /*Polygon Set*/
269 : {
270 0 : if ( mbFigure )
271 0 : mpOutAct->CloseRegion();
272 :
273 0 : sal_uInt16 nPoints = 0;
274 0 : boost::scoped_array<Point> pPoints(new Point[ 0x4000 ]);
275 :
276 0 : tools::PolyPolygon aPolyPolygon;
277 0 : FloatPoint aFloatPoint;
278 : sal_uInt32 nEdgeFlag;
279 0 : while ( mnParaSize < mnElementSize )
280 : {
281 0 : ImplGetPoint( aFloatPoint, true );
282 0 : nEdgeFlag = ImplGetUI16();
283 0 : pPoints[ nPoints++ ] = Point( (long)aFloatPoint.X, (long)aFloatPoint.Y );
284 0 : if ( ( nEdgeFlag & 2 ) || ( mnParaSize == mnElementSize ) )
285 : {
286 0 : Polygon aPolygon( nPoints );
287 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
288 : {
289 0 : aPolygon.SetPoint( pPoints[ i ], i );
290 : }
291 0 : aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
292 0 : nPoints = 0;
293 : }
294 : }
295 0 : pPoints.reset();
296 0 : mpOutAct->DrawPolyPolygon( aPolyPolygon );
297 : }
298 0 : break;
299 :
300 : case 0x09 : /*Cell Array*/
301 : {
302 0 : if ( mbFigure )
303 0 : mpOutAct->CloseRegion();
304 :
305 0 : if ( mpBitmapInUse )
306 : {
307 0 : CGMBitmap* pBmpDesc = mpBitmapInUse->GetNext();
308 0 : if ( pBmpDesc ) // we possibly get a bitmap back which does not fit to
309 : { // to the previous -> we need to delete this one too
310 0 : mpOutAct->DrawBitmap( pBmpDesc->GetBitmap() );
311 0 : delete pBmpDesc;
312 : }
313 : }
314 : else
315 : {
316 0 : mpBitmapInUse = new CGMBitmap( *this );
317 : }
318 : }
319 0 : break;
320 :
321 : case 0x0a : /*Generalized Drawing Primitive*/
322 : {
323 14 : ImplGetI( pElement->nIntegerPrecision ); //-Wall is this needed
324 14 : ImplGetUI( pElement->nIntegerPrecision ); //-Wall is this needed
325 14 : mnParaSize = mnElementSize;
326 : }
327 14 : break;
328 :
329 : case 0x0b : /*Rectangle*/
330 : {
331 11 : if ( mbFigure )
332 0 : mpOutAct->CloseRegion();
333 :
334 11 : FloatRect aFloatRect;
335 11 : ImplGetRectangle( aFloatRect, true );
336 11 : mpOutAct->DrawRectangle( aFloatRect );
337 : }
338 11 : break;
339 :
340 : case 0x0c : /*Circle*/
341 : {
342 11 : if ( mbFigure )
343 0 : mpOutAct->CloseRegion();
344 :
345 11 : double fRotation = 0;
346 11 : FloatPoint aCenter, aRadius;
347 11 : ImplGetPoint( aCenter, true );
348 11 : if ( pElement->eVDCType == VDC_REAL )
349 11 : aRadius.X = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
350 : else
351 0 : aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
352 11 : ImplMapDouble( aRadius.X );
353 11 : aRadius.Y = aRadius.X;
354 11 : mpOutAct->DrawEllipse( aCenter, aRadius, fRotation );
355 : }
356 11 : break;
357 :
358 : case 0x0d : /*Circular Arc 3 Point*/
359 : {
360 1 : FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
361 1 : ImplGetPoint( aStartingPoint, true );
362 1 : ImplGetPoint( aIntermediatePoint, true );
363 1 : ImplGetPoint( aEndingPoint, true );
364 :
365 1 : double fA = aIntermediatePoint.X - aStartingPoint.X;
366 1 : double fB = aIntermediatePoint.Y - aStartingPoint.Y;
367 1 : double fC = aEndingPoint.X - aStartingPoint.X;
368 1 : double fD = aEndingPoint.Y - aStartingPoint.Y;
369 :
370 1 : double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
371 1 : double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
372 :
373 1 : double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
374 :
375 1 : if ( fG != 0 )
376 : {
377 1 : aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
378 1 : aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
379 1 : double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
380 1 : double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
381 1 : double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
382 :
383 1 : int nSwitch = 0;
384 :
385 1 : if ( fStartAngle > fEndAngle )
386 : {
387 0 : nSwitch ^=1;
388 0 : aIntermediatePoint = aEndingPoint;
389 0 : aEndingPoint = aStartingPoint;
390 0 : aStartingPoint = aIntermediatePoint;
391 0 : fG = fStartAngle;
392 0 : fStartAngle = fEndAngle;
393 0 : fEndAngle = fG;
394 : }
395 1 : if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
396 : {
397 1 : nSwitch ^=1;
398 1 : aIntermediatePoint = aEndingPoint;
399 1 : aEndingPoint = aStartingPoint;
400 1 : aStartingPoint = aIntermediatePoint;
401 1 : fG = fStartAngle;
402 1 : fStartAngle = fEndAngle;
403 1 : fEndAngle = fG;
404 : }
405 1 : double fRadius = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
406 :
407 1 : if ( mbFigure )
408 : {
409 0 : Rectangle aBoundingBox( Point( (long)( aCenterPoint.X - fRadius ), long( aCenterPoint.Y - fRadius ) ),
410 0 : Size( ( static_cast< long >( 2 * fRadius ) ), (long)( 2 * fRadius) ) );
411 0 : Polygon aPolygon( aBoundingBox, Point( (long)aStartingPoint.X, (long)aStartingPoint.Y ) ,Point( (long)aEndingPoint.X, (long)aEndingPoint.Y ), POLY_ARC );
412 0 : if ( nSwitch )
413 0 : mpOutAct->RegPolyLine( aPolygon, true );
414 : else
415 0 : mpOutAct->RegPolyLine( aPolygon );
416 : }
417 : else
418 : {
419 1 : fG = 0;
420 1 : FloatPoint aRadius;
421 1 : aRadius.X = aRadius.Y = fRadius;
422 1 : mpOutAct->DrawEllipticalArc( aCenterPoint, aRadius, fG, 2, fStartAngle, fEndAngle );
423 : }
424 : }
425 : }
426 1 : break;
427 :
428 : case 0x0e : /*Circular Arc 3 Point Close*/
429 : {
430 2 : if ( mbFigure )
431 0 : mpOutAct->CloseRegion();
432 :
433 2 : FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
434 2 : ImplGetPoint( aStartingPoint );
435 2 : ImplGetPoint( aIntermediatePoint );
436 2 : ImplGetPoint( aEndingPoint );
437 :
438 2 : double fA = aIntermediatePoint.X - aStartingPoint.X;
439 2 : double fB = aIntermediatePoint.Y - aStartingPoint.Y;
440 2 : double fC = aEndingPoint.X - aStartingPoint.X;
441 2 : double fD = aEndingPoint.Y - aStartingPoint.Y;
442 :
443 2 : double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
444 2 : double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
445 :
446 2 : double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
447 :
448 2 : if ( fG != 0 )
449 : {
450 2 : aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
451 2 : aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
452 2 : double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
453 2 : double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
454 2 : double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
455 :
456 2 : if ( fStartAngle > fEndAngle )
457 : {
458 0 : aIntermediatePoint = aEndingPoint;
459 0 : aEndingPoint = aStartingPoint;
460 0 : aStartingPoint = aIntermediatePoint;
461 0 : fG = fStartAngle;
462 0 : fStartAngle = fEndAngle;
463 0 : fEndAngle = fG;
464 : }
465 2 : if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
466 : {
467 2 : aIntermediatePoint = aEndingPoint;
468 2 : aEndingPoint = aStartingPoint;
469 2 : aStartingPoint = aIntermediatePoint;
470 2 : fG = fStartAngle;
471 2 : fStartAngle = fEndAngle;
472 2 : fEndAngle = fG;
473 : }
474 2 : FloatPoint fRadius;
475 2 : fRadius.Y = fRadius.X = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
476 :
477 2 : sal_uInt32 nType = ImplGetUI16();
478 2 : if ( nType == 0 )
479 1 : nType = 0; // is PIE
480 : else
481 1 : nType = 1; // is CHORD
482 :
483 2 : double fOrientation = 0;
484 2 : mpOutAct->DrawEllipticalArc( aCenterPoint, fRadius, fOrientation, nType, fStartAngle, fEndAngle );
485 : }
486 : }
487 2 : break;
488 :
489 : case 0x0f : /*Circular Arc Centre*/
490 : {
491 : double fStartAngle, fEndAngle, vector[ 4 ];
492 11 : FloatPoint aCenter, aRadius;
493 :
494 11 : if ( mbFigure )
495 0 : mpOutAct->CloseRegion();
496 :
497 11 : ImplGetPoint( aCenter, true );
498 11 : ImplGetVector( &vector[ 0 ] );
499 :
500 11 : if ( pElement->eVDCType == VDC_REAL )
501 : {
502 11 : aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
503 : }
504 : else
505 : {
506 0 : aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
507 : }
508 :
509 11 : ImplMapDouble( aRadius.X );
510 11 : aRadius.Y = aRadius.X;
511 :
512 11 : fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
513 11 : fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
514 :
515 11 : if ( vector[ 1 ] > 0 )
516 2 : fStartAngle = 360 - fStartAngle;
517 11 : if ( vector[ 3 ] > 0 )
518 2 : fEndAngle = 360 - fEndAngle;
519 :
520 11 : if ( mbAngReverse )
521 2 : ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
522 :
523 11 : if ( mbFigure )
524 : {
525 : Rectangle aBoundingBox(
526 0 : Point( (long)( aCenter.X - aRadius.X ), long( aCenter.Y - aRadius.X ) ),
527 0 : Size( static_cast< long >( 2 * aRadius.X ), (long)( 2 * aRadius.X ) ) );
528 : Polygon aPolygon( aBoundingBox,
529 0 : Point( (long)vector[ 0 ], (long)vector[ 1 ] ),
530 0 : Point( (long)vector[ 2 ], (long)vector[ 3 ] ), POLY_ARC );
531 0 : mpOutAct->RegPolyLine( aPolygon );
532 : }
533 : else
534 : {
535 11 : double fOrientation = 0;
536 11 : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation, 2, fStartAngle, fEndAngle );
537 : }
538 11 : mnParaSize = mnElementSize;
539 :
540 : }
541 11 : break;
542 :
543 : case 0x10 : /*Circular Arc Centre Close*/
544 : {
545 : double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
546 24 : FloatPoint aCenter, aRadius;
547 :
548 24 : if ( mbFigure )
549 0 : mpOutAct->CloseRegion();
550 :
551 24 : ImplGetPoint( aCenter, true );
552 24 : ImplGetVector( &vector[ 0 ] );
553 24 : if ( pElement->eVDCType == VDC_REAL )
554 : {
555 24 : aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
556 : }
557 : else
558 : {
559 0 : aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
560 : }
561 24 : ImplMapDouble( aRadius.X );
562 24 : aRadius.Y = aRadius.X;
563 24 : fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
564 24 : fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
565 :
566 24 : if ( vector[ 1 ] > 0 )
567 4 : fStartAngle = 360 - fStartAngle;
568 24 : if ( vector[ 3 ] > 0 )
569 4 : fEndAngle = 360 - fEndAngle;
570 :
571 24 : if ( mbAngReverse )
572 4 : ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
573 :
574 :
575 24 : sal_uInt32 nType = ImplGetUI16();
576 24 : if ( nType == 0 )
577 13 : nType = 0; // is PIE
578 : else
579 11 : nType = 1; // is CHORD
580 24 : fOrientation = 0;
581 :
582 : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
583 24 : nType, fStartAngle, fEndAngle );
584 24 : mnParaSize = mnElementSize;
585 : }
586 24 : break;
587 :
588 : case 0x11 : /*Ellipse*/
589 : {
590 : double fOrientation;
591 0 : FloatPoint aCenter, aRadius;
592 :
593 0 : if ( mbFigure )
594 0 : mpOutAct->CloseRegion();
595 :
596 0 : ImplGetEllipse( aCenter, aRadius, fOrientation ) ;
597 0 : mpOutAct->DrawEllipse( aCenter, aRadius, fOrientation ) ;
598 : }
599 0 : break;
600 :
601 : case 0x12 : /*Elliptical Arc*/
602 : {
603 1 : if ( mbFigure )
604 0 : mpOutAct->CloseRegion();
605 :
606 : double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
607 1 : FloatPoint aCenter, aRadius;
608 :
609 1 : if ( mbFigure )
610 0 : mpOutAct->CloseRegion();
611 :
612 1 : bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
613 0 : ImplGetVector( &vector[ 0 ] );
614 :
615 0 : fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
616 0 : fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
617 :
618 0 : if ( vector[ 1 ] > 0 )
619 0 : fStartAngle = 360 - fStartAngle;
620 0 : if ( vector[ 3 ] > 0 )
621 0 : fEndAngle = 360 - fEndAngle;
622 :
623 0 : if ( bDirection )
624 : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
625 0 : 2, fStartAngle, fEndAngle );
626 : else
627 : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
628 0 : 2, fEndAngle, fStartAngle);
629 : }
630 0 : break;
631 :
632 : case 0x13 : /*Elliptical Arc Close*/
633 : {
634 : double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
635 0 : FloatPoint aCenter, aRadius;
636 :
637 0 : if ( mbFigure )
638 0 : mpOutAct->CloseRegion();
639 :
640 0 : bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
641 0 : ImplGetVector( &vector[ 0 ] );
642 :
643 0 : fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
644 0 : fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
645 :
646 0 : if ( vector[ 1 ] > 0 )
647 0 : fStartAngle = 360 - fStartAngle;
648 0 : if ( vector[ 3 ] > 0 )
649 0 : fEndAngle = 360 - fEndAngle;
650 :
651 0 : sal_uInt32 nType = ImplGetUI16();
652 0 : if ( nType == 0 )
653 0 : nType = 0; // is PIE
654 : else
655 0 : nType = 1; // is CHORD
656 :
657 0 : if ( bDirection )
658 : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
659 0 : nType, fStartAngle, fEndAngle );
660 : else
661 : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
662 0 : nType, fEndAngle, fStartAngle);
663 : }
664 0 : break;
665 : case 0x14 : /*Circular Arc Centre Reversed*/
666 : {
667 0 : if ( mbFigure )
668 0 : mpOutAct->CloseRegion();
669 : }
670 0 : break;
671 : case 0x15 : /*Connection Edge */ // NS
672 : {
673 : // if ( mbFigure )
674 : // mpOutAct->CloseRegion();
675 : }
676 0 : break;
677 : case 0x16 : /*Hyperbolic Arc */ // NS
678 : {
679 0 : if ( mbFigure )
680 0 : mpOutAct->CloseRegion();
681 : }
682 0 : break;
683 : case 0x17 : /*Parabolic Arc */ // NS
684 : {
685 0 : if ( mbFigure )
686 0 : mpOutAct->CloseRegion();
687 : }
688 0 : break;
689 : case 0x18 : /*Non Uniform B-Spline */ // NS
690 : {
691 0 : if ( mbFigure )
692 0 : mpOutAct->CloseRegion();
693 : }
694 0 : break;
695 : case 0x19 : /*Non Uniform Rational B-Spline */ // NS
696 : {
697 0 : if ( mbFigure )
698 0 : mpOutAct->CloseRegion();
699 : }
700 0 : break;
701 : case 0x1a : /*Polybezier*/
702 : {
703 0 : sal_uInt32 nOrder = ImplGetI( pElement->nIntegerPrecision );
704 :
705 0 : sal_uInt16 nNumberOfPoints = sal::static_int_cast< sal_uInt16 >(( mnElementSize - pElement->nIntegerPrecision ) / ImplGetPointSize());
706 :
707 0 : Polygon aPolygon( nNumberOfPoints );
708 :
709 0 : for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++)
710 : {
711 0 : FloatPoint aFloatPoint;
712 0 : ImplGetPoint( aFloatPoint, true );
713 0 : aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
714 : }
715 0 : if ( nOrder & 4 )
716 : {
717 0 : for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++ )
718 : {
719 0 : if ( ( i % 3 ) == 0 )
720 0 : aPolygon.SetFlags( i, POLY_NORMAL );
721 : else
722 0 : aPolygon.SetFlags( i, POLY_CONTROL );
723 : }
724 : }
725 : else
726 : {
727 0 : for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++ )
728 : {
729 0 : switch ( i & 3 )
730 : {
731 : case 0 :
732 0 : case 3 : aPolygon.SetFlags( i, POLY_NORMAL ); break;
733 0 : default : aPolygon.SetFlags( i, POLY_CONTROL ); break;
734 : }
735 : }
736 : }
737 0 : if ( mbFigure )
738 0 : mpOutAct->RegPolyLine( aPolygon );
739 : else
740 0 : mpOutAct->DrawPolybezier( aPolygon );
741 0 : mnParaSize = mnElementSize;
742 : }
743 0 : break;
744 :
745 : case 0x1b : /*Polysymbol */ // NS
746 : {
747 0 : if ( mbFigure )
748 0 : mpOutAct->CloseRegion();
749 : }
750 0 : break;
751 : case 0x1c : /*Bitonal Tile */ // NS
752 : {
753 0 : if ( mbFigure )
754 0 : mpOutAct->CloseRegion();
755 : }
756 0 : break;
757 : case 0x1d : /*Tile */ // NS
758 : {
759 0 : if ( mbFigure )
760 0 : mpOutAct->CloseRegion();
761 : }
762 0 : break;
763 : case 0x1e : /*Insert Object*/
764 : {
765 0 : if ( mbFigure )
766 0 : mpOutAct->CloseRegion();
767 : }
768 0 : break;
769 : case 0xff : /*Polybezier*/
770 : {
771 0 : if ( mbFigure )
772 0 : mpOutAct->CloseRegion();
773 : }
774 0 : break;
775 : case 0xfe : /*Sharp Polybezier*/
776 : {
777 0 : if ( mbFigure )
778 0 : mpOutAct->CloseRegion();
779 : }
780 0 : break;
781 : case 0xfd : /*Polyspline*/
782 : {
783 0 : if ( mbFigure )
784 0 : mpOutAct->CloseRegion();
785 : }
786 0 : break;
787 : case 0xfc : /*Reounded Rectangle*/
788 : {
789 0 : if ( mbFigure )
790 0 : mpOutAct->CloseRegion();
791 : }
792 0 : break;
793 : case 0xfb : /*Begin Cell Array*/
794 : {
795 0 : if ( mbFigure )
796 0 : mpOutAct->CloseRegion();
797 : }
798 0 : break;
799 : case 0xfa : /*End Cell Array*/
800 : {
801 0 : if ( mbFigure )
802 0 : mpOutAct->CloseRegion();
803 : }
804 0 : break;
805 : case 0xf9 : /*Insert File*/
806 : {
807 0 : if ( mbFigure )
808 0 : mpOutAct->CloseRegion();
809 : }
810 0 : break;
811 : case 0xf8 : /*Block Text*/
812 : {
813 0 : if ( mbFigure )
814 0 : mpOutAct->CloseRegion();
815 : }
816 0 : break;
817 : case 0xf7 : /*Variable Width Polyline*/
818 : {
819 0 : if ( mbFigure )
820 0 : mpOutAct->CloseRegion();
821 : }
822 0 : break;
823 : case 0xf6 : /*Elliptical Arc 3 Point*/
824 : {
825 0 : if ( mbFigure )
826 0 : mpOutAct->CloseRegion();
827 : }
828 0 : break;
829 0 : case 0xf1 : /*Hyperlink Definition */break;
830 0 : default: break;
831 : }
832 : }
833 : else
834 0 : mnParaSize = mnElementSize;
835 102 : };
836 :
837 :
838 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|