1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <stdio.h>
21 #include <string.h>
22 #include <osl/thread.h>
23 #include <sal/log.hxx>
24 #include <tools/stream.hxx>
25 #include <tools/vcompat.hxx>
26 #include <tools/helpers.hxx>
27 #include <vcl/dibtools.hxx>
28 #include <vcl/outdev.hxx>
29 #include <vcl/metaact.hxx>
30 #include <vcl/graphictools.hxx>
31 #include <unotools/fontdefs.hxx>
32 #include <vcl/TypeSerializer.hxx>
33
34 namespace
35 {
36
37 const char *
meta_action_name(MetaActionType nMetaAction)38 meta_action_name(MetaActionType nMetaAction)
39 {
40 #ifndef SAL_LOG_INFO
41 (void) nMetaAction;
42 return "";
43 #else
44 switch( nMetaAction )
45 {
46 case MetaActionType::NONE: return "NULL";
47 case MetaActionType::PIXEL: return "PIXEL";
48 case MetaActionType::POINT: return "POINT";
49 case MetaActionType::LINE: return "LINE";
50 case MetaActionType::RECT: return "RECT";
51 case MetaActionType::ROUNDRECT: return "ROUNDRECT";
52 case MetaActionType::ELLIPSE: return "ELLIPSE";
53 case MetaActionType::ARC: return "ARC";
54 case MetaActionType::PIE: return "PIE";
55 case MetaActionType::CHORD: return "CHORD";
56 case MetaActionType::POLYLINE: return "POLYLINE";
57 case MetaActionType::POLYGON: return "POLYGON";
58 case MetaActionType::POLYPOLYGON: return "POLYPOLYGON";
59 case MetaActionType::TEXT: return "TEXT";
60 case MetaActionType::TEXTARRAY: return "TEXTARRAY";
61 case MetaActionType::STRETCHTEXT: return "STRETCHTEXT";
62 case MetaActionType::TEXTRECT: return "TEXTRECT";
63 case MetaActionType::BMP: return "BMP";
64 case MetaActionType::BMPSCALE: return "BMPSCALE";
65 case MetaActionType::BMPSCALEPART: return "BMPSCALEPART";
66 case MetaActionType::BMPEX: return "BMPEX";
67 case MetaActionType::BMPEXSCALE: return "BMPEXSCALE";
68 case MetaActionType::BMPEXSCALEPART: return "BMPEXSCALEPART";
69 case MetaActionType::MASK: return "MASK";
70 case MetaActionType::MASKSCALE: return "MASKSCALE";
71 case MetaActionType::MASKSCALEPART: return "MASKSCALEPART";
72 case MetaActionType::GRADIENT: return "GRADIENT";
73 case MetaActionType::HATCH: return "HATCH";
74 case MetaActionType::WALLPAPER: return "WALLPAPER";
75 case MetaActionType::CLIPREGION: return "CLIPREGION";
76 case MetaActionType::ISECTRECTCLIPREGION: return "ISECTRECTCLIPREGION";
77 case MetaActionType::ISECTREGIONCLIPREGION: return "ISECTREGIONCLIPREGION";
78 case MetaActionType::MOVECLIPREGION: return "MOVECLIPREGION";
79 case MetaActionType::LINECOLOR: return "LINECOLOR";
80 case MetaActionType::FILLCOLOR: return "FILLCOLOR";
81 case MetaActionType::TEXTCOLOR: return "TEXTCOLOR";
82 case MetaActionType::TEXTFILLCOLOR: return "TEXTFILLCOLOR";
83 case MetaActionType::TEXTALIGN: return "TEXTALIGN";
84 case MetaActionType::MAPMODE: return "MAPMODE";
85 case MetaActionType::FONT: return "FONT";
86 case MetaActionType::PUSH: return "PUSH";
87 case MetaActionType::POP: return "POP";
88 case MetaActionType::RASTEROP: return "RASTEROP";
89 case MetaActionType::Transparent: return "TRANSPARENT";
90 case MetaActionType::EPS: return "EPS";
91 case MetaActionType::REFPOINT: return "REFPOINT";
92 case MetaActionType::TEXTLINECOLOR: return "TEXTLINECOLOR";
93 case MetaActionType::TEXTLINE: return "TEXTLINE";
94 case MetaActionType::FLOATTRANSPARENT: return "FLOATTRANSPARENT";
95 case MetaActionType::GRADIENTEX: return "GRADIENTEX";
96 case MetaActionType::LAYOUTMODE: return "LAYOUTMODE";
97 case MetaActionType::TEXTLANGUAGE: return "TEXTLANGUAGE";
98 case MetaActionType::OVERLINECOLOR: return "OVERLINECOLOR";
99 case MetaActionType::COMMENT: return "COMMENT";
100 default:
101 // Yes, return a pointer to a static buffer. This is a very
102 // local debugging output function, so no big deal.
103 static char buffer[11];
104 sprintf(buffer, "%u", static_cast<unsigned int>(nMetaAction));
105 return buffer;
106 }
107 #endif
108 }
109
ImplScalePoint(Point & rPt,double fScaleX,double fScaleY)110 void ImplScalePoint( Point& rPt, double fScaleX, double fScaleY )
111 {
112 rPt.setX( FRound( fScaleX * rPt.X() ) );
113 rPt.setY( FRound( fScaleY * rPt.Y() ) );
114 }
115
ImplScaleRect(tools::Rectangle & rRect,double fScaleX,double fScaleY)116 void ImplScaleRect( tools::Rectangle& rRect, double fScaleX, double fScaleY )
117 {
118 Point aTL( rRect.TopLeft() );
119 Point aBR( rRect.BottomRight() );
120
121 ImplScalePoint( aTL, fScaleX, fScaleY );
122 ImplScalePoint( aBR, fScaleX, fScaleY );
123
124 rRect = tools::Rectangle( aTL, aBR );
125 rRect.Justify();
126 }
127
ImplScalePoly(tools::Polygon & rPoly,double fScaleX,double fScaleY)128 void ImplScalePoly( tools::Polygon& rPoly, double fScaleX, double fScaleY )
129 {
130 for( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
131 ImplScalePoint( rPoly[ i ], fScaleX, fScaleY );
132 }
133
ImplScaleLineInfo(LineInfo & rLineInfo,double fScaleX,double fScaleY)134 void ImplScaleLineInfo( LineInfo& rLineInfo, double fScaleX, double fScaleY )
135 {
136 if( !rLineInfo.IsDefault() )
137 {
138 const double fScale = ( fabs(fScaleX) + fabs(fScaleY) ) * 0.5;
139
140 rLineInfo.SetWidth( FRound( fScale * rLineInfo.GetWidth() ) );
141 rLineInfo.SetDashLen( FRound( fScale * rLineInfo.GetDashLen() ) );
142 rLineInfo.SetDotLen( FRound( fScale * rLineInfo.GetDotLen() ) );
143 rLineInfo.SetDistance( FRound( fScale * rLineInfo.GetDistance() ) );
144 }
145 }
146
147 } //anonymous namespace
148
MetaAction()149 MetaAction::MetaAction() :
150 mnType( MetaActionType::NONE )
151 {
152 }
153
MetaAction(MetaActionType nType)154 MetaAction::MetaAction( MetaActionType nType ) :
155 mnType( nType )
156 {
157 }
158
MetaAction(MetaAction const & rOther)159 MetaAction::MetaAction( MetaAction const & rOther ) :
160 SimpleReferenceObject(), mnType( rOther.mnType )
161 {
162 }
163
~MetaAction()164 MetaAction::~MetaAction()
165 {
166 }
167
Execute(OutputDevice *)168 void MetaAction::Execute( OutputDevice* )
169 {
170 }
171
Clone() const172 rtl::Reference<MetaAction> MetaAction::Clone() const
173 {
174 return new MetaAction;
175 }
176
Move(tools::Long,tools::Long)177 void MetaAction::Move( tools::Long, tools::Long )
178 {
179 }
180
Scale(double,double)181 void MetaAction::Scale( double, double )
182 {
183 }
184
Write(SvStream & rOStm,ImplMetaWriteData *)185 void MetaAction::Write( SvStream& rOStm, ImplMetaWriteData* )
186 {
187 rOStm.WriteUInt16( static_cast<sal_uInt16>(mnType) );
188 }
189
Read(SvStream &,ImplMetaReadData *)190 void MetaAction::Read( SvStream&, ImplMetaReadData* )
191 {
192 // DO NOT read mnType - ReadMetaAction already did that!
193 }
194
ReadMetaAction(SvStream & rIStm,ImplMetaReadData * pData)195 rtl::Reference<MetaAction> MetaAction::ReadMetaAction( SvStream& rIStm, ImplMetaReadData* pData )
196 {
197 rtl::Reference<MetaAction> pAction;
198 sal_uInt16 nTmp = 0;
199 rIStm.ReadUInt16( nTmp );
200 MetaActionType nType = static_cast<MetaActionType>(nTmp);
201
202 SAL_INFO("vcl.gdi", "ReadMetaAction " << meta_action_name( nType ));
203
204 switch( nType )
205 {
206 case MetaActionType::NONE: pAction = new MetaAction; break;
207 case MetaActionType::PIXEL: pAction = new MetaPixelAction; break;
208 case MetaActionType::POINT: pAction = new MetaPointAction; break;
209 case MetaActionType::LINE: pAction = new MetaLineAction; break;
210 case MetaActionType::RECT: pAction = new MetaRectAction; break;
211 case MetaActionType::ROUNDRECT: pAction = new MetaRoundRectAction; break;
212 case MetaActionType::ELLIPSE: pAction = new MetaEllipseAction; break;
213 case MetaActionType::ARC: pAction = new MetaArcAction; break;
214 case MetaActionType::PIE: pAction = new MetaPieAction; break;
215 case MetaActionType::CHORD: pAction = new MetaChordAction; break;
216 case MetaActionType::POLYLINE: pAction = new MetaPolyLineAction; break;
217 case MetaActionType::POLYGON: pAction = new MetaPolygonAction; break;
218 case MetaActionType::POLYPOLYGON: pAction = new MetaPolyPolygonAction; break;
219 case MetaActionType::TEXT: pAction = new MetaTextAction; break;
220 case MetaActionType::TEXTARRAY: pAction = new MetaTextArrayAction; break;
221 case MetaActionType::STRETCHTEXT: pAction = new MetaStretchTextAction; break;
222 case MetaActionType::TEXTRECT: pAction = new MetaTextRectAction; break;
223 case MetaActionType::TEXTLINE: pAction = new MetaTextLineAction; break;
224 case MetaActionType::BMP: pAction = new MetaBmpAction; break;
225 case MetaActionType::BMPSCALE: pAction = new MetaBmpScaleAction; break;
226 case MetaActionType::BMPSCALEPART: pAction = new MetaBmpScalePartAction; break;
227 case MetaActionType::BMPEX: pAction = new MetaBmpExAction; break;
228 case MetaActionType::BMPEXSCALE: pAction = new MetaBmpExScaleAction; break;
229 case MetaActionType::BMPEXSCALEPART: pAction = new MetaBmpExScalePartAction; break;
230 case MetaActionType::MASK: pAction = new MetaMaskAction; break;
231 case MetaActionType::MASKSCALE: pAction = new MetaMaskScaleAction; break;
232 case MetaActionType::MASKSCALEPART: pAction = new MetaMaskScalePartAction; break;
233 case MetaActionType::GRADIENT: pAction = new MetaGradientAction; break;
234 case MetaActionType::GRADIENTEX: pAction = new MetaGradientExAction; break;
235 case MetaActionType::HATCH: pAction = new MetaHatchAction; break;
236 case MetaActionType::WALLPAPER: pAction = new MetaWallpaperAction; break;
237 case MetaActionType::CLIPREGION: pAction = new MetaClipRegionAction; break;
238 case MetaActionType::ISECTRECTCLIPREGION: pAction = new MetaISectRectClipRegionAction; break;
239 case MetaActionType::ISECTREGIONCLIPREGION: pAction = new MetaISectRegionClipRegionAction; break;
240 case MetaActionType::MOVECLIPREGION: pAction = new MetaMoveClipRegionAction; break;
241 case MetaActionType::LINECOLOR: pAction = new MetaLineColorAction; break;
242 case MetaActionType::FILLCOLOR: pAction = new MetaFillColorAction; break;
243 case MetaActionType::TEXTCOLOR: pAction = new MetaTextColorAction; break;
244 case MetaActionType::TEXTFILLCOLOR: pAction = new MetaTextFillColorAction; break;
245 case MetaActionType::TEXTLINECOLOR: pAction = new MetaTextLineColorAction; break;
246 case MetaActionType::OVERLINECOLOR: pAction = new MetaOverlineColorAction; break;
247 case MetaActionType::TEXTALIGN: pAction = new MetaTextAlignAction; break;
248 case MetaActionType::MAPMODE: pAction = new MetaMapModeAction; break;
249 case MetaActionType::FONT: pAction = new MetaFontAction; break;
250 case MetaActionType::PUSH: pAction = new MetaPushAction; break;
251 case MetaActionType::POP: pAction = new MetaPopAction; break;
252 case MetaActionType::RASTEROP: pAction = new MetaRasterOpAction; break;
253 case MetaActionType::Transparent: pAction = new MetaTransparentAction; break;
254 case MetaActionType::FLOATTRANSPARENT: pAction = new MetaFloatTransparentAction; break;
255 case MetaActionType::EPS: pAction = new MetaEPSAction; break;
256 case MetaActionType::REFPOINT: pAction = new MetaRefPointAction; break;
257 case MetaActionType::COMMENT: pAction = new MetaCommentAction; break;
258 case MetaActionType::LAYOUTMODE: pAction = new MetaLayoutModeAction; break;
259 case MetaActionType::TEXTLANGUAGE: pAction = new MetaTextLanguageAction; break;
260
261 default:
262 {
263 VersionCompatRead aCompat(rIStm);
264 }
265 break;
266 }
267
268 if( pAction )
269 pAction->Read( rIStm, pData );
270
271 return pAction;
272 }
273
ReadColor(SvStream & rIStm,::Color & rColor)274 void MetaAction::ReadColor(SvStream& rIStm, ::Color& rColor)
275 {
276 sal_uInt32 nTmp;
277 rIStm.ReadUInt32(nTmp);
278 rColor = ::Color(ColorTransparency, nTmp);
279 }
280
WriteColor(SvStream & rIStm,::Color aColor)281 void MetaAction::WriteColor(SvStream& rIStm, ::Color aColor)
282 {
283 rIStm.WriteUInt32(static_cast<sal_uInt32>(aColor));
284 }
285
MetaPixelAction()286 MetaPixelAction::MetaPixelAction() :
287 MetaAction(MetaActionType::PIXEL)
288 {}
289
~MetaPixelAction()290 MetaPixelAction::~MetaPixelAction()
291 {}
292
MetaPixelAction(const Point & rPt,const Color & rColor)293 MetaPixelAction::MetaPixelAction( const Point& rPt, const Color& rColor ) :
294 MetaAction ( MetaActionType::PIXEL ),
295 maPt ( rPt ),
296 maColor ( rColor )
297 {}
298
Execute(OutputDevice * pOut)299 void MetaPixelAction::Execute( OutputDevice* pOut )
300 {
301 pOut->DrawPixel( maPt, maColor );
302 }
303
Clone() const304 rtl::Reference<MetaAction> MetaPixelAction::Clone() const
305 {
306 return new MetaPixelAction( *this );
307 }
308
Move(tools::Long nHorzMove,tools::Long nVertMove)309 void MetaPixelAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
310 {
311 maPt.Move( nHorzMove, nVertMove );
312 }
313
Scale(double fScaleX,double fScaleY)314 void MetaPixelAction::Scale( double fScaleX, double fScaleY )
315 {
316 ImplScalePoint( maPt, fScaleX, fScaleY );
317 }
318
Write(SvStream & rOStm,ImplMetaWriteData * pData)319 void MetaPixelAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
320 {
321 MetaAction::Write(rOStm, pData);
322 VersionCompatWrite aCompat(rOStm, 1);
323 TypeSerializer aSerializer(rOStm);
324 aSerializer.writePoint(maPt);
325 WriteColor(rOStm, maColor);
326 }
327
Read(SvStream & rIStm,ImplMetaReadData *)328 void MetaPixelAction::Read( SvStream& rIStm, ImplMetaReadData* )
329 {
330 VersionCompatRead aCompat(rIStm);
331 TypeSerializer aSerializer(rIStm);
332 aSerializer.readPoint(maPt);
333 ReadColor(rIStm, maColor);
334 }
335
MetaPointAction()336 MetaPointAction::MetaPointAction() :
337 MetaAction(MetaActionType::POINT)
338 {}
339
~MetaPointAction()340 MetaPointAction::~MetaPointAction()
341 {}
342
MetaPointAction(const Point & rPt)343 MetaPointAction::MetaPointAction( const Point& rPt ) :
344 MetaAction ( MetaActionType::POINT ),
345 maPt ( rPt )
346 {}
347
Execute(OutputDevice * pOut)348 void MetaPointAction::Execute( OutputDevice* pOut )
349 {
350 pOut->DrawPixel( maPt );
351 }
352
Clone() const353 rtl::Reference<MetaAction> MetaPointAction::Clone() const
354 {
355 return new MetaPointAction( *this );
356 }
357
Move(tools::Long nHorzMove,tools::Long nVertMove)358 void MetaPointAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
359 {
360 maPt.Move( nHorzMove, nVertMove );
361 }
362
Scale(double fScaleX,double fScaleY)363 void MetaPointAction::Scale( double fScaleX, double fScaleY )
364 {
365 ImplScalePoint( maPt, fScaleX, fScaleY );
366 }
367
Write(SvStream & rOStm,ImplMetaWriteData * pData)368 void MetaPointAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
369 {
370 MetaAction::Write(rOStm, pData);
371 VersionCompatWrite aCompat(rOStm, 1);
372 TypeSerializer aSerializer(rOStm);
373 aSerializer.writePoint(maPt);
374 }
375
Read(SvStream & rIStm,ImplMetaReadData *)376 void MetaPointAction::Read( SvStream& rIStm, ImplMetaReadData* )
377 {
378 VersionCompatRead aCompat(rIStm);
379 TypeSerializer aSerializer(rIStm);
380 aSerializer.readPoint(maPt);
381 }
382
MetaLineAction()383 MetaLineAction::MetaLineAction() :
384 MetaAction(MetaActionType::LINE)
385 {}
386
~MetaLineAction()387 MetaLineAction::~MetaLineAction()
388 {}
389
MetaLineAction(const Point & rStart,const Point & rEnd)390 MetaLineAction::MetaLineAction( const Point& rStart, const Point& rEnd ) :
391 MetaAction ( MetaActionType::LINE ),
392 maStartPt ( rStart ),
393 maEndPt ( rEnd )
394 {}
395
MetaLineAction(const Point & rStart,const Point & rEnd,const LineInfo & rLineInfo)396 MetaLineAction::MetaLineAction( const Point& rStart, const Point& rEnd,
397 const LineInfo& rLineInfo ) :
398 MetaAction ( MetaActionType::LINE ),
399 maLineInfo ( rLineInfo ),
400 maStartPt ( rStart ),
401 maEndPt ( rEnd )
402 {}
403
Execute(OutputDevice * pOut)404 void MetaLineAction::Execute( OutputDevice* pOut )
405 {
406 if( maLineInfo.IsDefault() )
407 pOut->DrawLine( maStartPt, maEndPt );
408 else
409 pOut->DrawLine( maStartPt, maEndPt, maLineInfo );
410 }
411
Clone() const412 rtl::Reference<MetaAction> MetaLineAction::Clone() const
413 {
414 return new MetaLineAction( *this );
415 }
416
Move(tools::Long nHorzMove,tools::Long nVertMove)417 void MetaLineAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
418 {
419 maStartPt.Move( nHorzMove, nVertMove );
420 maEndPt.Move( nHorzMove, nVertMove );
421 }
422
Scale(double fScaleX,double fScaleY)423 void MetaLineAction::Scale( double fScaleX, double fScaleY )
424 {
425 ImplScalePoint( maStartPt, fScaleX, fScaleY );
426 ImplScalePoint( maEndPt, fScaleX, fScaleY );
427 ImplScaleLineInfo( maLineInfo, fScaleX, fScaleY );
428 }
429
Write(SvStream & rOStm,ImplMetaWriteData * pData)430 void MetaLineAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
431 {
432 MetaAction::Write(rOStm, pData);
433 VersionCompatWrite aCompat(rOStm, 2);
434
435 // Version 1
436 TypeSerializer aSerializer(rOStm);
437 aSerializer.writePoint(maStartPt);
438 aSerializer.writePoint(maEndPt);
439 // Version 2
440 WriteLineInfo( rOStm, maLineInfo );
441 }
442
Read(SvStream & rIStm,ImplMetaReadData *)443 void MetaLineAction::Read( SvStream& rIStm, ImplMetaReadData* )
444 {
445 VersionCompatRead aCompat(rIStm);
446
447 // Version 1
448 TypeSerializer aSerializer(rIStm);
449 aSerializer.readPoint(maStartPt);
450 aSerializer.readPoint(maEndPt);
451
452 // Version 2
453 if( aCompat.GetVersion() >= 2 )
454 {
455 ReadLineInfo( rIStm, maLineInfo );
456 }
457 }
458
MetaRectAction()459 MetaRectAction::MetaRectAction() :
460 MetaAction(MetaActionType::RECT)
461 {}
462
~MetaRectAction()463 MetaRectAction::~MetaRectAction()
464 {}
465
MetaRectAction(const tools::Rectangle & rRect)466 MetaRectAction::MetaRectAction( const tools::Rectangle& rRect ) :
467 MetaAction ( MetaActionType::RECT ),
468 maRect ( rRect )
469 {}
470
Execute(OutputDevice * pOut)471 void MetaRectAction::Execute( OutputDevice* pOut )
472 {
473 pOut->DrawRect( maRect );
474 }
475
Clone() const476 rtl::Reference<MetaAction> MetaRectAction::Clone() const
477 {
478 return new MetaRectAction( *this );
479 }
480
Move(tools::Long nHorzMove,tools::Long nVertMove)481 void MetaRectAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
482 {
483 maRect.Move( nHorzMove, nVertMove );
484 }
485
Scale(double fScaleX,double fScaleY)486 void MetaRectAction::Scale( double fScaleX, double fScaleY )
487 {
488 ImplScaleRect( maRect, fScaleX, fScaleY );
489 }
490
Write(SvStream & rOStm,ImplMetaWriteData * pData)491 void MetaRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
492 {
493 MetaAction::Write(rOStm, pData);
494 VersionCompatWrite aCompat(rOStm, 1);
495 TypeSerializer aSerializer(rOStm);
496 aSerializer.writeRectangle(maRect);
497 }
498
Read(SvStream & rIStm,ImplMetaReadData *)499 void MetaRectAction::Read( SvStream& rIStm, ImplMetaReadData* )
500 {
501 VersionCompatRead aCompat(rIStm);
502 TypeSerializer aSerializer(rIStm);
503 aSerializer.readRectangle(maRect);
504 }
505
MetaRoundRectAction()506 MetaRoundRectAction::MetaRoundRectAction() :
507 MetaAction ( MetaActionType::ROUNDRECT ),
508 mnHorzRound ( 0 ),
509 mnVertRound ( 0 )
510 {}
511
~MetaRoundRectAction()512 MetaRoundRectAction::~MetaRoundRectAction()
513 {}
514
MetaRoundRectAction(const tools::Rectangle & rRect,sal_uInt32 nHorzRound,sal_uInt32 nVertRound)515 MetaRoundRectAction::MetaRoundRectAction( const tools::Rectangle& rRect,
516 sal_uInt32 nHorzRound, sal_uInt32 nVertRound ) :
517 MetaAction ( MetaActionType::ROUNDRECT ),
518 maRect ( rRect ),
519 mnHorzRound ( nHorzRound ),
520 mnVertRound ( nVertRound )
521 {}
522
Execute(OutputDevice * pOut)523 void MetaRoundRectAction::Execute( OutputDevice* pOut )
524 {
525 pOut->DrawRect( maRect, mnHorzRound, mnVertRound );
526 }
527
Clone() const528 rtl::Reference<MetaAction> MetaRoundRectAction::Clone() const
529 {
530 return new MetaRoundRectAction( *this );
531 }
532
Move(tools::Long nHorzMove,tools::Long nVertMove)533 void MetaRoundRectAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
534 {
535 maRect.Move( nHorzMove, nVertMove );
536 }
537
Scale(double fScaleX,double fScaleY)538 void MetaRoundRectAction::Scale( double fScaleX, double fScaleY )
539 {
540 ImplScaleRect( maRect, fScaleX, fScaleY );
541 mnHorzRound = FRound( mnHorzRound * fabs(fScaleX) );
542 mnVertRound = FRound( mnVertRound * fabs(fScaleY) );
543 }
544
Write(SvStream & rOStm,ImplMetaWriteData * pData)545 void MetaRoundRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
546 {
547 MetaAction::Write(rOStm, pData);
548 VersionCompatWrite aCompat(rOStm, 1);
549 TypeSerializer aSerializer(rOStm);
550 aSerializer.writeRectangle(maRect);
551 rOStm.WriteUInt32( mnHorzRound ).WriteUInt32( mnVertRound );
552 }
553
Read(SvStream & rIStm,ImplMetaReadData *)554 void MetaRoundRectAction::Read( SvStream& rIStm, ImplMetaReadData* )
555 {
556 VersionCompatRead aCompat(rIStm);
557 TypeSerializer aSerializer(rIStm);
558 aSerializer.readRectangle(maRect);
559 rIStm.ReadUInt32( mnHorzRound ).ReadUInt32( mnVertRound );
560 }
561
MetaEllipseAction()562 MetaEllipseAction::MetaEllipseAction() :
563 MetaAction(MetaActionType::ELLIPSE)
564 {}
565
~MetaEllipseAction()566 MetaEllipseAction::~MetaEllipseAction()
567 {}
568
MetaEllipseAction(const tools::Rectangle & rRect)569 MetaEllipseAction::MetaEllipseAction( const tools::Rectangle& rRect ) :
570 MetaAction ( MetaActionType::ELLIPSE ),
571 maRect ( rRect )
572 {}
573
Execute(OutputDevice * pOut)574 void MetaEllipseAction::Execute( OutputDevice* pOut )
575 {
576 pOut->DrawEllipse( maRect );
577 }
578
Clone() const579 rtl::Reference<MetaAction> MetaEllipseAction::Clone() const
580 {
581 return new MetaEllipseAction( *this );
582 }
583
Move(tools::Long nHorzMove,tools::Long nVertMove)584 void MetaEllipseAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
585 {
586 maRect.Move( nHorzMove, nVertMove );
587 }
588
Scale(double fScaleX,double fScaleY)589 void MetaEllipseAction::Scale( double fScaleX, double fScaleY )
590 {
591 ImplScaleRect( maRect, fScaleX, fScaleY );
592 }
593
Write(SvStream & rOStm,ImplMetaWriteData * pData)594 void MetaEllipseAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
595 {
596 MetaAction::Write(rOStm, pData);
597 VersionCompatWrite aCompat(rOStm, 1);
598 TypeSerializer aSerializer(rOStm);
599 aSerializer.writeRectangle(maRect);
600 }
601
Read(SvStream & rIStm,ImplMetaReadData *)602 void MetaEllipseAction::Read( SvStream& rIStm, ImplMetaReadData* )
603 {
604 VersionCompatRead aCompat(rIStm);
605 TypeSerializer aSerializer(rIStm);
606 aSerializer.readRectangle(maRect);
607 }
608
MetaArcAction()609 MetaArcAction::MetaArcAction() :
610 MetaAction(MetaActionType::ARC)
611 {}
612
~MetaArcAction()613 MetaArcAction::~MetaArcAction()
614 {}
615
MetaArcAction(const tools::Rectangle & rRect,const Point & rStart,const Point & rEnd)616 MetaArcAction::MetaArcAction( const tools::Rectangle& rRect,
617 const Point& rStart, const Point& rEnd ) :
618 MetaAction ( MetaActionType::ARC ),
619 maRect ( rRect ),
620 maStartPt ( rStart ),
621 maEndPt ( rEnd )
622 {}
623
Execute(OutputDevice * pOut)624 void MetaArcAction::Execute( OutputDevice* pOut )
625 {
626 pOut->DrawArc( maRect, maStartPt, maEndPt );
627 }
628
Clone() const629 rtl::Reference<MetaAction> MetaArcAction::Clone() const
630 {
631 return new MetaArcAction( *this );
632 }
633
Move(tools::Long nHorzMove,tools::Long nVertMove)634 void MetaArcAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
635 {
636 maRect.Move( nHorzMove, nVertMove );
637 maStartPt.Move( nHorzMove, nVertMove );
638 maEndPt.Move( nHorzMove, nVertMove );
639 }
640
Scale(double fScaleX,double fScaleY)641 void MetaArcAction::Scale( double fScaleX, double fScaleY )
642 {
643 ImplScaleRect( maRect, fScaleX, fScaleY );
644 ImplScalePoint( maStartPt, fScaleX, fScaleY );
645 ImplScalePoint( maEndPt, fScaleX, fScaleY );
646 }
647
Write(SvStream & rOStm,ImplMetaWriteData * pData)648 void MetaArcAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
649 {
650 MetaAction::Write(rOStm, pData);
651 VersionCompatWrite aCompat(rOStm, 1);
652 TypeSerializer aSerializer(rOStm);
653 aSerializer.writeRectangle(maRect);
654 aSerializer.writePoint(maStartPt);
655 aSerializer.writePoint(maEndPt);
656 }
657
Read(SvStream & rIStm,ImplMetaReadData *)658 void MetaArcAction::Read( SvStream& rIStm, ImplMetaReadData* )
659 {
660 VersionCompatRead aCompat(rIStm);
661 TypeSerializer aSerializer(rIStm);
662 aSerializer.readRectangle(maRect);
663 aSerializer.readPoint(maStartPt);
664 aSerializer.readPoint(maEndPt);
665 }
666
MetaPieAction()667 MetaPieAction::MetaPieAction() :
668 MetaAction(MetaActionType::PIE)
669 {}
670
~MetaPieAction()671 MetaPieAction::~MetaPieAction()
672 {}
673
MetaPieAction(const tools::Rectangle & rRect,const Point & rStart,const Point & rEnd)674 MetaPieAction::MetaPieAction( const tools::Rectangle& rRect,
675 const Point& rStart, const Point& rEnd ) :
676 MetaAction ( MetaActionType::PIE ),
677 maRect ( rRect ),
678 maStartPt ( rStart ),
679 maEndPt ( rEnd )
680 {}
681
Execute(OutputDevice * pOut)682 void MetaPieAction::Execute( OutputDevice* pOut )
683 {
684 pOut->DrawPie( maRect, maStartPt, maEndPt );
685 }
686
Clone() const687 rtl::Reference<MetaAction> MetaPieAction::Clone() const
688 {
689 return new MetaPieAction( *this );
690 }
691
Move(tools::Long nHorzMove,tools::Long nVertMove)692 void MetaPieAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
693 {
694 maRect.Move( nHorzMove, nVertMove );
695 maStartPt.Move( nHorzMove, nVertMove );
696 maEndPt.Move( nHorzMove, nVertMove );
697 }
698
Scale(double fScaleX,double fScaleY)699 void MetaPieAction::Scale( double fScaleX, double fScaleY )
700 {
701 ImplScaleRect( maRect, fScaleX, fScaleY );
702 ImplScalePoint( maStartPt, fScaleX, fScaleY );
703 ImplScalePoint( maEndPt, fScaleX, fScaleY );
704 }
705
Write(SvStream & rOStm,ImplMetaWriteData * pData)706 void MetaPieAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
707 {
708 MetaAction::Write(rOStm, pData);
709 VersionCompatWrite aCompat(rOStm, 1);
710 TypeSerializer aSerializer(rOStm);
711 aSerializer.writeRectangle(maRect);
712 aSerializer.writePoint(maStartPt);
713 aSerializer.writePoint(maEndPt);
714 }
715
Read(SvStream & rIStm,ImplMetaReadData *)716 void MetaPieAction::Read( SvStream& rIStm, ImplMetaReadData* )
717 {
718 VersionCompatRead aCompat(rIStm);
719 TypeSerializer aSerializer(rIStm);
720 aSerializer.readRectangle(maRect);
721 aSerializer.readPoint(maStartPt);
722 aSerializer.readPoint(maEndPt);
723 }
724
MetaChordAction()725 MetaChordAction::MetaChordAction() :
726 MetaAction(MetaActionType::CHORD)
727 {}
728
~MetaChordAction()729 MetaChordAction::~MetaChordAction()
730 {}
731
MetaChordAction(const tools::Rectangle & rRect,const Point & rStart,const Point & rEnd)732 MetaChordAction::MetaChordAction( const tools::Rectangle& rRect,
733 const Point& rStart, const Point& rEnd ) :
734 MetaAction ( MetaActionType::CHORD ),
735 maRect ( rRect ),
736 maStartPt ( rStart ),
737 maEndPt ( rEnd )
738 {}
739
Execute(OutputDevice * pOut)740 void MetaChordAction::Execute( OutputDevice* pOut )
741 {
742 pOut->DrawChord( maRect, maStartPt, maEndPt );
743 }
744
Clone() const745 rtl::Reference<MetaAction> MetaChordAction::Clone() const
746 {
747 return new MetaChordAction( *this );
748 }
749
Move(tools::Long nHorzMove,tools::Long nVertMove)750 void MetaChordAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
751 {
752 maRect.Move( nHorzMove, nVertMove );
753 maStartPt.Move( nHorzMove, nVertMove );
754 maEndPt.Move( nHorzMove, nVertMove );
755 }
756
Scale(double fScaleX,double fScaleY)757 void MetaChordAction::Scale( double fScaleX, double fScaleY )
758 {
759 ImplScaleRect( maRect, fScaleX, fScaleY );
760 ImplScalePoint( maStartPt, fScaleX, fScaleY );
761 ImplScalePoint( maEndPt, fScaleX, fScaleY );
762 }
763
Write(SvStream & rOStm,ImplMetaWriteData * pData)764 void MetaChordAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
765 {
766 MetaAction::Write(rOStm, pData);
767 VersionCompatWrite aCompat(rOStm, 1);
768 TypeSerializer aSerializer(rOStm);
769 aSerializer.writeRectangle(maRect);
770 aSerializer.writePoint(maStartPt);
771 aSerializer.writePoint(maEndPt);
772 }
773
Read(SvStream & rIStm,ImplMetaReadData *)774 void MetaChordAction::Read( SvStream& rIStm, ImplMetaReadData* )
775 {
776 VersionCompatRead aCompat(rIStm);
777 TypeSerializer aSerializer(rIStm);
778 aSerializer.readRectangle(maRect);
779 aSerializer.readPoint(maStartPt);
780 aSerializer.readPoint(maEndPt);
781 }
782
MetaPolyLineAction()783 MetaPolyLineAction::MetaPolyLineAction() :
784 MetaAction(MetaActionType::POLYLINE)
785 {}
786
~MetaPolyLineAction()787 MetaPolyLineAction::~MetaPolyLineAction()
788 {}
789
MetaPolyLineAction(const tools::Polygon & rPoly)790 MetaPolyLineAction::MetaPolyLineAction( const tools::Polygon& rPoly ) :
791 MetaAction ( MetaActionType::POLYLINE ),
792 maPoly ( rPoly )
793 {}
794
MetaPolyLineAction(const tools::Polygon & rPoly,const LineInfo & rLineInfo)795 MetaPolyLineAction::MetaPolyLineAction( const tools::Polygon& rPoly, const LineInfo& rLineInfo ) :
796 MetaAction ( MetaActionType::POLYLINE ),
797 maLineInfo ( rLineInfo ),
798 maPoly ( rPoly )
799 {}
800
Execute(OutputDevice * pOut)801 void MetaPolyLineAction::Execute( OutputDevice* pOut )
802 {
803 if( maLineInfo.IsDefault() )
804 pOut->DrawPolyLine( maPoly );
805 else
806 pOut->DrawPolyLine( maPoly, maLineInfo );
807 }
808
Clone() const809 rtl::Reference<MetaAction> MetaPolyLineAction::Clone() const
810 {
811 return new MetaPolyLineAction( *this );
812 }
813
Move(tools::Long nHorzMove,tools::Long nVertMove)814 void MetaPolyLineAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
815 {
816 maPoly.Move( nHorzMove, nVertMove );
817 }
818
Scale(double fScaleX,double fScaleY)819 void MetaPolyLineAction::Scale( double fScaleX, double fScaleY )
820 {
821 ImplScalePoly( maPoly, fScaleX, fScaleY );
822 ImplScaleLineInfo( maLineInfo, fScaleX, fScaleY );
823 }
824
Write(SvStream & rOStm,ImplMetaWriteData * pData)825 void MetaPolyLineAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
826 {
827 MetaAction::Write(rOStm, pData);
828 VersionCompatWrite aCompat(rOStm, 3);
829
830 tools::Polygon aSimplePoly;
831 maPoly.AdaptiveSubdivide( aSimplePoly );
832
833 WritePolygon( rOStm, aSimplePoly ); // Version 1
834 WriteLineInfo( rOStm, maLineInfo ); // Version 2
835
836 bool bHasPolyFlags = maPoly.HasFlags(); // Version 3
837 rOStm.WriteBool( bHasPolyFlags );
838 if ( bHasPolyFlags )
839 maPoly.Write( rOStm );
840 }
841
Read(SvStream & rIStm,ImplMetaReadData *)842 void MetaPolyLineAction::Read( SvStream& rIStm, ImplMetaReadData* )
843 {
844 VersionCompatRead aCompat(rIStm);
845
846 // Version 1
847 ReadPolygon( rIStm, maPoly );
848
849 // Version 2
850 if( aCompat.GetVersion() >= 2 )
851 ReadLineInfo( rIStm, maLineInfo );
852 if ( aCompat.GetVersion() >= 3 )
853 {
854 sal_uInt8 bHasPolyFlags(0);
855 rIStm.ReadUChar( bHasPolyFlags );
856 if ( bHasPolyFlags )
857 maPoly.Read( rIStm );
858 }
859 }
860
MetaPolygonAction()861 MetaPolygonAction::MetaPolygonAction() :
862 MetaAction(MetaActionType::POLYGON)
863 {}
864
~MetaPolygonAction()865 MetaPolygonAction::~MetaPolygonAction()
866 {}
867
MetaPolygonAction(const tools::Polygon & rPoly)868 MetaPolygonAction::MetaPolygonAction( const tools::Polygon& rPoly ) :
869 MetaAction ( MetaActionType::POLYGON ),
870 maPoly ( rPoly )
871 {}
872
Execute(OutputDevice * pOut)873 void MetaPolygonAction::Execute( OutputDevice* pOut )
874 {
875 pOut->DrawPolygon( maPoly );
876 }
877
Clone() const878 rtl::Reference<MetaAction> MetaPolygonAction::Clone() const
879 {
880 return new MetaPolygonAction( *this );
881 }
882
Move(tools::Long nHorzMove,tools::Long nVertMove)883 void MetaPolygonAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
884 {
885 maPoly.Move( nHorzMove, nVertMove );
886 }
887
Scale(double fScaleX,double fScaleY)888 void MetaPolygonAction::Scale( double fScaleX, double fScaleY )
889 {
890 ImplScalePoly( maPoly, fScaleX, fScaleY );
891 }
892
Write(SvStream & rOStm,ImplMetaWriteData * pData)893 void MetaPolygonAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
894 {
895 MetaAction::Write(rOStm, pData);
896 VersionCompatWrite aCompat(rOStm, 2);
897
898 tools::Polygon aSimplePoly; // Version 1
899 maPoly.AdaptiveSubdivide( aSimplePoly );
900 WritePolygon( rOStm, aSimplePoly );
901
902 bool bHasPolyFlags = maPoly.HasFlags(); // Version 2
903 rOStm.WriteBool( bHasPolyFlags );
904 if ( bHasPolyFlags )
905 maPoly.Write( rOStm );
906 }
907
Read(SvStream & rIStm,ImplMetaReadData *)908 void MetaPolygonAction::Read( SvStream& rIStm, ImplMetaReadData* )
909 {
910 VersionCompatRead aCompat(rIStm);
911
912 ReadPolygon( rIStm, maPoly ); // Version 1
913
914 if( aCompat.GetVersion() >= 2 ) // Version 2
915 {
916 sal_uInt8 bHasPolyFlags(0);
917 rIStm.ReadUChar( bHasPolyFlags );
918 if ( bHasPolyFlags )
919 maPoly.Read( rIStm );
920 }
921 }
922
MetaPolyPolygonAction()923 MetaPolyPolygonAction::MetaPolyPolygonAction() :
924 MetaAction(MetaActionType::POLYPOLYGON)
925 {}
926
~MetaPolyPolygonAction()927 MetaPolyPolygonAction::~MetaPolyPolygonAction()
928 {}
929
MetaPolyPolygonAction(const tools::PolyPolygon & rPolyPoly)930 MetaPolyPolygonAction::MetaPolyPolygonAction( const tools::PolyPolygon& rPolyPoly ) :
931 MetaAction ( MetaActionType::POLYPOLYGON ),
932 maPolyPoly ( rPolyPoly )
933 {}
934
Execute(OutputDevice * pOut)935 void MetaPolyPolygonAction::Execute( OutputDevice* pOut )
936 {
937 pOut->DrawPolyPolygon( maPolyPoly );
938 }
939
Clone() const940 rtl::Reference<MetaAction> MetaPolyPolygonAction::Clone() const
941 {
942 return new MetaPolyPolygonAction( *this );
943 }
944
Move(tools::Long nHorzMove,tools::Long nVertMove)945 void MetaPolyPolygonAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
946 {
947 maPolyPoly.Move( nHorzMove, nVertMove );
948 }
949
Scale(double fScaleX,double fScaleY)950 void MetaPolyPolygonAction::Scale( double fScaleX, double fScaleY )
951 {
952 for( sal_uInt16 i = 0, nCount = maPolyPoly.Count(); i < nCount; i++ )
953 ImplScalePoly( maPolyPoly[ i ], fScaleX, fScaleY );
954 }
955
Write(SvStream & rOStm,ImplMetaWriteData * pData)956 void MetaPolyPolygonAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
957 {
958 MetaAction::Write(rOStm, pData);
959 VersionCompatWrite aCompat(rOStm, 2);
960
961 sal_uInt16 nNumberOfComplexPolygons = 0;
962 sal_uInt16 i, nPolyCount = maPolyPoly.Count();
963
964 tools::Polygon aSimplePoly; // Version 1
965 rOStm.WriteUInt16( nPolyCount );
966 for ( i = 0; i < nPolyCount; i++ )
967 {
968 const tools::Polygon& rPoly = maPolyPoly.GetObject( i );
969 if ( rPoly.HasFlags() )
970 nNumberOfComplexPolygons++;
971 rPoly.AdaptiveSubdivide( aSimplePoly );
972 WritePolygon( rOStm, aSimplePoly );
973 }
974
975 rOStm.WriteUInt16( nNumberOfComplexPolygons ); // Version 2
976 for ( i = 0; nNumberOfComplexPolygons && ( i < nPolyCount ); i++ )
977 {
978 const tools::Polygon& rPoly = maPolyPoly.GetObject( i );
979 if ( rPoly.HasFlags() )
980 {
981 rOStm.WriteUInt16( i );
982 rPoly.Write( rOStm );
983
984 nNumberOfComplexPolygons--;
985 }
986 }
987 }
988
Read(SvStream & rIStm,ImplMetaReadData *)989 void MetaPolyPolygonAction::Read( SvStream& rIStm, ImplMetaReadData* )
990 {
991 VersionCompatRead aCompat(rIStm);
992 ReadPolyPolygon( rIStm, maPolyPoly ); // Version 1
993
994 if ( aCompat.GetVersion() < 2 ) // Version 2
995 return;
996
997 sal_uInt16 nNumberOfComplexPolygons(0);
998 rIStm.ReadUInt16( nNumberOfComplexPolygons );
999 const size_t nMinRecordSize = sizeof(sal_uInt16);
1000 const size_t nMaxRecords = rIStm.remainingSize() / nMinRecordSize;
1001 if (nNumberOfComplexPolygons > nMaxRecords)
1002 {
1003 SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords <<
1004 " max possible entries, but " << nNumberOfComplexPolygons << " claimed, truncating");
1005 nNumberOfComplexPolygons = nMaxRecords;
1006 }
1007 for (sal_uInt16 i = 0; i < nNumberOfComplexPolygons; ++i)
1008 {
1009 sal_uInt16 nIndex(0);
1010 rIStm.ReadUInt16( nIndex );
1011 tools::Polygon aPoly;
1012 aPoly.Read( rIStm );
1013 if (nIndex >= maPolyPoly.Count())
1014 {
1015 SAL_WARN("vcl.gdi", "svm contains polygon index " << nIndex
1016 << " outside possible range " << maPolyPoly.Count());
1017 continue;
1018 }
1019 maPolyPoly.Replace( aPoly, nIndex );
1020 }
1021 }
1022
MetaTextAction()1023 MetaTextAction::MetaTextAction() :
1024 MetaAction ( MetaActionType::TEXT ),
1025 mnIndex ( 0 ),
1026 mnLen ( 0 )
1027 {}
1028
~MetaTextAction()1029 MetaTextAction::~MetaTextAction()
1030 {}
1031
MetaTextAction(const Point & rPt,const OUString & rStr,sal_Int32 nIndex,sal_Int32 nLen)1032 MetaTextAction::MetaTextAction( const Point& rPt, const OUString& rStr,
1033 sal_Int32 nIndex, sal_Int32 nLen ) :
1034 MetaAction ( MetaActionType::TEXT ),
1035 maPt ( rPt ),
1036 maStr ( rStr ),
1037 mnIndex ( nIndex ),
1038 mnLen ( nLen )
1039 {}
1040
Execute(OutputDevice * pOut)1041 void MetaTextAction::Execute( OutputDevice* pOut )
1042 {
1043 pOut->DrawText( maPt, maStr, mnIndex, mnLen );
1044 }
1045
Clone() const1046 rtl::Reference<MetaAction> MetaTextAction::Clone() const
1047 {
1048 return new MetaTextAction( *this );
1049 }
1050
Move(tools::Long nHorzMove,tools::Long nVertMove)1051 void MetaTextAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1052 {
1053 maPt.Move( nHorzMove, nVertMove );
1054 }
1055
Scale(double fScaleX,double fScaleY)1056 void MetaTextAction::Scale( double fScaleX, double fScaleY )
1057 {
1058 ImplScalePoint( maPt, fScaleX, fScaleY );
1059 }
1060
Write(SvStream & rOStm,ImplMetaWriteData * pData)1061 void MetaTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1062 {
1063 MetaAction::Write(rOStm, pData);
1064 VersionCompatWrite aCompat(rOStm, 2);
1065 TypeSerializer aSerializer(rOStm);
1066 aSerializer.writePoint(maPt);
1067 rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet );
1068 rOStm.WriteUInt16(mnIndex);
1069 rOStm.WriteUInt16(mnLen);
1070
1071 write_uInt16_lenPrefixed_uInt16s_FromOUString(rOStm, maStr); // version 2
1072 }
1073
Read(SvStream & rIStm,ImplMetaReadData * pData)1074 void MetaTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
1075 {
1076 VersionCompatRead aCompat(rIStm);
1077 TypeSerializer aSerializer(rIStm);
1078 aSerializer.readPoint(maPt);
1079 maStr = rIStm.ReadUniOrByteString(pData->meActualCharSet);
1080 sal_uInt16 nTmpIndex(0);
1081 rIStm.ReadUInt16(nTmpIndex);
1082 mnIndex = nTmpIndex;
1083 sal_uInt16 nTmpLen(0);
1084 rIStm.ReadUInt16(nTmpLen);
1085 mnLen = nTmpLen;
1086
1087 if ( aCompat.GetVersion() >= 2 ) // Version 2
1088 maStr = read_uInt16_lenPrefixed_uInt16s_ToOUString(rIStm);
1089 }
1090
MetaTextArrayAction()1091 MetaTextArrayAction::MetaTextArrayAction() :
1092 MetaAction ( MetaActionType::TEXTARRAY ),
1093 mnIndex ( 0 ),
1094 mnLen ( 0 )
1095 {}
1096
MetaTextArrayAction(const MetaTextArrayAction & rAction)1097 MetaTextArrayAction::MetaTextArrayAction( const MetaTextArrayAction& rAction ) :
1098 MetaAction ( MetaActionType::TEXTARRAY ),
1099 maStartPt ( rAction.maStartPt ),
1100 maStr ( rAction.maStr ),
1101 mnIndex ( rAction.mnIndex ),
1102 mnLen ( rAction.mnLen )
1103 {
1104 if( rAction.mpDXAry )
1105 {
1106 mpDXAry.reset( new tools::Long[ mnLen ] );
1107 memcpy( mpDXAry.get(), rAction.mpDXAry.get(), mnLen * sizeof( tools::Long ) );
1108 }
1109 }
1110
MetaTextArrayAction(const Point & rStartPt,const OUString & rStr,const tools::Long * pDXAry,sal_Int32 nIndex,sal_Int32 nLen)1111 MetaTextArrayAction::MetaTextArrayAction( const Point& rStartPt,
1112 const OUString& rStr,
1113 const tools::Long* pDXAry,
1114 sal_Int32 nIndex,
1115 sal_Int32 nLen ) :
1116 MetaAction ( MetaActionType::TEXTARRAY ),
1117 maStartPt ( rStartPt ),
1118 maStr ( rStr ),
1119 mnIndex ( nIndex ),
1120 mnLen ( nLen )
1121 {
1122 const sal_Int32 nAryLen = pDXAry ? mnLen : 0;
1123
1124 if (nAryLen > 0)
1125 {
1126 mpDXAry.reset( new tools::Long[ nAryLen ] );
1127 memcpy( mpDXAry.get(), pDXAry, nAryLen * sizeof(tools::Long) );
1128 }
1129 }
1130
~MetaTextArrayAction()1131 MetaTextArrayAction::~MetaTextArrayAction()
1132 {
1133 }
1134
Execute(OutputDevice * pOut)1135 void MetaTextArrayAction::Execute( OutputDevice* pOut )
1136 {
1137 pOut->DrawTextArray( maStartPt, maStr, mpDXAry.get(), mnIndex, mnLen );
1138 }
1139
Clone() const1140 rtl::Reference<MetaAction> MetaTextArrayAction::Clone() const
1141 {
1142 return new MetaTextArrayAction( *this );
1143 }
1144
Move(tools::Long nHorzMove,tools::Long nVertMove)1145 void MetaTextArrayAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1146 {
1147 maStartPt.Move( nHorzMove, nVertMove );
1148 }
1149
Scale(double fScaleX,double fScaleY)1150 void MetaTextArrayAction::Scale( double fScaleX, double fScaleY )
1151 {
1152 ImplScalePoint( maStartPt, fScaleX, fScaleY );
1153
1154 if ( mpDXAry && mnLen )
1155 {
1156 for ( sal_uInt16 i = 0, nCount = mnLen; i < nCount; i++ )
1157 mpDXAry[ i ] = FRound( mpDXAry[ i ] * fabs(fScaleX) );
1158 }
1159 }
1160
Write(SvStream & rOStm,ImplMetaWriteData * pData)1161 void MetaTextArrayAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1162 {
1163 const sal_Int32 nAryLen = mpDXAry ? mnLen : 0;
1164
1165 MetaAction::Write(rOStm, pData);
1166 VersionCompatWrite aCompat(rOStm, 2);
1167 TypeSerializer aSerializer(rOStm);
1168 aSerializer.writePoint(maStartPt);
1169 rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet );
1170 rOStm.WriteUInt16(mnIndex);
1171 rOStm.WriteUInt16(mnLen);
1172 rOStm.WriteInt32(nAryLen);
1173
1174 for (sal_Int32 i = 0; i < nAryLen; ++i)
1175 rOStm.WriteInt32( mpDXAry[ i ] );
1176
1177 write_uInt16_lenPrefixed_uInt16s_FromOUString(rOStm, maStr); // version 2
1178 }
1179
Read(SvStream & rIStm,ImplMetaReadData * pData)1180 void MetaTextArrayAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
1181 {
1182 mpDXAry.reset();
1183
1184 VersionCompatRead aCompat(rIStm);
1185 TypeSerializer aSerializer(rIStm);
1186 aSerializer.readPoint(maStartPt);
1187 maStr = rIStm.ReadUniOrByteString(pData->meActualCharSet);
1188 sal_uInt16 nTmpIndex(0);
1189 rIStm.ReadUInt16(nTmpIndex);
1190 mnIndex = nTmpIndex;
1191 sal_uInt16 nTmpLen(0);
1192 rIStm.ReadUInt16(nTmpLen);
1193 mnLen = nTmpLen;
1194 sal_Int32 nAryLen(0);
1195 rIStm.ReadInt32(nAryLen);
1196
1197 if (mnLen > maStr.getLength() - mnIndex)
1198 {
1199 mnIndex = 0;
1200 mpDXAry = nullptr;
1201 return;
1202 }
1203
1204 if( nAryLen )
1205 {
1206 // #i9762#, #106172# Ensure that DX array is at least mnLen entries long
1207 if ( mnLen >= nAryLen )
1208 {
1209 mpDXAry.reset( new (std::nothrow)tools::Long[ mnLen ] );
1210 if ( mpDXAry )
1211 {
1212 sal_Int32 i;
1213 sal_Int32 val;
1214 for( i = 0; i < nAryLen; i++ )
1215 {
1216 rIStm.ReadInt32( val);
1217 mpDXAry[ i ] = val;
1218 }
1219 // #106172# setup remainder
1220 for( ; i < mnLen; i++ )
1221 mpDXAry[ i ] = 0;
1222 }
1223 }
1224 else
1225 {
1226 mpDXAry = nullptr;
1227 return;
1228 }
1229 }
1230 else
1231 mpDXAry = nullptr;
1232
1233 if ( aCompat.GetVersion() >= 2 ) // Version 2
1234 {
1235 maStr = read_uInt16_lenPrefixed_uInt16s_ToOUString(rIStm);
1236
1237 if ( mnIndex + mnLen > maStr.getLength() )
1238 {
1239 mnIndex = 0;
1240 mpDXAry.reset();
1241 }
1242 }
1243 }
1244
MetaStretchTextAction()1245 MetaStretchTextAction::MetaStretchTextAction() :
1246 MetaAction ( MetaActionType::STRETCHTEXT ),
1247 mnWidth ( 0 ),
1248 mnIndex ( 0 ),
1249 mnLen ( 0 )
1250 {}
1251
~MetaStretchTextAction()1252 MetaStretchTextAction::~MetaStretchTextAction()
1253 {}
1254
MetaStretchTextAction(const Point & rPt,sal_uInt32 nWidth,const OUString & rStr,sal_Int32 nIndex,sal_Int32 nLen)1255 MetaStretchTextAction::MetaStretchTextAction( const Point& rPt, sal_uInt32 nWidth,
1256 const OUString& rStr,
1257 sal_Int32 nIndex, sal_Int32 nLen ) :
1258 MetaAction ( MetaActionType::STRETCHTEXT ),
1259 maPt ( rPt ),
1260 maStr ( rStr ),
1261 mnWidth ( nWidth ),
1262 mnIndex ( nIndex ),
1263 mnLen ( nLen )
1264 {}
1265
Execute(OutputDevice * pOut)1266 void MetaStretchTextAction::Execute( OutputDevice* pOut )
1267 {
1268 pOut->DrawStretchText( maPt, mnWidth, maStr, mnIndex, mnLen );
1269 }
1270
Clone() const1271 rtl::Reference<MetaAction> MetaStretchTextAction::Clone() const
1272 {
1273 return new MetaStretchTextAction( *this );
1274 }
1275
Move(tools::Long nHorzMove,tools::Long nVertMove)1276 void MetaStretchTextAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1277 {
1278 maPt.Move( nHorzMove, nVertMove );
1279 }
1280
Scale(double fScaleX,double fScaleY)1281 void MetaStretchTextAction::Scale( double fScaleX, double fScaleY )
1282 {
1283 ImplScalePoint( maPt, fScaleX, fScaleY );
1284 mnWidth = static_cast<sal_uLong>(FRound( mnWidth * fabs(fScaleX) ));
1285 }
1286
Write(SvStream & rOStm,ImplMetaWriteData * pData)1287 void MetaStretchTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1288 {
1289 MetaAction::Write(rOStm, pData);
1290 VersionCompatWrite aCompat(rOStm, 2);
1291 TypeSerializer aSerializer(rOStm);
1292 aSerializer.writePoint(maPt);
1293 rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet );
1294 rOStm.WriteUInt32( mnWidth );
1295 rOStm.WriteUInt16( mnIndex );
1296 rOStm.WriteUInt16( mnLen );
1297
1298 write_uInt16_lenPrefixed_uInt16s_FromOUString(rOStm, maStr); // version 2
1299 }
1300
Read(SvStream & rIStm,ImplMetaReadData * pData)1301 void MetaStretchTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
1302 {
1303 VersionCompatRead aCompat(rIStm);
1304 TypeSerializer aSerializer(rIStm);
1305 aSerializer.readPoint(maPt);
1306 maStr = rIStm.ReadUniOrByteString(pData->meActualCharSet);
1307 rIStm.ReadUInt32( mnWidth );
1308 sal_uInt16 nTmpIndex(0);
1309 rIStm.ReadUInt16(nTmpIndex);
1310 mnIndex = nTmpIndex;
1311 sal_uInt16 nTmpLen(0);
1312 rIStm.ReadUInt16(nTmpLen);
1313 mnLen = nTmpLen;
1314
1315 if ( aCompat.GetVersion() >= 2 ) // Version 2
1316 maStr = read_uInt16_lenPrefixed_uInt16s_ToOUString(rIStm);
1317 }
1318
MetaTextRectAction()1319 MetaTextRectAction::MetaTextRectAction() :
1320 MetaAction ( MetaActionType::TEXTRECT ),
1321 mnStyle ( DrawTextFlags::NONE )
1322 {}
1323
~MetaTextRectAction()1324 MetaTextRectAction::~MetaTextRectAction()
1325 {}
1326
MetaTextRectAction(const tools::Rectangle & rRect,const OUString & rStr,DrawTextFlags nStyle)1327 MetaTextRectAction::MetaTextRectAction( const tools::Rectangle& rRect,
1328 const OUString& rStr, DrawTextFlags nStyle ) :
1329 MetaAction ( MetaActionType::TEXTRECT ),
1330 maRect ( rRect ),
1331 maStr ( rStr ),
1332 mnStyle ( nStyle )
1333 {}
1334
Execute(OutputDevice * pOut)1335 void MetaTextRectAction::Execute( OutputDevice* pOut )
1336 {
1337 pOut->DrawText( maRect, maStr, mnStyle );
1338 }
1339
Clone() const1340 rtl::Reference<MetaAction> MetaTextRectAction::Clone() const
1341 {
1342 return new MetaTextRectAction( *this );
1343 }
1344
Move(tools::Long nHorzMove,tools::Long nVertMove)1345 void MetaTextRectAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1346 {
1347 maRect.Move( nHorzMove, nVertMove );
1348 }
1349
Scale(double fScaleX,double fScaleY)1350 void MetaTextRectAction::Scale( double fScaleX, double fScaleY )
1351 {
1352 ImplScaleRect( maRect, fScaleX, fScaleY );
1353 }
1354
Write(SvStream & rOStm,ImplMetaWriteData * pData)1355 void MetaTextRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1356 {
1357 MetaAction::Write(rOStm, pData);
1358 VersionCompatWrite aCompat(rOStm, 2);
1359 TypeSerializer aSerializer(rOStm);
1360 aSerializer.writeRectangle(maRect);
1361 rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet );
1362 rOStm.WriteUInt16( static_cast<sal_uInt16>(mnStyle) );
1363
1364 write_uInt16_lenPrefixed_uInt16s_FromOUString(rOStm, maStr); // version 2
1365 }
1366
Read(SvStream & rIStm,ImplMetaReadData * pData)1367 void MetaTextRectAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
1368 {
1369 VersionCompatRead aCompat(rIStm);
1370 TypeSerializer aSerializer(rIStm);
1371 aSerializer.readRectangle(maRect);
1372 maStr = rIStm.ReadUniOrByteString(pData->meActualCharSet);
1373 sal_uInt16 nTmp;
1374 rIStm .ReadUInt16( nTmp );
1375 mnStyle = static_cast<DrawTextFlags>(nTmp);
1376
1377 if ( aCompat.GetVersion() >= 2 ) // Version 2
1378 maStr = read_uInt16_lenPrefixed_uInt16s_ToOUString(rIStm);
1379 }
1380
MetaTextLineAction()1381 MetaTextLineAction::MetaTextLineAction() :
1382 MetaAction ( MetaActionType::TEXTLINE ),
1383 mnWidth ( 0 ),
1384 meStrikeout ( STRIKEOUT_NONE ),
1385 meUnderline ( LINESTYLE_NONE ),
1386 meOverline ( LINESTYLE_NONE )
1387 {}
1388
~MetaTextLineAction()1389 MetaTextLineAction::~MetaTextLineAction()
1390 {}
1391
MetaTextLineAction(const Point & rPos,tools::Long nWidth,FontStrikeout eStrikeout,FontLineStyle eUnderline,FontLineStyle eOverline)1392 MetaTextLineAction::MetaTextLineAction( const Point& rPos, tools::Long nWidth,
1393 FontStrikeout eStrikeout,
1394 FontLineStyle eUnderline,
1395 FontLineStyle eOverline ) :
1396 MetaAction ( MetaActionType::TEXTLINE ),
1397 maPos ( rPos ),
1398 mnWidth ( nWidth ),
1399 meStrikeout ( eStrikeout ),
1400 meUnderline ( eUnderline ),
1401 meOverline ( eOverline )
1402 {}
1403
Execute(OutputDevice * pOut)1404 void MetaTextLineAction::Execute( OutputDevice* pOut )
1405 {
1406 pOut->DrawTextLine( maPos, mnWidth, meStrikeout, meUnderline, meOverline );
1407 }
1408
Clone() const1409 rtl::Reference<MetaAction> MetaTextLineAction::Clone() const
1410 {
1411 return new MetaTextLineAction( *this );
1412 }
1413
Move(tools::Long nHorzMove,tools::Long nVertMove)1414 void MetaTextLineAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1415 {
1416 maPos.Move( nHorzMove, nVertMove );
1417 }
1418
Scale(double fScaleX,double fScaleY)1419 void MetaTextLineAction::Scale( double fScaleX, double fScaleY )
1420 {
1421 ImplScalePoint( maPos, fScaleX, fScaleY );
1422 mnWidth = FRound( mnWidth * fabs(fScaleX) );
1423 }
1424
Write(SvStream & rOStm,ImplMetaWriteData * pData)1425 void MetaTextLineAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1426 {
1427 MetaAction::Write(rOStm, pData);
1428 VersionCompatWrite aCompat(rOStm, 2);
1429
1430 TypeSerializer aSerializer(rOStm);
1431 aSerializer.writePoint(maPos);
1432
1433 rOStm.WriteInt32( mnWidth );
1434 rOStm.WriteUInt32( meStrikeout );
1435 rOStm.WriteUInt32( meUnderline );
1436 // new in version 2
1437 rOStm.WriteUInt32( meOverline );
1438 }
1439
Read(SvStream & rIStm,ImplMetaReadData *)1440 void MetaTextLineAction::Read( SvStream& rIStm, ImplMetaReadData* )
1441 {
1442 VersionCompatRead aCompat(rIStm);
1443
1444 sal_Int32 nTempWidth(0);
1445 TypeSerializer aSerializer(rIStm);
1446 aSerializer.readPoint(maPos);
1447 rIStm.ReadInt32(nTempWidth);
1448 mnWidth = nTempWidth;
1449
1450 sal_uInt32 nTempStrikeout(0);
1451 rIStm.ReadUInt32( nTempStrikeout );
1452 meStrikeout = static_cast<FontStrikeout>(nTempStrikeout);
1453
1454 sal_uInt32 nTempUnderline(0);
1455 rIStm.ReadUInt32( nTempUnderline );
1456 meUnderline = static_cast<FontLineStyle>(nTempUnderline);
1457
1458 if (aCompat.GetVersion() >= 2)
1459 {
1460 sal_uInt32 nTempOverline(0);
1461 rIStm.ReadUInt32(nTempOverline);
1462 meOverline = static_cast<FontLineStyle>(nTempOverline);
1463 }
1464 }
1465
MetaBmpAction()1466 MetaBmpAction::MetaBmpAction() :
1467 MetaAction(MetaActionType::BMP)
1468 {}
1469
~MetaBmpAction()1470 MetaBmpAction::~MetaBmpAction()
1471 {}
1472
MetaBmpAction(const Point & rPt,const Bitmap & rBmp)1473 MetaBmpAction::MetaBmpAction( const Point& rPt, const Bitmap& rBmp ) :
1474 MetaAction ( MetaActionType::BMP ),
1475 maBmp ( rBmp ),
1476 maPt ( rPt )
1477 {}
1478
Execute(OutputDevice * pOut)1479 void MetaBmpAction::Execute( OutputDevice* pOut )
1480 {
1481 pOut->DrawBitmap( maPt, maBmp );
1482 }
1483
Clone() const1484 rtl::Reference<MetaAction> MetaBmpAction::Clone() const
1485 {
1486 return new MetaBmpAction( *this );
1487 }
1488
Move(tools::Long nHorzMove,tools::Long nVertMove)1489 void MetaBmpAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1490 {
1491 maPt.Move( nHorzMove, nVertMove );
1492 }
1493
Scale(double fScaleX,double fScaleY)1494 void MetaBmpAction::Scale( double fScaleX, double fScaleY )
1495 {
1496 ImplScalePoint( maPt, fScaleX, fScaleY );
1497 }
1498
Write(SvStream & rOStm,ImplMetaWriteData * pData)1499 void MetaBmpAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1500 {
1501 if( !maBmp.IsEmpty() )
1502 {
1503 MetaAction::Write(rOStm, pData);
1504 VersionCompatWrite aCompat(rOStm, 1);
1505 WriteDIB(maBmp, rOStm, false, true);
1506 TypeSerializer aSerializer(rOStm);
1507 aSerializer.writePoint(maPt);
1508 }
1509 }
1510
Read(SvStream & rIStm,ImplMetaReadData *)1511 void MetaBmpAction::Read( SvStream& rIStm, ImplMetaReadData* )
1512 {
1513 VersionCompatRead aCompat(rIStm);
1514 ReadDIB(maBmp, rIStm, true);
1515 TypeSerializer aSerializer(rIStm);
1516 aSerializer.readPoint(maPt);
1517 }
1518
MetaBmpScaleAction()1519 MetaBmpScaleAction::MetaBmpScaleAction() :
1520 MetaAction(MetaActionType::BMPSCALE)
1521 {}
1522
~MetaBmpScaleAction()1523 MetaBmpScaleAction::~MetaBmpScaleAction()
1524 {}
1525
MetaBmpScaleAction(const Point & rPt,const Size & rSz,const Bitmap & rBmp)1526 MetaBmpScaleAction::MetaBmpScaleAction( const Point& rPt, const Size& rSz,
1527 const Bitmap& rBmp ) :
1528 MetaAction ( MetaActionType::BMPSCALE ),
1529 maBmp ( rBmp ),
1530 maPt ( rPt ),
1531 maSz ( rSz )
1532 {}
1533
Execute(OutputDevice * pOut)1534 void MetaBmpScaleAction::Execute( OutputDevice* pOut )
1535 {
1536 pOut->DrawBitmap( maPt, maSz, maBmp );
1537 }
1538
Clone() const1539 rtl::Reference<MetaAction> MetaBmpScaleAction::Clone() const
1540 {
1541 return new MetaBmpScaleAction( *this );
1542 }
1543
Move(tools::Long nHorzMove,tools::Long nVertMove)1544 void MetaBmpScaleAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1545 {
1546 maPt.Move( nHorzMove, nVertMove );
1547 }
1548
Scale(double fScaleX,double fScaleY)1549 void MetaBmpScaleAction::Scale( double fScaleX, double fScaleY )
1550 {
1551 tools::Rectangle aRectangle(maPt, maSz);
1552 ImplScaleRect( aRectangle, fScaleX, fScaleY );
1553 maPt = aRectangle.TopLeft();
1554 maSz = aRectangle.GetSize();
1555 }
1556
Write(SvStream & rOStm,ImplMetaWriteData * pData)1557 void MetaBmpScaleAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1558 {
1559 if( !maBmp.IsEmpty() )
1560 {
1561 MetaAction::Write(rOStm, pData);
1562 VersionCompatWrite aCompat(rOStm, 1);
1563 WriteDIB(maBmp, rOStm, false, true);
1564 TypeSerializer aSerializer(rOStm);
1565 aSerializer.writePoint(maPt);
1566 aSerializer.writeSize(maSz);
1567
1568 }
1569 }
1570
Read(SvStream & rIStm,ImplMetaReadData *)1571 void MetaBmpScaleAction::Read( SvStream& rIStm, ImplMetaReadData* )
1572 {
1573 VersionCompatRead aCompat(rIStm);
1574 ReadDIB(maBmp, rIStm, true);
1575 TypeSerializer aSerializer(rIStm);
1576 aSerializer.readPoint(maPt);
1577 aSerializer.readSize(maSz);
1578 }
1579
MetaBmpScalePartAction()1580 MetaBmpScalePartAction::MetaBmpScalePartAction() :
1581 MetaAction(MetaActionType::BMPSCALEPART)
1582 {}
1583
~MetaBmpScalePartAction()1584 MetaBmpScalePartAction::~MetaBmpScalePartAction()
1585 {}
1586
MetaBmpScalePartAction(const Point & rDstPt,const Size & rDstSz,const Point & rSrcPt,const Size & rSrcSz,const Bitmap & rBmp)1587 MetaBmpScalePartAction::MetaBmpScalePartAction( const Point& rDstPt, const Size& rDstSz,
1588 const Point& rSrcPt, const Size& rSrcSz,
1589 const Bitmap& rBmp ) :
1590 MetaAction ( MetaActionType::BMPSCALEPART ),
1591 maBmp ( rBmp ),
1592 maDstPt ( rDstPt ),
1593 maDstSz ( rDstSz ),
1594 maSrcPt ( rSrcPt ),
1595 maSrcSz ( rSrcSz )
1596 {}
1597
Execute(OutputDevice * pOut)1598 void MetaBmpScalePartAction::Execute( OutputDevice* pOut )
1599 {
1600 pOut->DrawBitmap( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmp );
1601 }
1602
Clone() const1603 rtl::Reference<MetaAction> MetaBmpScalePartAction::Clone() const
1604 {
1605 return new MetaBmpScalePartAction( *this );
1606 }
1607
Move(tools::Long nHorzMove,tools::Long nVertMove)1608 void MetaBmpScalePartAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1609 {
1610 maDstPt.Move( nHorzMove, nVertMove );
1611 }
1612
Scale(double fScaleX,double fScaleY)1613 void MetaBmpScalePartAction::Scale( double fScaleX, double fScaleY )
1614 {
1615 tools::Rectangle aRectangle(maDstPt, maDstSz);
1616 ImplScaleRect( aRectangle, fScaleX, fScaleY );
1617 maDstPt = aRectangle.TopLeft();
1618 maDstSz = aRectangle.GetSize();
1619 }
1620
Write(SvStream & rOStm,ImplMetaWriteData * pData)1621 void MetaBmpScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1622 {
1623 if( !maBmp.IsEmpty() )
1624 {
1625 MetaAction::Write(rOStm, pData);
1626 VersionCompatWrite aCompat(rOStm, 1);
1627 WriteDIB(maBmp, rOStm, false, true);
1628 TypeSerializer aSerializer(rOStm);
1629 aSerializer.writePoint(maDstPt);
1630 aSerializer.writeSize(maDstSz);
1631 aSerializer.writePoint(maSrcPt);
1632 aSerializer.writeSize(maSrcSz);
1633
1634 }
1635 }
1636
Read(SvStream & rIStm,ImplMetaReadData *)1637 void MetaBmpScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
1638 {
1639 VersionCompatRead aCompat(rIStm);
1640 ReadDIB(maBmp, rIStm, true);
1641 TypeSerializer aSerializer(rIStm);
1642 aSerializer.readPoint(maDstPt);
1643 aSerializer.readSize(maDstSz);
1644 aSerializer.readPoint(maSrcPt);
1645 aSerializer.readSize(maSrcSz);
1646 }
1647
MetaBmpExAction()1648 MetaBmpExAction::MetaBmpExAction() :
1649 MetaAction(MetaActionType::BMPEX)
1650 {}
1651
~MetaBmpExAction()1652 MetaBmpExAction::~MetaBmpExAction()
1653 {}
1654
MetaBmpExAction(const Point & rPt,const BitmapEx & rBmpEx)1655 MetaBmpExAction::MetaBmpExAction( const Point& rPt, const BitmapEx& rBmpEx ) :
1656 MetaAction ( MetaActionType::BMPEX ),
1657 maBmpEx ( rBmpEx ),
1658 maPt ( rPt )
1659 {}
1660
Execute(OutputDevice * pOut)1661 void MetaBmpExAction::Execute( OutputDevice* pOut )
1662 {
1663 pOut->DrawBitmapEx( maPt, maBmpEx );
1664 }
1665
Clone() const1666 rtl::Reference<MetaAction> MetaBmpExAction::Clone() const
1667 {
1668 return new MetaBmpExAction( *this );
1669 }
1670
Move(tools::Long nHorzMove,tools::Long nVertMove)1671 void MetaBmpExAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1672 {
1673 maPt.Move( nHorzMove, nVertMove );
1674 }
1675
Scale(double fScaleX,double fScaleY)1676 void MetaBmpExAction::Scale( double fScaleX, double fScaleY )
1677 {
1678 ImplScalePoint( maPt, fScaleX, fScaleY );
1679 }
1680
Write(SvStream & rOStm,ImplMetaWriteData * pData)1681 void MetaBmpExAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1682 {
1683 if( !maBmpEx.GetBitmap().IsEmpty() )
1684 {
1685 MetaAction::Write(rOStm, pData);
1686 VersionCompatWrite aCompat(rOStm, 1);
1687 WriteDIBBitmapEx(maBmpEx, rOStm);
1688 TypeSerializer aSerializer(rOStm);
1689 aSerializer.writePoint(maPt);
1690 }
1691 }
1692
Read(SvStream & rIStm,ImplMetaReadData *)1693 void MetaBmpExAction::Read( SvStream& rIStm, ImplMetaReadData* )
1694 {
1695 VersionCompatRead aCompat(rIStm);
1696 ReadDIBBitmapEx(maBmpEx, rIStm);
1697 TypeSerializer aSerializer(rIStm);
1698 aSerializer.readPoint(maPt);
1699 }
1700
MetaBmpExScaleAction()1701 MetaBmpExScaleAction::MetaBmpExScaleAction() :
1702 MetaAction(MetaActionType::BMPEXSCALE)
1703 {}
1704
~MetaBmpExScaleAction()1705 MetaBmpExScaleAction::~MetaBmpExScaleAction()
1706 {}
1707
MetaBmpExScaleAction(const Point & rPt,const Size & rSz,const BitmapEx & rBmpEx)1708 MetaBmpExScaleAction::MetaBmpExScaleAction( const Point& rPt, const Size& rSz,
1709 const BitmapEx& rBmpEx ) :
1710 MetaAction ( MetaActionType::BMPEXSCALE ),
1711 maBmpEx ( rBmpEx ),
1712 maPt ( rPt ),
1713 maSz ( rSz )
1714 {}
1715
Execute(OutputDevice * pOut)1716 void MetaBmpExScaleAction::Execute( OutputDevice* pOut )
1717 {
1718 pOut->DrawBitmapEx( maPt, maSz, maBmpEx );
1719 }
1720
Clone() const1721 rtl::Reference<MetaAction> MetaBmpExScaleAction::Clone() const
1722 {
1723 return new MetaBmpExScaleAction( *this );
1724 }
1725
Move(tools::Long nHorzMove,tools::Long nVertMove)1726 void MetaBmpExScaleAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1727 {
1728 maPt.Move( nHorzMove, nVertMove );
1729 }
1730
Scale(double fScaleX,double fScaleY)1731 void MetaBmpExScaleAction::Scale( double fScaleX, double fScaleY )
1732 {
1733 tools::Rectangle aRectangle(maPt, maSz);
1734 ImplScaleRect( aRectangle, fScaleX, fScaleY );
1735 maPt = aRectangle.TopLeft();
1736 maSz = aRectangle.GetSize();
1737 }
1738
Write(SvStream & rOStm,ImplMetaWriteData * pData)1739 void MetaBmpExScaleAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1740 {
1741 if( !maBmpEx.GetBitmap().IsEmpty() )
1742 {
1743 MetaAction::Write(rOStm, pData);
1744 VersionCompatWrite aCompat(rOStm, 1);
1745 WriteDIBBitmapEx(maBmpEx, rOStm);
1746 TypeSerializer aSerializer(rOStm);
1747 aSerializer.writePoint(maPt);
1748 aSerializer.writeSize(maSz);
1749 }
1750 }
1751
Read(SvStream & rIStm,ImplMetaReadData *)1752 void MetaBmpExScaleAction::Read( SvStream& rIStm, ImplMetaReadData* )
1753 {
1754 VersionCompatRead aCompat(rIStm);
1755 ReadDIBBitmapEx(maBmpEx, rIStm);
1756 TypeSerializer aSerializer(rIStm);
1757 aSerializer.readPoint(maPt);
1758 aSerializer.readSize(maSz);
1759 }
1760
MetaBmpExScalePartAction()1761 MetaBmpExScalePartAction::MetaBmpExScalePartAction() :
1762 MetaAction(MetaActionType::BMPEXSCALEPART)
1763 {}
1764
~MetaBmpExScalePartAction()1765 MetaBmpExScalePartAction::~MetaBmpExScalePartAction()
1766 {}
1767
MetaBmpExScalePartAction(const Point & rDstPt,const Size & rDstSz,const Point & rSrcPt,const Size & rSrcSz,const BitmapEx & rBmpEx)1768 MetaBmpExScalePartAction::MetaBmpExScalePartAction( const Point& rDstPt, const Size& rDstSz,
1769 const Point& rSrcPt, const Size& rSrcSz,
1770 const BitmapEx& rBmpEx ) :
1771 MetaAction ( MetaActionType::BMPEXSCALEPART ),
1772 maBmpEx ( rBmpEx ),
1773 maDstPt ( rDstPt ),
1774 maDstSz ( rDstSz ),
1775 maSrcPt ( rSrcPt ),
1776 maSrcSz ( rSrcSz )
1777 {}
1778
Execute(OutputDevice * pOut)1779 void MetaBmpExScalePartAction::Execute( OutputDevice* pOut )
1780 {
1781 pOut->DrawBitmapEx( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmpEx );
1782 }
1783
Clone() const1784 rtl::Reference<MetaAction> MetaBmpExScalePartAction::Clone() const
1785 {
1786 return new MetaBmpExScalePartAction( *this );
1787 }
1788
Move(tools::Long nHorzMove,tools::Long nVertMove)1789 void MetaBmpExScalePartAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1790 {
1791 maDstPt.Move( nHorzMove, nVertMove );
1792 }
1793
Scale(double fScaleX,double fScaleY)1794 void MetaBmpExScalePartAction::Scale( double fScaleX, double fScaleY )
1795 {
1796 tools::Rectangle aRectangle(maDstPt, maDstSz);
1797 ImplScaleRect( aRectangle, fScaleX, fScaleY );
1798 maDstPt = aRectangle.TopLeft();
1799 maDstSz = aRectangle.GetSize();
1800 }
1801
Write(SvStream & rOStm,ImplMetaWriteData * pData)1802 void MetaBmpExScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1803 {
1804 if( !maBmpEx.GetBitmap().IsEmpty() )
1805 {
1806 MetaAction::Write(rOStm, pData);
1807 VersionCompatWrite aCompat(rOStm, 1);
1808 WriteDIBBitmapEx(maBmpEx, rOStm);
1809 TypeSerializer aSerializer(rOStm);
1810 aSerializer.writePoint(maDstPt);
1811 aSerializer.writeSize(maDstSz);
1812 aSerializer.writePoint(maSrcPt);
1813 aSerializer.writeSize(maSrcSz);
1814 }
1815 }
1816
Read(SvStream & rIStm,ImplMetaReadData *)1817 void MetaBmpExScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
1818 {
1819 VersionCompatRead aCompat(rIStm);
1820 ReadDIBBitmapEx(maBmpEx, rIStm);
1821 TypeSerializer aSerializer(rIStm);
1822 aSerializer.readPoint(maDstPt);
1823 aSerializer.readSize(maDstSz);
1824 aSerializer.readPoint(maSrcPt);
1825 aSerializer.readSize(maSrcSz);
1826 }
1827
MetaMaskAction()1828 MetaMaskAction::MetaMaskAction() :
1829 MetaAction(MetaActionType::MASK)
1830 {}
1831
~MetaMaskAction()1832 MetaMaskAction::~MetaMaskAction()
1833 {}
1834
MetaMaskAction(const Point & rPt,const Bitmap & rBmp,const Color & rColor)1835 MetaMaskAction::MetaMaskAction( const Point& rPt,
1836 const Bitmap& rBmp,
1837 const Color& rColor ) :
1838 MetaAction ( MetaActionType::MASK ),
1839 maBmp ( rBmp ),
1840 maColor ( rColor ),
1841 maPt ( rPt )
1842 {}
1843
Execute(OutputDevice * pOut)1844 void MetaMaskAction::Execute( OutputDevice* pOut )
1845 {
1846 pOut->DrawMask( maPt, maBmp, maColor );
1847 }
1848
Clone() const1849 rtl::Reference<MetaAction> MetaMaskAction::Clone() const
1850 {
1851 return new MetaMaskAction( *this );
1852 }
1853
Move(tools::Long nHorzMove,tools::Long nVertMove)1854 void MetaMaskAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1855 {
1856 maPt.Move( nHorzMove, nVertMove );
1857 }
1858
Scale(double fScaleX,double fScaleY)1859 void MetaMaskAction::Scale( double fScaleX, double fScaleY )
1860 {
1861 ImplScalePoint( maPt, fScaleX, fScaleY );
1862 }
1863
Write(SvStream & rOStm,ImplMetaWriteData * pData)1864 void MetaMaskAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1865 {
1866 if( !maBmp.IsEmpty() )
1867 {
1868 MetaAction::Write(rOStm, pData);
1869 VersionCompatWrite aCompat(rOStm, 1);
1870 WriteDIB(maBmp, rOStm, false, true);
1871 TypeSerializer aSerializer(rOStm);
1872 aSerializer.writePoint(maPt);
1873 }
1874 }
1875
Read(SvStream & rIStm,ImplMetaReadData *)1876 void MetaMaskAction::Read( SvStream& rIStm, ImplMetaReadData* )
1877 {
1878 VersionCompatRead aCompat(rIStm);
1879 ReadDIB(maBmp, rIStm, true);
1880 TypeSerializer aSerializer(rIStm);
1881 aSerializer.readPoint(maPt);
1882 }
1883
MetaMaskScaleAction()1884 MetaMaskScaleAction::MetaMaskScaleAction() :
1885 MetaAction(MetaActionType::MASKSCALE)
1886 {}
1887
~MetaMaskScaleAction()1888 MetaMaskScaleAction::~MetaMaskScaleAction()
1889 {}
1890
MetaMaskScaleAction(const Point & rPt,const Size & rSz,const Bitmap & rBmp,const Color & rColor)1891 MetaMaskScaleAction::MetaMaskScaleAction( const Point& rPt, const Size& rSz,
1892 const Bitmap& rBmp,
1893 const Color& rColor ) :
1894 MetaAction ( MetaActionType::MASKSCALE ),
1895 maBmp ( rBmp ),
1896 maColor ( rColor ),
1897 maPt ( rPt ),
1898 maSz ( rSz )
1899 {}
1900
Execute(OutputDevice * pOut)1901 void MetaMaskScaleAction::Execute( OutputDevice* pOut )
1902 {
1903 pOut->DrawMask( maPt, maSz, maBmp, maColor );
1904 }
1905
Clone() const1906 rtl::Reference<MetaAction> MetaMaskScaleAction::Clone() const
1907 {
1908 return new MetaMaskScaleAction( *this );
1909 }
1910
Move(tools::Long nHorzMove,tools::Long nVertMove)1911 void MetaMaskScaleAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1912 {
1913 maPt.Move( nHorzMove, nVertMove );
1914 }
1915
Scale(double fScaleX,double fScaleY)1916 void MetaMaskScaleAction::Scale( double fScaleX, double fScaleY )
1917 {
1918 tools::Rectangle aRectangle(maPt, maSz);
1919 ImplScaleRect( aRectangle, fScaleX, fScaleY );
1920 maPt = aRectangle.TopLeft();
1921 maSz = aRectangle.GetSize();
1922 }
1923
Write(SvStream & rOStm,ImplMetaWriteData * pData)1924 void MetaMaskScaleAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1925 {
1926 if( !maBmp.IsEmpty() )
1927 {
1928 MetaAction::Write(rOStm, pData);
1929 VersionCompatWrite aCompat(rOStm, 1);
1930 WriteDIB(maBmp, rOStm, false, true);
1931 TypeSerializer aSerializer(rOStm);
1932 aSerializer.writePoint(maPt);
1933 aSerializer.writeSize(maSz);
1934 }
1935 }
1936
Read(SvStream & rIStm,ImplMetaReadData *)1937 void MetaMaskScaleAction::Read( SvStream& rIStm, ImplMetaReadData* )
1938 {
1939 VersionCompatRead aCompat(rIStm);
1940 ReadDIB(maBmp, rIStm, true);
1941 TypeSerializer aSerializer(rIStm);
1942 aSerializer.readPoint(maPt);
1943 aSerializer.readSize(maSz);
1944 }
1945
MetaMaskScalePartAction()1946 MetaMaskScalePartAction::MetaMaskScalePartAction() :
1947 MetaAction(MetaActionType::MASKSCALEPART)
1948 {}
1949
~MetaMaskScalePartAction()1950 MetaMaskScalePartAction::~MetaMaskScalePartAction()
1951 {}
1952
MetaMaskScalePartAction(const Point & rDstPt,const Size & rDstSz,const Point & rSrcPt,const Size & rSrcSz,const Bitmap & rBmp,const Color & rColor)1953 MetaMaskScalePartAction::MetaMaskScalePartAction( const Point& rDstPt, const Size& rDstSz,
1954 const Point& rSrcPt, const Size& rSrcSz,
1955 const Bitmap& rBmp,
1956 const Color& rColor ) :
1957 MetaAction ( MetaActionType::MASKSCALEPART ),
1958 maBmp ( rBmp ),
1959 maColor ( rColor ),
1960 maDstPt ( rDstPt ),
1961 maDstSz ( rDstSz ),
1962 maSrcPt ( rSrcPt ),
1963 maSrcSz ( rSrcSz )
1964 {}
1965
Execute(OutputDevice * pOut)1966 void MetaMaskScalePartAction::Execute( OutputDevice* pOut )
1967 {
1968 pOut->DrawMask( maDstPt, maDstSz, maSrcPt, maSrcSz, maBmp, maColor, MetaActionType::MASKSCALE );
1969 }
1970
Clone() const1971 rtl::Reference<MetaAction> MetaMaskScalePartAction::Clone() const
1972 {
1973 return new MetaMaskScalePartAction( *this );
1974 }
1975
Move(tools::Long nHorzMove,tools::Long nVertMove)1976 void MetaMaskScalePartAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
1977 {
1978 maDstPt.Move( nHorzMove, nVertMove );
1979 }
1980
Scale(double fScaleX,double fScaleY)1981 void MetaMaskScalePartAction::Scale( double fScaleX, double fScaleY )
1982 {
1983 tools::Rectangle aRectangle(maDstPt, maDstSz);
1984 ImplScaleRect( aRectangle, fScaleX, fScaleY );
1985 maDstPt = aRectangle.TopLeft();
1986 maDstSz = aRectangle.GetSize();
1987 }
1988
Write(SvStream & rOStm,ImplMetaWriteData * pData)1989 void MetaMaskScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
1990 {
1991 if( !maBmp.IsEmpty() )
1992 {
1993 MetaAction::Write(rOStm, pData);
1994 VersionCompatWrite aCompat(rOStm, 1);
1995 WriteDIB(maBmp, rOStm, false, true);
1996 WriteColor(rOStm, maColor);
1997 TypeSerializer aSerializer(rOStm);
1998 aSerializer.writePoint(maDstPt);
1999 aSerializer.writeSize(maDstSz);
2000 aSerializer.writePoint(maSrcPt);
2001 aSerializer.writeSize(maSrcSz);
2002 }
2003 }
2004
Read(SvStream & rIStm,ImplMetaReadData *)2005 void MetaMaskScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
2006 {
2007 VersionCompatRead aCompat(rIStm);
2008 ReadDIB(maBmp, rIStm, true);
2009 ReadColor(rIStm, maColor);
2010 TypeSerializer aSerializer(rIStm);
2011 aSerializer.readPoint(maDstPt);
2012 aSerializer.readSize(maDstSz);
2013 aSerializer.readPoint(maSrcPt);
2014 aSerializer.readSize(maSrcSz);
2015 }
2016
MetaGradientAction()2017 MetaGradientAction::MetaGradientAction() :
2018 MetaAction(MetaActionType::GRADIENT)
2019 {}
2020
~MetaGradientAction()2021 MetaGradientAction::~MetaGradientAction()
2022 {}
2023
MetaGradientAction(const tools::Rectangle & rRect,const Gradient & rGradient)2024 MetaGradientAction::MetaGradientAction( const tools::Rectangle& rRect, const Gradient& rGradient ) :
2025 MetaAction ( MetaActionType::GRADIENT ),
2026 maRect ( rRect ),
2027 maGradient ( rGradient )
2028 {}
2029
Execute(OutputDevice * pOut)2030 void MetaGradientAction::Execute( OutputDevice* pOut )
2031 {
2032 pOut->DrawGradient( maRect, maGradient );
2033 }
2034
Clone() const2035 rtl::Reference<MetaAction> MetaGradientAction::Clone() const
2036 {
2037 return new MetaGradientAction( *this );
2038 }
2039
Move(tools::Long nHorzMove,tools::Long nVertMove)2040 void MetaGradientAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
2041 {
2042 maRect.Move( nHorzMove, nVertMove );
2043 }
2044
Scale(double fScaleX,double fScaleY)2045 void MetaGradientAction::Scale( double fScaleX, double fScaleY )
2046 {
2047 ImplScaleRect( maRect, fScaleX, fScaleY );
2048 }
2049
Write(SvStream & rOStm,ImplMetaWriteData * pData)2050 void MetaGradientAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2051 {
2052 MetaAction::Write(rOStm, pData);
2053 VersionCompatWrite aCompat(rOStm, 1);
2054 TypeSerializer aSerializer(rOStm);
2055 aSerializer.writeRectangle(maRect);
2056 aSerializer.writeGradient(maGradient);
2057 }
2058
Read(SvStream & rIStm,ImplMetaReadData *)2059 void MetaGradientAction::Read( SvStream& rIStm, ImplMetaReadData* )
2060 {
2061 VersionCompatRead aCompat(rIStm);
2062 TypeSerializer aSerializer(rIStm);
2063 aSerializer.readRectangle(maRect);
2064 aSerializer.readGradient(maGradient);
2065 }
2066
MetaGradientExAction()2067 MetaGradientExAction::MetaGradientExAction() :
2068 MetaAction ( MetaActionType::GRADIENTEX )
2069 {}
2070
MetaGradientExAction(const tools::PolyPolygon & rPolyPoly,const Gradient & rGradient)2071 MetaGradientExAction::MetaGradientExAction( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ) :
2072 MetaAction ( MetaActionType::GRADIENTEX ),
2073 maPolyPoly ( rPolyPoly ),
2074 maGradient ( rGradient )
2075 {}
2076
~MetaGradientExAction()2077 MetaGradientExAction::~MetaGradientExAction()
2078 {}
2079
Execute(OutputDevice * pOut)2080 void MetaGradientExAction::Execute( OutputDevice* pOut )
2081 {
2082 if( pOut->GetConnectMetaFile() )
2083 {
2084 pOut->GetConnectMetaFile()->AddAction( this );
2085 }
2086 }
2087
Clone() const2088 rtl::Reference<MetaAction> MetaGradientExAction::Clone() const
2089 {
2090 return new MetaGradientExAction( *this );
2091 }
2092
Move(tools::Long nHorzMove,tools::Long nVertMove)2093 void MetaGradientExAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
2094 {
2095 maPolyPoly.Move( nHorzMove, nVertMove );
2096 }
2097
Scale(double fScaleX,double fScaleY)2098 void MetaGradientExAction::Scale( double fScaleX, double fScaleY )
2099 {
2100 for( sal_uInt16 i = 0, nCount = maPolyPoly.Count(); i < nCount; i++ )
2101 ImplScalePoly( maPolyPoly[ i ], fScaleX, fScaleY );
2102 }
2103
Write(SvStream & rOStm,ImplMetaWriteData * pData)2104 void MetaGradientExAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2105 {
2106 MetaAction::Write(rOStm, pData);
2107 VersionCompatWrite aCompat(rOStm, 1);
2108
2109 // #i105373# see comment at MetaTransparentAction::Write
2110 tools::PolyPolygon aNoCurvePolyPolygon;
2111 maPolyPoly.AdaptiveSubdivide(aNoCurvePolyPolygon);
2112
2113 WritePolyPolygon( rOStm, aNoCurvePolyPolygon );
2114 TypeSerializer aSerializer(rOStm);
2115 aSerializer.writeGradient(maGradient);
2116 }
2117
Read(SvStream & rIStm,ImplMetaReadData *)2118 void MetaGradientExAction::Read( SvStream& rIStm, ImplMetaReadData* )
2119 {
2120 VersionCompatRead aCompat(rIStm);
2121 ReadPolyPolygon( rIStm, maPolyPoly );
2122 TypeSerializer aSerializer(rIStm);
2123 aSerializer.readGradient(maGradient);
2124 }
2125
MetaHatchAction()2126 MetaHatchAction::MetaHatchAction() :
2127 MetaAction(MetaActionType::HATCH)
2128 {}
2129
~MetaHatchAction()2130 MetaHatchAction::~MetaHatchAction()
2131 {}
2132
MetaHatchAction(const tools::PolyPolygon & rPolyPoly,const Hatch & rHatch)2133 MetaHatchAction::MetaHatchAction( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch ) :
2134 MetaAction ( MetaActionType::HATCH ),
2135 maPolyPoly ( rPolyPoly ),
2136 maHatch ( rHatch )
2137 {}
2138
Execute(OutputDevice * pOut)2139 void MetaHatchAction::Execute( OutputDevice* pOut )
2140 {
2141 pOut->DrawHatch( maPolyPoly, maHatch );
2142 }
2143
Clone() const2144 rtl::Reference<MetaAction> MetaHatchAction::Clone() const
2145 {
2146 return new MetaHatchAction( *this );
2147 }
2148
Move(tools::Long nHorzMove,tools::Long nVertMove)2149 void MetaHatchAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
2150 {
2151 maPolyPoly.Move( nHorzMove, nVertMove );
2152 }
2153
Scale(double fScaleX,double fScaleY)2154 void MetaHatchAction::Scale( double fScaleX, double fScaleY )
2155 {
2156 for( sal_uInt16 i = 0, nCount = maPolyPoly.Count(); i < nCount; i++ )
2157 ImplScalePoly( maPolyPoly[ i ], fScaleX, fScaleY );
2158 }
2159
Write(SvStream & rOStm,ImplMetaWriteData * pData)2160 void MetaHatchAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2161 {
2162 MetaAction::Write(rOStm, pData);
2163 VersionCompatWrite aCompat(rOStm, 1);
2164
2165 // #i105373# see comment at MetaTransparentAction::Write
2166 tools::PolyPolygon aNoCurvePolyPolygon;
2167 maPolyPoly.AdaptiveSubdivide(aNoCurvePolyPolygon);
2168
2169 WritePolyPolygon( rOStm, aNoCurvePolyPolygon );
2170 WriteHatch( rOStm, maHatch );
2171 }
2172
Read(SvStream & rIStm,ImplMetaReadData *)2173 void MetaHatchAction::Read( SvStream& rIStm, ImplMetaReadData* )
2174 {
2175 VersionCompatRead aCompat(rIStm);
2176 ReadPolyPolygon( rIStm, maPolyPoly );
2177 ReadHatch( rIStm, maHatch );
2178 }
2179
MetaWallpaperAction()2180 MetaWallpaperAction::MetaWallpaperAction() :
2181 MetaAction(MetaActionType::WALLPAPER)
2182 {}
2183
~MetaWallpaperAction()2184 MetaWallpaperAction::~MetaWallpaperAction()
2185 {}
2186
MetaWallpaperAction(const tools::Rectangle & rRect,const Wallpaper & rPaper)2187 MetaWallpaperAction::MetaWallpaperAction( const tools::Rectangle& rRect,
2188 const Wallpaper& rPaper ) :
2189 MetaAction ( MetaActionType::WALLPAPER ),
2190 maRect ( rRect ),
2191 maWallpaper ( rPaper )
2192 {}
2193
Execute(OutputDevice * pOut)2194 void MetaWallpaperAction::Execute( OutputDevice* pOut )
2195 {
2196 pOut->DrawWallpaper( maRect, maWallpaper );
2197 }
2198
Clone() const2199 rtl::Reference<MetaAction> MetaWallpaperAction::Clone() const
2200 {
2201 return new MetaWallpaperAction( *this );
2202 }
2203
Move(tools::Long nHorzMove,tools::Long nVertMove)2204 void MetaWallpaperAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
2205 {
2206 maRect.Move( nHorzMove, nVertMove );
2207 }
2208
Scale(double fScaleX,double fScaleY)2209 void MetaWallpaperAction::Scale( double fScaleX, double fScaleY )
2210 {
2211 ImplScaleRect( maRect, fScaleX, fScaleY );
2212 }
2213
Write(SvStream & rOStm,ImplMetaWriteData * pData)2214 void MetaWallpaperAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2215 {
2216 MetaAction::Write(rOStm, pData);
2217 VersionCompatWrite aCompat(rOStm, 1);
2218
2219 WriteWallpaper( rOStm, maWallpaper );
2220 }
2221
Read(SvStream & rIStm,ImplMetaReadData *)2222 void MetaWallpaperAction::Read( SvStream& rIStm, ImplMetaReadData* )
2223 {
2224 VersionCompatRead aCompat(rIStm);
2225 ReadWallpaper( rIStm, maWallpaper );
2226 }
2227
MetaClipRegionAction()2228 MetaClipRegionAction::MetaClipRegionAction() :
2229 MetaAction ( MetaActionType::CLIPREGION ),
2230 mbClip ( false )
2231 {}
2232
~MetaClipRegionAction()2233 MetaClipRegionAction::~MetaClipRegionAction()
2234 {}
2235
MetaClipRegionAction(const vcl::Region & rRegion,bool bClip)2236 MetaClipRegionAction::MetaClipRegionAction( const vcl::Region& rRegion, bool bClip ) :
2237 MetaAction ( MetaActionType::CLIPREGION ),
2238 maRegion ( rRegion ),
2239 mbClip ( bClip )
2240 {}
2241
Execute(OutputDevice * pOut)2242 void MetaClipRegionAction::Execute( OutputDevice* pOut )
2243 {
2244 if( mbClip )
2245 pOut->SetClipRegion( maRegion );
2246 else
2247 pOut->SetClipRegion();
2248 }
2249
Clone() const2250 rtl::Reference<MetaAction> MetaClipRegionAction::Clone() const
2251 {
2252 return new MetaClipRegionAction( *this );
2253 }
2254
Move(tools::Long nHorzMove,tools::Long nVertMove)2255 void MetaClipRegionAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
2256 {
2257 maRegion.Move( nHorzMove, nVertMove );
2258 }
2259
Scale(double fScaleX,double fScaleY)2260 void MetaClipRegionAction::Scale( double fScaleX, double fScaleY )
2261 {
2262 maRegion.Scale( fScaleX, fScaleY );
2263 }
2264
Write(SvStream & rOStm,ImplMetaWriteData * pData)2265 void MetaClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2266 {
2267 MetaAction::Write(rOStm, pData);
2268 VersionCompatWrite aCompat(rOStm, 1);
2269
2270 WriteRegion( rOStm, maRegion );
2271 rOStm.WriteBool( mbClip );
2272 }
2273
Read(SvStream & rIStm,ImplMetaReadData *)2274 void MetaClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
2275 {
2276 VersionCompatRead aCompat(rIStm);
2277 ReadRegion( rIStm, maRegion );
2278 rIStm.ReadCharAsBool( mbClip );
2279 }
2280
MetaISectRectClipRegionAction()2281 MetaISectRectClipRegionAction::MetaISectRectClipRegionAction() :
2282 MetaAction(MetaActionType::ISECTRECTCLIPREGION)
2283 {}
2284
~MetaISectRectClipRegionAction()2285 MetaISectRectClipRegionAction::~MetaISectRectClipRegionAction()
2286 {}
2287
MetaISectRectClipRegionAction(const tools::Rectangle & rRect)2288 MetaISectRectClipRegionAction::MetaISectRectClipRegionAction( const tools::Rectangle& rRect ) :
2289 MetaAction ( MetaActionType::ISECTRECTCLIPREGION ),
2290 maRect ( rRect )
2291 {}
2292
Execute(OutputDevice * pOut)2293 void MetaISectRectClipRegionAction::Execute( OutputDevice* pOut )
2294 {
2295 pOut->IntersectClipRegion( maRect );
2296 }
2297
Clone() const2298 rtl::Reference<MetaAction> MetaISectRectClipRegionAction::Clone() const
2299 {
2300 return new MetaISectRectClipRegionAction( *this );
2301 }
2302
Move(tools::Long nHorzMove,tools::Long nVertMove)2303 void MetaISectRectClipRegionAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
2304 {
2305 maRect.Move( nHorzMove, nVertMove );
2306 }
2307
Scale(double fScaleX,double fScaleY)2308 void MetaISectRectClipRegionAction::Scale( double fScaleX, double fScaleY )
2309 {
2310 ImplScaleRect( maRect, fScaleX, fScaleY );
2311 }
2312
Write(SvStream & rOStm,ImplMetaWriteData * pData)2313 void MetaISectRectClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2314 {
2315 MetaAction::Write(rOStm, pData);
2316 VersionCompatWrite aCompat(rOStm, 1);
2317 TypeSerializer aSerializer(rOStm);
2318 aSerializer.writeRectangle(maRect);
2319 }
2320
Read(SvStream & rIStm,ImplMetaReadData *)2321 void MetaISectRectClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
2322 {
2323 VersionCompatRead aCompat(rIStm);
2324 TypeSerializer aSerializer(rIStm);
2325 aSerializer.readRectangle(maRect);
2326 }
2327
MetaISectRegionClipRegionAction()2328 MetaISectRegionClipRegionAction::MetaISectRegionClipRegionAction() :
2329 MetaAction(MetaActionType::ISECTREGIONCLIPREGION)
2330 {}
2331
~MetaISectRegionClipRegionAction()2332 MetaISectRegionClipRegionAction::~MetaISectRegionClipRegionAction()
2333 {}
2334
MetaISectRegionClipRegionAction(const vcl::Region & rRegion)2335 MetaISectRegionClipRegionAction::MetaISectRegionClipRegionAction( const vcl::Region& rRegion ) :
2336 MetaAction ( MetaActionType::ISECTREGIONCLIPREGION ),
2337 maRegion ( rRegion )
2338 {
2339 }
2340
Execute(OutputDevice * pOut)2341 void MetaISectRegionClipRegionAction::Execute( OutputDevice* pOut )
2342 {
2343 pOut->IntersectClipRegion( maRegion );
2344 }
2345
Clone() const2346 rtl::Reference<MetaAction> MetaISectRegionClipRegionAction::Clone() const
2347 {
2348 return new MetaISectRegionClipRegionAction( *this );
2349 }
2350
Move(tools::Long nHorzMove,tools::Long nVertMove)2351 void MetaISectRegionClipRegionAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
2352 {
2353 maRegion.Move( nHorzMove, nVertMove );
2354 }
2355
Scale(double fScaleX,double fScaleY)2356 void MetaISectRegionClipRegionAction::Scale( double fScaleX, double fScaleY )
2357 {
2358 maRegion.Scale( fScaleX, fScaleY );
2359 }
2360
Write(SvStream & rOStm,ImplMetaWriteData * pData)2361 void MetaISectRegionClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2362 {
2363 MetaAction::Write(rOStm, pData);
2364 VersionCompatWrite aCompat(rOStm, 1);
2365 WriteRegion( rOStm, maRegion );
2366 }
2367
Read(SvStream & rIStm,ImplMetaReadData *)2368 void MetaISectRegionClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
2369 {
2370 VersionCompatRead aCompat(rIStm);
2371 ReadRegion( rIStm, maRegion );
2372 }
2373
MetaMoveClipRegionAction()2374 MetaMoveClipRegionAction::MetaMoveClipRegionAction() :
2375 MetaAction ( MetaActionType::MOVECLIPREGION ),
2376 mnHorzMove ( 0 ),
2377 mnVertMove ( 0 )
2378 {}
2379
~MetaMoveClipRegionAction()2380 MetaMoveClipRegionAction::~MetaMoveClipRegionAction()
2381 {}
2382
MetaMoveClipRegionAction(tools::Long nHorzMove,tools::Long nVertMove)2383 MetaMoveClipRegionAction::MetaMoveClipRegionAction( tools::Long nHorzMove, tools::Long nVertMove ) :
2384 MetaAction ( MetaActionType::MOVECLIPREGION ),
2385 mnHorzMove ( nHorzMove ),
2386 mnVertMove ( nVertMove )
2387 {}
2388
Execute(OutputDevice * pOut)2389 void MetaMoveClipRegionAction::Execute( OutputDevice* pOut )
2390 {
2391 pOut->MoveClipRegion( mnHorzMove, mnVertMove );
2392 }
2393
Clone() const2394 rtl::Reference<MetaAction> MetaMoveClipRegionAction::Clone() const
2395 {
2396 return new MetaMoveClipRegionAction( *this );
2397 }
2398
Scale(double fScaleX,double fScaleY)2399 void MetaMoveClipRegionAction::Scale( double fScaleX, double fScaleY )
2400 {
2401 mnHorzMove = FRound( mnHorzMove * fScaleX );
2402 mnVertMove = FRound( mnVertMove * fScaleY );
2403 }
2404
Write(SvStream & rOStm,ImplMetaWriteData * pData)2405 void MetaMoveClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2406 {
2407 MetaAction::Write(rOStm, pData);
2408 VersionCompatWrite aCompat(rOStm, 1);
2409 rOStm.WriteInt32( mnHorzMove ).WriteInt32( mnVertMove );
2410 }
2411
Read(SvStream & rIStm,ImplMetaReadData *)2412 void MetaMoveClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
2413 {
2414 VersionCompatRead aCompat(rIStm);
2415 sal_Int32 nTmpHM(0), nTmpVM(0);
2416 rIStm.ReadInt32( nTmpHM ).ReadInt32( nTmpVM );
2417 mnHorzMove = nTmpHM;
2418 mnVertMove = nTmpVM;
2419 }
2420
MetaLineColorAction()2421 MetaLineColorAction::MetaLineColorAction() :
2422 MetaAction ( MetaActionType::LINECOLOR ),
2423 mbSet ( false )
2424 {}
2425
~MetaLineColorAction()2426 MetaLineColorAction::~MetaLineColorAction()
2427 {}
2428
MetaLineColorAction(const Color & rColor,bool bSet)2429 MetaLineColorAction::MetaLineColorAction( const Color& rColor, bool bSet ) :
2430 MetaAction ( MetaActionType::LINECOLOR ),
2431 maColor ( rColor ),
2432 mbSet ( bSet )
2433 {}
2434
Execute(OutputDevice * pOut)2435 void MetaLineColorAction::Execute( OutputDevice* pOut )
2436 {
2437 if( mbSet )
2438 pOut->SetLineColor( maColor );
2439 else
2440 pOut->SetLineColor();
2441 }
2442
Clone() const2443 rtl::Reference<MetaAction> MetaLineColorAction::Clone() const
2444 {
2445 return new MetaLineColorAction( *this );
2446 }
2447
Write(SvStream & rOStm,ImplMetaWriteData * pData)2448 void MetaLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2449 {
2450 MetaAction::Write(rOStm, pData);
2451 VersionCompatWrite aCompat(rOStm, 1);
2452 WriteColor(rOStm, maColor);
2453 rOStm.WriteBool( mbSet );
2454 }
2455
Read(SvStream & rIStm,ImplMetaReadData *)2456 void MetaLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
2457 {
2458 VersionCompatRead aCompat(rIStm);
2459 ReadColor(rIStm, maColor);
2460 rIStm.ReadCharAsBool( mbSet );
2461 }
2462
MetaFillColorAction()2463 MetaFillColorAction::MetaFillColorAction() :
2464 MetaAction ( MetaActionType::FILLCOLOR ),
2465 mbSet ( false )
2466 {}
2467
~MetaFillColorAction()2468 MetaFillColorAction::~MetaFillColorAction()
2469 {}
2470
MetaFillColorAction(const Color & rColor,bool bSet)2471 MetaFillColorAction::MetaFillColorAction( const Color& rColor, bool bSet ) :
2472 MetaAction ( MetaActionType::FILLCOLOR ),
2473 maColor ( rColor ),
2474 mbSet ( bSet )
2475 {}
2476
Execute(OutputDevice * pOut)2477 void MetaFillColorAction::Execute( OutputDevice* pOut )
2478 {
2479 if( mbSet )
2480 pOut->SetFillColor( maColor );
2481 else
2482 pOut->SetFillColor();
2483 }
2484
Clone() const2485 rtl::Reference<MetaAction> MetaFillColorAction::Clone() const
2486 {
2487 return new MetaFillColorAction( *this );
2488 }
2489
Write(SvStream & rOStm,ImplMetaWriteData * pData)2490 void MetaFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2491 {
2492 MetaAction::Write(rOStm, pData);
2493 VersionCompatWrite aCompat(rOStm, 1);
2494 WriteColor(rOStm, maColor);
2495 rOStm.WriteBool( mbSet );
2496 }
2497
Read(SvStream & rIStm,ImplMetaReadData *)2498 void MetaFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
2499 {
2500 VersionCompatRead aCompat(rIStm);
2501 ReadColor(rIStm, maColor);
2502 rIStm.ReadCharAsBool( mbSet );
2503 }
2504
MetaTextColorAction()2505 MetaTextColorAction::MetaTextColorAction() :
2506 MetaAction(MetaActionType::TEXTCOLOR)
2507 {}
2508
~MetaTextColorAction()2509 MetaTextColorAction::~MetaTextColorAction()
2510 {}
2511
MetaTextColorAction(const Color & rColor)2512 MetaTextColorAction::MetaTextColorAction( const Color& rColor ) :
2513 MetaAction ( MetaActionType::TEXTCOLOR ),
2514 maColor ( rColor )
2515 {}
2516
Execute(OutputDevice * pOut)2517 void MetaTextColorAction::Execute( OutputDevice* pOut )
2518 {
2519 pOut->SetTextColor( maColor );
2520 }
2521
Clone() const2522 rtl::Reference<MetaAction> MetaTextColorAction::Clone() const
2523 {
2524 return new MetaTextColorAction( *this );
2525 }
2526
Write(SvStream & rOStm,ImplMetaWriteData * pData)2527 void MetaTextColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2528 {
2529 MetaAction::Write(rOStm, pData);
2530 VersionCompatWrite aCompat(rOStm, 1);
2531 WriteColor(rOStm, maColor);
2532 }
2533
Read(SvStream & rIStm,ImplMetaReadData *)2534 void MetaTextColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
2535 {
2536 VersionCompatRead aCompat(rIStm);
2537 ReadColor(rIStm, maColor);
2538 }
2539
MetaTextFillColorAction()2540 MetaTextFillColorAction::MetaTextFillColorAction() :
2541 MetaAction ( MetaActionType::TEXTFILLCOLOR ),
2542 mbSet ( false )
2543 {}
2544
~MetaTextFillColorAction()2545 MetaTextFillColorAction::~MetaTextFillColorAction()
2546 {}
2547
MetaTextFillColorAction(const Color & rColor,bool bSet)2548 MetaTextFillColorAction::MetaTextFillColorAction( const Color& rColor, bool bSet ) :
2549 MetaAction ( MetaActionType::TEXTFILLCOLOR ),
2550 maColor ( rColor ),
2551 mbSet ( bSet )
2552 {}
2553
Execute(OutputDevice * pOut)2554 void MetaTextFillColorAction::Execute( OutputDevice* pOut )
2555 {
2556 if( mbSet )
2557 pOut->SetTextFillColor( maColor );
2558 else
2559 pOut->SetTextFillColor();
2560 }
2561
Clone() const2562 rtl::Reference<MetaAction> MetaTextFillColorAction::Clone() const
2563 {
2564 return new MetaTextFillColorAction( *this );
2565 }
2566
Write(SvStream & rOStm,ImplMetaWriteData * pData)2567 void MetaTextFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2568 {
2569 MetaAction::Write(rOStm, pData);
2570 VersionCompatWrite aCompat(rOStm, 1);
2571 WriteColor(rOStm, maColor);
2572 rOStm.WriteBool( mbSet );
2573 }
2574
Read(SvStream & rIStm,ImplMetaReadData *)2575 void MetaTextFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
2576 {
2577 VersionCompatRead aCompat(rIStm);
2578 ReadColor(rIStm, maColor);
2579 rIStm.ReadCharAsBool( mbSet );
2580 }
2581
MetaTextLineColorAction()2582 MetaTextLineColorAction::MetaTextLineColorAction() :
2583 MetaAction ( MetaActionType::TEXTLINECOLOR ),
2584 mbSet ( false )
2585 {}
2586
~MetaTextLineColorAction()2587 MetaTextLineColorAction::~MetaTextLineColorAction()
2588 {}
2589
MetaTextLineColorAction(const Color & rColor,bool bSet)2590 MetaTextLineColorAction::MetaTextLineColorAction( const Color& rColor, bool bSet ) :
2591 MetaAction ( MetaActionType::TEXTLINECOLOR ),
2592 maColor ( rColor ),
2593 mbSet ( bSet )
2594 {}
2595
Execute(OutputDevice * pOut)2596 void MetaTextLineColorAction::Execute( OutputDevice* pOut )
2597 {
2598 if( mbSet )
2599 pOut->SetTextLineColor( maColor );
2600 else
2601 pOut->SetTextLineColor();
2602 }
2603
Clone() const2604 rtl::Reference<MetaAction> MetaTextLineColorAction::Clone() const
2605 {
2606 return new MetaTextLineColorAction( *this );
2607 }
2608
Write(SvStream & rOStm,ImplMetaWriteData * pData)2609 void MetaTextLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2610 {
2611 MetaAction::Write(rOStm, pData);
2612 VersionCompatWrite aCompat(rOStm, 1);
2613 WriteColor(rOStm, maColor);
2614 rOStm.WriteBool( mbSet );
2615 }
2616
Read(SvStream & rIStm,ImplMetaReadData *)2617 void MetaTextLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
2618 {
2619 VersionCompatRead aCompat(rIStm);
2620 ReadColor(rIStm, maColor);
2621 rIStm.ReadCharAsBool( mbSet );
2622 }
2623
MetaOverlineColorAction()2624 MetaOverlineColorAction::MetaOverlineColorAction() :
2625 MetaAction ( MetaActionType::OVERLINECOLOR ),
2626 mbSet ( false )
2627 {}
2628
~MetaOverlineColorAction()2629 MetaOverlineColorAction::~MetaOverlineColorAction()
2630 {}
2631
MetaOverlineColorAction(const Color & rColor,bool bSet)2632 MetaOverlineColorAction::MetaOverlineColorAction( const Color& rColor, bool bSet ) :
2633 MetaAction ( MetaActionType::OVERLINECOLOR ),
2634 maColor ( rColor ),
2635 mbSet ( bSet )
2636 {}
2637
Execute(OutputDevice * pOut)2638 void MetaOverlineColorAction::Execute( OutputDevice* pOut )
2639 {
2640 if( mbSet )
2641 pOut->SetOverlineColor( maColor );
2642 else
2643 pOut->SetOverlineColor();
2644 }
2645
Clone() const2646 rtl::Reference<MetaAction> MetaOverlineColorAction::Clone() const
2647 {
2648 return new MetaOverlineColorAction( *this );
2649 }
2650
Write(SvStream & rOStm,ImplMetaWriteData * pData)2651 void MetaOverlineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2652 {
2653 MetaAction::Write(rOStm, pData);
2654 VersionCompatWrite aCompat(rOStm, 1);
2655 WriteColor(rOStm, maColor);
2656 rOStm.WriteBool( mbSet );
2657 }
2658
Read(SvStream & rIStm,ImplMetaReadData *)2659 void MetaOverlineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
2660 {
2661 VersionCompatRead aCompat(rIStm);
2662 ReadColor(rIStm, maColor);
2663 rIStm.ReadCharAsBool( mbSet );
2664 }
2665
MetaTextAlignAction()2666 MetaTextAlignAction::MetaTextAlignAction() :
2667 MetaAction ( MetaActionType::TEXTALIGN ),
2668 maAlign ( ALIGN_TOP )
2669 {}
2670
~MetaTextAlignAction()2671 MetaTextAlignAction::~MetaTextAlignAction()
2672 {}
2673
MetaTextAlignAction(TextAlign aAlign)2674 MetaTextAlignAction::MetaTextAlignAction( TextAlign aAlign ) :
2675 MetaAction ( MetaActionType::TEXTALIGN ),
2676 maAlign ( aAlign )
2677 {}
2678
Execute(OutputDevice * pOut)2679 void MetaTextAlignAction::Execute( OutputDevice* pOut )
2680 {
2681 pOut->SetTextAlign( maAlign );
2682 }
2683
Clone() const2684 rtl::Reference<MetaAction> MetaTextAlignAction::Clone() const
2685 {
2686 return new MetaTextAlignAction( *this );
2687 }
2688
Write(SvStream & rOStm,ImplMetaWriteData * pData)2689 void MetaTextAlignAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2690 {
2691 MetaAction::Write(rOStm, pData);
2692 VersionCompatWrite aCompat(rOStm, 1);
2693 rOStm.WriteUInt16( maAlign );
2694 }
2695
Read(SvStream & rIStm,ImplMetaReadData *)2696 void MetaTextAlignAction::Read( SvStream& rIStm, ImplMetaReadData* )
2697 {
2698 sal_uInt16 nTmp16(0);
2699
2700 VersionCompatRead aCompat(rIStm);
2701 rIStm.ReadUInt16( nTmp16 ); maAlign = static_cast<TextAlign>(nTmp16);
2702 }
2703
MetaMapModeAction()2704 MetaMapModeAction::MetaMapModeAction() :
2705 MetaAction(MetaActionType::MAPMODE)
2706 {}
2707
~MetaMapModeAction()2708 MetaMapModeAction::~MetaMapModeAction()
2709 {}
2710
MetaMapModeAction(const MapMode & rMapMode)2711 MetaMapModeAction::MetaMapModeAction( const MapMode& rMapMode ) :
2712 MetaAction ( MetaActionType::MAPMODE ),
2713 maMapMode ( rMapMode )
2714 {}
2715
Execute(OutputDevice * pOut)2716 void MetaMapModeAction::Execute( OutputDevice* pOut )
2717 {
2718 pOut->SetMapMode( maMapMode );
2719 }
2720
Clone() const2721 rtl::Reference<MetaAction> MetaMapModeAction::Clone() const
2722 {
2723 return new MetaMapModeAction( *this );
2724 }
2725
Scale(double fScaleX,double fScaleY)2726 void MetaMapModeAction::Scale( double fScaleX, double fScaleY )
2727 {
2728 Point aPoint( maMapMode.GetOrigin() );
2729
2730 ImplScalePoint( aPoint, fScaleX, fScaleY );
2731 maMapMode.SetOrigin( aPoint );
2732 }
2733
Write(SvStream & rOStm,ImplMetaWriteData * pData)2734 void MetaMapModeAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2735 {
2736 MetaAction::Write(rOStm, pData);
2737 VersionCompatWrite aCompat(rOStm, 1);
2738 TypeSerializer aSerializer(rOStm);
2739 aSerializer.writeMapMode(maMapMode);
2740 }
2741
Read(SvStream & rIStm,ImplMetaReadData *)2742 void MetaMapModeAction::Read( SvStream& rIStm, ImplMetaReadData* )
2743 {
2744 VersionCompatRead aCompat(rIStm);
2745 TypeSerializer aSerializer(rIStm);
2746 aSerializer.readMapMode(maMapMode);
2747 }
2748
MetaFontAction()2749 MetaFontAction::MetaFontAction() :
2750 MetaAction(MetaActionType::FONT)
2751 {}
2752
~MetaFontAction()2753 MetaFontAction::~MetaFontAction()
2754 {}
2755
MetaFontAction(const vcl::Font & rFont)2756 MetaFontAction::MetaFontAction( const vcl::Font& rFont ) :
2757 MetaAction ( MetaActionType::FONT ),
2758 maFont ( rFont )
2759 {
2760 // #96876: because RTL_TEXTENCODING_SYMBOL is often set at the StarSymbol font,
2761 // we change the textencoding to RTL_TEXTENCODING_UNICODE here, which seems
2762 // to be the right way; changing the textencoding at other sources
2763 // is too dangerous at the moment
2764 if ( IsStarSymbol( maFont.GetFamilyName() )
2765 && ( maFont.GetCharSet() != RTL_TEXTENCODING_UNICODE ) )
2766 {
2767 maFont.SetCharSet( RTL_TEXTENCODING_UNICODE );
2768 }
2769 }
2770
Execute(OutputDevice * pOut)2771 void MetaFontAction::Execute( OutputDevice* pOut )
2772 {
2773 pOut->SetFont( maFont );
2774 }
2775
Clone() const2776 rtl::Reference<MetaAction> MetaFontAction::Clone() const
2777 {
2778 return new MetaFontAction( *this );
2779 }
2780
Scale(double fScaleX,double fScaleY)2781 void MetaFontAction::Scale( double fScaleX, double fScaleY )
2782 {
2783 const Size aSize(
2784 FRound(maFont.GetFontSize().Width() * fabs(fScaleX)),
2785 FRound(maFont.GetFontSize().Height() * fabs(fScaleY)));
2786 maFont.SetFontSize( aSize );
2787 }
2788
Write(SvStream & rOStm,ImplMetaWriteData * pData)2789 void MetaFontAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2790 {
2791 MetaAction::Write(rOStm, pData);
2792 VersionCompatWrite aCompat(rOStm, 1);
2793 WriteFont( rOStm, maFont );
2794 pData->meActualCharSet = maFont.GetCharSet();
2795 if ( pData->meActualCharSet == RTL_TEXTENCODING_DONTKNOW )
2796 pData->meActualCharSet = osl_getThreadTextEncoding();
2797 }
2798
Read(SvStream & rIStm,ImplMetaReadData * pData)2799 void MetaFontAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
2800 {
2801 VersionCompatRead aCompat(rIStm);
2802 ReadFont( rIStm, maFont );
2803 pData->meActualCharSet = maFont.GetCharSet();
2804 if ( pData->meActualCharSet == RTL_TEXTENCODING_DONTKNOW )
2805 pData->meActualCharSet = osl_getThreadTextEncoding();
2806 }
2807
MetaPushAction()2808 MetaPushAction::MetaPushAction() :
2809 MetaAction ( MetaActionType::PUSH ),
2810 mnFlags ( PushFlags::NONE )
2811 {}
2812
~MetaPushAction()2813 MetaPushAction::~MetaPushAction()
2814 {}
2815
MetaPushAction(PushFlags nFlags)2816 MetaPushAction::MetaPushAction( PushFlags nFlags ) :
2817 MetaAction ( MetaActionType::PUSH ),
2818 mnFlags ( nFlags )
2819 {}
2820
Execute(OutputDevice * pOut)2821 void MetaPushAction::Execute( OutputDevice* pOut )
2822 {
2823 pOut->Push( mnFlags );
2824 }
2825
Clone() const2826 rtl::Reference<MetaAction> MetaPushAction::Clone() const
2827 {
2828 return new MetaPushAction( *this );
2829 }
2830
Write(SvStream & rOStm,ImplMetaWriteData * pData)2831 void MetaPushAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2832 {
2833 MetaAction::Write(rOStm, pData);
2834 VersionCompatWrite aCompat(rOStm, 1);
2835 rOStm.WriteUInt16( static_cast<sal_uInt16>(mnFlags) );
2836 }
2837
Read(SvStream & rIStm,ImplMetaReadData *)2838 void MetaPushAction::Read( SvStream& rIStm, ImplMetaReadData* )
2839 {
2840 VersionCompatRead aCompat(rIStm);
2841 sal_uInt16 tmp;
2842 rIStm.ReadUInt16( tmp );
2843 mnFlags = static_cast<PushFlags>(tmp);
2844 }
2845
MetaPopAction()2846 MetaPopAction::MetaPopAction() :
2847 MetaAction(MetaActionType::POP)
2848 {}
2849
~MetaPopAction()2850 MetaPopAction::~MetaPopAction()
2851 {}
2852
Execute(OutputDevice * pOut)2853 void MetaPopAction::Execute( OutputDevice* pOut )
2854 {
2855 pOut->Pop();
2856 }
2857
Clone() const2858 rtl::Reference<MetaAction> MetaPopAction::Clone() const
2859 {
2860 return new MetaPopAction( *this );
2861 }
2862
Write(SvStream & rOStm,ImplMetaWriteData * pData)2863 void MetaPopAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2864 {
2865 MetaAction::Write(rOStm, pData);
2866 VersionCompatWrite aCompat(rOStm, 1);
2867 }
2868
Read(SvStream & rIStm,ImplMetaReadData *)2869 void MetaPopAction::Read( SvStream& rIStm, ImplMetaReadData* )
2870 {
2871 VersionCompatRead aCompat(rIStm);
2872 }
2873
MetaRasterOpAction()2874 MetaRasterOpAction::MetaRasterOpAction() :
2875 MetaAction ( MetaActionType::RASTEROP ),
2876 meRasterOp ( RasterOp::OverPaint )
2877 {}
2878
~MetaRasterOpAction()2879 MetaRasterOpAction::~MetaRasterOpAction()
2880 {}
2881
MetaRasterOpAction(RasterOp eRasterOp)2882 MetaRasterOpAction::MetaRasterOpAction( RasterOp eRasterOp ) :
2883 MetaAction ( MetaActionType::RASTEROP ),
2884 meRasterOp ( eRasterOp )
2885 {
2886 }
2887
Execute(OutputDevice * pOut)2888 void MetaRasterOpAction::Execute( OutputDevice* pOut )
2889 {
2890 pOut->SetRasterOp( meRasterOp );
2891 }
2892
Clone() const2893 rtl::Reference<MetaAction> MetaRasterOpAction::Clone() const
2894 {
2895 return new MetaRasterOpAction( *this );
2896 }
2897
Write(SvStream & rOStm,ImplMetaWriteData * pData)2898 void MetaRasterOpAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2899 {
2900 MetaAction::Write(rOStm, pData);
2901 VersionCompatWrite aCompat(rOStm, 1);
2902 rOStm.WriteUInt16( static_cast<sal_uInt16>(meRasterOp) );
2903 }
2904
Read(SvStream & rIStm,ImplMetaReadData *)2905 void MetaRasterOpAction::Read( SvStream& rIStm, ImplMetaReadData* )
2906 {
2907 sal_uInt16 nTmp16(0);
2908
2909 VersionCompatRead aCompat(rIStm);
2910 rIStm.ReadUInt16( nTmp16 ); meRasterOp = static_cast<RasterOp>(nTmp16);
2911 }
2912
MetaTransparentAction()2913 MetaTransparentAction::MetaTransparentAction() :
2914 MetaAction ( MetaActionType::Transparent ),
2915 mnTransPercent ( 0 )
2916 {}
2917
~MetaTransparentAction()2918 MetaTransparentAction::~MetaTransparentAction()
2919 {}
2920
MetaTransparentAction(const tools::PolyPolygon & rPolyPoly,sal_uInt16 nTransPercent)2921 MetaTransparentAction::MetaTransparentAction( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransPercent ) :
2922 MetaAction ( MetaActionType::Transparent ),
2923 maPolyPoly ( rPolyPoly ),
2924 mnTransPercent ( nTransPercent )
2925 {}
2926
Execute(OutputDevice * pOut)2927 void MetaTransparentAction::Execute( OutputDevice* pOut )
2928 {
2929 pOut->DrawTransparent( maPolyPoly, mnTransPercent );
2930 }
2931
Clone() const2932 rtl::Reference<MetaAction> MetaTransparentAction::Clone() const
2933 {
2934 return new MetaTransparentAction( *this );
2935 }
2936
Move(tools::Long nHorzMove,tools::Long nVertMove)2937 void MetaTransparentAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
2938 {
2939 maPolyPoly.Move( nHorzMove, nVertMove );
2940 }
2941
Scale(double fScaleX,double fScaleY)2942 void MetaTransparentAction::Scale( double fScaleX, double fScaleY )
2943 {
2944 for( sal_uInt16 i = 0, nCount = maPolyPoly.Count(); i < nCount; i++ )
2945 ImplScalePoly( maPolyPoly[ i ], fScaleX, fScaleY );
2946 }
2947
Write(SvStream & rOStm,ImplMetaWriteData * pData)2948 void MetaTransparentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
2949 {
2950 MetaAction::Write(rOStm, pData);
2951 VersionCompatWrite aCompat(rOStm, 1);
2952
2953 // #i105373# The tools::PolyPolygon in this action may be a curve; this
2954 // was ignored until now what is an error. To make older office
2955 // versions work with MetaFiles, i opt for applying AdaptiveSubdivide
2956 // to the PolyPolygon.
2957 // The alternative would be to really write the curve information
2958 // like in MetaPolyPolygonAction::Write (where someone extended it
2959 // correctly, but not here :-( ).
2960 // The golden solution would be to combine both, but i think it's
2961 // not necessary; a good subdivision will be sufficient.
2962 tools::PolyPolygon aNoCurvePolyPolygon;
2963 maPolyPoly.AdaptiveSubdivide(aNoCurvePolyPolygon);
2964
2965 WritePolyPolygon( rOStm, aNoCurvePolyPolygon );
2966 rOStm.WriteUInt16( mnTransPercent );
2967 }
2968
Read(SvStream & rIStm,ImplMetaReadData *)2969 void MetaTransparentAction::Read( SvStream& rIStm, ImplMetaReadData* )
2970 {
2971 VersionCompatRead aCompat(rIStm);
2972 ReadPolyPolygon( rIStm, maPolyPoly );
2973 rIStm.ReadUInt16( mnTransPercent );
2974 }
2975
MetaFloatTransparentAction()2976 MetaFloatTransparentAction::MetaFloatTransparentAction() :
2977 MetaAction(MetaActionType::FLOATTRANSPARENT)
2978 {}
2979
~MetaFloatTransparentAction()2980 MetaFloatTransparentAction::~MetaFloatTransparentAction()
2981 {}
2982
MetaFloatTransparentAction(const GDIMetaFile & rMtf,const Point & rPos,const Size & rSize,const Gradient & rGradient)2983 MetaFloatTransparentAction::MetaFloatTransparentAction( const GDIMetaFile& rMtf, const Point& rPos,
2984 const Size& rSize, const Gradient& rGradient ) :
2985 MetaAction ( MetaActionType::FLOATTRANSPARENT ),
2986 maMtf ( rMtf ),
2987 maPoint ( rPos ),
2988 maSize ( rSize ),
2989 maGradient ( rGradient )
2990 {}
2991
Execute(OutputDevice * pOut)2992 void MetaFloatTransparentAction::Execute( OutputDevice* pOut )
2993 {
2994 pOut->DrawTransparent( maMtf, maPoint, maSize, maGradient );
2995 }
2996
Clone() const2997 rtl::Reference<MetaAction> MetaFloatTransparentAction::Clone() const
2998 {
2999 return new MetaFloatTransparentAction( *this );
3000 }
3001
Move(tools::Long nHorzMove,tools::Long nVertMove)3002 void MetaFloatTransparentAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
3003 {
3004 maPoint.Move( nHorzMove, nVertMove );
3005 }
3006
Scale(double fScaleX,double fScaleY)3007 void MetaFloatTransparentAction::Scale( double fScaleX, double fScaleY )
3008 {
3009 tools::Rectangle aRectangle(maPoint, maSize);
3010 ImplScaleRect( aRectangle, fScaleX, fScaleY );
3011 maPoint = aRectangle.TopLeft();
3012 maSize = aRectangle.GetSize();
3013 }
3014
Write(SvStream & rOStm,ImplMetaWriteData * pData)3015 void MetaFloatTransparentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3016 {
3017 MetaAction::Write(rOStm, pData);
3018 VersionCompatWrite aCompat(rOStm, 1);
3019
3020 maMtf.Write( rOStm );
3021 TypeSerializer aSerializer(rOStm);
3022 aSerializer.writePoint(maPoint);
3023 aSerializer.writeSize(maSize);
3024 aSerializer.writeGradient(maGradient);
3025 }
3026
Read(SvStream & rIStm,ImplMetaReadData * pData)3027 void MetaFloatTransparentAction::Read(SvStream& rIStm, ImplMetaReadData* pData)
3028 {
3029 VersionCompatRead aCompat(rIStm);
3030 ReadGDIMetaFile(rIStm, maMtf, pData);
3031 TypeSerializer aSerializer(rIStm);
3032 aSerializer.readPoint(maPoint);
3033 aSerializer.readSize(maSize);
3034 aSerializer.readGradient(maGradient);
3035 }
3036
MetaEPSAction()3037 MetaEPSAction::MetaEPSAction() :
3038 MetaAction(MetaActionType::EPS)
3039 {}
3040
~MetaEPSAction()3041 MetaEPSAction::~MetaEPSAction()
3042 {}
3043
MetaEPSAction(const Point & rPoint,const Size & rSize,const GfxLink & rGfxLink,const GDIMetaFile & rSubst)3044 MetaEPSAction::MetaEPSAction( const Point& rPoint, const Size& rSize,
3045 const GfxLink& rGfxLink, const GDIMetaFile& rSubst ) :
3046 MetaAction ( MetaActionType::EPS ),
3047 maGfxLink ( rGfxLink ),
3048 maSubst ( rSubst ),
3049 maPoint ( rPoint ),
3050 maSize ( rSize )
3051 {}
3052
Execute(OutputDevice * pOut)3053 void MetaEPSAction::Execute( OutputDevice* pOut )
3054 {
3055 pOut->DrawEPS( maPoint, maSize, maGfxLink, &maSubst );
3056 }
3057
Clone() const3058 rtl::Reference<MetaAction> MetaEPSAction::Clone() const
3059 {
3060 return new MetaEPSAction( *this );
3061 }
3062
Move(tools::Long nHorzMove,tools::Long nVertMove)3063 void MetaEPSAction::Move( tools::Long nHorzMove, tools::Long nVertMove )
3064 {
3065 maPoint.Move( nHorzMove, nVertMove );
3066 }
3067
Scale(double fScaleX,double fScaleY)3068 void MetaEPSAction::Scale( double fScaleX, double fScaleY )
3069 {
3070 tools::Rectangle aRectangle(maPoint, maSize);
3071 ImplScaleRect( aRectangle, fScaleX, fScaleY );
3072 maPoint = aRectangle.TopLeft();
3073 maSize = aRectangle.GetSize();
3074 }
3075
Write(SvStream & rOStm,ImplMetaWriteData * pData)3076 void MetaEPSAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3077 {
3078 MetaAction::Write(rOStm, pData);
3079 VersionCompatWrite aCompat(rOStm, 1);
3080
3081 TypeSerializer aSerializer(rOStm);
3082 aSerializer.writeGfxLink(maGfxLink);
3083 aSerializer.writePoint(maPoint);
3084 aSerializer.writeSize(maSize);
3085 maSubst.Write( rOStm );
3086 }
3087
Read(SvStream & rIStm,ImplMetaReadData *)3088 void MetaEPSAction::Read( SvStream& rIStm, ImplMetaReadData* )
3089 {
3090 VersionCompatRead aCompat(rIStm);
3091 TypeSerializer aSerializer(rIStm);
3092 aSerializer.readGfxLink(maGfxLink);
3093 aSerializer.readPoint(maPoint);
3094 aSerializer.readSize(maSize);
3095 ReadGDIMetaFile( rIStm, maSubst );
3096 }
3097
MetaRefPointAction()3098 MetaRefPointAction::MetaRefPointAction() :
3099 MetaAction ( MetaActionType::REFPOINT ),
3100 mbSet ( false )
3101 {}
3102
~MetaRefPointAction()3103 MetaRefPointAction::~MetaRefPointAction()
3104 {}
3105
MetaRefPointAction(const Point & rRefPoint,bool bSet)3106 MetaRefPointAction::MetaRefPointAction( const Point& rRefPoint, bool bSet ) :
3107 MetaAction ( MetaActionType::REFPOINT ),
3108 maRefPoint ( rRefPoint ),
3109 mbSet ( bSet )
3110 {}
3111
Execute(OutputDevice * pOut)3112 void MetaRefPointAction::Execute( OutputDevice* pOut )
3113 {
3114 if( mbSet )
3115 pOut->SetRefPoint( maRefPoint );
3116 else
3117 pOut->SetRefPoint();
3118 }
3119
Clone() const3120 rtl::Reference<MetaAction> MetaRefPointAction::Clone() const
3121 {
3122 return new MetaRefPointAction( *this );
3123 }
3124
Write(SvStream & rOStm,ImplMetaWriteData * pData)3125 void MetaRefPointAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3126 {
3127 MetaAction::Write(rOStm, pData);
3128 VersionCompatWrite aCompat(rOStm, 1);
3129
3130 TypeSerializer aSerializer(rOStm);
3131 aSerializer.writePoint(maRefPoint);
3132 rOStm.WriteBool( mbSet );
3133 }
3134
Read(SvStream & rIStm,ImplMetaReadData *)3135 void MetaRefPointAction::Read( SvStream& rIStm, ImplMetaReadData* )
3136 {
3137 VersionCompatRead aCompat(rIStm);
3138 TypeSerializer aSerializer(rIStm);
3139 aSerializer.readPoint(maRefPoint);
3140 rIStm.ReadCharAsBool( mbSet );
3141 }
3142
MetaCommentAction()3143 MetaCommentAction::MetaCommentAction() :
3144 MetaAction ( MetaActionType::COMMENT ),
3145 mnValue ( 0 )
3146 {
3147 ImplInitDynamicData( nullptr, 0UL );
3148 }
3149
MetaCommentAction(const MetaCommentAction & rAct)3150 MetaCommentAction::MetaCommentAction( const MetaCommentAction& rAct ) :
3151 MetaAction ( MetaActionType::COMMENT ),
3152 maComment ( rAct.maComment ),
3153 mnValue ( rAct.mnValue )
3154 {
3155 ImplInitDynamicData( rAct.mpData.get(), rAct.mnDataSize );
3156 }
3157
MetaCommentAction(const OString & rComment,sal_Int32 nValue,const sal_uInt8 * pData,sal_uInt32 nDataSize)3158 MetaCommentAction::MetaCommentAction( const OString& rComment, sal_Int32 nValue, const sal_uInt8* pData, sal_uInt32 nDataSize ) :
3159 MetaAction ( MetaActionType::COMMENT ),
3160 maComment ( rComment ),
3161 mnValue ( nValue )
3162 {
3163 ImplInitDynamicData( pData, nDataSize );
3164 }
3165
~MetaCommentAction()3166 MetaCommentAction::~MetaCommentAction()
3167 {
3168 }
3169
ImplInitDynamicData(const sal_uInt8 * pData,sal_uInt32 nDataSize)3170 void MetaCommentAction::ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize )
3171 {
3172 if ( nDataSize && pData )
3173 {
3174 mnDataSize = nDataSize;
3175 mpData.reset( new sal_uInt8[ mnDataSize ] );
3176 memcpy( mpData.get(), pData, mnDataSize );
3177 }
3178 else
3179 {
3180 mnDataSize = 0;
3181 mpData = nullptr;
3182 }
3183 }
3184
Execute(OutputDevice * pOut)3185 void MetaCommentAction::Execute( OutputDevice* pOut )
3186 {
3187 if ( pOut->GetConnectMetaFile() )
3188 {
3189 pOut->GetConnectMetaFile()->AddAction( this );
3190 }
3191 }
3192
Clone() const3193 rtl::Reference<MetaAction> MetaCommentAction::Clone() const
3194 {
3195 return new MetaCommentAction( *this );
3196 }
3197
Move(tools::Long nXMove,tools::Long nYMove)3198 void MetaCommentAction::Move( tools::Long nXMove, tools::Long nYMove )
3199 {
3200 if ( !(nXMove || nYMove) )
3201 return;
3202
3203 if ( !(mnDataSize && mpData) )
3204 return;
3205
3206 bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN");
3207 if ( !(bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN") )
3208 return;
3209
3210 SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ );
3211 SvMemoryStream aDest;
3212 if ( bPathStroke )
3213 {
3214 SvtGraphicStroke aStroke;
3215 ReadSvtGraphicStroke( aMemStm, aStroke );
3216
3217 tools::Polygon aPath;
3218 aStroke.getPath( aPath );
3219 aPath.Move( nXMove, nYMove );
3220 aStroke.setPath( aPath );
3221
3222 tools::PolyPolygon aStartArrow;
3223 aStroke.getStartArrow(aStartArrow);
3224 aStartArrow.Move(nXMove, nYMove);
3225 aStroke.setStartArrow(aStartArrow);
3226
3227 tools::PolyPolygon aEndArrow;
3228 aStroke.getEndArrow(aEndArrow);
3229 aEndArrow.Move(nXMove, nYMove);
3230 aStroke.setEndArrow(aEndArrow);
3231
3232 WriteSvtGraphicStroke( aDest, aStroke );
3233 }
3234 else
3235 {
3236 SvtGraphicFill aFill;
3237 ReadSvtGraphicFill( aMemStm, aFill );
3238
3239 tools::PolyPolygon aPath;
3240 aFill.getPath( aPath );
3241 aPath.Move( nXMove, nYMove );
3242 aFill.setPath( aPath );
3243
3244 WriteSvtGraphicFill( aDest, aFill );
3245 }
3246 mpData.reset();
3247 ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() );
3248 }
3249
3250 // SJ: 25.07.06 #i56656# we are not able to mirror certain kind of
3251 // comments properly, especially the XPATHSTROKE and XPATHFILL lead to
3252 // problems, so it is better to remove these comments when mirroring
3253 // FIXME: fake comment to apply the next hunk in the right location
Scale(double fXScale,double fYScale)3254 void MetaCommentAction::Scale( double fXScale, double fYScale )
3255 {
3256 if (( fXScale == 1.0 ) && ( fYScale == 1.0 ))
3257 return;
3258
3259 if ( !(mnDataSize && mpData) )
3260 return;
3261
3262 bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN");
3263 if ( bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN" )
3264 {
3265 SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ );
3266 SvMemoryStream aDest;
3267 if ( bPathStroke )
3268 {
3269 SvtGraphicStroke aStroke;
3270 ReadSvtGraphicStroke( aMemStm, aStroke );
3271 aStroke.scale( fXScale, fYScale );
3272 WriteSvtGraphicStroke( aDest, aStroke );
3273 }
3274 else
3275 {
3276 SvtGraphicFill aFill;
3277 ReadSvtGraphicFill( aMemStm, aFill );
3278 tools::PolyPolygon aPath;
3279 aFill.getPath( aPath );
3280 aPath.Scale( fXScale, fYScale );
3281 aFill.setPath( aPath );
3282 WriteSvtGraphicFill( aDest, aFill );
3283 }
3284 mpData.reset();
3285 ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() );
3286 } else if( maComment == "EMF_PLUS_HEADER_INFO" ){
3287 SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ );
3288 SvMemoryStream aDest;
3289
3290 sal_Int32 nLeft(0), nRight(0), nTop(0), nBottom(0);
3291 sal_Int32 nPixX(0), nPixY(0), nMillX(0), nMillY(0);
3292 float m11(0), m12(0), m21(0), m22(0), mdx(0), mdy(0);
3293
3294 // read data
3295 aMemStm.ReadInt32( nLeft ).ReadInt32( nTop ).ReadInt32( nRight ).ReadInt32( nBottom );
3296 aMemStm.ReadInt32( nPixX ).ReadInt32( nPixY ).ReadInt32( nMillX ).ReadInt32( nMillY );
3297 aMemStm.ReadFloat( m11 ).ReadFloat( m12 ).ReadFloat( m21 ).ReadFloat( m22 ).ReadFloat( mdx ).ReadFloat( mdy );
3298
3299 // add scale to the transformation
3300 m11 *= fXScale;
3301 m12 *= fXScale;
3302 m22 *= fYScale;
3303 m21 *= fYScale;
3304
3305 // prepare new data
3306 aDest.WriteInt32( nLeft ).WriteInt32( nTop ).WriteInt32( nRight ).WriteInt32( nBottom );
3307 aDest.WriteInt32( nPixX ).WriteInt32( nPixY ).WriteInt32( nMillX ).WriteInt32( nMillY );
3308 aDest.WriteFloat( m11 ).WriteFloat( m12 ).WriteFloat( m21 ).WriteFloat( m22 ).WriteFloat( mdx ).WriteFloat( mdy );
3309
3310 // save them
3311 ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() );
3312 }
3313 }
3314
Write(SvStream & rOStm,ImplMetaWriteData * pData)3315 void MetaCommentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3316 {
3317 MetaAction::Write(rOStm, pData);
3318 VersionCompatWrite aCompat(rOStm, 1);
3319 write_uInt16_lenPrefixed_uInt8s_FromOString(rOStm, maComment);
3320 rOStm.WriteInt32( mnValue ).WriteUInt32( mnDataSize );
3321
3322 if ( mnDataSize )
3323 rOStm.WriteBytes( mpData.get(), mnDataSize );
3324 }
3325
Read(SvStream & rIStm,ImplMetaReadData *)3326 void MetaCommentAction::Read( SvStream& rIStm, ImplMetaReadData* )
3327 {
3328 VersionCompatRead aCompat(rIStm);
3329 maComment = read_uInt16_lenPrefixed_uInt8s_ToOString(rIStm);
3330 rIStm.ReadInt32( mnValue ).ReadUInt32( mnDataSize );
3331
3332 if (mnDataSize > rIStm.remainingSize())
3333 {
3334 SAL_WARN("vcl.gdi", "Parsing error: " << rIStm.remainingSize() <<
3335 " available data, but " << mnDataSize << " claimed, truncating");
3336 mnDataSize = rIStm.remainingSize();
3337 }
3338
3339 SAL_INFO("vcl.gdi", "MetaCommentAction::Read " << maComment);
3340
3341 mpData.reset();
3342
3343 if( mnDataSize )
3344 {
3345 mpData.reset(new sal_uInt8[ mnDataSize ]);
3346 rIStm.ReadBytes(mpData.get(), mnDataSize);
3347 }
3348 }
3349
MetaLayoutModeAction()3350 MetaLayoutModeAction::MetaLayoutModeAction() :
3351 MetaAction ( MetaActionType::LAYOUTMODE ),
3352 mnLayoutMode( ComplexTextLayoutFlags::Default )
3353 {}
3354
~MetaLayoutModeAction()3355 MetaLayoutModeAction::~MetaLayoutModeAction()
3356 {}
3357
MetaLayoutModeAction(ComplexTextLayoutFlags nLayoutMode)3358 MetaLayoutModeAction::MetaLayoutModeAction( ComplexTextLayoutFlags nLayoutMode ) :
3359 MetaAction ( MetaActionType::LAYOUTMODE ),
3360 mnLayoutMode( nLayoutMode )
3361 {}
3362
Execute(OutputDevice * pOut)3363 void MetaLayoutModeAction::Execute( OutputDevice* pOut )
3364 {
3365 pOut->SetLayoutMode( mnLayoutMode );
3366 }
3367
Clone() const3368 rtl::Reference<MetaAction> MetaLayoutModeAction::Clone() const
3369 {
3370 return new MetaLayoutModeAction( *this );
3371 }
3372
Write(SvStream & rOStm,ImplMetaWriteData * pData)3373 void MetaLayoutModeAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3374 {
3375 MetaAction::Write(rOStm, pData);
3376 VersionCompatWrite aCompat(rOStm, 1);
3377 rOStm.WriteUInt32( static_cast<sal_uInt32>(mnLayoutMode) );
3378 }
3379
Read(SvStream & rIStm,ImplMetaReadData *)3380 void MetaLayoutModeAction::Read( SvStream& rIStm, ImplMetaReadData* )
3381 {
3382 VersionCompatRead aCompat(rIStm);
3383 sal_uInt32 tmp;
3384 rIStm.ReadUInt32( tmp );
3385 mnLayoutMode = static_cast<ComplexTextLayoutFlags>(tmp);
3386 }
3387
MetaTextLanguageAction()3388 MetaTextLanguageAction::MetaTextLanguageAction() :
3389 MetaAction ( MetaActionType::TEXTLANGUAGE ),
3390 meTextLanguage( LANGUAGE_DONTKNOW )
3391 {}
3392
~MetaTextLanguageAction()3393 MetaTextLanguageAction::~MetaTextLanguageAction()
3394 {}
3395
MetaTextLanguageAction(LanguageType eTextLanguage)3396 MetaTextLanguageAction::MetaTextLanguageAction( LanguageType eTextLanguage ) :
3397 MetaAction ( MetaActionType::TEXTLANGUAGE ),
3398 meTextLanguage( eTextLanguage )
3399 {}
3400
Execute(OutputDevice * pOut)3401 void MetaTextLanguageAction::Execute( OutputDevice* pOut )
3402 {
3403 pOut->SetDigitLanguage( meTextLanguage );
3404 }
3405
Clone() const3406 rtl::Reference<MetaAction> MetaTextLanguageAction::Clone() const
3407 {
3408 return new MetaTextLanguageAction( *this );
3409 }
3410
Write(SvStream & rOStm,ImplMetaWriteData * pData)3411 void MetaTextLanguageAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
3412 {
3413 MetaAction::Write(rOStm, pData);
3414 VersionCompatWrite aCompat(rOStm, 1);
3415 rOStm.WriteUInt16( static_cast<sal_uInt16>(meTextLanguage) );
3416 }
3417
Read(SvStream & rIStm,ImplMetaReadData *)3418 void MetaTextLanguageAction::Read( SvStream& rIStm, ImplMetaReadData* )
3419 {
3420 VersionCompatRead aCompat(rIStm);
3421 sal_uInt16 nTmp = 0;
3422 rIStm.ReadUInt16( nTmp );
3423 meTextLanguage = static_cast<LanguageType>(nTmp);
3424 }
3425
3426 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
3427