xref: /aoo41x/main/vcl/source/gdi/metaact.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_vcl.hxx"
30 
31 #define ENABLE_BYTESTRING_STREAM_OPERATORS
32 
33 #include <algorithm>
34 #include <string.h>
35 #include <tools/stream.hxx>
36 #include <tools/vcompat.hxx>
37 #include <vcl/outdev.hxx>
38 #include <vcl/salbtype.hxx>
39 #include <vcl/metaact.hxx>
40 #include <vcl/graphictools.hxx>
41 #include <vcl/rendergraphicrasterizer.hxx>
42 
43 // ========================================================================
44 
45 inline void ImplScalePoint( Point& rPt, double fScaleX, double fScaleY )
46 {
47 	rPt.X() = FRound( fScaleX * rPt.X() );
48 	rPt.Y() = FRound( fScaleY * rPt.Y() );
49 }
50 
51 // ------------------------------------------------------------------------
52 
53 inline void ImplScaleRect( Rectangle& rRect, double fScaleX, double fScaleY )
54 {
55 	Point aTL( rRect.TopLeft() );
56 	Point aBR( rRect.BottomRight() );
57 
58 	ImplScalePoint( aTL, fScaleX, fScaleY );
59 	ImplScalePoint( aBR, fScaleX, fScaleY );
60 
61 	rRect = Rectangle( aTL, aBR );
62     rRect.Justify();
63 }
64 
65 // ------------------------------------------------------------------------
66 
67 inline void ImplScalePoly( Polygon& rPoly, double fScaleX, double fScaleY )
68 {
69 	for( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
70 		ImplScalePoint( rPoly[ i ], fScaleX, fScaleY );
71 }
72 
73 // ------------------------------------------------------------------------
74 
75 inline void ImplScaleLineInfo( LineInfo& rLineInfo, double fScaleX, double fScaleY )
76 {
77 	if( !rLineInfo.IsDefault() )
78 	{
79 		const double fScale = ( fabs(fScaleX) + fabs(fScaleY) ) * 0.5;
80 
81 		rLineInfo.SetWidth( FRound( fScale * rLineInfo.GetWidth() ) );
82 		rLineInfo.SetDashLen( FRound( fScale * rLineInfo.GetDashLen() ) );
83 		rLineInfo.SetDotLen( FRound( fScale * rLineInfo.GetDotLen() ) );
84 		rLineInfo.SetDistance( FRound( fScale * rLineInfo.GetDistance() ) );
85 	}
86 }
87 
88 // ========================================================================
89 
90 #define COMPAT( _def_rIStm ) VersionCompat aCompat( ( _def_rIStm ), STREAM_READ );
91 #define COMPAT_VERSION() aCompat.GetVersion()
92 #define WRITE_BASE_COMPAT( _def_rOStm, _def_nVer, _pWriteData ) 		\
93 	MetaAction::Write( ( _def_rOStm ), _pWriteData );					\
94 	VersionCompat aCompat( ( _def_rOStm ), STREAM_WRITE, ( _def_nVer ) );
95 
96 // ========================================================================
97 
98 MetaAction::MetaAction() :
99 	mnRefCount( 1 ),
100 	mnType( META_NULL_ACTION )
101 {
102 }
103 
104 // ------------------------------------------------------------------------
105 
106 MetaAction::MetaAction( sal_uInt16 nType ) :
107 	mnRefCount( 1 ),
108 	mnType( nType )
109 {
110 }
111 
112 // ------------------------------------------------------------------------
113 
114 MetaAction::~MetaAction()
115 {
116 }
117 
118 // ------------------------------------------------------------------------
119 
120 void MetaAction::Execute( OutputDevice* )
121 {
122 }
123 
124 // ------------------------------------------------------------------------
125 
126 MetaAction* MetaAction::Clone()
127 {
128 	return new MetaAction;
129 }
130 
131 // ------------------------------------------------------------------------
132 
133 void MetaAction::Move( long, long )
134 {
135 }
136 
137 // ------------------------------------------------------------------------
138 
139 void MetaAction::Scale( double, double )
140 {
141 }
142 
143 // ------------------------------------------------------------------------
144 
145 sal_Bool MetaAction::Compare( const MetaAction& ) const
146 {
147 	return sal_True;
148 }
149 
150 // ------------------------------------------------------------------------
151 
152 sal_Bool MetaAction::IsEqual( const MetaAction& rMetaAction ) const
153 {
154 	if ( mnType != rMetaAction.mnType )
155 		return sal_False;
156 	else
157 		return Compare( rMetaAction );
158 }
159 
160 // ------------------------------------------------------------------------
161 
162 void MetaAction::Write( SvStream& rOStm, ImplMetaWriteData* )
163 {
164 	rOStm << mnType;
165 }
166 
167 // ------------------------------------------------------------------------
168 
169 void MetaAction::Read( SvStream& rIStm, ImplMetaReadData* )
170 {
171 	rIStm >> mnType;
172 }
173 
174 // ------------------------------------------------------------------------
175 
176 MetaAction* MetaAction::ReadMetaAction( SvStream& rIStm, ImplMetaReadData* pData )
177 {
178 	MetaAction* pAction = NULL;
179 	sal_uInt16		nType;
180 
181 	rIStm >> nType;
182 
183 	switch( nType )
184 	{
185 		case( META_NULL_ACTION ): pAction = new MetaAction; break;
186 		case( META_PIXEL_ACTION ): pAction = new MetaPixelAction; break;
187 		case( META_POINT_ACTION ): pAction = new MetaPointAction; break;
188 		case( META_LINE_ACTION ): pAction = new MetaLineAction; break;
189 		case( META_RECT_ACTION ): pAction = new MetaRectAction; break;
190 		case( META_ROUNDRECT_ACTION ): pAction = new MetaRoundRectAction; break;
191 		case( META_ELLIPSE_ACTION ): pAction = new MetaEllipseAction; break;
192 		case( META_ARC_ACTION ): pAction = new MetaArcAction; break;
193 		case( META_PIE_ACTION ): pAction = new MetaPieAction; break;
194 		case( META_CHORD_ACTION ): pAction = new MetaChordAction; break;
195 		case( META_POLYLINE_ACTION ): pAction = new MetaPolyLineAction; break;
196 		case( META_POLYGON_ACTION ): pAction = new MetaPolygonAction; break;
197 		case( META_POLYPOLYGON_ACTION ): pAction = new MetaPolyPolygonAction; break;
198 		case( META_TEXT_ACTION ): pAction = new MetaTextAction; break;
199 		case( META_TEXTARRAY_ACTION ): pAction = new MetaTextArrayAction; break;
200 		case( META_STRETCHTEXT_ACTION ): pAction = new MetaStretchTextAction; break;
201 		case( META_TEXTRECT_ACTION ): pAction = new MetaTextRectAction; break;
202 		case( META_TEXTLINE_ACTION ): pAction = new MetaTextLineAction; break;
203 		case( META_BMP_ACTION ): pAction = new MetaBmpAction; break;
204 		case( META_BMPSCALE_ACTION ): pAction = new MetaBmpScaleAction; break;
205 		case( META_BMPSCALEPART_ACTION ): pAction = new MetaBmpScalePartAction; break;
206 		case( META_BMPEX_ACTION ): pAction = new MetaBmpExAction; break;
207 		case( META_BMPEXSCALE_ACTION ): pAction = new MetaBmpExScaleAction; break;
208 		case( META_BMPEXSCALEPART_ACTION ): pAction = new MetaBmpExScalePartAction; break;
209 		case( META_MASK_ACTION ): pAction = new MetaMaskAction; break;
210 		case( META_MASKSCALE_ACTION ): pAction = new MetaMaskScaleAction; break;
211 		case( META_MASKSCALEPART_ACTION ): pAction = new MetaMaskScalePartAction; break;
212 		case( META_GRADIENT_ACTION ): pAction = new MetaGradientAction; break;
213 		case( META_GRADIENTEX_ACTION ): pAction = new MetaGradientExAction; break;
214 		case( META_HATCH_ACTION ): pAction = new MetaHatchAction; break;
215 		case( META_WALLPAPER_ACTION ): pAction = new MetaWallpaperAction; break;
216 		case( META_CLIPREGION_ACTION ): pAction = new MetaClipRegionAction; break;
217 		case( META_ISECTRECTCLIPREGION_ACTION ): pAction = new MetaISectRectClipRegionAction; break;
218 		case( META_ISECTREGIONCLIPREGION_ACTION ): pAction = new MetaISectRegionClipRegionAction; break;
219 		case( META_MOVECLIPREGION_ACTION ): pAction = new MetaMoveClipRegionAction; break;
220 		case( META_LINECOLOR_ACTION ): pAction = new MetaLineColorAction; break;
221 		case( META_FILLCOLOR_ACTION ): pAction = new MetaFillColorAction; break;
222 		case( META_TEXTCOLOR_ACTION ): pAction = new MetaTextColorAction; break;
223 		case( META_TEXTFILLCOLOR_ACTION ): pAction = new MetaTextFillColorAction; break;
224 		case( META_TEXTLINECOLOR_ACTION ): pAction = new MetaTextLineColorAction; break;
225 		case( META_OVERLINECOLOR_ACTION ): pAction = new MetaOverlineColorAction; break;
226 		case( META_TEXTALIGN_ACTION ): pAction = new MetaTextAlignAction; break;
227 		case( META_MAPMODE_ACTION ): pAction = new MetaMapModeAction; break;
228 		case( META_FONT_ACTION ): pAction = new MetaFontAction; break;
229 		case( META_PUSH_ACTION ): pAction = new MetaPushAction; break;
230 		case( META_POP_ACTION ): pAction = new MetaPopAction; break;
231 		case( META_RASTEROP_ACTION ): pAction = new MetaRasterOpAction; break;
232 		case( META_TRANSPARENT_ACTION ): pAction = new MetaTransparentAction; break;
233 		case( META_FLOATTRANSPARENT_ACTION ): pAction = new MetaFloatTransparentAction; break;
234 		case( META_EPS_ACTION ): pAction = new MetaEPSAction; break;
235 		case( META_REFPOINT_ACTION ): pAction = new MetaRefPointAction; break;
236 		case( META_COMMENT_ACTION ): pAction = new MetaCommentAction; break;
237 		case( META_LAYOUTMODE_ACTION ): pAction = new MetaLayoutModeAction; break;
238 		case( META_TEXTLANGUAGE_ACTION ): pAction = new MetaTextLanguageAction; break;
239         case( META_RENDERGRAPHIC_ACTION	): pAction = new MetaRenderGraphicAction; break;
240 
241 		default:
242 		{
243 			// Action ueberlesen durch Kombination Ctor/Dtor,
244 			// new/delete, weil Compiler sonst vielleicht wegoptimieren
245 			delete ( new VersionCompat( rIStm, STREAM_READ ) );
246 		}
247 		break;
248 	}
249 
250 	if( pAction )
251 		pAction->Read( rIStm, pData );
252 
253 	return pAction;
254 }
255 
256 // ========================================================================
257 
258 IMPL_META_ACTION( Pixel, META_PIXEL_ACTION )
259 
260 // ------------------------------------------------------------------------
261 
262 MetaPixelAction::MetaPixelAction( const Point& rPt, const Color& rColor ) :
263 	MetaAction	( META_PIXEL_ACTION ),
264 	maPt		( rPt ),
265 	maColor 	( rColor )
266 {
267 }
268 
269 // ------------------------------------------------------------------------
270 
271 void MetaPixelAction::Execute( OutputDevice* pOut )
272 {
273 	pOut->DrawPixel( maPt, maColor );
274 }
275 
276 // ------------------------------------------------------------------------
277 
278 MetaAction* MetaPixelAction::Clone()
279 {
280 	MetaAction* pClone = (MetaAction*) new MetaPixelAction( *this );
281 	pClone->ResetRefCount();
282 	return pClone;
283 }
284 
285 // ------------------------------------------------------------------------
286 
287 void MetaPixelAction::Move( long nHorzMove, long nVertMove )
288 {
289 	maPt.Move( nHorzMove, nVertMove );
290 }
291 
292 // ------------------------------------------------------------------------
293 
294 void MetaPixelAction::Scale( double fScaleX, double fScaleY )
295 {
296 	ImplScalePoint( maPt, fScaleX, fScaleY );
297 }
298 
299 // ------------------------------------------------------------------------
300 
301 sal_Bool MetaPixelAction::Compare( const MetaAction& rMetaAction ) const
302 {
303 	return ( maPt == ((MetaPixelAction&)rMetaAction).maPt ) &&
304 		   ( maColor == ((MetaPixelAction&)rMetaAction).maColor );
305 }
306 
307 // ------------------------------------------------------------------------
308 
309 void MetaPixelAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
310 {
311 	WRITE_BASE_COMPAT( rOStm, 1, pData );
312 	rOStm << maPt;
313 	maColor.Write( rOStm, sal_True );
314 }
315 
316 // ------------------------------------------------------------------------
317 
318 void MetaPixelAction::Read( SvStream& rIStm, ImplMetaReadData* )
319 {
320 	COMPAT( rIStm );
321 	rIStm >> maPt;
322 	maColor.Read( rIStm, sal_True );
323 }
324 
325 // ========================================================================
326 
327 IMPL_META_ACTION( Point, META_POINT_ACTION )
328 
329 // ------------------------------------------------------------------------
330 
331 MetaPointAction::MetaPointAction( const Point& rPt ) :
332 	MetaAction	( META_POINT_ACTION ),
333 	maPt		( rPt )
334 {
335 }
336 
337 // ------------------------------------------------------------------------
338 
339 void MetaPointAction::Execute( OutputDevice* pOut )
340 {
341 	pOut->DrawPixel( maPt );
342 }
343 
344 // ------------------------------------------------------------------------
345 
346 MetaAction* MetaPointAction::Clone()
347 {
348 	MetaAction* pClone = (MetaAction*) new MetaPointAction( *this );
349 	pClone->ResetRefCount();
350 	return pClone;
351 }
352 
353 // ------------------------------------------------------------------------
354 
355 void MetaPointAction::Move( long nHorzMove, long nVertMove )
356 {
357 	maPt.Move( nHorzMove, nVertMove );
358 }
359 
360 // ------------------------------------------------------------------------
361 
362 void MetaPointAction::Scale( double fScaleX, double fScaleY )
363 {
364 	ImplScalePoint( maPt, fScaleX, fScaleY );
365 }
366 
367 // ------------------------------------------------------------------------
368 
369 sal_Bool MetaPointAction::Compare( const MetaAction& rMetaAction ) const
370 {
371 	return maPt == ((MetaPointAction&)rMetaAction).maPt;
372 }
373 
374 // ------------------------------------------------------------------------
375 
376 void MetaPointAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
377 {
378 	WRITE_BASE_COMPAT( rOStm, 1, pData );
379 	rOStm << maPt;
380 }
381 
382 // ------------------------------------------------------------------------
383 
384 void MetaPointAction::Read( SvStream& rIStm, ImplMetaReadData* )
385 {
386 	COMPAT( rIStm );
387 	rIStm >> maPt;
388 }
389 
390 // ========================================================================
391 
392 IMPL_META_ACTION( Line, META_LINE_ACTION )
393 
394 // ------------------------------------------------------------------------
395 
396 MetaLineAction::MetaLineAction( const Point& rStart, const Point& rEnd ) :
397 	MetaAction	( META_LINE_ACTION ),
398 	maStartPt	( rStart ),
399 	maEndPt 	( rEnd )
400 {
401 }
402 
403 // ------------------------------------------------------------------------
404 
405 MetaLineAction::MetaLineAction( const Point& rStart, const Point& rEnd,
406 								const LineInfo& rLineInfo ) :
407 	MetaAction	( META_LINE_ACTION ),
408 	maLineInfo	( rLineInfo ),
409 	maStartPt	( rStart ),
410 	maEndPt 	( rEnd )
411 {
412 }
413 
414 // ------------------------------------------------------------------------
415 
416 void MetaLineAction::Execute( OutputDevice* pOut )
417 {
418 	if( maLineInfo.IsDefault() )
419 		pOut->DrawLine( maStartPt, maEndPt );
420 	else
421 		pOut->DrawLine( maStartPt, maEndPt, maLineInfo );
422 }
423 
424 // ------------------------------------------------------------------------
425 
426 MetaAction* MetaLineAction::Clone()
427 {
428 	MetaAction* pClone = (MetaAction*) new MetaLineAction( *this );
429 	pClone->ResetRefCount();
430 	return pClone;
431 }
432 
433 // ------------------------------------------------------------------------
434 
435 void MetaLineAction::Move( long nHorzMove, long nVertMove )
436 {
437 	maStartPt.Move( nHorzMove, nVertMove );
438 	maEndPt.Move( nHorzMove, nVertMove );
439 }
440 
441 // ------------------------------------------------------------------------
442 
443 void MetaLineAction::Scale( double fScaleX, double fScaleY )
444 {
445 	ImplScalePoint( maStartPt, fScaleX, fScaleY );
446 	ImplScalePoint( maEndPt, fScaleX, fScaleY );
447 	ImplScaleLineInfo( maLineInfo, fScaleX, fScaleY );
448 }
449 
450 // ------------------------------------------------------------------------
451 
452 sal_Bool MetaLineAction::Compare( const MetaAction& rMetaAction ) const
453 {
454 	return ( maLineInfo == ((MetaLineAction&)rMetaAction).maLineInfo ) &&
455 	       ( maStartPt == ((MetaLineAction&)rMetaAction).maStartPt ) &&
456 		   ( maEndPt == ((MetaLineAction&)rMetaAction).maEndPt );
457 }
458 
459 // ------------------------------------------------------------------------
460 
461 void MetaLineAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
462 {
463 	WRITE_BASE_COMPAT( rOStm, 2, pData );
464 
465 	rOStm << maStartPt << maEndPt;	// Version 1
466 	rOStm << maLineInfo;			// Version 2
467 }
468 
469 // ------------------------------------------------------------------------
470 
471 void MetaLineAction::Read( SvStream& rIStm, ImplMetaReadData* )
472 {
473 	COMPAT( rIStm );
474 
475 	// Version 1
476 	rIStm >> maStartPt >> maEndPt;
477 
478 	// Version 2
479 	if( aCompat.GetVersion() >= 2 )
480 	{
481 		rIStm >> maLineInfo;
482 	}
483 }
484 
485 // ========================================================================
486 
487 IMPL_META_ACTION( Rect, META_RECT_ACTION )
488 
489 // ------------------------------------------------------------------------
490 
491 MetaRectAction::MetaRectAction( const Rectangle& rRect ) :
492 	MetaAction	( META_RECT_ACTION ),
493 	maRect		( rRect )
494 {
495 }
496 
497 // ------------------------------------------------------------------------
498 
499 void MetaRectAction::Execute( OutputDevice* pOut )
500 {
501 	pOut->DrawRect( maRect );
502 }
503 
504 // ------------------------------------------------------------------------
505 
506 MetaAction* MetaRectAction::Clone()
507 {
508 	MetaAction* pClone = (MetaAction*) new MetaRectAction( *this );
509 	pClone->ResetRefCount();
510 	return pClone;
511 }
512 
513 // ------------------------------------------------------------------------
514 
515 void MetaRectAction::Move( long nHorzMove, long nVertMove )
516 {
517 	maRect.Move( nHorzMove, nVertMove );
518 }
519 
520 // ------------------------------------------------------------------------
521 
522 void MetaRectAction::Scale( double fScaleX, double fScaleY )
523 {
524 	ImplScaleRect( maRect, fScaleX, fScaleY );
525 }
526 
527 // ------------------------------------------------------------------------
528 
529 sal_Bool MetaRectAction::Compare( const MetaAction& rMetaAction ) const
530 {
531 	return maRect == ((MetaRectAction&)rMetaAction).maRect;
532 }
533 
534 // ------------------------------------------------------------------------
535 
536 void MetaRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
537 {
538 	WRITE_BASE_COMPAT( rOStm, 1, pData );
539 	rOStm << maRect;
540 }
541 
542 // ------------------------------------------------------------------------
543 
544 void MetaRectAction::Read( SvStream& rIStm, ImplMetaReadData* )
545 {
546 	COMPAT( rIStm );
547 	rIStm >> maRect;
548 }
549 
550 // ========================================================================
551 
552 IMPL_META_ACTION( RoundRect, META_ROUNDRECT_ACTION )
553 
554 // ------------------------------------------------------------------------
555 
556 MetaRoundRectAction::MetaRoundRectAction( const Rectangle& rRect,
557 										  sal_uInt32 nHorzRound, sal_uInt32 nVertRound ) :
558 	MetaAction	( META_ROUNDRECT_ACTION ),
559 	maRect		( rRect ),
560 	mnHorzRound ( nHorzRound ),
561 	mnVertRound ( nVertRound )
562 {
563 }
564 
565 // ------------------------------------------------------------------------
566 
567 void MetaRoundRectAction::Execute( OutputDevice* pOut )
568 {
569 	pOut->DrawRect( maRect, mnHorzRound, mnVertRound );
570 }
571 
572 // ------------------------------------------------------------------------
573 
574 MetaAction* MetaRoundRectAction::Clone()
575 {
576 	MetaAction* pClone = (MetaAction*) new MetaRoundRectAction( *this );
577 	pClone->ResetRefCount();
578 	return pClone;
579 }
580 
581 // ------------------------------------------------------------------------
582 
583 void MetaRoundRectAction::Move( long nHorzMove, long nVertMove )
584 {
585 	maRect.Move( nHorzMove, nVertMove );
586 }
587 
588 // ------------------------------------------------------------------------
589 
590 void MetaRoundRectAction::Scale( double fScaleX, double fScaleY )
591 {
592 	ImplScaleRect( maRect, fScaleX, fScaleY );
593 	mnHorzRound = FRound( mnHorzRound * fabs(fScaleX) );
594 	mnVertRound = FRound( mnVertRound * fabs(fScaleY) );
595 }
596 
597 // ------------------------------------------------------------------------
598 
599 sal_Bool MetaRoundRectAction::Compare( const MetaAction& rMetaAction ) const
600 {
601 	return ( maRect == ((MetaRoundRectAction&)rMetaAction).maRect ) &&
602 		   ( mnHorzRound == ((MetaRoundRectAction&)rMetaAction).mnHorzRound ) &&
603 		   ( mnVertRound == ((MetaRoundRectAction&)rMetaAction).mnVertRound );
604 }
605 
606 // ------------------------------------------------------------------------
607 
608 void MetaRoundRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
609 {
610 	WRITE_BASE_COMPAT( rOStm, 1, pData );
611 	rOStm << maRect << mnHorzRound << mnVertRound;
612 }
613 
614 // ------------------------------------------------------------------------
615 
616 void MetaRoundRectAction::Read( SvStream& rIStm, ImplMetaReadData* )
617 {
618 	COMPAT( rIStm );
619 	rIStm >> maRect >> mnHorzRound >> mnVertRound;
620 }
621 
622 // ========================================================================
623 
624 IMPL_META_ACTION( Ellipse, META_ELLIPSE_ACTION )
625 
626 // ------------------------------------------------------------------------
627 
628 MetaEllipseAction::MetaEllipseAction( const Rectangle& rRect ) :
629 	MetaAction	( META_ELLIPSE_ACTION ),
630 	maRect		( rRect )
631 {
632 }
633 
634 // ------------------------------------------------------------------------
635 
636 void MetaEllipseAction::Execute( OutputDevice* pOut )
637 {
638 	pOut->DrawEllipse( maRect );
639 }
640 
641 // ------------------------------------------------------------------------
642 
643 MetaAction* MetaEllipseAction::Clone()
644 {
645 	MetaAction* pClone = (MetaAction*) new MetaEllipseAction( *this );
646 	pClone->ResetRefCount();
647 	return pClone;
648 }
649 
650 // ------------------------------------------------------------------------
651 
652 void MetaEllipseAction::Move( long nHorzMove, long nVertMove )
653 {
654 	maRect.Move( nHorzMove, nVertMove );
655 }
656 
657 // ------------------------------------------------------------------------
658 
659 void MetaEllipseAction::Scale( double fScaleX, double fScaleY )
660 {
661 	ImplScaleRect( maRect, fScaleX, fScaleY );
662 }
663 
664 // ------------------------------------------------------------------------
665 
666 sal_Bool MetaEllipseAction::Compare( const MetaAction& rMetaAction ) const
667 {
668 	return maRect == ((MetaEllipseAction&)rMetaAction).maRect;
669 }
670 
671 // ------------------------------------------------------------------------
672 
673 void MetaEllipseAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
674 {
675 	WRITE_BASE_COMPAT( rOStm, 1, pData );
676 	rOStm << maRect;
677 }
678 
679 // ------------------------------------------------------------------------
680 
681 void MetaEllipseAction::Read( SvStream& rIStm, ImplMetaReadData* )
682 {
683 	COMPAT( rIStm );
684 	rIStm >> maRect;
685 }
686 
687 // ========================================================================
688 
689 IMPL_META_ACTION( Arc, META_ARC_ACTION )
690 
691 // ------------------------------------------------------------------------
692 
693 MetaArcAction::MetaArcAction( const Rectangle& rRect,
694 							  const Point& rStart, const Point& rEnd ) :
695 	MetaAction	( META_ARC_ACTION ),
696 	maRect		( rRect ),
697 	maStartPt	( rStart ),
698 	maEndPt 	( rEnd )
699 {
700 }
701 
702 // ------------------------------------------------------------------------
703 
704 void MetaArcAction::Execute( OutputDevice* pOut )
705 {
706 	pOut->DrawArc( maRect, maStartPt, maEndPt );
707 }
708 
709 // ------------------------------------------------------------------------
710 
711 MetaAction* MetaArcAction::Clone()
712 {
713 	MetaAction* pClone = (MetaAction*) new MetaArcAction( *this );
714 	pClone->ResetRefCount();
715 	return pClone;
716 }
717 
718 // ------------------------------------------------------------------------
719 
720 void MetaArcAction::Move( long nHorzMove, long nVertMove )
721 {
722 	maRect.Move(  nHorzMove, nVertMove );
723 	maStartPt.Move(  nHorzMove, nVertMove );
724 	maEndPt.Move(  nHorzMove, nVertMove );
725 }
726 
727 // ------------------------------------------------------------------------
728 
729 void MetaArcAction::Scale( double fScaleX, double fScaleY )
730 {
731 	ImplScaleRect( maRect, fScaleX, fScaleY );
732 	ImplScalePoint( maStartPt, fScaleX, fScaleY );
733 	ImplScalePoint( maEndPt, fScaleX, fScaleY );
734 }
735 
736 // ------------------------------------------------------------------------
737 
738 sal_Bool MetaArcAction::Compare( const MetaAction& rMetaAction ) const
739 {
740 	return ( maRect == ((MetaArcAction&)rMetaAction).maRect ) &&
741 		   ( maStartPt == ((MetaArcAction&)rMetaAction).maStartPt ) &&
742 		   ( maEndPt == ((MetaArcAction&)rMetaAction).maEndPt );
743 }
744 
745 // ------------------------------------------------------------------------
746 
747 void MetaArcAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
748 {
749 	WRITE_BASE_COMPAT( rOStm, 1, pData );
750 	rOStm << maRect << maStartPt << maEndPt;
751 }
752 
753 // ------------------------------------------------------------------------
754 
755 void MetaArcAction::Read( SvStream& rIStm, ImplMetaReadData* )
756 {
757 	COMPAT( rIStm );
758 	rIStm >> maRect >> maStartPt >> maEndPt;
759 }
760 
761 // ========================================================================
762 
763 IMPL_META_ACTION( Pie, META_PIE_ACTION )
764 
765 // ------------------------------------------------------------------------
766 
767 MetaPieAction::MetaPieAction( const Rectangle& rRect,
768 							  const Point& rStart, const Point& rEnd ) :
769 	MetaAction	( META_PIE_ACTION ),
770 	maRect		( rRect ),
771 	maStartPt	( rStart ),
772 	maEndPt 	( rEnd )
773 {
774 }
775 
776 // ------------------------------------------------------------------------
777 
778 void MetaPieAction::Execute( OutputDevice* pOut )
779 {
780 	pOut->DrawPie( maRect, maStartPt, maEndPt );
781 }
782 
783 // ------------------------------------------------------------------------
784 
785 MetaAction* MetaPieAction::Clone()
786 {
787 	MetaAction* pClone = (MetaAction*) new MetaPieAction( *this );
788 	pClone->ResetRefCount();
789 	return pClone;
790 }
791 
792 // ------------------------------------------------------------------------
793 
794 void MetaPieAction::Move( long nHorzMove, long nVertMove )
795 {
796 	maRect.Move(  nHorzMove, nVertMove );
797 	maStartPt.Move(  nHorzMove, nVertMove );
798 	maEndPt.Move(  nHorzMove, nVertMove );
799 }
800 
801 // ------------------------------------------------------------------------
802 
803 void MetaPieAction::Scale( double fScaleX, double fScaleY )
804 {
805 	ImplScaleRect( maRect, fScaleX, fScaleY );
806 	ImplScalePoint( maStartPt, fScaleX, fScaleY );
807 	ImplScalePoint( maEndPt, fScaleX, fScaleY );
808 }
809 
810 // ------------------------------------------------------------------------
811 
812 sal_Bool MetaPieAction::Compare( const MetaAction& rMetaAction ) const
813 {
814 	return ( maRect == ((MetaPieAction&)rMetaAction).maRect ) &&
815 		   ( maStartPt == ((MetaPieAction&)rMetaAction).maStartPt ) &&
816 		   ( maEndPt == ((MetaPieAction&)rMetaAction).maEndPt );
817 }
818 
819 // ------------------------------------------------------------------------
820 
821 void MetaPieAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
822 {
823 	WRITE_BASE_COMPAT( rOStm, 1, pData );
824 	rOStm << maRect << maStartPt << maEndPt;
825 }
826 
827 // ------------------------------------------------------------------------
828 
829 void MetaPieAction::Read( SvStream& rIStm, ImplMetaReadData* )
830 {
831 	COMPAT( rIStm );
832 	rIStm >> maRect >> maStartPt >> maEndPt;
833 }
834 
835 // ========================================================================
836 
837 IMPL_META_ACTION( Chord, META_CHORD_ACTION )
838 
839 // ------------------------------------------------------------------------
840 
841 MetaChordAction::MetaChordAction( const Rectangle& rRect,
842 								  const Point& rStart, const Point& rEnd ) :
843 	MetaAction	( META_CHORD_ACTION ),
844 	maRect		( rRect ),
845 	maStartPt	( rStart ),
846 	maEndPt 	( rEnd )
847 {
848 }
849 
850 // ------------------------------------------------------------------------
851 
852 void MetaChordAction::Execute( OutputDevice* pOut )
853 {
854 	pOut->DrawChord( maRect, maStartPt, maEndPt );
855 }
856 
857 // ------------------------------------------------------------------------
858 
859 MetaAction* MetaChordAction::Clone()
860 {
861 	MetaAction* pClone = (MetaAction*) new MetaChordAction( *this );
862 	pClone->ResetRefCount();
863 	return pClone;
864 }
865 
866 // ------------------------------------------------------------------------
867 
868 void MetaChordAction::Move( long nHorzMove, long nVertMove )
869 {
870 	maRect.Move(  nHorzMove, nVertMove );
871 	maStartPt.Move(  nHorzMove, nVertMove );
872 	maEndPt.Move(  nHorzMove, nVertMove );
873 }
874 
875 // ------------------------------------------------------------------------
876 
877 void MetaChordAction::Scale( double fScaleX, double fScaleY )
878 {
879 	ImplScaleRect( maRect, fScaleX, fScaleY );
880 	ImplScalePoint( maStartPt, fScaleX, fScaleY );
881 	ImplScalePoint( maEndPt, fScaleX, fScaleY );
882 }
883 
884 // ------------------------------------------------------------------------
885 
886 sal_Bool MetaChordAction::Compare( const MetaAction& rMetaAction ) const
887 {
888 	return ( maRect == ((MetaChordAction&)rMetaAction).maRect ) &&
889 		   ( maStartPt == ((MetaChordAction&)rMetaAction).maStartPt ) &&
890 		   ( maEndPt == ((MetaChordAction&)rMetaAction).maEndPt );
891 }
892 
893 // ------------------------------------------------------------------------
894 
895 void MetaChordAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
896 {
897 	WRITE_BASE_COMPAT( rOStm, 1, pData );
898 	rOStm << maRect << maStartPt << maEndPt;
899 }
900 
901 // ------------------------------------------------------------------------
902 
903 void MetaChordAction::Read( SvStream& rIStm, ImplMetaReadData* )
904 {
905 	COMPAT( rIStm );
906 	rIStm >> maRect >> maStartPt >> maEndPt;
907 }
908 
909 // ========================================================================
910 
911 IMPL_META_ACTION( PolyLine, META_POLYLINE_ACTION )
912 
913 // ------------------------------------------------------------------------
914 
915 MetaPolyLineAction::MetaPolyLineAction( const Polygon& rPoly ) :
916 	MetaAction	( META_POLYLINE_ACTION ),
917 	maPoly		( rPoly )
918 {
919 }
920 
921 // ------------------------------------------------------------------------
922 
923 MetaPolyLineAction::MetaPolyLineAction( const Polygon& rPoly, const LineInfo& rLineInfo ) :
924 	MetaAction	( META_POLYLINE_ACTION ),
925 	maLineInfo	( rLineInfo ),
926 	maPoly		( rPoly )
927 {
928 }
929 
930 // ------------------------------------------------------------------------
931 
932 void MetaPolyLineAction::Execute( OutputDevice* pOut )
933 {
934 	if( maLineInfo.IsDefault() )
935 		pOut->DrawPolyLine( maPoly );
936 	else
937 		pOut->DrawPolyLine( maPoly, maLineInfo );
938 }
939 
940 // ------------------------------------------------------------------------
941 
942 MetaAction* MetaPolyLineAction::Clone()
943 {
944 	MetaAction* pClone = (MetaAction*) new MetaPolyLineAction( *this );
945 	pClone->ResetRefCount();
946 	return pClone;
947 }
948 
949 // ------------------------------------------------------------------------
950 
951 void MetaPolyLineAction::Move( long nHorzMove, long nVertMove )
952 {
953 	maPoly.Move( nHorzMove, nVertMove );
954 }
955 
956 // ------------------------------------------------------------------------
957 
958 void MetaPolyLineAction::Scale( double fScaleX, double fScaleY )
959 {
960 	ImplScalePoly( maPoly, fScaleX, fScaleY );
961 	ImplScaleLineInfo( maLineInfo, fScaleX, fScaleY );
962 }
963 
964 // ------------------------------------------------------------------------
965 
966 sal_Bool MetaPolyLineAction::Compare( const MetaAction& rMetaAction ) const
967 {
968 	sal_Bool bIsEqual = sal_True;;
969 	if ( maLineInfo != ((MetaPolyLineAction&)rMetaAction).maLineInfo )
970 		bIsEqual = sal_False;
971 	else
972 		bIsEqual = maPoly.IsEqual(((MetaPolyLineAction&)rMetaAction).maPoly );
973 	return bIsEqual;
974 
975 }
976 
977 // ------------------------------------------------------------------------
978 
979 void MetaPolyLineAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
980 {
981 	WRITE_BASE_COMPAT( rOStm, 3, pData );
982 
983 	Polygon aSimplePoly;
984 	maPoly.AdaptiveSubdivide( aSimplePoly );
985 
986 	rOStm << aSimplePoly;								// Version 1
987 	rOStm << maLineInfo;								// Version 2
988 
989 	sal_uInt8 bHasPolyFlags = maPoly.HasFlags();		// Version 3
990 	rOStm << bHasPolyFlags;
991 	if ( bHasPolyFlags )
992 		maPoly.Write( rOStm );
993 }
994 
995 // ------------------------------------------------------------------------
996 
997 void MetaPolyLineAction::Read( SvStream& rIStm, ImplMetaReadData* )
998 {
999 	COMPAT( rIStm );
1000 
1001 	// Version 1
1002 	rIStm >> maPoly;
1003 
1004 	// Version 2
1005 	if( aCompat.GetVersion() >= 2 )
1006 		rIStm >> maLineInfo;
1007 	if ( aCompat.GetVersion() >= 3 )
1008 	{
1009 		sal_uInt8 bHasPolyFlags;
1010 		rIStm >> bHasPolyFlags;
1011 		if ( bHasPolyFlags )
1012 			maPoly.Read( rIStm );
1013 	}
1014 }
1015 
1016 // ========================================================================
1017 
1018 IMPL_META_ACTION( Polygon, META_POLYGON_ACTION )
1019 
1020 // ------------------------------------------------------------------------
1021 
1022 MetaPolygonAction::MetaPolygonAction( const Polygon& rPoly ) :
1023 	MetaAction	( META_POLYGON_ACTION ),
1024 	maPoly		( rPoly )
1025 {
1026 }
1027 
1028 // ------------------------------------------------------------------------
1029 
1030 void MetaPolygonAction::Execute( OutputDevice* pOut )
1031 {
1032 	pOut->DrawPolygon( maPoly );
1033 }
1034 
1035 // ------------------------------------------------------------------------
1036 
1037 MetaAction* MetaPolygonAction::Clone()
1038 {
1039 	MetaAction* pClone = (MetaAction*) new MetaPolygonAction( *this );
1040 	pClone->ResetRefCount();
1041 	return pClone;
1042 }
1043 
1044 // ------------------------------------------------------------------------
1045 
1046 void MetaPolygonAction::Move( long nHorzMove, long nVertMove )
1047 {
1048 	maPoly.Move( nHorzMove, nVertMove );
1049 }
1050 
1051 // ------------------------------------------------------------------------
1052 
1053 void MetaPolygonAction::Scale( double fScaleX, double fScaleY )
1054 {
1055 	ImplScalePoly( maPoly, fScaleX, fScaleY );
1056 }
1057 
1058 // ------------------------------------------------------------------------
1059 
1060 sal_Bool MetaPolygonAction::Compare( const MetaAction& rMetaAction ) const
1061 {
1062 	return maPoly.IsEqual(((MetaPolygonAction&)rMetaAction).maPoly );
1063 }
1064 
1065 // ------------------------------------------------------------------------
1066 
1067 void MetaPolygonAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1068 {
1069 	WRITE_BASE_COMPAT( rOStm, 2, pData );
1070 
1071 	Polygon aSimplePoly;							// Version 1
1072 	maPoly.AdaptiveSubdivide( aSimplePoly );
1073 	rOStm << aSimplePoly;
1074 
1075 	sal_uInt8 bHasPolyFlags = maPoly.HasFlags();	// Version 2
1076 	rOStm << bHasPolyFlags;
1077 	if ( bHasPolyFlags )
1078 		maPoly.Write( rOStm );
1079 }
1080 
1081 // ------------------------------------------------------------------------
1082 
1083 void MetaPolygonAction::Read( SvStream& rIStm, ImplMetaReadData* )
1084 {
1085 	COMPAT( rIStm );
1086 
1087 	rIStm >> maPoly;					// Version 1
1088 
1089 	if( aCompat.GetVersion() >= 2 )		// Version 2
1090 	{
1091 		sal_uInt8 bHasPolyFlags;
1092 		rIStm >> bHasPolyFlags;
1093 		if ( bHasPolyFlags )
1094 			maPoly.Read( rIStm );
1095 	}
1096 }
1097 
1098 // ========================================================================
1099 
1100 IMPL_META_ACTION( PolyPolygon, META_POLYPOLYGON_ACTION )
1101 
1102 // ------------------------------------------------------------------------
1103 
1104 MetaPolyPolygonAction::MetaPolyPolygonAction( const PolyPolygon& rPolyPoly ) :
1105 	MetaAction	( META_POLYPOLYGON_ACTION ),
1106 	maPolyPoly	( rPolyPoly )
1107 {
1108 }
1109 
1110 // ------------------------------------------------------------------------
1111 
1112 void MetaPolyPolygonAction::Execute( OutputDevice* pOut )
1113 {
1114 	pOut->DrawPolyPolygon( maPolyPoly );
1115 }
1116 
1117 // ------------------------------------------------------------------------
1118 
1119 MetaAction* MetaPolyPolygonAction::Clone()
1120 {
1121 	MetaAction* pClone = (MetaAction*) new MetaPolyPolygonAction( *this );
1122 	pClone->ResetRefCount();
1123 	return pClone;
1124 }
1125 
1126 // ------------------------------------------------------------------------
1127 
1128 void MetaPolyPolygonAction::Move( long nHorzMove, long nVertMove )
1129 {
1130 	maPolyPoly.Move( nHorzMove, nVertMove );
1131 }
1132 
1133 // ------------------------------------------------------------------------
1134 
1135 void MetaPolyPolygonAction::Scale( double fScaleX, double fScaleY )
1136 {
1137 	for( sal_uInt16 i = 0, nCount = maPolyPoly.Count(); i < nCount; i++ )
1138 		ImplScalePoly( maPolyPoly[ i ], fScaleX, fScaleY );
1139 }
1140 
1141 // ------------------------------------------------------------------------
1142 
1143 sal_Bool MetaPolyPolygonAction::Compare( const MetaAction& rMetaAction ) const
1144 {
1145 	return maPolyPoly.IsEqual(((MetaPolyPolygonAction&)rMetaAction).maPolyPoly );
1146 }
1147 
1148 // ------------------------------------------------------------------------
1149 
1150 void MetaPolyPolygonAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1151 {
1152 	WRITE_BASE_COMPAT( rOStm, 2, pData );
1153 
1154 	sal_uInt16 nNumberOfComplexPolygons = 0;
1155 	sal_uInt16 i, nPolyCount = maPolyPoly.Count();
1156 
1157 	Polygon aSimplePoly;								// Version 1
1158 	rOStm << nPolyCount;
1159 	for ( i = 0; i < nPolyCount; i++ )
1160 	{
1161 		const Polygon& rPoly = maPolyPoly.GetObject( i );
1162 		if ( rPoly.HasFlags() )
1163 			nNumberOfComplexPolygons++;
1164 		rPoly.AdaptiveSubdivide( aSimplePoly );
1165 		rOStm << aSimplePoly;
1166 	}
1167 
1168 	rOStm << nNumberOfComplexPolygons;					// Version 2
1169 	for ( i = 0; nNumberOfComplexPolygons && ( i < nPolyCount ); i++ )
1170 	{
1171 		const Polygon& rPoly = maPolyPoly.GetObject( i );
1172 		if ( rPoly.HasFlags() )
1173 		{
1174 			rOStm << i;
1175 			rPoly.Write( rOStm );
1176 
1177 			nNumberOfComplexPolygons--;
1178 		}
1179 	}
1180 }
1181 
1182 // ------------------------------------------------------------------------
1183 
1184 void MetaPolyPolygonAction::Read( SvStream& rIStm, ImplMetaReadData* )
1185 {
1186 	COMPAT( rIStm );
1187 	rIStm >> maPolyPoly;				// Version 1
1188 
1189 	if ( aCompat.GetVersion() >= 2 )	// Version 2
1190 	{
1191 		sal_uInt16 i, nIndex, nNumberOfComplexPolygons;
1192 		rIStm >> nNumberOfComplexPolygons;
1193 		for ( i = 0; i < nNumberOfComplexPolygons; i++ )
1194 		{
1195 			rIStm >> nIndex;
1196 			Polygon aPoly;
1197 			aPoly.Read( rIStm );
1198 			maPolyPoly.Replace( aPoly, nIndex );
1199 		}
1200 	}
1201 }
1202 
1203 // ========================================================================
1204 
1205 IMPL_META_ACTION( Text, META_TEXT_ACTION )
1206 
1207 // ------------------------------------------------------------------------
1208 
1209 MetaTextAction::MetaTextAction( const Point& rPt, const XubString& rStr,
1210 								sal_uInt16 nIndex, sal_uInt16 nLen ) :
1211 	MetaAction	( META_TEXT_ACTION ),
1212 	maPt		( rPt ),
1213 	maStr		( rStr ),
1214 	mnIndex 	( nIndex ),
1215 	mnLen		( nLen )
1216 {
1217 }
1218 
1219 // ------------------------------------------------------------------------
1220 
1221 void MetaTextAction::Execute( OutputDevice* pOut )
1222 {
1223 	pOut->DrawText( maPt, maStr, mnIndex, mnLen );
1224 }
1225 
1226 // ------------------------------------------------------------------------
1227 
1228 MetaAction* MetaTextAction::Clone()
1229 {
1230 	MetaAction* pClone = (MetaAction*) new MetaTextAction( *this );
1231 	pClone->ResetRefCount();
1232 	return pClone;
1233 }
1234 
1235 // ------------------------------------------------------------------------
1236 
1237 void MetaTextAction::Move( long nHorzMove, long nVertMove )
1238 {
1239 	maPt.Move( nHorzMove, nVertMove );
1240 }
1241 
1242 // ------------------------------------------------------------------------
1243 
1244 void MetaTextAction::Scale( double fScaleX, double fScaleY )
1245 {
1246 	ImplScalePoint( maPt, fScaleX, fScaleY );
1247 }
1248 
1249 // ------------------------------------------------------------------------
1250 
1251 sal_Bool MetaTextAction::Compare( const MetaAction& rMetaAction ) const
1252 {
1253 	return ( maPt == ((MetaTextAction&)rMetaAction).maPt ) &&
1254 		   ( maStr == ((MetaTextAction&)rMetaAction).maStr ) &&
1255 		   ( mnIndex == ((MetaTextAction&)rMetaAction).mnIndex ) &&
1256 		   ( mnLen == ((MetaTextAction&)rMetaAction).mnLen );
1257 }
1258 
1259 // ------------------------------------------------------------------------
1260 
1261 void MetaTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1262 {
1263 	WRITE_BASE_COMPAT( rOStm, 2, pData );
1264 	rOStm	<< maPt;
1265 	rOStm.WriteByteString( maStr, pData->meActualCharSet );
1266 	rOStm	<< mnIndex;
1267 	rOStm	<< mnLen;
1268 
1269 	sal_uInt16 i, nLen = maStr.Len();							// version 2
1270 	rOStm << nLen;
1271 	for ( i = 0; i < nLen; i++ )
1272 	{
1273 		sal_Unicode nUni = maStr.GetChar( i );
1274 		rOStm << nUni;
1275 	}
1276 }
1277 
1278 // ------------------------------------------------------------------------
1279 
1280 void MetaTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
1281 {
1282 	COMPAT( rIStm );
1283 	rIStm	>> maPt;
1284 	rIStm.ReadByteString( maStr, pData->meActualCharSet );
1285 	rIStm	>> mnIndex;
1286 	rIStm	>> mnLen;
1287 
1288 	if ( aCompat.GetVersion() >= 2 )							// Version 2
1289 	{
1290 		sal_uInt16 nLen;
1291 		rIStm >> nLen;
1292 		sal_Unicode* pBuffer = maStr.AllocBuffer( nLen );
1293 		while ( nLen-- )
1294 			rIStm >> *pBuffer++;
1295 	}
1296 }
1297 
1298 // ========================================================================
1299 
1300 MetaTextArrayAction::MetaTextArrayAction() :
1301 	MetaAction	( META_TEXTARRAY_ACTION ),
1302 	mpDXAry 	( NULL ),
1303 	mnIndex 	( 0 ),
1304 	mnLen		( 0 )
1305 {
1306 }
1307 
1308 // ------------------------------------------------------------------------
1309 
1310 MetaTextArrayAction::MetaTextArrayAction( const MetaTextArrayAction& rAction ) :
1311 	MetaAction	( META_TEXTARRAY_ACTION ),
1312 	maStartPt	( rAction.maStartPt ),
1313 	maStr		( rAction.maStr ),
1314 	mnIndex 	( rAction.mnIndex ),
1315 	mnLen		( rAction.mnLen )
1316 {
1317 	if( rAction.mpDXAry )
1318 	{
1319 		const sal_uLong nAryLen = mnLen;
1320 
1321 		mpDXAry = new sal_Int32[ nAryLen ];
1322 		memcpy( mpDXAry, rAction.mpDXAry, nAryLen * sizeof( sal_Int32 ) );
1323 	}
1324 	else
1325 		mpDXAry = NULL;
1326 }
1327 
1328 // ------------------------------------------------------------------------
1329 
1330 MetaTextArrayAction::MetaTextArrayAction( const Point& rStartPt,
1331 										  const XubString& rStr,
1332 										  const sal_Int32* pDXAry,
1333 										  sal_uInt16 nIndex,
1334 										  sal_uInt16 nLen ) :
1335 	MetaAction	( META_TEXTARRAY_ACTION ),
1336 	maStartPt	( rStartPt ),
1337 	maStr		( rStr ),
1338 	mnIndex 	( nIndex ),
1339 	mnLen		( ( nLen == STRING_LEN ) ? rStr.Len() : nLen )
1340 {
1341     const sal_uLong nAryLen = pDXAry ? mnLen : 0;
1342 
1343 	if( nAryLen )
1344 	{
1345 		mpDXAry = new sal_Int32[ nAryLen ];
1346 		memcpy( mpDXAry, pDXAry, nAryLen * sizeof( sal_Int32 ) );
1347 	}
1348 	else
1349 		mpDXAry = NULL;
1350 }
1351 
1352 // ------------------------------------------------------------------------
1353 
1354 MetaTextArrayAction::~MetaTextArrayAction()
1355 {
1356 	delete[] mpDXAry;
1357 }
1358 
1359 // ------------------------------------------------------------------------
1360 
1361 void MetaTextArrayAction::Execute( OutputDevice* pOut )
1362 {
1363 	pOut->DrawTextArray( maStartPt, maStr, mpDXAry, mnIndex, mnLen );
1364 }
1365 
1366 // ------------------------------------------------------------------------
1367 
1368 MetaAction* MetaTextArrayAction::Clone()
1369 {
1370 	MetaAction* pClone = (MetaAction*) new MetaTextArrayAction( *this );
1371 	pClone->ResetRefCount();
1372 	return pClone;
1373 }
1374 
1375 // ------------------------------------------------------------------------
1376 
1377 void MetaTextArrayAction::Move( long nHorzMove, long nVertMove )
1378 {
1379 	maStartPt.Move( nHorzMove, nVertMove );
1380 }
1381 
1382 // ------------------------------------------------------------------------
1383 
1384 void MetaTextArrayAction::Scale( double fScaleX, double fScaleY )
1385 {
1386 	ImplScalePoint( maStartPt, fScaleX, fScaleY );
1387 
1388 	if ( mpDXAry && mnLen )
1389 	{
1390 		for ( sal_uInt16 i = 0, nCount = mnLen; i < nCount; i++ )
1391 			mpDXAry[ i ] = FRound( mpDXAry[ i ] * fabs(fScaleX) );
1392 	}
1393 }
1394 
1395 // ------------------------------------------------------------------------
1396 
1397 sal_Bool MetaTextArrayAction::Compare( const MetaAction& rMetaAction ) const
1398 {
1399 	return ( maStartPt == ((MetaTextArrayAction&)rMetaAction).maStartPt ) &&
1400 		   ( maStr == ((MetaTextArrayAction&)rMetaAction).maStr ) &&
1401 		   ( mnIndex == ((MetaTextArrayAction&)rMetaAction).mnIndex ) &&
1402 		   ( mnLen == ((MetaTextArrayAction&)rMetaAction).mnLen ) &&
1403 		   ( memcmp( mpDXAry, ((MetaTextArrayAction&)rMetaAction).mpDXAry, mnLen ) == 0 );
1404 }
1405 
1406 // ------------------------------------------------------------------------
1407 
1408 void MetaTextArrayAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1409 {
1410     const sal_uInt32 nAryLen = mpDXAry ? mnLen : 0;
1411 
1412 	WRITE_BASE_COMPAT( rOStm, 2, pData );
1413 	rOStm	<< maStartPt;
1414 	rOStm.WriteByteString( maStr, pData->meActualCharSet );
1415 	rOStm	<< mnIndex;
1416 	rOStm	<< mnLen;
1417 	rOStm	<< nAryLen;
1418 
1419 	for( sal_uLong i = 0UL; i < nAryLen; i++ )
1420 		rOStm << mpDXAry[ i ];
1421 
1422 	sal_uInt16 j, nLen = maStr.Len();							// version 2
1423 	rOStm << nLen;
1424 	for ( j = 0; j < nLen; j++ )
1425 	{
1426 		sal_Unicode nUni = maStr.GetChar( j );
1427 		rOStm << nUni;
1428 	}
1429 }
1430 
1431 // ------------------------------------------------------------------------
1432 
1433 void MetaTextArrayAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
1434 {
1435 	sal_uInt32 nAryLen;
1436 
1437 	delete[] mpDXAry;
1438 
1439 	COMPAT( rIStm );
1440 	rIStm	>> maStartPt;
1441 	rIStm.ReadByteString( maStr, pData->meActualCharSet );
1442 	rIStm	>> mnIndex;
1443 	rIStm	>> mnLen;
1444 	rIStm	>> nAryLen;
1445 
1446 	if ( mnIndex + mnLen > maStr.Len() )
1447 	{
1448 		mnIndex = 0;
1449 		mpDXAry = 0;
1450 		return;
1451 	}
1452 
1453 	if( nAryLen )
1454 	{
1455         // #i9762#, #106172# Ensure that DX array is at least mnLen entries long
1456 		if ( mnLen >= nAryLen )
1457 		{
1458 			mpDXAry = new (std::nothrow)sal_Int32[ mnLen ];
1459 			if ( mpDXAry )
1460 			{
1461 	       		sal_uLong i;
1462 				for( i = 0UL; i < nAryLen; i++ )
1463 					rIStm >> mpDXAry[ i ];
1464 
1465 				// #106172# setup remainder
1466 				for( ; i < mnLen; i++ )
1467 					mpDXAry[ i ] = 0;
1468 			}
1469 		}
1470 		else
1471 		{
1472 			mpDXAry = NULL;
1473 			return;
1474 		}
1475 	}
1476 	else
1477 		mpDXAry = NULL;
1478 
1479 	if ( aCompat.GetVersion() >= 2 )							// Version 2
1480 	{
1481 		sal_uInt16 nLen;
1482 		rIStm >> nLen;
1483 		sal_Unicode* pBuffer = maStr.AllocBuffer( nLen );
1484 		while ( nLen-- )
1485 			rIStm >> *pBuffer++;
1486 
1487 		if ( mnIndex + mnLen > maStr.Len() )
1488 		{
1489 			mnIndex = 0;
1490 			delete[] mpDXAry, mpDXAry = NULL;
1491 		}
1492 	}
1493 }
1494 
1495 // ========================================================================
1496 
1497 IMPL_META_ACTION( StretchText, META_STRETCHTEXT_ACTION )
1498 
1499 // ------------------------------------------------------------------------
1500 
1501 MetaStretchTextAction::MetaStretchTextAction( const Point& rPt, sal_uInt32 nWidth,
1502 											  const XubString& rStr,
1503 											  sal_uInt16 nIndex, sal_uInt16 nLen ) :
1504 	MetaAction	( META_STRETCHTEXT_ACTION ),
1505 	maPt		( rPt ),
1506 	maStr		( rStr ),
1507 	mnWidth 	( nWidth ),
1508 	mnIndex 	( nIndex ),
1509 	mnLen		( nLen )
1510 {
1511 }
1512 
1513 // ------------------------------------------------------------------------
1514 
1515 void MetaStretchTextAction::Execute( OutputDevice* pOut )
1516 {
1517 	pOut->DrawStretchText( maPt, mnWidth, maStr, mnIndex, mnLen );
1518 }
1519 
1520 // ------------------------------------------------------------------------
1521 
1522 MetaAction* MetaStretchTextAction::Clone()
1523 {
1524 	MetaAction* pClone = (MetaAction*) new MetaStretchTextAction( *this );
1525 	pClone->ResetRefCount();
1526 	return pClone;
1527 }
1528 
1529 // ------------------------------------------------------------------------
1530 
1531 void MetaStretchTextAction::Move( long nHorzMove, long nVertMove )
1532 {
1533 	maPt.Move( nHorzMove, nVertMove );
1534 }
1535 
1536 // ------------------------------------------------------------------------
1537 
1538 void MetaStretchTextAction::Scale( double fScaleX, double fScaleY )
1539 {
1540 	ImplScalePoint( maPt, fScaleX, fScaleY );
1541 	mnWidth = (sal_uLong)FRound( mnWidth * fabs(fScaleX) );
1542 }
1543 
1544 // ------------------------------------------------------------------------
1545 
1546 sal_Bool MetaStretchTextAction::Compare( const MetaAction& rMetaAction ) const
1547 {
1548 	return ( maPt == ((MetaStretchTextAction&)rMetaAction).maPt ) &&
1549 		   ( maStr == ((MetaStretchTextAction&)rMetaAction).maStr ) &&
1550 		   ( mnWidth == ((MetaStretchTextAction&)rMetaAction).mnWidth ) &&
1551 		   ( mnIndex == ((MetaStretchTextAction&)rMetaAction).mnIndex ) &&
1552 		   ( mnLen == ((MetaStretchTextAction&)rMetaAction).mnLen );
1553 }
1554 
1555 // ------------------------------------------------------------------------
1556 
1557 void MetaStretchTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1558 {
1559 	WRITE_BASE_COMPAT( rOStm, 2, pData );
1560 	rOStm	<< maPt;
1561 	rOStm.WriteByteString( maStr, pData->meActualCharSet );
1562 	rOStm	<< mnWidth;
1563 	rOStm	<< mnIndex;
1564 	rOStm	<< mnLen;
1565 
1566 	sal_uInt16 i, nLen = maStr.Len();							// version 2
1567 	rOStm << nLen;
1568 	for ( i = 0; i < nLen; i++ )
1569 	{
1570 		sal_Unicode nUni = maStr.GetChar( i );
1571 		rOStm << nUni;
1572 	}
1573 }
1574 
1575 // ------------------------------------------------------------------------
1576 
1577 void MetaStretchTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
1578 {
1579 	COMPAT( rIStm );
1580 	rIStm	>> maPt;
1581 	rIStm.ReadByteString( maStr, pData->meActualCharSet );
1582 	rIStm	>> mnWidth;
1583 	rIStm	>> mnIndex;
1584 	rIStm	>> mnLen;
1585 
1586 	if ( aCompat.GetVersion() >= 2 )							// Version 2
1587 	{
1588 		sal_uInt16 nLen;
1589 		rIStm >> nLen;
1590 		sal_Unicode* pBuffer = maStr.AllocBuffer( nLen );
1591 		while ( nLen-- )
1592 			rIStm >> *pBuffer++;
1593 	}
1594 }
1595 
1596 // ========================================================================
1597 
1598 IMPL_META_ACTION( TextRect, META_TEXTRECT_ACTION )
1599 
1600 // ------------------------------------------------------------------------
1601 
1602 MetaTextRectAction::MetaTextRectAction( const Rectangle& rRect,
1603 										const XubString& rStr, sal_uInt16 nStyle ) :
1604 	MetaAction	( META_TEXTRECT_ACTION ),
1605 	maRect		( rRect ),
1606 	maStr		( rStr ),
1607 	mnStyle 	( nStyle )
1608 {
1609 }
1610 
1611 // ------------------------------------------------------------------------
1612 
1613 void MetaTextRectAction::Execute( OutputDevice* pOut )
1614 {
1615 	pOut->DrawText( maRect, maStr, mnStyle );
1616 }
1617 
1618 // ------------------------------------------------------------------------
1619 
1620 MetaAction* MetaTextRectAction::Clone()
1621 {
1622 	MetaAction* pClone = (MetaAction*) new MetaTextRectAction( *this );
1623 	pClone->ResetRefCount();
1624 	return pClone;
1625 }
1626 
1627 // ------------------------------------------------------------------------
1628 
1629 void MetaTextRectAction::Move( long nHorzMove, long nVertMove )
1630 {
1631 	maRect.Move( nHorzMove, nVertMove );
1632 }
1633 
1634 // ------------------------------------------------------------------------
1635 
1636 void MetaTextRectAction::Scale( double fScaleX, double fScaleY )
1637 {
1638 	ImplScaleRect( maRect, fScaleX, fScaleY );
1639 }
1640 
1641 // ------------------------------------------------------------------------
1642 
1643 sal_Bool MetaTextRectAction::Compare( const MetaAction& rMetaAction ) const
1644 {
1645 	return ( maRect == ((MetaTextRectAction&)rMetaAction).maRect ) &&
1646 		   ( maStr == ((MetaTextRectAction&)rMetaAction).maStr ) &&
1647 		   ( mnStyle == ((MetaTextRectAction&)rMetaAction).mnStyle );
1648 }
1649 
1650 // ------------------------------------------------------------------------
1651 
1652 void MetaTextRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1653 {
1654 	WRITE_BASE_COMPAT( rOStm, 2, pData );
1655 	rOStm	<< maRect;
1656 	rOStm.WriteByteString( maStr, pData->meActualCharSet );
1657 	rOStm	<< mnStyle;
1658 
1659 	sal_uInt16 i, nLen = maStr.Len();							// version 2
1660 	rOStm << nLen;
1661 	for ( i = 0; i < nLen; i++ )
1662 	{
1663 		sal_Unicode nUni = maStr.GetChar( i );
1664 		rOStm << nUni;
1665 	}
1666 }
1667 
1668 // ------------------------------------------------------------------------
1669 
1670 void MetaTextRectAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
1671 {
1672 	COMPAT( rIStm );
1673 	rIStm	>> maRect;
1674 	rIStm.ReadByteString( maStr, pData->meActualCharSet );
1675 	rIStm	>> mnStyle;
1676 
1677 	if ( aCompat.GetVersion() >= 2 )							// Version 2
1678 	{
1679 		sal_uInt16 nLen;
1680 		rIStm >> nLen;
1681 		sal_Unicode* pBuffer = maStr.AllocBuffer( nLen );
1682 		while ( nLen-- )
1683 			rIStm >> *pBuffer++;
1684 	}
1685 }
1686 
1687 // ========================================================================
1688 
1689 IMPL_META_ACTION( TextLine, META_TEXTLINE_ACTION )
1690 
1691 // ------------------------------------------------------------------------
1692 
1693 MetaTextLineAction::MetaTextLineAction( const Point& rPos, long nWidth,
1694 										FontStrikeout eStrikeout,
1695 										FontUnderline eUnderline,
1696 										FontUnderline eOverline ) :
1697 	MetaAction	( META_TEXTLINE_ACTION ),
1698 	maPos		( rPos ),
1699 	mnWidth 	( nWidth ),
1700 	meStrikeout ( eStrikeout ),
1701 	meUnderline ( eUnderline ),
1702 	meOverline  ( eOverline )
1703 {
1704 }
1705 
1706 // ------------------------------------------------------------------------
1707 
1708 void MetaTextLineAction::Execute( OutputDevice* pOut )
1709 {
1710 	pOut->DrawTextLine( maPos, mnWidth, meStrikeout, meUnderline, meOverline );
1711 }
1712 
1713 // ------------------------------------------------------------------------
1714 
1715 MetaAction* MetaTextLineAction::Clone()
1716 {
1717 	MetaAction* pClone = (MetaAction*)new MetaTextLineAction( *this );
1718 	pClone->ResetRefCount();
1719 	return pClone;
1720 }
1721 
1722 // ------------------------------------------------------------------------
1723 
1724 void MetaTextLineAction::Move( long nHorzMove, long nVertMove )
1725 {
1726 	maPos.Move( nHorzMove, nVertMove );
1727 }
1728 
1729 // ------------------------------------------------------------------------
1730 
1731 void MetaTextLineAction::Scale( double fScaleX, double fScaleY )
1732 {
1733 	ImplScalePoint( maPos, fScaleX, fScaleY );
1734 	mnWidth = FRound( mnWidth * fabs(fScaleX) );
1735 }
1736 
1737 // ------------------------------------------------------------------------
1738 
1739 sal_Bool MetaTextLineAction::Compare( const MetaAction& rMetaAction ) const
1740 {
1741 	return ( maPos == ((MetaTextLineAction&)rMetaAction).maPos ) &&
1742 		   ( mnWidth == ((MetaTextLineAction&)rMetaAction).mnWidth ) &&
1743 		   ( meStrikeout == ((MetaTextLineAction&)rMetaAction).meStrikeout ) &&
1744 		   ( meUnderline == ((MetaTextLineAction&)rMetaAction).meUnderline ) &&
1745 		   ( meOverline  == ((MetaTextLineAction&)rMetaAction).meOverline );
1746 }
1747 
1748 // ------------------------------------------------------------------------
1749 
1750 void MetaTextLineAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1751 {
1752 	WRITE_BASE_COMPAT( rOStm, 2, pData );
1753 
1754 	rOStm << maPos;
1755 	rOStm << mnWidth;
1756 	rOStm << static_cast<sal_uInt32>(meStrikeout);
1757 	rOStm << static_cast<sal_uInt32>(meUnderline);
1758     // new in version 2
1759 	rOStm << static_cast<sal_uInt32>(meOverline);
1760 }
1761 
1762 // ------------------------------------------------------------------------
1763 
1764 void MetaTextLineAction::Read( SvStream& rIStm, ImplMetaReadData* )
1765 {
1766 	COMPAT( rIStm );
1767 
1768 	sal_uInt32 nTemp;
1769 	rIStm >> maPos;
1770 	rIStm >> mnWidth;
1771 	rIStm >> nTemp;
1772 	meStrikeout = (FontStrikeout)nTemp;
1773 	rIStm >> nTemp;
1774 	meUnderline = (FontUnderline)nTemp;
1775     if ( aCompat.GetVersion() >= 2 ) {
1776         rIStm >> nTemp;
1777         meUnderline = (FontUnderline)nTemp;
1778     }
1779 }
1780 
1781 // ========================================================================
1782 
1783 IMPL_META_ACTION( Bmp, META_BMP_ACTION )
1784 
1785 // ------------------------------------------------------------------------
1786 
1787 MetaBmpAction::MetaBmpAction( const Point& rPt, const Bitmap& rBmp ) :
1788 	MetaAction	( META_BMP_ACTION ),
1789 	maBmp		( rBmp ),
1790 	maPt		( rPt )
1791 {
1792 }
1793 
1794 // ------------------------------------------------------------------------
1795 
1796 void MetaBmpAction::Execute( OutputDevice* pOut )
1797 {
1798 	pOut->DrawBitmap( maPt, maBmp );
1799 }
1800 
1801 // ------------------------------------------------------------------------
1802 
1803 MetaAction* MetaBmpAction::Clone()
1804 {
1805 	MetaAction* pClone = (MetaAction*) new MetaBmpAction( *this );
1806 	pClone->ResetRefCount();
1807 	return pClone;
1808 }
1809 
1810 // ------------------------------------------------------------------------
1811 
1812 void MetaBmpAction::Move( long nHorzMove, long nVertMove )
1813 {
1814 	maPt.Move( nHorzMove, nVertMove );
1815 }
1816 
1817 // ------------------------------------------------------------------------
1818 
1819 void MetaBmpAction::Scale( double fScaleX, double fScaleY )
1820 {
1821 	ImplScalePoint( maPt, fScaleX, fScaleY );
1822 }
1823 
1824 // ------------------------------------------------------------------------
1825 
1826 sal_Bool MetaBmpAction::Compare( const MetaAction& rMetaAction ) const
1827 {
1828 	return maBmp.IsEqual(((MetaBmpAction&)rMetaAction).maBmp ) &&
1829 		   ( maPt == ((MetaBmpAction&)rMetaAction).maPt );
1830 }
1831 
1832 // ------------------------------------------------------------------------
1833 
1834 void MetaBmpAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1835 {
1836 	if( !!maBmp )
1837 	{
1838 		WRITE_BASE_COMPAT( rOStm, 1, pData );
1839 		rOStm << maBmp << maPt;
1840 	}
1841 }
1842 
1843 // ------------------------------------------------------------------------
1844 
1845 void MetaBmpAction::Read( SvStream& rIStm, ImplMetaReadData* )
1846 {
1847 	COMPAT( rIStm );
1848 	rIStm >> maBmp >> maPt;
1849 }
1850 
1851 // ========================================================================
1852 
1853 IMPL_META_ACTION( BmpScale, META_BMPSCALE_ACTION )
1854 
1855 // ------------------------------------------------------------------------
1856 
1857 MetaBmpScaleAction::MetaBmpScaleAction( const Point& rPt, const Size& rSz,
1858 										const Bitmap& rBmp ) :
1859 	MetaAction	( META_BMPSCALE_ACTION ),
1860 	maBmp		( rBmp ),
1861 	maPt		( rPt ),
1862 	maSz		( rSz )
1863 {
1864 }
1865 
1866 // ------------------------------------------------------------------------
1867 
1868 void MetaBmpScaleAction::Execute( OutputDevice* pOut )
1869 {
1870 	pOut->DrawBitmap( maPt, maSz, maBmp );
1871 }
1872 
1873 // ------------------------------------------------------------------------
1874 
1875 MetaAction* MetaBmpScaleAction::Clone()
1876 {
1877 	MetaAction* pClone = (MetaAction*) new MetaBmpScaleAction( *this );
1878 	pClone->ResetRefCount();
1879 	return pClone;
1880 }
1881 
1882 // ------------------------------------------------------------------------
1883 
1884 void MetaBmpScaleAction::Move( long nHorzMove, long nVertMove )
1885 {
1886 	maPt.Move( nHorzMove, nVertMove );
1887 }
1888 
1889 // ------------------------------------------------------------------------
1890 
1891 void MetaBmpScaleAction::Scale( double fScaleX, double fScaleY )
1892 {
1893     Rectangle aRectangle(maPt, maSz);
1894 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
1895     maPt = aRectangle.TopLeft();
1896     maSz = aRectangle.GetSize();
1897 }
1898 
1899 // ------------------------------------------------------------------------
1900 
1901 sal_Bool MetaBmpScaleAction::Compare( const MetaAction& rMetaAction ) const
1902 {
1903 	return ( maBmp.IsEqual(((MetaBmpScaleAction&)rMetaAction).maBmp )) &&
1904 		   ( maPt == ((MetaBmpScaleAction&)rMetaAction).maPt ) &&
1905 		   ( maSz == ((MetaBmpScaleAction&)rMetaAction).maSz );
1906 }
1907 
1908 // ------------------------------------------------------------------------
1909 
1910 void MetaBmpScaleAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1911 {
1912 	if( !!maBmp )
1913 	{
1914 		WRITE_BASE_COMPAT( rOStm, 1, pData );
1915 		rOStm << maBmp << maPt << maSz;
1916 	}
1917 }
1918 
1919 // ------------------------------------------------------------------------
1920 
1921 void MetaBmpScaleAction::Read( SvStream& rIStm, ImplMetaReadData* )
1922 {
1923 	COMPAT( rIStm );
1924 	rIStm >> maBmp >> maPt >> maSz;
1925 }
1926 
1927 // ========================================================================
1928 
1929 IMPL_META_ACTION( BmpScalePart, META_BMPSCALEPART_ACTION )
1930 
1931 // ------------------------------------------------------------------------
1932 
1933 MetaBmpScalePartAction::MetaBmpScalePartAction( const Point& rDstPt, const Size& rDstSz,
1934 												const Point& rSrcPt, const Size& rSrcSz,
1935 												const Bitmap& rBmp ) :
1936 	MetaAction	( META_BMPSCALEPART_ACTION ),
1937 	maBmp		( rBmp ),
1938 	maDstPt 	( rDstPt ),
1939 	maDstSz 	( rDstSz ),
1940 	maSrcPt 	( rSrcPt ),
1941 	maSrcSz 	( rSrcSz )
1942 {
1943 }
1944 
1945 // ------------------------------------------------------------------------
1946 
1947 void MetaBmpScalePartAction::Execute( OutputDevice* pOut )
1948 {
1949 	pOut->DrawBitmap( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmp );
1950 }
1951 
1952 // ------------------------------------------------------------------------
1953 
1954 MetaAction* MetaBmpScalePartAction::Clone()
1955 {
1956 	MetaAction* pClone = (MetaAction*) new MetaBmpScalePartAction( *this );
1957 	pClone->ResetRefCount();
1958 	return pClone;
1959 }
1960 
1961 // ------------------------------------------------------------------------
1962 
1963 void MetaBmpScalePartAction::Move( long nHorzMove, long nVertMove )
1964 {
1965 	maDstPt.Move( nHorzMove, nVertMove );
1966 }
1967 
1968 // ------------------------------------------------------------------------
1969 
1970 void MetaBmpScalePartAction::Scale( double fScaleX, double fScaleY )
1971 {
1972     Rectangle aRectangle(maDstPt, maDstSz);
1973 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
1974     maDstPt = aRectangle.TopLeft();
1975     maDstSz = aRectangle.GetSize();
1976 }
1977 
1978 // ------------------------------------------------------------------------
1979 
1980 sal_Bool MetaBmpScalePartAction::Compare( const MetaAction& rMetaAction ) const
1981 {
1982 	return ( maBmp.IsEqual(((MetaBmpScalePartAction&)rMetaAction).maBmp )) &&
1983 		   ( maDstPt == ((MetaBmpScalePartAction&)rMetaAction).maDstPt ) &&
1984 		   ( maDstSz == ((MetaBmpScalePartAction&)rMetaAction).maDstSz ) &&
1985 		   ( maSrcPt == ((MetaBmpScalePartAction&)rMetaAction).maSrcPt ) &&
1986 		   ( maSrcSz == ((MetaBmpScalePartAction&)rMetaAction).maSrcSz );
1987 }
1988 
1989 // ------------------------------------------------------------------------
1990 
1991 void MetaBmpScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1992 {
1993 	if( !!maBmp )
1994 	{
1995 		WRITE_BASE_COMPAT( rOStm, 1, pData );
1996 		rOStm << maBmp << maDstPt << maDstSz << maSrcPt << maSrcSz;
1997 	}
1998 }
1999 
2000 // ------------------------------------------------------------------------
2001 
2002 void MetaBmpScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
2003 {
2004 	COMPAT( rIStm );
2005 	rIStm >> maBmp >> maDstPt >> maDstSz >> maSrcPt >> maSrcSz;
2006 }
2007 
2008 // ========================================================================
2009 
2010 IMPL_META_ACTION( BmpEx, META_BMPEX_ACTION )
2011 
2012 // ------------------------------------------------------------------------
2013 
2014 MetaBmpExAction::MetaBmpExAction( const Point& rPt, const BitmapEx& rBmpEx ) :
2015 	MetaAction	( META_BMPEX_ACTION ),
2016 	maBmpEx 	( rBmpEx ),
2017 	maPt		( rPt )
2018 {
2019 }
2020 
2021 // ------------------------------------------------------------------------
2022 
2023 void MetaBmpExAction::Execute( OutputDevice* pOut )
2024 {
2025 	pOut->DrawBitmapEx( maPt, maBmpEx );
2026 }
2027 
2028 // ------------------------------------------------------------------------
2029 
2030 MetaAction* MetaBmpExAction::Clone()
2031 {
2032 	MetaAction* pClone = (MetaAction*) new MetaBmpExAction( *this );
2033 	pClone->ResetRefCount();
2034 	return pClone;
2035 }
2036 
2037 // ------------------------------------------------------------------------
2038 
2039 void MetaBmpExAction::Move( long nHorzMove, long nVertMove )
2040 {
2041 	maPt.Move( nHorzMove, nVertMove );
2042 }
2043 
2044 // ------------------------------------------------------------------------
2045 
2046 void MetaBmpExAction::Scale( double fScaleX, double fScaleY )
2047 {
2048 	ImplScalePoint( maPt, fScaleX, fScaleY );
2049 }
2050 
2051 // ------------------------------------------------------------------------
2052 
2053 sal_Bool MetaBmpExAction::Compare( const MetaAction& rMetaAction ) const
2054 {
2055 	return ( maBmpEx.IsEqual(((MetaBmpExAction&)rMetaAction).maBmpEx )) &&
2056 		   ( maPt == ((MetaBmpExAction&)rMetaAction).maPt );
2057 }
2058 
2059 // ------------------------------------------------------------------------
2060 
2061 void MetaBmpExAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2062 {
2063 	if( !!maBmpEx.GetBitmap() )
2064 	{
2065 		WRITE_BASE_COMPAT( rOStm, 1, pData );
2066 		rOStm << maBmpEx << maPt;
2067 	}
2068 }
2069 
2070 // ------------------------------------------------------------------------
2071 
2072 void MetaBmpExAction::Read( SvStream& rIStm, ImplMetaReadData* )
2073 {
2074 	COMPAT( rIStm );
2075 	rIStm >> maBmpEx >> maPt;
2076 }
2077 
2078 // ========================================================================
2079 
2080 IMPL_META_ACTION( BmpExScale, META_BMPEXSCALE_ACTION )
2081 
2082 // ------------------------------------------------------------------------
2083 
2084 MetaBmpExScaleAction::MetaBmpExScaleAction( const Point& rPt, const Size& rSz,
2085 											const BitmapEx& rBmpEx ) :
2086 	MetaAction	( META_BMPEXSCALE_ACTION ),
2087 	maBmpEx 	( rBmpEx ),
2088 	maPt		( rPt ),
2089 	maSz		( rSz )
2090 {
2091 }
2092 
2093 // ------------------------------------------------------------------------
2094 
2095 void MetaBmpExScaleAction::Execute( OutputDevice* pOut )
2096 {
2097 	pOut->DrawBitmapEx( maPt, maSz, maBmpEx );
2098 }
2099 
2100 // ------------------------------------------------------------------------
2101 
2102 MetaAction* MetaBmpExScaleAction::Clone()
2103 {
2104 	MetaAction* pClone = (MetaAction*) new MetaBmpExScaleAction( *this );
2105 	pClone->ResetRefCount();
2106 	return pClone;
2107 }
2108 
2109 // ------------------------------------------------------------------------
2110 
2111 void MetaBmpExScaleAction::Move( long nHorzMove, long nVertMove )
2112 {
2113 	maPt.Move( nHorzMove, nVertMove );
2114 }
2115 
2116 // ------------------------------------------------------------------------
2117 
2118 void MetaBmpExScaleAction::Scale( double fScaleX, double fScaleY )
2119 {
2120     Rectangle aRectangle(maPt, maSz);
2121 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
2122     maPt = aRectangle.TopLeft();
2123     maSz = aRectangle.GetSize();
2124 }
2125 
2126 // ------------------------------------------------------------------------
2127 
2128 sal_Bool MetaBmpExScaleAction::Compare( const MetaAction& rMetaAction ) const
2129 {
2130 	return ( maBmpEx.IsEqual(((MetaBmpExScaleAction&)rMetaAction).maBmpEx )) &&
2131 		   ( maPt == ((MetaBmpExScaleAction&)rMetaAction).maPt ) &&
2132 		   ( maSz == ((MetaBmpExScaleAction&)rMetaAction).maSz );
2133 }
2134 
2135 // ------------------------------------------------------------------------
2136 
2137 void MetaBmpExScaleAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2138 {
2139 	if( !!maBmpEx.GetBitmap() )
2140 	{
2141 		WRITE_BASE_COMPAT( rOStm, 1, pData );
2142 		rOStm << maBmpEx << maPt << maSz;
2143 	}
2144 }
2145 
2146 // ------------------------------------------------------------------------
2147 
2148 void MetaBmpExScaleAction::Read( SvStream& rIStm, ImplMetaReadData* )
2149 {
2150 	COMPAT( rIStm );
2151 	rIStm >> maBmpEx >> maPt >> maSz;
2152 }
2153 
2154 // ========================================================================
2155 
2156 IMPL_META_ACTION( BmpExScalePart, META_BMPEXSCALEPART_ACTION )
2157 
2158 // ------------------------------------------------------------------------
2159 
2160 MetaBmpExScalePartAction::MetaBmpExScalePartAction( const Point& rDstPt, const Size& rDstSz,
2161 													const Point& rSrcPt, const Size& rSrcSz,
2162 													const BitmapEx& rBmpEx ) :
2163 	MetaAction	( META_BMPEXSCALEPART_ACTION ),
2164 	maBmpEx 	( rBmpEx ),
2165 	maDstPt 	( rDstPt ),
2166 	maDstSz 	( rDstSz ),
2167 	maSrcPt 	( rSrcPt ),
2168 	maSrcSz 	( rSrcSz )
2169 {
2170 }
2171 
2172 // ------------------------------------------------------------------------
2173 
2174 void MetaBmpExScalePartAction::Execute( OutputDevice* pOut )
2175 {
2176 	pOut->DrawBitmapEx( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmpEx );
2177 }
2178 
2179 // ------------------------------------------------------------------------
2180 
2181 MetaAction* MetaBmpExScalePartAction::Clone()
2182 {
2183 	MetaAction* pClone = (MetaAction*) new MetaBmpExScalePartAction( *this );
2184 	pClone->ResetRefCount();
2185 	return pClone;
2186 }
2187 
2188 // ------------------------------------------------------------------------
2189 
2190 void MetaBmpExScalePartAction::Move( long nHorzMove, long nVertMove )
2191 {
2192 	maDstPt.Move( nHorzMove, nVertMove );
2193 }
2194 
2195 // ------------------------------------------------------------------------
2196 
2197 void MetaBmpExScalePartAction::Scale( double fScaleX, double fScaleY )
2198 {
2199     Rectangle aRectangle(maDstPt, maDstSz);
2200 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
2201     maDstPt = aRectangle.TopLeft();
2202     maDstSz = aRectangle.GetSize();
2203 }
2204 
2205 // ------------------------------------------------------------------------
2206 
2207 sal_Bool MetaBmpExScalePartAction::Compare( const MetaAction& rMetaAction ) const
2208 {
2209 	return ( maBmpEx.IsEqual(((MetaBmpExScalePartAction&)rMetaAction).maBmpEx )) &&
2210 		   ( maDstPt == ((MetaBmpExScalePartAction&)rMetaAction).maDstPt ) &&
2211 		   ( maDstSz == ((MetaBmpExScalePartAction&)rMetaAction).maDstSz ) &&
2212 		   ( maSrcPt == ((MetaBmpExScalePartAction&)rMetaAction).maSrcPt ) &&
2213 		   ( maSrcSz == ((MetaBmpExScalePartAction&)rMetaAction).maSrcSz );
2214 }
2215 
2216 // ------------------------------------------------------------------------
2217 
2218 void MetaBmpExScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2219 {
2220 	if( !!maBmpEx.GetBitmap() )
2221 	{
2222 		WRITE_BASE_COMPAT( rOStm, 1, pData );
2223 		rOStm << maBmpEx << maDstPt << maDstSz << maSrcPt << maSrcSz;
2224 	}
2225 }
2226 
2227 // ------------------------------------------------------------------------
2228 
2229 void MetaBmpExScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
2230 {
2231 	COMPAT( rIStm );
2232 	rIStm >> maBmpEx >> maDstPt >> maDstSz >> maSrcPt >> maSrcSz;
2233 }
2234 
2235 // ========================================================================
2236 
2237 IMPL_META_ACTION( Mask, META_MASK_ACTION )
2238 
2239 // ------------------------------------------------------------------------
2240 
2241 MetaMaskAction::MetaMaskAction( const Point& rPt,
2242 								const Bitmap& rBmp,
2243 								const Color& rColor ) :
2244 	MetaAction	( META_MASK_ACTION ),
2245 	maBmp		( rBmp ),
2246 	maColor 	( rColor ),
2247 	maPt		( rPt )
2248 {
2249 }
2250 
2251 // ------------------------------------------------------------------------
2252 
2253 void MetaMaskAction::Execute( OutputDevice* pOut )
2254 {
2255 	pOut->DrawMask( maPt, maBmp, maColor );
2256 }
2257 
2258 // ------------------------------------------------------------------------
2259 
2260 MetaAction* MetaMaskAction::Clone()
2261 {
2262 	MetaAction* pClone = (MetaAction*) new MetaMaskAction( *this );
2263 	pClone->ResetRefCount();
2264 	return pClone;
2265 }
2266 
2267 // ------------------------------------------------------------------------
2268 
2269 void MetaMaskAction::Move( long nHorzMove, long nVertMove )
2270 {
2271 	maPt.Move( nHorzMove, nVertMove );
2272 }
2273 
2274 // ------------------------------------------------------------------------
2275 
2276 void MetaMaskAction::Scale( double fScaleX, double fScaleY )
2277 {
2278 	ImplScalePoint( maPt, fScaleX, fScaleY );
2279 }
2280 
2281 // ------------------------------------------------------------------------
2282 
2283 sal_Bool MetaMaskAction::Compare( const MetaAction& rMetaAction ) const
2284 {
2285 	return ( maBmp.IsEqual(((MetaMaskAction&)rMetaAction).maBmp )) &&
2286 		   ( maColor == ((MetaMaskAction&)rMetaAction).maColor ) &&
2287 		   ( maPt == ((MetaMaskAction&)rMetaAction).maPt );
2288 }
2289 
2290 // ------------------------------------------------------------------------
2291 
2292 void MetaMaskAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2293 {
2294 	if( !!maBmp )
2295 	{
2296 		WRITE_BASE_COMPAT( rOStm, 1, pData );
2297 		rOStm << maBmp << maPt;
2298 	}
2299 }
2300 
2301 // ------------------------------------------------------------------------
2302 
2303 void MetaMaskAction::Read( SvStream& rIStm, ImplMetaReadData* )
2304 {
2305 	COMPAT( rIStm );
2306 	rIStm >> maBmp >> maPt;
2307 }
2308 
2309 // ========================================================================
2310 
2311 IMPL_META_ACTION( MaskScale, META_MASKSCALE_ACTION )
2312 
2313 // ------------------------------------------------------------------------
2314 
2315 MetaMaskScaleAction::MetaMaskScaleAction( const Point& rPt, const Size& rSz,
2316 										  const Bitmap& rBmp,
2317 										  const Color& rColor ) :
2318 	MetaAction	( META_MASKSCALE_ACTION ),
2319 	maBmp		( rBmp ),
2320 	maColor 	( rColor ),
2321 	maPt		( rPt ),
2322 	maSz		( rSz )
2323 {
2324 }
2325 
2326 // ------------------------------------------------------------------------
2327 
2328 void MetaMaskScaleAction::Execute( OutputDevice* pOut )
2329 {
2330 	pOut->DrawMask( maPt, maSz, maBmp, maColor );
2331 }
2332 
2333 // ------------------------------------------------------------------------
2334 
2335 MetaAction* MetaMaskScaleAction::Clone()
2336 {
2337 	MetaAction* pClone = (MetaAction*) new MetaMaskScaleAction( *this );
2338 	pClone->ResetRefCount();
2339 	return pClone;
2340 }
2341 
2342 // ------------------------------------------------------------------------
2343 
2344 void MetaMaskScaleAction::Move( long nHorzMove, long nVertMove )
2345 {
2346 	maPt.Move( nHorzMove, nVertMove );
2347 }
2348 
2349 // ------------------------------------------------------------------------
2350 
2351 void MetaMaskScaleAction::Scale( double fScaleX, double fScaleY )
2352 {
2353     Rectangle aRectangle(maPt, maSz);
2354 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
2355     maPt = aRectangle.TopLeft();
2356     maSz = aRectangle.GetSize();
2357 }
2358 
2359 // ------------------------------------------------------------------------
2360 
2361 sal_Bool MetaMaskScaleAction::Compare( const MetaAction& rMetaAction ) const
2362 {
2363 	return ( maBmp.IsEqual(((MetaMaskScaleAction&)rMetaAction).maBmp )) &&
2364 		   ( maColor == ((MetaMaskScaleAction&)rMetaAction).maColor ) &&
2365 		   ( maPt == ((MetaMaskScaleAction&)rMetaAction).maPt ) &&
2366 		   ( maSz == ((MetaMaskScaleAction&)rMetaAction).maSz );
2367 }
2368 
2369 // ------------------------------------------------------------------------
2370 
2371 void MetaMaskScaleAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2372 {
2373 	if( !!maBmp )
2374 	{
2375 		WRITE_BASE_COMPAT( rOStm, 1, pData );
2376 		rOStm << maBmp << maPt << maSz;
2377 	}
2378 }
2379 
2380 // ------------------------------------------------------------------------
2381 
2382 void MetaMaskScaleAction::Read( SvStream& rIStm, ImplMetaReadData* )
2383 {
2384 	COMPAT( rIStm );
2385 	rIStm >> maBmp >> maPt >> maSz;
2386 }
2387 
2388 // ========================================================================
2389 
2390 IMPL_META_ACTION( MaskScalePart, META_MASKSCALEPART_ACTION )
2391 
2392 // ------------------------------------------------------------------------
2393 
2394 MetaMaskScalePartAction::MetaMaskScalePartAction( const Point& rDstPt, const Size& rDstSz,
2395 												  const Point& rSrcPt, const Size& rSrcSz,
2396 												  const Bitmap& rBmp,
2397 												  const Color& rColor ) :
2398 	MetaAction	( META_MASKSCALEPART_ACTION ),
2399 	maBmp		( rBmp ),
2400 	maColor 	( rColor ),
2401 	maDstPt 	( rDstPt ),
2402 	maDstSz 	( rDstSz ),
2403 	maSrcPt 	( rSrcPt ),
2404 	maSrcSz 	( rSrcSz )
2405 {
2406 }
2407 
2408 // ------------------------------------------------------------------------
2409 
2410 void MetaMaskScalePartAction::Execute( OutputDevice* pOut )
2411 {
2412 	pOut->DrawMask( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmp, maColor );
2413 }
2414 
2415 // ------------------------------------------------------------------------
2416 
2417 MetaAction* MetaMaskScalePartAction::Clone()
2418 {
2419 	MetaAction* pClone = (MetaAction*) new MetaMaskScalePartAction( *this );
2420 	pClone->ResetRefCount();
2421 	return pClone;
2422 }
2423 
2424 // ------------------------------------------------------------------------
2425 
2426 void MetaMaskScalePartAction::Move( long nHorzMove, long nVertMove )
2427 {
2428 	maDstPt.Move( nHorzMove, nVertMove );
2429 }
2430 
2431 // ------------------------------------------------------------------------
2432 
2433 void MetaMaskScalePartAction::Scale( double fScaleX, double fScaleY )
2434 {
2435     Rectangle aRectangle(maDstPt, maDstSz);
2436 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
2437     maDstPt = aRectangle.TopLeft();
2438     maDstSz = aRectangle.GetSize();
2439 }
2440 
2441 // ------------------------------------------------------------------------
2442 
2443 sal_Bool MetaMaskScalePartAction::Compare( const MetaAction& rMetaAction ) const
2444 {
2445 	return ( maBmp.IsEqual(((MetaMaskScalePartAction&)rMetaAction).maBmp )) &&
2446 		   ( maColor == ((MetaMaskScalePartAction&)rMetaAction).maColor ) &&
2447 		   ( maDstPt == ((MetaMaskScalePartAction&)rMetaAction).maDstPt ) &&
2448 		   ( maDstSz == ((MetaMaskScalePartAction&)rMetaAction).maDstSz ) &&
2449 		   ( maSrcPt == ((MetaMaskScalePartAction&)rMetaAction).maSrcPt ) &&
2450 		   ( maSrcSz == ((MetaMaskScalePartAction&)rMetaAction).maSrcSz );
2451 }
2452 
2453 // ------------------------------------------------------------------------
2454 
2455 void MetaMaskScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2456 {
2457 	if( !!maBmp )
2458 	{
2459 		WRITE_BASE_COMPAT( rOStm, 1, pData );
2460 		rOStm << maBmp;
2461 		maColor.Write( rOStm, sal_True );
2462 		rOStm << maDstPt << maDstSz << maSrcPt << maSrcSz;
2463 	}
2464 }
2465 
2466 // ------------------------------------------------------------------------
2467 
2468 void MetaMaskScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
2469 {
2470 	COMPAT( rIStm );
2471 	rIStm >> maBmp;
2472 	maColor.Read( rIStm, sal_True );
2473 	rIStm >> maDstPt >> maDstSz >> maSrcPt >> maSrcSz;
2474 }
2475 
2476 // ========================================================================
2477 
2478 IMPL_META_ACTION( Gradient, META_GRADIENT_ACTION )
2479 
2480 // ------------------------------------------------------------------------
2481 
2482 MetaGradientAction::MetaGradientAction( const Rectangle& rRect, const Gradient& rGradient ) :
2483 	MetaAction	( META_GRADIENT_ACTION ),
2484 	maRect		( rRect ),
2485 	maGradient	( rGradient )
2486 {
2487 }
2488 
2489 // ------------------------------------------------------------------------
2490 
2491 void MetaGradientAction::Execute( OutputDevice* pOut )
2492 {
2493 	pOut->DrawGradient( maRect, maGradient );
2494 }
2495 
2496 // ------------------------------------------------------------------------
2497 
2498 MetaAction* MetaGradientAction::Clone()
2499 {
2500 	MetaAction* pClone = (MetaAction*) new MetaGradientAction( *this );
2501 	pClone->ResetRefCount();
2502 	return pClone;
2503 }
2504 
2505 // ------------------------------------------------------------------------
2506 
2507 void MetaGradientAction::Move( long nHorzMove, long nVertMove )
2508 {
2509 	maRect.Move( nHorzMove, nVertMove );
2510 }
2511 
2512 // ------------------------------------------------------------------------
2513 
2514 void MetaGradientAction::Scale( double fScaleX, double fScaleY )
2515 {
2516 	ImplScaleRect( maRect, fScaleX, fScaleY );
2517 }
2518 
2519 // ------------------------------------------------------------------------
2520 
2521 sal_Bool MetaGradientAction::Compare( const MetaAction& rMetaAction ) const
2522 {
2523 	return ( maRect == ((MetaGradientAction&)rMetaAction).maRect ) &&
2524 		   ( maGradient == ((MetaGradientAction&)rMetaAction).maGradient );
2525 }
2526 
2527 // ------------------------------------------------------------------------
2528 
2529 void MetaGradientAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2530 {
2531 	WRITE_BASE_COMPAT( rOStm, 1, pData );
2532 	rOStm << maRect << maGradient;
2533 }
2534 
2535 // ------------------------------------------------------------------------
2536 
2537 void MetaGradientAction::Read( SvStream& rIStm, ImplMetaReadData* )
2538 {
2539 	COMPAT( rIStm );
2540 	rIStm >> maRect >> maGradient;
2541 }
2542 
2543 // ========================================================================
2544 
2545 MetaGradientExAction::MetaGradientExAction() :
2546 	MetaAction	( META_GRADIENTEX_ACTION )
2547 {
2548 }
2549 
2550 // ------------------------------------------------------------------------
2551 
2552 MetaGradientExAction::MetaGradientExAction( const PolyPolygon& rPolyPoly, const Gradient& rGradient ) :
2553 	MetaAction	( META_GRADIENTEX_ACTION ),
2554 	maPolyPoly	( rPolyPoly ),
2555 	maGradient	( rGradient )
2556 {
2557 }
2558 
2559 // ------------------------------------------------------------------------
2560 
2561 MetaGradientExAction::~MetaGradientExAction()
2562 {
2563 }
2564 
2565 // ------------------------------------------------------------------------
2566 
2567 void MetaGradientExAction::Execute( OutputDevice* pOut )
2568 {
2569 	if( pOut->GetConnectMetaFile() )
2570     {
2571         Duplicate();
2572 		pOut->GetConnectMetaFile()->AddAction( this );
2573     }
2574 }
2575 
2576 // ------------------------------------------------------------------------
2577 
2578 MetaAction* MetaGradientExAction::Clone()
2579 {
2580 	MetaAction* pClone = (MetaAction*) new MetaGradientExAction( *this );
2581 	pClone->ResetRefCount();
2582 	return pClone;
2583 }
2584 
2585 // ------------------------------------------------------------------------
2586 
2587 void MetaGradientExAction::Move( long nHorzMove, long nVertMove )
2588 {
2589 	maPolyPoly.Move( nHorzMove, nVertMove );
2590 }
2591 
2592 // ------------------------------------------------------------------------
2593 
2594 void MetaGradientExAction::Scale( double fScaleX, double fScaleY )
2595 {
2596 	for( sal_uInt16 i = 0, nCount = maPolyPoly.Count(); i < nCount; i++ )
2597 		ImplScalePoly( maPolyPoly[ i ], fScaleX, fScaleY );
2598 }
2599 
2600 // ------------------------------------------------------------------------
2601 
2602 sal_Bool MetaGradientExAction::Compare( const MetaAction& rMetaAction ) const
2603 {
2604 	return ( maPolyPoly == ((MetaGradientExAction&)rMetaAction).maPolyPoly ) &&
2605 		   ( maGradient == ((MetaGradientExAction&)rMetaAction).maGradient );
2606 }
2607 
2608 // ------------------------------------------------------------------------
2609 
2610 void MetaGradientExAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2611 {
2612 	WRITE_BASE_COMPAT( rOStm, 1, pData );
2613 
2614     // #i105373# see comment at MetaTransparentAction::Write
2615     PolyPolygon aNoCurvePolyPolygon;
2616     maPolyPoly.AdaptiveSubdivide(aNoCurvePolyPolygon);
2617 
2618     rOStm << aNoCurvePolyPolygon;
2619     rOStm << maGradient;
2620 }
2621 
2622 // ------------------------------------------------------------------------
2623 
2624 void MetaGradientExAction::Read( SvStream& rIStm, ImplMetaReadData* )
2625 {
2626 	COMPAT( rIStm );
2627 	rIStm >> maPolyPoly >> maGradient;
2628 }
2629 
2630 // ========================================================================
2631 
2632 IMPL_META_ACTION( Hatch, META_HATCH_ACTION )
2633 
2634 // ------------------------------------------------------------------------
2635 
2636 MetaHatchAction::MetaHatchAction( const PolyPolygon& rPolyPoly, const Hatch& rHatch ) :
2637 	MetaAction	( META_HATCH_ACTION ),
2638 	maPolyPoly	( rPolyPoly ),
2639 	maHatch 	( rHatch )
2640 {
2641 }
2642 
2643 // ------------------------------------------------------------------------
2644 
2645 void MetaHatchAction::Execute( OutputDevice* pOut )
2646 {
2647 	pOut->DrawHatch( maPolyPoly, maHatch );
2648 }
2649 
2650 // ------------------------------------------------------------------------
2651 
2652 MetaAction* MetaHatchAction::Clone()
2653 {
2654 	MetaAction* pClone = (MetaAction*) new MetaHatchAction( *this );
2655 	pClone->ResetRefCount();
2656 	return pClone;
2657 }
2658 
2659 // ------------------------------------------------------------------------
2660 
2661 void MetaHatchAction::Move( long nHorzMove, long nVertMove )
2662 {
2663 	maPolyPoly.Move( nHorzMove, nVertMove );
2664 }
2665 
2666 // ------------------------------------------------------------------------
2667 
2668 void MetaHatchAction::Scale( double fScaleX, double fScaleY )
2669 {
2670 	for( sal_uInt16 i = 0, nCount = maPolyPoly.Count(); i < nCount; i++ )
2671 		ImplScalePoly( maPolyPoly[ i ], fScaleX, fScaleY );
2672 }
2673 
2674 // ------------------------------------------------------------------------
2675 
2676 sal_Bool MetaHatchAction::Compare( const MetaAction& rMetaAction ) const
2677 {
2678 	return ( maPolyPoly == ((MetaHatchAction&)rMetaAction).maPolyPoly ) &&
2679 		   ( maHatch == ((MetaHatchAction&)rMetaAction).maHatch );
2680 }
2681 
2682 // ------------------------------------------------------------------------
2683 
2684 void MetaHatchAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2685 {
2686 	WRITE_BASE_COMPAT( rOStm, 1, pData );
2687 
2688     // #i105373# see comment at MetaTransparentAction::Write
2689     PolyPolygon aNoCurvePolyPolygon;
2690     maPolyPoly.AdaptiveSubdivide(aNoCurvePolyPolygon);
2691 
2692     rOStm << aNoCurvePolyPolygon;
2693     rOStm << maHatch;
2694 }
2695 
2696 // ------------------------------------------------------------------------
2697 
2698 void MetaHatchAction::Read( SvStream& rIStm, ImplMetaReadData* )
2699 {
2700 	COMPAT( rIStm );
2701 	rIStm >> maPolyPoly >> maHatch;
2702 }
2703 
2704 // ========================================================================
2705 
2706 IMPL_META_ACTION( Wallpaper, META_WALLPAPER_ACTION )
2707 
2708 // ------------------------------------------------------------------------
2709 
2710 MetaWallpaperAction::MetaWallpaperAction( const Rectangle& rRect,
2711 										  const Wallpaper& rPaper ) :
2712 	MetaAction	( META_WALLPAPER_ACTION ),
2713 	maRect		( rRect ),
2714 	maWallpaper ( rPaper )
2715 {
2716 }
2717 
2718 // ------------------------------------------------------------------------
2719 
2720 void MetaWallpaperAction::Execute( OutputDevice* pOut )
2721 {
2722 	pOut->DrawWallpaper( maRect, maWallpaper );
2723 }
2724 
2725 // ------------------------------------------------------------------------
2726 
2727 MetaAction* MetaWallpaperAction::Clone()
2728 {
2729 	MetaAction* pClone = (MetaAction*) new MetaWallpaperAction( *this );
2730 	pClone->ResetRefCount();
2731 	return pClone;
2732 }
2733 
2734 // ------------------------------------------------------------------------
2735 
2736 void MetaWallpaperAction::Move( long nHorzMove, long nVertMove )
2737 {
2738 	maRect.Move( nHorzMove, nVertMove );
2739 }
2740 
2741 // ------------------------------------------------------------------------
2742 
2743 void MetaWallpaperAction::Scale( double fScaleX, double fScaleY )
2744 {
2745 	ImplScaleRect( maRect, fScaleX, fScaleY );
2746 }
2747 
2748 // ------------------------------------------------------------------------
2749 
2750 sal_Bool MetaWallpaperAction::Compare( const MetaAction& rMetaAction ) const
2751 {
2752 	return ( maRect == ((MetaWallpaperAction&)rMetaAction).maRect ) &&
2753 		   ( maWallpaper == ((MetaWallpaperAction&)rMetaAction).maWallpaper );
2754 }
2755 
2756 // ------------------------------------------------------------------------
2757 
2758 void MetaWallpaperAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2759 {
2760 	WRITE_BASE_COMPAT( rOStm, 1, pData );
2761 	rOStm << maWallpaper;
2762 }
2763 
2764 // ------------------------------------------------------------------------
2765 
2766 void MetaWallpaperAction::Read( SvStream& rIStm, ImplMetaReadData* )
2767 {
2768 	COMPAT( rIStm );
2769 	rIStm >> maWallpaper;
2770 }
2771 
2772 // ========================================================================
2773 
2774 IMPL_META_ACTION( ClipRegion, META_CLIPREGION_ACTION )
2775 
2776 // ------------------------------------------------------------------------
2777 
2778 MetaClipRegionAction::MetaClipRegionAction( const Region& rRegion, sal_Bool bClip ) :
2779 	MetaAction	( META_CLIPREGION_ACTION ),
2780 	maRegion	( rRegion ),
2781 	mbClip		( bClip )
2782 {
2783 }
2784 
2785 // ------------------------------------------------------------------------
2786 
2787 void MetaClipRegionAction::Execute( OutputDevice* pOut )
2788 {
2789 	if( mbClip )
2790 		pOut->SetClipRegion( maRegion );
2791 	else
2792 		pOut->SetClipRegion();
2793 }
2794 
2795 // ------------------------------------------------------------------------
2796 
2797 MetaAction* MetaClipRegionAction::Clone()
2798 {
2799 	MetaAction* pClone = (MetaAction*) new MetaClipRegionAction( *this );
2800 	pClone->ResetRefCount();
2801 	return pClone;
2802 }
2803 
2804 // ------------------------------------------------------------------------
2805 
2806 void MetaClipRegionAction::Move( long nHorzMove, long nVertMove )
2807 {
2808 	maRegion.Move( nHorzMove, nVertMove );
2809 }
2810 
2811 // ------------------------------------------------------------------------
2812 
2813 void MetaClipRegionAction::Scale( double fScaleX, double fScaleY )
2814 {
2815 	maRegion.Scale( fScaleX, fScaleY );
2816 }
2817 
2818 // ------------------------------------------------------------------------
2819 
2820 sal_Bool MetaClipRegionAction::Compare( const MetaAction& rMetaAction ) const
2821 {
2822 	return ( maRegion == ((MetaClipRegionAction&)rMetaAction).maRegion ) &&
2823 		   ( mbClip == ((MetaClipRegionAction&)rMetaAction).mbClip );
2824 }
2825 
2826 // ------------------------------------------------------------------------
2827 
2828 void MetaClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2829 {
2830 	WRITE_BASE_COMPAT( rOStm, 1, pData );
2831 	rOStm << maRegion << mbClip;
2832 }
2833 
2834 // ------------------------------------------------------------------------
2835 
2836 void MetaClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
2837 {
2838 	COMPAT( rIStm );
2839 	rIStm >> maRegion >> mbClip;
2840 }
2841 
2842 // ========================================================================
2843 
2844 IMPL_META_ACTION( ISectRectClipRegion, META_ISECTRECTCLIPREGION_ACTION )
2845 
2846 // ------------------------------------------------------------------------
2847 
2848 MetaISectRectClipRegionAction::MetaISectRectClipRegionAction( const Rectangle& rRect ) :
2849 	MetaAction	( META_ISECTRECTCLIPREGION_ACTION ),
2850 	maRect		( rRect )
2851 {
2852 }
2853 
2854 // ------------------------------------------------------------------------
2855 
2856 void MetaISectRectClipRegionAction::Execute( OutputDevice* pOut )
2857 {
2858 	pOut->IntersectClipRegion( maRect );
2859 }
2860 
2861 // ------------------------------------------------------------------------
2862 
2863 MetaAction* MetaISectRectClipRegionAction::Clone()
2864 {
2865 	MetaAction* pClone = (MetaAction*) new MetaISectRectClipRegionAction( *this );
2866 	pClone->ResetRefCount();
2867 	return pClone;
2868 }
2869 
2870 // ------------------------------------------------------------------------
2871 
2872 void MetaISectRectClipRegionAction::Move( long nHorzMove, long nVertMove )
2873 {
2874 	maRect.Move( nHorzMove, nVertMove );
2875 }
2876 
2877 // ------------------------------------------------------------------------
2878 
2879 void MetaISectRectClipRegionAction::Scale( double fScaleX, double fScaleY )
2880 {
2881 	ImplScaleRect( maRect, fScaleX, fScaleY );
2882 }
2883 
2884 // ------------------------------------------------------------------------
2885 
2886 sal_Bool MetaISectRectClipRegionAction::Compare( const MetaAction& rMetaAction ) const
2887 {
2888 	return maRect == ((MetaISectRectClipRegionAction&)rMetaAction).maRect;
2889 }
2890 
2891 // ------------------------------------------------------------------------
2892 
2893 void MetaISectRectClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2894 {
2895 	WRITE_BASE_COMPAT( rOStm, 1, pData );
2896 	rOStm << maRect;
2897 }
2898 
2899 // ------------------------------------------------------------------------
2900 
2901 void MetaISectRectClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
2902 {
2903 	COMPAT( rIStm );
2904 	rIStm >> maRect;
2905 }
2906 
2907 // ========================================================================
2908 
2909 IMPL_META_ACTION( ISectRegionClipRegion, META_ISECTREGIONCLIPREGION_ACTION )
2910 
2911 // ------------------------------------------------------------------------
2912 
2913 MetaISectRegionClipRegionAction::MetaISectRegionClipRegionAction( const Region& rRegion ) :
2914 	MetaAction	( META_ISECTREGIONCLIPREGION_ACTION ),
2915 	maRegion	( rRegion )
2916 {
2917 }
2918 
2919 // ------------------------------------------------------------------------
2920 
2921 void MetaISectRegionClipRegionAction::Execute( OutputDevice* pOut )
2922 {
2923 	pOut->IntersectClipRegion( maRegion );
2924 }
2925 
2926 // ------------------------------------------------------------------------
2927 
2928 MetaAction* MetaISectRegionClipRegionAction::Clone()
2929 {
2930 	MetaAction* pClone = (MetaAction*) new MetaISectRegionClipRegionAction( *this );
2931 	pClone->ResetRefCount();
2932 	return pClone;
2933 }
2934 
2935 // ------------------------------------------------------------------------
2936 
2937 void MetaISectRegionClipRegionAction::Move( long nHorzMove, long nVertMove )
2938 {
2939 	maRegion.Move( nHorzMove, nVertMove );
2940 }
2941 
2942 // ------------------------------------------------------------------------
2943 
2944 void MetaISectRegionClipRegionAction::Scale( double fScaleX, double fScaleY )
2945 {
2946 	maRegion.Scale( fScaleX, fScaleY );
2947 }
2948 
2949 // ------------------------------------------------------------------------
2950 
2951 sal_Bool MetaISectRegionClipRegionAction::Compare( const MetaAction& rMetaAction ) const
2952 {
2953 	return maRegion == ((MetaISectRegionClipRegionAction&)rMetaAction).maRegion;
2954 }
2955 
2956 // ------------------------------------------------------------------------
2957 
2958 void MetaISectRegionClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2959 {
2960 	WRITE_BASE_COMPAT( rOStm, 1, pData );
2961 	rOStm << maRegion;
2962 }
2963 
2964 // ------------------------------------------------------------------------
2965 
2966 void MetaISectRegionClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
2967 {
2968 	COMPAT( rIStm );
2969 	rIStm >> maRegion;
2970 }
2971 
2972 // ========================================================================
2973 
2974 IMPL_META_ACTION( MoveClipRegion, META_MOVECLIPREGION_ACTION )
2975 
2976 // ------------------------------------------------------------------------
2977 
2978 MetaMoveClipRegionAction::MetaMoveClipRegionAction( long nHorzMove, long nVertMove ) :
2979 	MetaAction	( META_MOVECLIPREGION_ACTION ),
2980 	mnHorzMove	( nHorzMove ),
2981 	mnVertMove	( nVertMove )
2982 {
2983 }
2984 
2985 // ------------------------------------------------------------------------
2986 
2987 void MetaMoveClipRegionAction::Execute( OutputDevice* pOut )
2988 {
2989 	pOut->MoveClipRegion( mnHorzMove, mnVertMove );
2990 }
2991 
2992 // ------------------------------------------------------------------------
2993 
2994 MetaAction* MetaMoveClipRegionAction::Clone()
2995 {
2996 	MetaAction* pClone = (MetaAction*) new MetaMoveClipRegionAction( *this );
2997 	pClone->ResetRefCount();
2998 	return pClone;
2999 }
3000 
3001 // ------------------------------------------------------------------------
3002 
3003 void MetaMoveClipRegionAction::Scale( double fScaleX, double fScaleY )
3004 {
3005 	mnHorzMove = FRound( mnHorzMove * fScaleX );
3006 	mnVertMove = FRound( mnVertMove * fScaleY );
3007 }
3008 
3009 // ------------------------------------------------------------------------
3010 
3011 sal_Bool MetaMoveClipRegionAction::Compare( const MetaAction& rMetaAction ) const
3012 {
3013 	return ( mnHorzMove == ((MetaMoveClipRegionAction&)rMetaAction).mnHorzMove ) &&
3014 		   ( mnVertMove == ((MetaMoveClipRegionAction&)rMetaAction).mnVertMove );
3015 }
3016 
3017 // ------------------------------------------------------------------------
3018 
3019 void MetaMoveClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3020 {
3021 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3022 	rOStm << mnHorzMove << mnVertMove;
3023 }
3024 
3025 // ------------------------------------------------------------------------
3026 
3027 void MetaMoveClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
3028 {
3029 	COMPAT( rIStm );
3030 	rIStm >> mnHorzMove >> mnVertMove;
3031 }
3032 
3033 // ========================================================================
3034 
3035 IMPL_META_ACTION( LineColor, META_LINECOLOR_ACTION )
3036 
3037 // ------------------------------------------------------------------------
3038 
3039 MetaLineColorAction::MetaLineColorAction( const Color& rColor, sal_Bool bSet ) :
3040 	MetaAction	( META_LINECOLOR_ACTION ),
3041 	maColor 	( rColor ),
3042 	mbSet		( bSet )
3043 {
3044 }
3045 
3046 // ------------------------------------------------------------------------
3047 
3048 void MetaLineColorAction::Execute( OutputDevice* pOut )
3049 {
3050 	if( mbSet )
3051 		pOut->SetLineColor( maColor );
3052 	else
3053 		pOut->SetLineColor();
3054 }
3055 
3056 // ------------------------------------------------------------------------
3057 
3058 MetaAction* MetaLineColorAction::Clone()
3059 {
3060 	MetaAction* pClone = (MetaAction*) new MetaLineColorAction( *this );
3061 	pClone->ResetRefCount();
3062 	return pClone;
3063 }
3064 
3065 // ------------------------------------------------------------------------
3066 
3067 sal_Bool MetaLineColorAction::Compare( const MetaAction& rMetaAction ) const
3068 {
3069 	return ( maColor == ((MetaLineColorAction&)rMetaAction).maColor ) &&
3070 		   ( mbSet == ((MetaLineColorAction&)rMetaAction).mbSet );
3071 }
3072 
3073 // ------------------------------------------------------------------------
3074 
3075 void MetaLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3076 {
3077 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3078 	maColor.Write( rOStm, sal_True );
3079 	rOStm << mbSet;
3080 }
3081 
3082 // ------------------------------------------------------------------------
3083 
3084 void MetaLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
3085 {
3086 	COMPAT( rIStm );
3087 	maColor.Read( rIStm, sal_True );
3088 	rIStm >> mbSet;
3089 }
3090 
3091 // ========================================================================
3092 
3093 IMPL_META_ACTION( FillColor, META_FILLCOLOR_ACTION )
3094 
3095 // ------------------------------------------------------------------------
3096 
3097 MetaFillColorAction::MetaFillColorAction( const Color& rColor, sal_Bool bSet ) :
3098 	MetaAction	( META_FILLCOLOR_ACTION ),
3099 	maColor 	( rColor ),
3100 	mbSet		( bSet )
3101 {
3102 }
3103 
3104 // ------------------------------------------------------------------------
3105 
3106 void MetaFillColorAction::Execute( OutputDevice* pOut )
3107 {
3108 	if( mbSet )
3109 		pOut->SetFillColor( maColor );
3110 	else
3111 		pOut->SetFillColor();
3112 }
3113 
3114 // ------------------------------------------------------------------------
3115 
3116 MetaAction* MetaFillColorAction::Clone()
3117 {
3118 	MetaAction* pClone = (MetaAction*) new MetaFillColorAction( *this );
3119 	pClone->ResetRefCount();
3120 	return pClone;
3121 }
3122 
3123 // ------------------------------------------------------------------------
3124 
3125 sal_Bool MetaFillColorAction::Compare( const MetaAction& rMetaAction ) const
3126 {
3127 	return ( maColor == ((MetaFillColorAction&)rMetaAction).maColor ) &&
3128 		   ( mbSet == ((MetaFillColorAction&)rMetaAction).mbSet );
3129 }
3130 
3131 // ------------------------------------------------------------------------
3132 
3133 void MetaFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3134 {
3135 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3136 	maColor.Write( rOStm, sal_True );
3137 	rOStm << mbSet;
3138 }
3139 
3140 // ------------------------------------------------------------------------
3141 
3142 void MetaFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
3143 {
3144 	COMPAT( rIStm );
3145 	maColor.Read( rIStm, sal_True );
3146 	rIStm >> mbSet;
3147 }
3148 
3149 // ========================================================================
3150 
3151 IMPL_META_ACTION( TextColor, META_TEXTCOLOR_ACTION )
3152 
3153 // ------------------------------------------------------------------------
3154 
3155 MetaTextColorAction::MetaTextColorAction( const Color& rColor ) :
3156 	MetaAction	( META_TEXTCOLOR_ACTION ),
3157 	maColor 	( rColor )
3158 {
3159 }
3160 
3161 // ------------------------------------------------------------------------
3162 
3163 void MetaTextColorAction::Execute( OutputDevice* pOut )
3164 {
3165 	pOut->SetTextColor( maColor );
3166 }
3167 
3168 // ------------------------------------------------------------------------
3169 
3170 MetaAction* MetaTextColorAction::Clone()
3171 {
3172 	MetaAction* pClone = (MetaAction*) new MetaTextColorAction( *this );
3173 	pClone->ResetRefCount();
3174 	return pClone;
3175 }
3176 
3177 // ------------------------------------------------------------------------
3178 
3179 sal_Bool MetaTextColorAction::Compare( const MetaAction& rMetaAction ) const
3180 {
3181 	return maColor == ((MetaTextColorAction&)rMetaAction).maColor;
3182 }
3183 
3184 // ------------------------------------------------------------------------
3185 
3186 void MetaTextColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3187 {
3188 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3189 	maColor.Write( rOStm, sal_True );
3190 }
3191 
3192 // ------------------------------------------------------------------------
3193 
3194 void MetaTextColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
3195 {
3196 	COMPAT( rIStm );
3197 	maColor.Read( rIStm, sal_True );
3198 }
3199 
3200 // ========================================================================
3201 
3202 IMPL_META_ACTION( TextFillColor, META_TEXTFILLCOLOR_ACTION )
3203 
3204 // ------------------------------------------------------------------------
3205 
3206 MetaTextFillColorAction::MetaTextFillColorAction( const Color& rColor, sal_Bool bSet ) :
3207 	MetaAction	( META_TEXTFILLCOLOR_ACTION ),
3208 	maColor 	( rColor ),
3209 	mbSet		( bSet )
3210 {
3211 }
3212 
3213 // ------------------------------------------------------------------------
3214 
3215 void MetaTextFillColorAction::Execute( OutputDevice* pOut )
3216 {
3217 	if( mbSet )
3218 		pOut->SetTextFillColor( maColor );
3219 	else
3220 		pOut->SetTextFillColor();
3221 }
3222 
3223 // ------------------------------------------------------------------------
3224 
3225 MetaAction* MetaTextFillColorAction::Clone()
3226 {
3227 	MetaAction* pClone = (MetaAction*) new MetaTextFillColorAction( *this );
3228 	pClone->ResetRefCount();
3229 	return pClone;
3230 }
3231 
3232 // ------------------------------------------------------------------------
3233 
3234 sal_Bool MetaTextFillColorAction::Compare( const MetaAction& rMetaAction ) const
3235 {
3236 	return ( maColor == ((MetaTextFillColorAction&)rMetaAction).maColor ) &&
3237 		   ( mbSet == ((MetaTextFillColorAction&)rMetaAction).mbSet );
3238 }
3239 
3240 // ------------------------------------------------------------------------
3241 
3242 void MetaTextFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3243 {
3244 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3245 	maColor.Write( rOStm, sal_True );
3246 	rOStm << mbSet;
3247 }
3248 
3249 // ------------------------------------------------------------------------
3250 
3251 void MetaTextFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
3252 {
3253 	COMPAT( rIStm );
3254 	maColor.Read( rIStm, sal_True );
3255 	rIStm >> mbSet;
3256 }
3257 
3258 // ========================================================================
3259 
3260 IMPL_META_ACTION( TextLineColor, META_TEXTLINECOLOR_ACTION )
3261 
3262 // ------------------------------------------------------------------------
3263 
3264 MetaTextLineColorAction::MetaTextLineColorAction( const Color& rColor, sal_Bool bSet ) :
3265 	MetaAction	( META_TEXTLINECOLOR_ACTION ),
3266 	maColor 	( rColor ),
3267 	mbSet		( bSet )
3268 {
3269 }
3270 
3271 // ------------------------------------------------------------------------
3272 
3273 void MetaTextLineColorAction::Execute( OutputDevice* pOut )
3274 {
3275 	if( mbSet )
3276 		pOut->SetTextLineColor( maColor );
3277 	else
3278 		pOut->SetTextLineColor();
3279 }
3280 
3281 // ------------------------------------------------------------------------
3282 
3283 MetaAction* MetaTextLineColorAction::Clone()
3284 {
3285 	MetaAction* pClone = (MetaAction*) new MetaTextLineColorAction( *this );
3286 	pClone->ResetRefCount();
3287 	return pClone;
3288 }
3289 
3290 // ------------------------------------------------------------------------
3291 
3292 sal_Bool MetaTextLineColorAction::Compare( const MetaAction& rMetaAction ) const
3293 {
3294 	return ( maColor == ((MetaTextLineColorAction&)rMetaAction).maColor ) &&
3295 		   ( mbSet == ((MetaTextLineColorAction&)rMetaAction).mbSet );
3296 }
3297 
3298 // ------------------------------------------------------------------------
3299 
3300 void MetaTextLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3301 {
3302 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3303 	maColor.Write( rOStm, sal_True );
3304 	rOStm << mbSet;
3305 }
3306 
3307 // ------------------------------------------------------------------------
3308 
3309 void MetaTextLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
3310 {
3311 	COMPAT( rIStm );
3312 	maColor.Read( rIStm, sal_True );
3313 	rIStm >> mbSet;
3314 }
3315 
3316 // ========================================================================
3317 
3318 IMPL_META_ACTION( OverlineColor, META_OVERLINECOLOR_ACTION )
3319 
3320 // ------------------------------------------------------------------------
3321 
3322 MetaOverlineColorAction::MetaOverlineColorAction( const Color& rColor, sal_Bool bSet ) :
3323 	MetaAction	( META_OVERLINECOLOR_ACTION ),
3324 	maColor 	( rColor ),
3325 	mbSet		( bSet )
3326 {
3327 }
3328 
3329 // ------------------------------------------------------------------------
3330 
3331 void MetaOverlineColorAction::Execute( OutputDevice* pOut )
3332 {
3333 	if( mbSet )
3334 		pOut->SetOverlineColor( maColor );
3335 	else
3336 		pOut->SetOverlineColor();
3337 }
3338 
3339 // ------------------------------------------------------------------------
3340 
3341 MetaAction* MetaOverlineColorAction::Clone()
3342 {
3343 	MetaAction* pClone = (MetaAction*) new MetaOverlineColorAction( *this );
3344 	pClone->ResetRefCount();
3345 	return pClone;
3346 }
3347 
3348 // ------------------------------------------------------------------------
3349 
3350 sal_Bool MetaOverlineColorAction::Compare( const MetaAction& rMetaAction ) const
3351 {
3352 	return ( maColor == ((MetaOverlineColorAction&)rMetaAction).maColor ) &&
3353 		   ( mbSet == ((MetaOverlineColorAction&)rMetaAction).mbSet );
3354 }
3355 
3356 // ------------------------------------------------------------------------
3357 
3358 void MetaOverlineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3359 {
3360 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3361 	maColor.Write( rOStm, sal_True );
3362 	rOStm << mbSet;
3363 }
3364 
3365 // ------------------------------------------------------------------------
3366 
3367 void MetaOverlineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
3368 {
3369 	COMPAT( rIStm );
3370 	maColor.Read( rIStm, sal_True );
3371 	rIStm >> mbSet;
3372 }
3373 
3374 // ========================================================================
3375 
3376 IMPL_META_ACTION( TextAlign, META_TEXTALIGN_ACTION )
3377 
3378 // ------------------------------------------------------------------------
3379 
3380 MetaTextAlignAction::MetaTextAlignAction( TextAlign aAlign ) :
3381 	MetaAction	( META_TEXTALIGN_ACTION ),
3382 	maAlign 	( aAlign )
3383 {
3384 }
3385 
3386 // ------------------------------------------------------------------------
3387 
3388 void MetaTextAlignAction::Execute( OutputDevice* pOut )
3389 {
3390 	pOut->SetTextAlign( maAlign );
3391 }
3392 
3393 // ------------------------------------------------------------------------
3394 
3395 MetaAction* MetaTextAlignAction::Clone()
3396 {
3397 	MetaAction* pClone = (MetaAction*) new MetaTextAlignAction( *this );
3398 	pClone->ResetRefCount();
3399 	return pClone;
3400 }
3401 
3402 // ------------------------------------------------------------------------
3403 
3404 sal_Bool MetaTextAlignAction::Compare( const MetaAction& rMetaAction ) const
3405 {
3406 	return maAlign == ((MetaTextAlignAction&)rMetaAction).maAlign;
3407 }
3408 
3409 // ------------------------------------------------------------------------
3410 
3411 void MetaTextAlignAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3412 {
3413 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3414 	rOStm << (sal_uInt16) maAlign;
3415 }
3416 
3417 // ------------------------------------------------------------------------
3418 
3419 void MetaTextAlignAction::Read( SvStream& rIStm, ImplMetaReadData* )
3420 {
3421 	sal_uInt16 nTmp16;
3422 
3423 	COMPAT( rIStm );
3424 	rIStm >> nTmp16; maAlign = (TextAlign) nTmp16;
3425 }
3426 
3427 // ========================================================================
3428 
3429 IMPL_META_ACTION( MapMode, META_MAPMODE_ACTION )
3430 
3431 // ------------------------------------------------------------------------
3432 
3433 MetaMapModeAction::MetaMapModeAction( const MapMode& rMapMode ) :
3434 	MetaAction	( META_MAPMODE_ACTION ),
3435 	maMapMode	( rMapMode )
3436 {
3437 }
3438 
3439 // ------------------------------------------------------------------------
3440 
3441 void MetaMapModeAction::Execute( OutputDevice* pOut )
3442 {
3443 	pOut->SetMapMode( maMapMode );
3444 }
3445 
3446 // ------------------------------------------------------------------------
3447 
3448 MetaAction* MetaMapModeAction::Clone()
3449 {
3450 	MetaAction* pClone = (MetaAction*) new MetaMapModeAction( *this );
3451 	pClone->ResetRefCount();
3452 	return pClone;
3453 }
3454 
3455 // ------------------------------------------------------------------------
3456 
3457 void MetaMapModeAction::Scale( double fScaleX, double fScaleY )
3458 {
3459 	Point aPoint( maMapMode.GetOrigin() );
3460 
3461 	ImplScalePoint( aPoint, fScaleX, fScaleY );
3462 	maMapMode.SetOrigin( aPoint );
3463 }
3464 
3465 // ------------------------------------------------------------------------
3466 
3467 sal_Bool MetaMapModeAction::Compare( const MetaAction& rMetaAction ) const
3468 {
3469 	return maMapMode == ((MetaMapModeAction&)rMetaAction).maMapMode;
3470 }
3471 
3472 // ------------------------------------------------------------------------
3473 
3474 void MetaMapModeAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3475 {
3476 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3477 	rOStm << maMapMode;
3478 }
3479 
3480 // ------------------------------------------------------------------------
3481 
3482 void MetaMapModeAction::Read( SvStream& rIStm, ImplMetaReadData* )
3483 {
3484 	COMPAT( rIStm );
3485 	rIStm >> maMapMode;
3486 }
3487 
3488 // ========================================================================
3489 
3490 IMPL_META_ACTION( Font, META_FONT_ACTION )
3491 
3492 // ------------------------------------------------------------------------
3493 
3494 MetaFontAction::MetaFontAction( const Font& rFont ) :
3495 	MetaAction	( META_FONT_ACTION ),
3496 	maFont		( rFont )
3497 {
3498     // #96876: because RTL_TEXTENCODING_SYMBOL is often set at the StarSymbol font,
3499     // we change the textencoding to RTL_TEXTENCODING_UNICODE here, which seems
3500     // to be the right way; changing the textencoding at other sources
3501     // is too dangerous at the moment
3502     if( ( ( maFont.GetName().SearchAscii( "StarSymbol" ) != STRING_NOTFOUND )
3503        || ( maFont.GetName().SearchAscii( "OpenSymbol" ) != STRING_NOTFOUND ) )
3504      && ( maFont.GetCharSet() != RTL_TEXTENCODING_UNICODE ) )
3505     {
3506         maFont.SetCharSet( RTL_TEXTENCODING_UNICODE );
3507     }
3508 }
3509 
3510 // ------------------------------------------------------------------------
3511 
3512 void MetaFontAction::Execute( OutputDevice* pOut )
3513 {
3514 	pOut->SetFont( maFont );
3515 }
3516 
3517 // ------------------------------------------------------------------------
3518 
3519 MetaAction* MetaFontAction::Clone()
3520 {
3521 	MetaAction* pClone = (MetaAction*) new MetaFontAction( *this );
3522 	pClone->ResetRefCount();
3523 	return pClone;
3524 }
3525 
3526 // ------------------------------------------------------------------------
3527 
3528 void MetaFontAction::Scale( double fScaleX, double fScaleY )
3529 {
3530 	const Size aSize(
3531         FRound(maFont.GetSize().Width() * fabs(fScaleX)),
3532         FRound(maFont.GetSize().Height() * fabs(fScaleY)));
3533 	maFont.SetSize( aSize );
3534 }
3535 
3536 // ------------------------------------------------------------------------
3537 
3538 sal_Bool MetaFontAction::Compare( const MetaAction& rMetaAction ) const
3539 {
3540 	return maFont == ((MetaFontAction&)rMetaAction).maFont;
3541 }
3542 
3543 // ------------------------------------------------------------------------
3544 
3545 void MetaFontAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3546 {
3547 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3548 	rOStm << maFont;
3549 	pData->meActualCharSet = maFont.GetCharSet();
3550 	if ( pData->meActualCharSet == RTL_TEXTENCODING_DONTKNOW )
3551 		pData->meActualCharSet = gsl_getSystemTextEncoding();
3552 }
3553 
3554 // ------------------------------------------------------------------------
3555 
3556 void MetaFontAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
3557 {
3558 	COMPAT( rIStm );
3559 	rIStm >> maFont;
3560 	pData->meActualCharSet = maFont.GetCharSet();
3561 	if ( pData->meActualCharSet == RTL_TEXTENCODING_DONTKNOW )
3562 		pData->meActualCharSet = gsl_getSystemTextEncoding();
3563 }
3564 
3565 // ========================================================================
3566 
3567 IMPL_META_ACTION( Push, META_PUSH_ACTION )
3568 
3569 // ------------------------------------------------------------------------
3570 
3571 MetaPushAction::MetaPushAction( sal_uInt16 nFlags ) :
3572 	MetaAction	( META_PUSH_ACTION ),
3573 	mnFlags 	( nFlags )
3574 {
3575 }
3576 
3577 // ------------------------------------------------------------------------
3578 
3579 void MetaPushAction::Execute( OutputDevice* pOut )
3580 {
3581 	pOut->Push( mnFlags );
3582 }
3583 
3584 // ------------------------------------------------------------------------
3585 
3586 MetaAction* MetaPushAction::Clone()
3587 {
3588 	MetaAction* pClone = (MetaAction*) new MetaPushAction( *this );
3589 	pClone->ResetRefCount();
3590 	return pClone;
3591 }
3592 
3593 // ------------------------------------------------------------------------
3594 
3595 sal_Bool MetaPushAction::Compare( const MetaAction& rMetaAction ) const
3596 {
3597 	return mnFlags == ((MetaPushAction&)rMetaAction).mnFlags;
3598 }
3599 
3600 // ------------------------------------------------------------------------
3601 
3602 void MetaPushAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3603 {
3604 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3605 	rOStm << mnFlags;
3606 }
3607 
3608 // ------------------------------------------------------------------------
3609 
3610 void MetaPushAction::Read( SvStream& rIStm, ImplMetaReadData* )
3611 {
3612 	COMPAT( rIStm );
3613 	rIStm >> mnFlags;
3614 }
3615 
3616 // ========================================================================
3617 
3618 IMPL_META_ACTION( Pop, META_POP_ACTION )
3619 
3620 // ------------------------------------------------------------------------
3621 
3622 void MetaPopAction::Execute( OutputDevice* pOut )
3623 {
3624 	pOut->Pop();
3625 }
3626 
3627 // ------------------------------------------------------------------------
3628 
3629 MetaAction* MetaPopAction::Clone()
3630 {
3631 	MetaAction* pClone = (MetaAction*) new MetaPopAction( *this );
3632 	pClone->ResetRefCount();
3633 	return pClone;
3634 }
3635 
3636 // ------------------------------------------------------------------------
3637 
3638 void MetaPopAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3639 {
3640 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3641 }
3642 
3643 // ------------------------------------------------------------------------
3644 
3645 void MetaPopAction::Read( SvStream& rIStm, ImplMetaReadData* )
3646 {
3647 	COMPAT( rIStm );
3648 }
3649 
3650 // ========================================================================
3651 
3652 IMPL_META_ACTION( RasterOp, META_RASTEROP_ACTION )
3653 
3654 // ------------------------------------------------------------------------
3655 
3656 MetaRasterOpAction::MetaRasterOpAction( RasterOp eRasterOp ) :
3657 	MetaAction	( META_RASTEROP_ACTION ),
3658 	meRasterOp	( eRasterOp )
3659 {
3660 }
3661 
3662 // ------------------------------------------------------------------------
3663 
3664 void MetaRasterOpAction::Execute( OutputDevice* pOut )
3665 {
3666 	pOut->SetRasterOp( meRasterOp );
3667 }
3668 
3669 // ------------------------------------------------------------------------
3670 
3671 MetaAction* MetaRasterOpAction::Clone()
3672 {
3673 	MetaAction* pClone = (MetaAction*) new MetaRasterOpAction( *this );
3674 	pClone->ResetRefCount();
3675 	return pClone;
3676 }
3677 
3678 // ------------------------------------------------------------------------
3679 
3680 sal_Bool MetaRasterOpAction::Compare( const MetaAction& rMetaAction ) const
3681 {
3682 	return meRasterOp == ((MetaRasterOpAction&)rMetaAction).meRasterOp;
3683 }
3684 
3685 // ------------------------------------------------------------------------
3686 
3687 void MetaRasterOpAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3688 {
3689 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3690 	rOStm << (sal_uInt16) meRasterOp;
3691 }
3692 
3693 // ------------------------------------------------------------------------
3694 
3695 void MetaRasterOpAction::Read( SvStream& rIStm, ImplMetaReadData* )
3696 {
3697 	sal_uInt16 nTmp16;
3698 
3699 	COMPAT( rIStm );
3700 	rIStm >> nTmp16; meRasterOp = (RasterOp) nTmp16;
3701 }
3702 
3703 // ========================================================================
3704 
3705 IMPL_META_ACTION( Transparent, META_TRANSPARENT_ACTION )
3706 
3707 // ------------------------------------------------------------------------
3708 
3709 MetaTransparentAction::MetaTransparentAction( const PolyPolygon& rPolyPoly, sal_uInt16 nTransPercent ) :
3710 	MetaAction		( META_TRANSPARENT_ACTION ),
3711 	maPolyPoly		( rPolyPoly ),
3712 	mnTransPercent	( nTransPercent )
3713 {
3714 }
3715 
3716 // ------------------------------------------------------------------------
3717 
3718 void MetaTransparentAction::Execute( OutputDevice* pOut )
3719 {
3720 	pOut->DrawTransparent( maPolyPoly, mnTransPercent );
3721 }
3722 
3723 // ------------------------------------------------------------------------
3724 
3725 MetaAction* MetaTransparentAction::Clone()
3726 {
3727 	MetaAction* pClone = (MetaAction*) new MetaTransparentAction( *this );
3728 	pClone->ResetRefCount();
3729 	return pClone;
3730 }
3731 
3732 // ------------------------------------------------------------------------
3733 
3734 void MetaTransparentAction::Move( long nHorzMove, long nVertMove )
3735 {
3736 	maPolyPoly.Move( nHorzMove, nVertMove );
3737 }
3738 
3739 // ------------------------------------------------------------------------
3740 
3741 void MetaTransparentAction::Scale( double fScaleX, double fScaleY )
3742 {
3743 	for( sal_uInt16 i = 0, nCount = maPolyPoly.Count(); i < nCount; i++ )
3744 		ImplScalePoly( maPolyPoly[ i ], fScaleX, fScaleY );
3745 }
3746 
3747 // ------------------------------------------------------------------------
3748 
3749 sal_Bool MetaTransparentAction::Compare( const MetaAction& rMetaAction ) const
3750 {
3751 	return ( maPolyPoly == ((MetaTransparentAction&)rMetaAction).maPolyPoly ) &&
3752 		   ( mnTransPercent == ((MetaTransparentAction&)rMetaAction).mnTransPercent );
3753 }
3754 
3755 // ------------------------------------------------------------------------
3756 
3757 void MetaTransparentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3758 {
3759 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3760 
3761     // #i105373# The PolyPolygon in this action may be a curve; this
3762     // was ignored until now what is an error. To make older office
3763     // versions work with MetaFiles, i opt for applying AdaptiveSubdivide
3764     // to the PolyPoylgon.
3765     // The alternative would be to really write the curve information
3766     // like in MetaPolyPolygonAction::Write (where someone extended it
3767     // correctly, but not here :-( ).
3768     // The golden solution would be to combine both, but i think it's
3769     // not necessary; a good subdivision will be sufficient.
3770     PolyPolygon aNoCurvePolyPolygon;
3771     maPolyPoly.AdaptiveSubdivide(aNoCurvePolyPolygon);
3772 
3773     rOStm << aNoCurvePolyPolygon;
3774 	rOStm << mnTransPercent;
3775 }
3776 
3777 // ------------------------------------------------------------------------
3778 
3779 void MetaTransparentAction::Read( SvStream& rIStm, ImplMetaReadData* )
3780 {
3781 	COMPAT( rIStm );
3782 	rIStm >> maPolyPoly;
3783 	rIStm >> mnTransPercent;
3784 }
3785 
3786 // ========================================================================
3787 
3788 IMPL_META_ACTION( FloatTransparent, META_FLOATTRANSPARENT_ACTION )
3789 
3790 // ------------------------------------------------------------------------
3791 
3792 MetaFloatTransparentAction::MetaFloatTransparentAction( const GDIMetaFile& rMtf, const Point& rPos,
3793 														const Size& rSize, const Gradient& rGradient ) :
3794 	MetaAction		( META_FLOATTRANSPARENT_ACTION ),
3795 	maMtf			( rMtf ),
3796 	maPoint 		( rPos ),
3797 	maSize			( rSize ),
3798 	maGradient		( rGradient )
3799 {
3800 }
3801 
3802 // ------------------------------------------------------------------------
3803 
3804 void MetaFloatTransparentAction::Execute( OutputDevice* pOut )
3805 {
3806 	pOut->DrawTransparent( maMtf, maPoint, maSize, maGradient );
3807 }
3808 
3809 // ------------------------------------------------------------------------
3810 
3811 MetaAction* MetaFloatTransparentAction::Clone()
3812 {
3813 	MetaAction* pClone = (MetaAction*) new MetaFloatTransparentAction( *this );
3814 	pClone->ResetRefCount();
3815 	return pClone;
3816 }
3817 
3818 // ------------------------------------------------------------------------
3819 
3820 void MetaFloatTransparentAction::Move( long nHorzMove, long nVertMove )
3821 {
3822 	maPoint.Move( nHorzMove, nVertMove );
3823 }
3824 
3825 // ------------------------------------------------------------------------
3826 
3827 void MetaFloatTransparentAction::Scale( double fScaleX, double fScaleY )
3828 {
3829     Rectangle aRectangle(maPoint, maSize);
3830 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
3831     maPoint = aRectangle.TopLeft();
3832     maSize = aRectangle.GetSize();
3833 }
3834 
3835 // ------------------------------------------------------------------------
3836 
3837 sal_Bool MetaFloatTransparentAction::Compare( const MetaAction& rMetaAction ) const
3838 {
3839 	return ( maMtf == ((MetaFloatTransparentAction&)rMetaAction).maMtf ) &&
3840 		   ( maPoint == ((MetaFloatTransparentAction&)rMetaAction).maPoint ) &&
3841 		   ( maSize == ((MetaFloatTransparentAction&)rMetaAction).maSize ) &&
3842 		   ( maGradient == ((MetaFloatTransparentAction&)rMetaAction).maGradient );
3843 }
3844 
3845 // ------------------------------------------------------------------------
3846 
3847 void MetaFloatTransparentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3848 {
3849 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3850 
3851 	maMtf.Write( rOStm );
3852 	rOStm << maPoint << maSize << maGradient;
3853 }
3854 
3855 // ------------------------------------------------------------------------
3856 
3857 void MetaFloatTransparentAction::Read( SvStream& rIStm, ImplMetaReadData* )
3858 {
3859 	COMPAT( rIStm );
3860 	rIStm >> maMtf >> maPoint >> maSize >> maGradient;
3861 }
3862 
3863 // ========================================================================
3864 
3865 IMPL_META_ACTION( EPS, META_EPS_ACTION )
3866 
3867 // ------------------------------------------------------------------------
3868 
3869 MetaEPSAction::MetaEPSAction( const Point& rPoint, const Size& rSize,
3870 							  const GfxLink& rGfxLink, const GDIMetaFile& rSubst ) :
3871 	MetaAction	( META_EPS_ACTION ),
3872 	maGfxLink	( rGfxLink ),
3873 	maSubst 	( rSubst ),
3874 	maPoint 	( rPoint ),
3875 	maSize		( rSize )
3876 {
3877 }
3878 
3879 // ------------------------------------------------------------------------
3880 
3881 void MetaEPSAction::Execute( OutputDevice* pOut )
3882 {
3883 	pOut->DrawEPS( maPoint, maSize, maGfxLink, &maSubst );
3884 }
3885 
3886 // ------------------------------------------------------------------------
3887 
3888 MetaAction* MetaEPSAction::Clone()
3889 {
3890 	MetaAction* pClone = (MetaAction*) new MetaEPSAction( *this );
3891 	pClone->ResetRefCount();
3892 	return pClone;
3893 }
3894 
3895 // ------------------------------------------------------------------------
3896 
3897 void MetaEPSAction::Move( long nHorzMove, long nVertMove )
3898 {
3899 	maPoint.Move( nHorzMove, nVertMove );
3900 }
3901 
3902 // ------------------------------------------------------------------------
3903 
3904 void MetaEPSAction::Scale( double fScaleX, double fScaleY )
3905 {
3906     Rectangle aRectangle(maPoint, maSize);
3907 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
3908     maPoint = aRectangle.TopLeft();
3909     maSize = aRectangle.GetSize();
3910 }
3911 
3912 // ------------------------------------------------------------------------
3913 
3914 sal_Bool MetaEPSAction::Compare( const MetaAction& rMetaAction ) const
3915 {
3916 	return ( maGfxLink.IsEqual(((MetaEPSAction&)rMetaAction).maGfxLink )) &&
3917 		   ( maSubst == ((MetaEPSAction&)rMetaAction).maSubst ) &&
3918 		   ( maPoint == ((MetaEPSAction&)rMetaAction).maPoint ) &&
3919 		   ( maSize == ((MetaEPSAction&)rMetaAction).maSize );
3920 }
3921 
3922 // ------------------------------------------------------------------------
3923 
3924 void MetaEPSAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3925 {
3926 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3927 	rOStm << maGfxLink;
3928 	rOStm << maPoint;
3929 	rOStm << maSize;
3930 	maSubst.Write( rOStm );
3931 }
3932 
3933 // ------------------------------------------------------------------------
3934 
3935 void MetaEPSAction::Read( SvStream& rIStm, ImplMetaReadData* )
3936 {
3937 	COMPAT( rIStm );
3938 	rIStm >> maGfxLink;
3939 	rIStm >> maPoint;
3940 	rIStm >> maSize;
3941 	rIStm >> maSubst;
3942 }
3943 
3944 // ========================================================================
3945 
3946 IMPL_META_ACTION( RefPoint, META_REFPOINT_ACTION )
3947 
3948 // ------------------------------------------------------------------------
3949 
3950 MetaRefPointAction::MetaRefPointAction( const Point& rRefPoint, sal_Bool bSet ) :
3951 	MetaAction	( META_REFPOINT_ACTION ),
3952 	maRefPoint	( rRefPoint ),
3953 	mbSet		( bSet )
3954 {
3955 }
3956 
3957 // ------------------------------------------------------------------------
3958 
3959 void MetaRefPointAction::Execute( OutputDevice* pOut )
3960 {
3961 	if( mbSet )
3962 		pOut->SetRefPoint( maRefPoint );
3963 	else
3964 		pOut->SetRefPoint();
3965 }
3966 
3967 // ------------------------------------------------------------------------
3968 
3969 MetaAction* MetaRefPointAction::Clone()
3970 {
3971 	MetaAction* pClone = (MetaAction*) new MetaRefPointAction( *this );
3972 	pClone->ResetRefCount();
3973 	return pClone;
3974 }
3975 
3976 // ------------------------------------------------------------------------
3977 
3978 sal_Bool MetaRefPointAction::Compare( const MetaAction& rMetaAction ) const
3979 {
3980 	return ( maRefPoint == ((MetaRefPointAction&)rMetaAction).maRefPoint ) &&
3981 		   ( mbSet == ((MetaRefPointAction&)rMetaAction).mbSet );
3982 }
3983 
3984 // ------------------------------------------------------------------------
3985 
3986 void MetaRefPointAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3987 {
3988 	WRITE_BASE_COMPAT( rOStm, 1, pData );
3989 	rOStm << maRefPoint << mbSet;
3990 }
3991 
3992 // ------------------------------------------------------------------------
3993 
3994 void MetaRefPointAction::Read( SvStream& rIStm, ImplMetaReadData* )
3995 {
3996 	COMPAT( rIStm );
3997 	rIStm >> maRefPoint >> mbSet;
3998 }
3999 
4000 // ========================================================================
4001 
4002 MetaCommentAction::MetaCommentAction( sal_Int32 nValue ) :
4003 	MetaAction	( META_COMMENT_ACTION ),
4004 	mnValue 	( nValue )
4005 {
4006 	ImplInitDynamicData( NULL, 0UL );
4007 }
4008 
4009 // ------------------------------------------------------------------------
4010 
4011 MetaCommentAction::MetaCommentAction( const MetaCommentAction& rAct ) :
4012 	MetaAction	( META_COMMENT_ACTION ),
4013 	maComment	( rAct.maComment ),
4014 	mnValue 	( rAct.mnValue )
4015 {
4016 	ImplInitDynamicData( rAct.mpData, rAct.mnDataSize );
4017 }
4018 
4019 // ------------------------------------------------------------------------
4020 
4021 MetaCommentAction::MetaCommentAction( const ByteString& rComment, sal_Int32 nValue, const sal_uInt8* pData, sal_uInt32 nDataSize ) :
4022 	MetaAction	( META_COMMENT_ACTION ),
4023 	maComment	( rComment ),
4024 	mnValue 	( nValue )
4025 {
4026 	ImplInitDynamicData( pData, nDataSize );
4027 }
4028 
4029 // ------------------------------------------------------------------------
4030 
4031 MetaCommentAction::MetaCommentAction( const sal_uInt8* pData, sal_uInt32 nDataSize ) :
4032 	MetaAction	( META_COMMENT_ACTION ),
4033 	mnValue 	( 0L )
4034 {
4035 	ImplInitDynamicData( pData, nDataSize );
4036 }
4037 
4038 // ------------------------------------------------------------------------
4039 
4040 MetaCommentAction::~MetaCommentAction()
4041 {
4042 	if ( mpData )
4043 		delete[] mpData;
4044 }
4045 
4046 // ------------------------------------------------------------------------
4047 
4048 void MetaCommentAction::ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize )
4049 {
4050 	if ( nDataSize && pData )
4051 	{
4052 		mnDataSize = nDataSize, mpData = new sal_uInt8[ mnDataSize ];
4053 		memcpy( mpData, pData, mnDataSize );
4054 	}
4055 	else
4056 	{
4057 		mnDataSize = 0;
4058 		mpData = NULL;
4059 	}
4060 }
4061 
4062 // ------------------------------------------------------------------------
4063 
4064 void MetaCommentAction::Execute( OutputDevice* pOut )
4065 {
4066 	if ( pOut->GetConnectMetaFile() )
4067     {
4068         Duplicate();
4069 		pOut->GetConnectMetaFile()->AddAction( this );
4070     }
4071 }
4072 
4073 // ------------------------------------------------------------------------
4074 
4075 MetaAction* MetaCommentAction::Clone()
4076 {
4077 	MetaAction* pClone = (MetaAction*) new MetaCommentAction( *this );
4078 	pClone->ResetRefCount();
4079 	return pClone;
4080 }
4081 
4082 void MetaCommentAction::Move( long nXMove, long nYMove )
4083 {
4084 	if ( nXMove || nYMove )
4085 	{
4086 		if ( mnDataSize && mpData )
4087 		{
4088 			sal_Bool bPathStroke = maComment.Equals( "XPATHSTROKE_SEQ_BEGIN" );
4089 			if ( bPathStroke || maComment.Equals( "XPATHFILL_SEQ_BEGIN" ) )
4090 			{
4091 				SvMemoryStream	aMemStm( (void*)mpData, mnDataSize, STREAM_READ );
4092 				SvMemoryStream	aDest;
4093 				if ( bPathStroke )
4094 				{
4095 					SvtGraphicStroke aStroke;
4096 					aMemStm >> aStroke;
4097 					Polygon aPath;
4098 					aStroke.getPath( aPath );
4099 					aPath.Move( nXMove, nYMove );
4100 					aStroke.setPath( aPath );
4101 					aDest << aStroke;
4102 				}
4103 				else
4104 				{
4105 					SvtGraphicFill aFill;
4106 					aMemStm >> aFill;
4107 					PolyPolygon aPath;
4108 					aFill.getPath( aPath );
4109 					aPath.Move( nXMove, nYMove );
4110 					aFill.setPath( aPath );
4111 					aDest << aFill;
4112 				}
4113 				delete[] mpData;
4114 				ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() );
4115 			}
4116 		}
4117 	}
4118 }
4119 
4120 // ------------------------------------------------------------------------
4121 // SJ: 25.07.06 #i56656# we are not able to mirrorcertain kind of
4122 // comments properly, especially the XPATHSTROKE and XPATHFILL lead to
4123 // problems, so it is better to remove these comments when mirroring
4124 void MetaCommentAction::Scale( double fXScale, double fYScale )
4125 {
4126 	if ( ( fXScale != 1.0 ) || ( fYScale != 1.0 ) )
4127 	{
4128 		if ( mnDataSize && mpData )
4129 		{
4130 			sal_Bool bPathStroke = maComment.Equals( "XPATHSTROKE_SEQ_BEGIN" );
4131 			if ( bPathStroke || maComment.Equals( "XPATHFILL_SEQ_BEGIN" ) )
4132 			{
4133 				SvMemoryStream	aMemStm( (void*)mpData, mnDataSize, STREAM_READ );
4134 				SvMemoryStream	aDest;
4135 				if ( bPathStroke )
4136 				{
4137 					SvtGraphicStroke aStroke;
4138 					aMemStm >> aStroke;
4139 					Polygon aPath;
4140 					aStroke.getPath( aPath );
4141 					aPath.Scale( fXScale, fYScale );
4142 					aStroke.setPath( aPath );
4143 					aDest << aStroke;
4144 				}
4145 				else
4146 				{
4147 					SvtGraphicFill aFill;
4148 					aMemStm >> aFill;
4149 					PolyPolygon aPath;
4150 					aFill.getPath( aPath );
4151 					aPath.Scale( fXScale, fYScale );
4152 					aFill.setPath( aPath );
4153 					aDest << aFill;
4154 				}
4155 				delete[] mpData;
4156 				ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() );
4157 			}
4158 		}
4159 	}
4160 }
4161 
4162 // ------------------------------------------------------------------------
4163 
4164 sal_Bool MetaCommentAction::Compare( const MetaAction& rMetaAction ) const
4165 {
4166 	return ( maComment == ((MetaCommentAction&)rMetaAction).maComment ) &&
4167 		   ( mnValue == ((MetaCommentAction&)rMetaAction).mnValue ) &&
4168 		   ( mnDataSize == ((MetaCommentAction&)rMetaAction).mnDataSize ) &&
4169 		   ( memcmp( mpData, ((MetaCommentAction&)rMetaAction).mpData, mnDataSize ) == 0 );
4170 }
4171 
4172 // ------------------------------------------------------------------------
4173 
4174 void MetaCommentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
4175 {
4176 	WRITE_BASE_COMPAT( rOStm, 1, pData );
4177 	rOStm << maComment << mnValue << mnDataSize;
4178 
4179 	if ( mnDataSize )
4180 		rOStm.Write( mpData, mnDataSize );
4181 }
4182 
4183 // ------------------------------------------------------------------------
4184 
4185 void MetaCommentAction::Read( SvStream& rIStm, ImplMetaReadData* )
4186 {
4187 	COMPAT( rIStm );
4188 	rIStm >> maComment >> mnValue >> mnDataSize;
4189 
4190 	if( mpData )
4191 		delete[] mpData;
4192 
4193 	if( mnDataSize )
4194 	{
4195 		mpData = new sal_uInt8[ mnDataSize ];
4196 		rIStm.Read( mpData, mnDataSize );
4197 	}
4198 	else
4199 		mpData = NULL;
4200 }
4201 
4202 // ========================================================================
4203 
4204 IMPL_META_ACTION( LayoutMode, META_LAYOUTMODE_ACTION )
4205 
4206 // ------------------------------------------------------------------------
4207 
4208 MetaLayoutModeAction::MetaLayoutModeAction( sal_uInt32 nLayoutMode ) :
4209 	MetaAction	( META_LAYOUTMODE_ACTION ),
4210 	mnLayoutMode( nLayoutMode )
4211 {
4212 }
4213 
4214 // ------------------------------------------------------------------------
4215 
4216 void MetaLayoutModeAction::Execute( OutputDevice* pOut )
4217 {
4218 	pOut->SetLayoutMode( mnLayoutMode );
4219 }
4220 
4221 // ------------------------------------------------------------------------
4222 
4223 MetaAction* MetaLayoutModeAction::Clone()
4224 {
4225 	MetaAction* pClone = (MetaAction*) new MetaLayoutModeAction( *this );
4226 	pClone->ResetRefCount();
4227 	return pClone;
4228 }
4229 
4230 // ------------------------------------------------------------------------
4231 
4232 sal_Bool MetaLayoutModeAction::Compare( const MetaAction& rMetaAction ) const
4233 {
4234 	return mnLayoutMode == ((MetaLayoutModeAction&)rMetaAction).mnLayoutMode;
4235 }
4236 
4237 // ------------------------------------------------------------------------
4238 
4239 void MetaLayoutModeAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
4240 {
4241 	WRITE_BASE_COMPAT( rOStm, 1, pData );
4242 	rOStm << mnLayoutMode;
4243 }
4244 
4245 // ------------------------------------------------------------------------
4246 
4247 void MetaLayoutModeAction::Read( SvStream& rIStm, ImplMetaReadData* )
4248 {
4249 	COMPAT( rIStm );
4250 	rIStm >> mnLayoutMode;
4251 }
4252 
4253 // ========================================================================
4254 
4255 IMPL_META_ACTION( TextLanguage, META_TEXTLANGUAGE_ACTION )
4256 
4257 // ------------------------------------------------------------------------
4258 
4259 MetaTextLanguageAction::MetaTextLanguageAction( LanguageType eTextLanguage ) :
4260 	MetaAction	( META_TEXTLANGUAGE_ACTION ),
4261 	meTextLanguage( eTextLanguage )
4262 {
4263 }
4264 
4265 // ------------------------------------------------------------------------
4266 
4267 void MetaTextLanguageAction::Execute( OutputDevice* pOut )
4268 {
4269 	pOut->SetDigitLanguage( meTextLanguage );
4270 }
4271 
4272 // ------------------------------------------------------------------------
4273 
4274 MetaAction* MetaTextLanguageAction::Clone()
4275 {
4276 	MetaAction* pClone = (MetaAction*) new MetaTextLanguageAction( *this );
4277 	pClone->ResetRefCount();
4278 	return pClone;
4279 }
4280 
4281 // ------------------------------------------------------------------------
4282 
4283 sal_Bool MetaTextLanguageAction::Compare( const MetaAction& rMetaAction ) const
4284 {
4285 	return meTextLanguage == ((MetaTextLanguageAction&)rMetaAction).meTextLanguage;
4286 }
4287 
4288 // ------------------------------------------------------------------------
4289 
4290 void MetaTextLanguageAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
4291 {
4292 	WRITE_BASE_COMPAT( rOStm, 1, pData );
4293 	rOStm << meTextLanguage;
4294 }
4295 
4296 // ------------------------------------------------------------------------
4297 
4298 void MetaTextLanguageAction::Read( SvStream& rIStm, ImplMetaReadData* )
4299 {
4300 	COMPAT( rIStm );
4301 	rIStm >> meTextLanguage;
4302 }
4303 
4304 // ========================================================================
4305 
4306 IMPL_META_ACTION( RenderGraphic, META_RENDERGRAPHIC_ACTION )
4307 
4308 // ------------------------------------------------------------------------
4309 
4310 MetaRenderGraphicAction::MetaRenderGraphicAction( const Point& rPoint, const Size& rSize,
4311                                                   const vcl::RenderGraphic& rRenderGraphic,
4312                                                   double fRotateAngle, double fShearAngleX, double fShearAngleY ) :
4313 	MetaAction( META_RENDERGRAPHIC_ACTION ),
4314 	maRenderGraphic( rRenderGraphic ),
4315 	maPoint( rPoint ),
4316 	maSize( rSize ),
4317 	mfRotateAngle( fRotateAngle ),
4318 	mfShearAngleX( fShearAngleX ),
4319 	mfShearAngleY( fShearAngleY )
4320 {
4321 }
4322 
4323 // ------------------------------------------------------------------------
4324 
4325 void MetaRenderGraphicAction::Execute( OutputDevice* pOut )
4326 {
4327 	pOut->DrawRenderGraphic( maPoint, maSize, maRenderGraphic );
4328 }
4329 
4330 // ------------------------------------------------------------------------
4331 
4332 MetaAction* MetaRenderGraphicAction::Clone()
4333 {
4334 	MetaAction* pClone = (MetaAction*) new MetaRenderGraphicAction( *this );
4335 	pClone->ResetRefCount();
4336 	return pClone;
4337 }
4338 
4339 // ------------------------------------------------------------------------
4340 
4341 void MetaRenderGraphicAction::Move( long nHorzMove, long nVertMove )
4342 {
4343 	maPoint.Move( nHorzMove, nVertMove );
4344 }
4345 
4346 // ------------------------------------------------------------------------
4347 
4348 void MetaRenderGraphicAction::Scale( double fScaleX, double fScaleY )
4349 {
4350     Rectangle aRectangle( maPoint, maSize );
4351 	ImplScaleRect( aRectangle, fScaleX, fScaleY );
4352     maPoint = aRectangle.TopLeft();
4353     maSize = aRectangle.GetSize();
4354 }
4355 
4356 // ------------------------------------------------------------------------
4357 
4358 sal_Bool MetaRenderGraphicAction::Compare( const MetaAction& rMetaAction ) const
4359 {
4360 	return ( maRenderGraphic.IsEqual( ( (MetaRenderGraphicAction&) rMetaAction).maRenderGraphic ) &&
4361 		   ( maPoint == ( (MetaRenderGraphicAction&) rMetaAction).maPoint ) &&
4362 		   ( maSize == ( (MetaRenderGraphicAction&) rMetaAction).maSize ) &&
4363 		   ( mfRotateAngle == ( (MetaRenderGraphicAction&) rMetaAction).mfRotateAngle ) &&
4364 		   ( mfShearAngleX == ( (MetaRenderGraphicAction&) rMetaAction).mfShearAngleX ) &&
4365 		   ( mfShearAngleY == ( (MetaRenderGraphicAction&) rMetaAction).mfShearAngleY ) );
4366 }
4367 
4368 // ------------------------------------------------------------------------
4369 
4370 void MetaRenderGraphicAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
4371 {
4372 	WRITE_BASE_COMPAT( rOStm, 1, pData );
4373     rOStm << maRenderGraphic << maPoint << maSize << mfRotateAngle << mfShearAngleX << mfShearAngleY;
4374 }
4375 
4376 // ------------------------------------------------------------------------
4377 
4378 void MetaRenderGraphicAction::Read( SvStream& rIStm, ImplMetaReadData* )
4379 {
4380 	COMPAT( rIStm );
4381 	rIStm >> maRenderGraphic >> maPoint >> maSize >> mfRotateAngle >> mfShearAngleX >> mfShearAngleY;
4382 }
4383