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