Update ooo320-m1
[ooovba.git] / vcl / source / gdi / cvtsvm.cxx
blobde119d6a4674ad4ed92570f428423b7b97fde99e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cvtsvm.cxx,v $
10 * $Revision: 1.16.134.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #define ENABLE_BYTESTRING_STREAM_OPERATORS
36 #include <algorithm>
37 #include <string.h>
38 #include <tools/stack.hxx>
39 #include <tools/debug.hxx>
40 #include <tools/stream.hxx>
41 #include <vcl/virdev.hxx>
42 #include <vcl/graph.hxx>
43 #include <vcl/lineinfo.hxx>
44 #include <vcl/salbtype.hxx>
45 #include <vcl/cvtsvm.hxx>
47 // -----------
48 // - Defines -
49 // -----------
51 #define CVTSVM_WRITE_SUBACTIONCOUNT 1
53 // -----------
54 // - Inlines -
55 // -----------
57 void ImplReadRect( SvStream& rIStm, Rectangle& rRect )
59 Point aTL;
60 Point aBR;
62 rIStm >> aTL;
63 rIStm >> aBR;
65 rRect = Rectangle( aTL, aBR );
68 // ------------------------------------------------------------------------
70 void ImplWriteRect( SvStream& rOStm, const Rectangle& rRect )
72 rOStm << rRect.TopLeft();
73 rOStm << rRect.BottomRight();
76 // ------------------------------------------------------------------------
78 void ImplReadPoly( SvStream& rIStm, Polygon& rPoly )
80 INT32 nSize;
82 rIStm >> nSize;
83 rPoly = Polygon( (USHORT) nSize );
85 for( USHORT i = 0; i < (USHORT) nSize; i++ )
86 rIStm >> rPoly[ i ];
89 // ------------------------------------------------------------------------
91 void ImplWritePoly( SvStream& rOStm, const Polygon& rPoly )
93 INT32 nSize = rPoly.GetSize();
95 rOStm << nSize;
97 for( INT32 i = 0; i < nSize; i++ )
98 rOStm << rPoly[ (USHORT) i ];
101 // ------------------------------------------------------------------------
103 void ImplReadPolyPoly( SvStream& rIStm, PolyPolygon& rPolyPoly )
105 Polygon aPoly;
106 INT32 nPolyCount;
108 rIStm >> nPolyCount;
110 for( USHORT i = 0; i < (USHORT) nPolyCount; i++ )
112 ImplReadPoly( rIStm, aPoly );
113 rPolyPoly.Insert( aPoly );
117 // ------------------------------------------------------------------------
119 void ImplWritePolyPolyAction( SvStream& rOStm, const PolyPolygon& rPolyPoly )
121 const USHORT nPoly = rPolyPoly.Count();
122 USHORT nPoints = 0;
123 USHORT n;
125 for( n = 0; n < nPoly; n++ )
126 nPoints = sal::static_int_cast<USHORT>(nPoints + rPolyPoly[ n ].GetSize());
128 rOStm << (INT16) GDI_POLYPOLYGON_ACTION;
129 rOStm << (INT32) ( 8 + ( nPoly << 2 ) + ( nPoints << 3 ) );
130 rOStm << (INT32) nPoly;
132 for( n = 0; n < nPoly; n++ )
134 const Polygon& rPoly = rPolyPoly[ n ];
135 const USHORT nSize = rPoly.GetSize();
137 rOStm << (INT32) nSize;
139 for( USHORT j = 0; j < nSize; j++ )
140 rOStm << rPoly[ j ];
144 // ------------------------------------------------------------------------
146 void ImplReadColor( SvStream& rIStm, Color& rColor )
148 INT16 nVal;
150 rIStm >> nVal; rColor.SetRed( sal::static_int_cast<UINT8>((USHORT)nVal >> 8) );
151 rIStm >> nVal; rColor.SetGreen( sal::static_int_cast<UINT8>((USHORT)nVal >> 8) );
152 rIStm >> nVal; rColor.SetBlue( sal::static_int_cast<UINT8>((USHORT)nVal >> 8) );
155 // ------------------------------------------------------------------------
157 void ImplWriteColor( SvStream& rOStm, const Color& rColor )
159 INT16 nVal;
161 nVal = ( (INT16) rColor.GetRed() << 8 ) | rColor.GetRed();
162 rOStm << nVal;
164 nVal = ( (INT16) rColor.GetGreen() << 8 ) | rColor.GetGreen();
165 rOStm << nVal;
167 nVal = ( (INT16) rColor.GetBlue() << 8 ) | rColor.GetBlue();
168 rOStm << nVal;
171 // ------------------------------------------------------------------------
173 void ImplReadMapMode( SvStream& rIStm, MapMode& rMapMode )
175 Point aOrg;
176 INT32 nXNum;
177 INT32 nXDenom;
178 INT32 nYNum;
179 INT32 nYDenom;
180 INT16 nUnit;
182 rIStm >> nUnit >> aOrg >> nXNum >> nXDenom >> nYNum >> nYDenom;
183 rMapMode = MapMode( (MapUnit) nUnit, aOrg, Fraction( nXNum, nXDenom ), Fraction( nYNum, nYDenom ) );
186 // ------------------------------------------------------------------------
188 void ImplWriteMapMode( SvStream& rOStm, const MapMode& rMapMode )
190 rOStm << (INT16) rMapMode.GetMapUnit();
191 rOStm << rMapMode.GetOrigin();
192 rOStm << (INT32) rMapMode.GetScaleX().GetNumerator();
193 rOStm << (INT32) rMapMode.GetScaleX().GetDenominator();
194 rOStm << (INT32) rMapMode.GetScaleY().GetNumerator();
195 rOStm << (INT32) rMapMode.GetScaleY().GetDenominator();
198 // ------------------------------------------------------------------------
200 void ImplWritePushAction( SvStream& rOStm )
202 rOStm << (INT16) GDI_PUSH_ACTION;
203 rOStm << (INT32) 4;
206 // ------------------------------------------------------------------------
208 void ImplWritePopAction( SvStream& rOStm )
210 rOStm << (INT16) GDI_POP_ACTION;
211 rOStm << (INT32) 4;
214 // ------------------------------------------------------------------------
216 void ImplWriteLineColor( SvStream& rOStm, const Color& rColor, INT16 nStyle, INT32 nWidth = 0L )
218 if( rColor.GetTransparency() > 127 )
219 nStyle = 0;
221 rOStm << (INT16) GDI_PEN_ACTION;
222 rOStm << (INT32) 16;
223 ImplWriteColor( rOStm, rColor );
224 rOStm << nWidth;
225 rOStm << nStyle;
228 // ------------------------------------------------------------------------
230 void ImplWriteFillColor( SvStream& rOStm, const Color& rColor, INT16 nStyle )
232 rOStm << (INT16) GDI_FILLBRUSH_ACTION;
233 rOStm << (INT32) 20;
234 ImplWriteColor( rOStm, rColor );
236 if( rColor.GetTransparency() > 127 )
237 nStyle = 0;
239 if( nStyle > 1 )
241 ImplWriteColor( rOStm, COL_WHITE );
242 rOStm << nStyle;
243 rOStm << (INT16) 1;
245 else
247 ImplWriteColor( rOStm, COL_BLACK );
248 rOStm << nStyle;
249 rOStm << (INT16) 0;
253 // ------------------------------------------------------------------------
255 void ImplWriteFont( SvStream& rOStm, const Font& rFont,
256 rtl_TextEncoding& rActualCharSet )
258 char aName[32];
259 short nWeight;
261 ByteString aByteName( rFont.GetName(), rOStm.GetStreamCharSet() );
262 strncpy( aName, aByteName.GetBuffer(), 32 );
264 switch ( rFont.GetWeight() )
266 case WEIGHT_THIN:
267 case WEIGHT_ULTRALIGHT:
268 case WEIGHT_LIGHT:
269 nWeight = 1;
270 break;
272 case WEIGHT_NORMAL:
273 case WEIGHT_MEDIUM:
274 nWeight = 2;
275 break;
277 case WEIGHT_BOLD:
278 case WEIGHT_ULTRABOLD:
279 case WEIGHT_BLACK:
280 nWeight = 3;
281 break;
283 default:
284 nWeight = 0;
285 break;
288 rOStm << (INT16) GDI_FONT_ACTION;
289 rOStm << (INT32) 78;
291 rActualCharSet = GetStoreCharSet( rFont.GetCharSet() );
292 ImplWriteColor( rOStm, rFont.GetColor() );
293 ImplWriteColor( rOStm, rFont.GetFillColor() );
294 rOStm.Write( aName, 32 );
295 rOStm << rFont.GetSize();
296 rOStm << (INT16) 0; // no character orientation anymore
297 rOStm << (INT16) rFont.GetOrientation();
298 rOStm << (INT16) rActualCharSet;
299 rOStm << (INT16) rFont.GetFamily();
300 rOStm << (INT16) rFont.GetPitch();
301 rOStm << (INT16) rFont.GetAlign();
302 rOStm << (INT16) nWeight;
303 rOStm << (INT16) rFont.GetUnderline();
304 rOStm << (INT16) rFont.GetStrikeout();
305 rOStm << (BOOL) ( rFont.GetItalic() != ITALIC_NONE );
306 rOStm << rFont.IsOutline();
307 rOStm << rFont.IsShadow();
308 rOStm << rFont.IsTransparent();
309 if ( rActualCharSet == RTL_TEXTENCODING_DONTKNOW )
310 rActualCharSet = gsl_getSystemTextEncoding();
313 // ------------------------------------------------------------------------
315 void ImplWriteRasterOpAction( SvStream& rOStm, INT16 nRasterOp )
317 rOStm << (INT16) GDI_RASTEROP_ACTION << (INT32) 6 << nRasterOp;
320 // ------------------------------------------------------------------------
322 sal_Bool ImplWriteUnicodeComment( SvStream& rOStm, const String& rString )
324 xub_StrLen i, nStringLen = rString.Len();
325 if ( nStringLen )
327 sal_uInt32 nSize = ( nStringLen << 1 ) + 4;
328 sal_uInt16 nType = GDI_UNICODE_COMMENT;
330 rOStm << nType << nSize;
331 for ( i = 0; i < nStringLen; i++ )
333 sal_Unicode nUni = rString.GetChar( i );
334 rOStm << nUni;
337 return nStringLen != 0;
340 // ------------------------------------------------------------------------
342 void ImplReadUnicodeComment( sal_uInt32 nStrmPos, SvStream& rIStm, String& rString )
344 sal_uInt32 nOld = rIStm.Tell();
345 if ( nStrmPos )
347 sal_uInt16 nType;
348 sal_uInt32 nActionSize;
349 xub_StrLen nStringLen;
351 rIStm.Seek( nStrmPos );
352 rIStm >> nType
353 >> nActionSize;
355 nStringLen = sal::static_int_cast<xub_StrLen>(( nActionSize - 4 ) >> 1);
357 if ( nStringLen && ( nType == GDI_UNICODE_COMMENT ) )
359 sal_Unicode* pBuffer = rString.AllocBuffer( nStringLen );
360 while ( nStringLen-- )
361 rIStm >> *pBuffer++;
364 rIStm.Seek( nOld );
367 // ------------------------------------------------------------------------
369 void ImplSkipActions( SvStream& rIStm, ULONG nSkipCount )
371 INT32 nActionSize;
372 INT16 nType;
374 for( ULONG i = 0UL; i < nSkipCount; i++ )
376 rIStm >> nType >> nActionSize;
377 rIStm.SeekRel( nActionSize - 4L );
381 // ----------------
382 // - SVMConverter -
383 // ----------------
385 SVMConverter::SVMConverter( SvStream& rStm, GDIMetaFile& rMtf, ULONG nConvertMode )
387 if( !rStm.GetError() )
389 if( CONVERT_FROM_SVM1 == nConvertMode )
390 ImplConvertFromSVM1( rStm, rMtf );
391 else if( CONVERT_TO_SVM1 == nConvertMode )
392 ImplConvertToSVM1( rStm, rMtf );
396 // ------------------------------------------------------------------------
398 void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
400 const ULONG nPos = rIStm.Tell();
401 const USHORT nOldFormat = rIStm.GetNumberFormatInt();
403 rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
405 char aCode[ 5 ];
406 Size aPrefSz;
407 INT16 nSize;
408 INT16 nVersion;
410 // read header
411 rIStm.Read( (char*) &aCode, sizeof( aCode ) ); // Kennung
412 rIStm >> nSize; // Size
413 rIStm >> nVersion; // Version
414 rIStm >> aPrefSz.Width(); // PrefSize.Width()
415 rIStm >> aPrefSz.Height(); // PrefSize.Height()
417 // check header-magic and version
418 if( rIStm.GetError()
419 || ( memcmp( aCode, "SVGDI", sizeof( aCode ) ) != 0 )
420 || ( nVersion != 200 ) )
422 rIStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
423 rIStm.SetNumberFormatInt( nOldFormat );
424 rIStm.Seek( nPos );
425 return;
428 LineInfo aLineInfo( LINE_NONE, 0 );
429 Stack aLIStack;
430 VirtualDevice aFontVDev;
431 rtl_TextEncoding eActualCharSet = gsl_getSystemTextEncoding();
432 BOOL bFatLine = FALSE;
434 // TODO: fix reindentation below if you can accept being blamed by the SCM
435 MapMode aMapMode;
436 Polygon aActionPoly;
437 Rectangle aRect;
438 Point aPt, aPt1;
439 Size aSz;
440 Color aActionColor;
441 INT32 nTmp, nTmp1, nActionSize;
442 INT32 nActions;
443 INT16 nType;
445 sal_uInt32 nUnicodeCommentStreamPos = 0;
446 INT32 nUnicodeCommentActionNumber = 0;
448 ImplReadMapMode( rIStm, aMapMode ); // MapMode
449 rIStm >> nActions; // Action count
451 rMtf.SetPrefSize( aPrefSz );
452 rMtf.SetPrefMapMode( aMapMode );
454 for( INT32 i = 0L; i < nActions; i++ )
456 rIStm >> nType;
457 sal_Int32 nActBegin = rIStm.Tell();
458 rIStm >> nActionSize;
460 DBG_ASSERT( ( nType <= 33 ) || ( nType >= 1024 ), "Unknown GDIMetaAction while converting!" );
462 switch( nType )
464 case( GDI_PIXEL_ACTION ):
466 rIStm >> aPt;
467 ImplReadColor( rIStm, aActionColor );
468 rMtf.AddAction( new MetaPixelAction( aPt, aActionColor ) );
470 break;
472 case( GDI_POINT_ACTION ):
474 rIStm >> aPt;
475 rMtf.AddAction( new MetaPointAction( aPt ) );
477 break;
479 case( GDI_LINE_ACTION ):
481 rIStm >> aPt >> aPt1;
482 rMtf.AddAction( new MetaLineAction( aPt, aPt1, aLineInfo ) );
484 break;
486 case( GDI_RECT_ACTION ):
488 ImplReadRect( rIStm, aRect );
489 rIStm >> nTmp >> nTmp1;
491 if( nTmp || nTmp1 )
492 rMtf.AddAction( new MetaRoundRectAction( aRect, nTmp, nTmp1 ) );
493 else
495 rMtf.AddAction( new MetaRectAction( aRect ) );
497 if( bFatLine )
498 rMtf.AddAction( new MetaPolyLineAction( aRect, aLineInfo ) );
501 break;
503 case( GDI_ELLIPSE_ACTION ):
505 ImplReadRect( rIStm, aRect );
507 if( bFatLine )
509 const Polygon aPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
511 rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR ) );
512 rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, FALSE ) );
513 rMtf.AddAction( new MetaPolygonAction( aPoly ) );
514 rMtf.AddAction( new MetaPopAction() );
515 rMtf.AddAction( new MetaPolyLineAction( aPoly, aLineInfo ) );
517 else
518 rMtf.AddAction( new MetaEllipseAction( aRect ) );
520 break;
522 case( GDI_ARC_ACTION ):
524 ImplReadRect( rIStm, aRect );
525 rIStm >> aPt >> aPt1;
527 if( bFatLine )
529 const Polygon aPoly( aRect, aPt, aPt1, POLY_ARC );
531 rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR ) );
532 rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, FALSE ) );
533 rMtf.AddAction( new MetaPolygonAction( aPoly ) );
534 rMtf.AddAction( new MetaPopAction() );
535 rMtf.AddAction( new MetaPolyLineAction( aPoly, aLineInfo ) );
537 else
538 rMtf.AddAction( new MetaArcAction( aRect, aPt, aPt1 ) );
540 break;
542 case( GDI_PIE_ACTION ):
544 ImplReadRect( rIStm, aRect );
545 rIStm >> aPt >> aPt1;
547 if( bFatLine )
549 const Polygon aPoly( aRect, aPt, aPt1, POLY_PIE );
551 rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR ) );
552 rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, FALSE ) );
553 rMtf.AddAction( new MetaPolygonAction( aPoly ) );
554 rMtf.AddAction( new MetaPopAction() );
555 rMtf.AddAction( new MetaPolyLineAction( aPoly, aLineInfo ) );
557 else
558 rMtf.AddAction( new MetaPieAction( aRect, aPt, aPt1 ) );
560 break;
562 case( GDI_INVERTRECT_ACTION ):
563 case( GDI_HIGHLIGHTRECT_ACTION ):
565 ImplReadRect( rIStm, aRect );
566 rMtf.AddAction( new MetaPushAction( PUSH_RASTEROP ) );
567 rMtf.AddAction( new MetaRasterOpAction( ROP_INVERT ) );
568 rMtf.AddAction( new MetaRectAction( aRect ) );
569 rMtf.AddAction( new MetaPopAction() );
571 break;
573 case( GDI_POLYLINE_ACTION ):
575 ImplReadPoly( rIStm, aActionPoly );
577 if( bFatLine )
578 rMtf.AddAction( new MetaPolyLineAction( aActionPoly, aLineInfo ) );
579 else
580 rMtf.AddAction( new MetaPolyLineAction( aActionPoly ) );
582 break;
584 case( GDI_POLYGON_ACTION ):
586 ImplReadPoly( rIStm, aActionPoly );
588 if( bFatLine )
590 rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR ) );
591 rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, FALSE ) );
592 rMtf.AddAction( new MetaPolygonAction( aActionPoly ) );
593 rMtf.AddAction( new MetaPopAction() );
594 rMtf.AddAction( new MetaPolyLineAction( aActionPoly, aLineInfo ) );
596 else
597 rMtf.AddAction( new MetaPolygonAction( aActionPoly ) );
599 break;
601 case( GDI_POLYPOLYGON_ACTION ):
603 PolyPolygon aPolyPoly;
605 ImplReadPolyPoly( rIStm, aPolyPoly );
607 if( bFatLine )
609 rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR ) );
610 rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, FALSE ) );
611 rMtf.AddAction( new MetaPolyPolygonAction( aPolyPoly ) );
612 rMtf.AddAction( new MetaPopAction() );
614 for( USHORT nPoly = 0, nCount = aPolyPoly.Count(); nPoly < nCount; nPoly++ )
615 rMtf.AddAction( new MetaPolyLineAction( aPolyPoly[ nPoly ], aLineInfo ) );
617 else
618 rMtf.AddAction( new MetaPolyPolygonAction( aPolyPoly ) );
620 break;
622 case( GDI_FONT_ACTION ):
624 Font aFont;
625 char aName[ 32 ];
626 INT32 nWidth, nHeight;
627 INT16 nCharSet, nFamily, nPitch, nAlign, nWeight, nUnderline, nStrikeout;
628 INT16 nCharOrient, nLineOrient;
629 BOOL bItalic, bOutline, bShadow, bTransparent;
631 ImplReadColor( rIStm, aActionColor ); aFont.SetColor( aActionColor );
632 ImplReadColor( rIStm, aActionColor ); aFont.SetFillColor( aActionColor );
633 rIStm.Read( aName, 32 );
634 aFont.SetName( UniString( aName, rIStm.GetStreamCharSet() ) );
635 rIStm >> nWidth >> nHeight;
636 rIStm >> nCharOrient >> nLineOrient;
637 rIStm >> nCharSet >> nFamily >> nPitch >> nAlign >> nWeight >> nUnderline >> nStrikeout;
638 rIStm >> bItalic >> bOutline >> bShadow >> bTransparent;
640 aFont.SetSize( Size( nWidth, nHeight ) );
641 aFont.SetCharSet( (CharSet) nCharSet );
642 aFont.SetFamily( (FontFamily) nFamily );
643 aFont.SetPitch( (FontPitch) nPitch );
644 aFont.SetAlign( (FontAlign) nAlign );
645 aFont.SetWeight( ( nWeight == 1 ) ? WEIGHT_LIGHT : ( nWeight == 2 ) ? WEIGHT_NORMAL :
646 ( nWeight == 3 ) ? WEIGHT_BOLD : WEIGHT_DONTKNOW );
647 aFont.SetUnderline( (FontUnderline) nUnderline );
648 aFont.SetStrikeout( (FontStrikeout) nStrikeout );
649 aFont.SetItalic( bItalic ? ITALIC_NORMAL : ITALIC_NONE );
650 aFont.SetOutline( bOutline );
651 aFont.SetShadow( bShadow );
652 aFont.SetOrientation( nLineOrient );
653 aFont.SetTransparent( bTransparent );
655 eActualCharSet = aFont.GetCharSet();
656 if ( eActualCharSet == RTL_TEXTENCODING_DONTKNOW )
657 eActualCharSet = gsl_getSystemTextEncoding();
659 rMtf.AddAction( new MetaFontAction( aFont ) );
660 rMtf.AddAction( new MetaTextAlignAction( aFont.GetAlign() ) );
661 rMtf.AddAction( new MetaTextColorAction( aFont.GetColor() ) );
662 rMtf.AddAction( new MetaTextFillColorAction( aFont.GetFillColor(), !aFont.IsTransparent() ) );
664 // #106172# Track font relevant data in shadow VDev
665 aFontVDev.SetFont( aFont );
667 break;
669 case( GDI_TEXT_ACTION ):
671 ByteString aByteStr;
672 INT32 nIndex, nLen;
674 rIStm >> aPt >> nIndex >> nLen >> nTmp;
675 if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) )
677 rIStm.Read( aByteStr.AllocBuffer( (USHORT)nTmp ), nTmp + 1 );
678 UniString aStr( aByteStr, eActualCharSet );
679 if ( nUnicodeCommentActionNumber == i )
680 ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr );
681 rMtf.AddAction( new MetaTextAction( aPt, aStr, (USHORT) nIndex, (USHORT) nLen ) );
683 rIStm.Seek( nActBegin + nActionSize );
685 break;
687 case( GDI_TEXTARRAY_ACTION ):
689 ByteString aByteStr;
690 sal_Int32* pDXAry = NULL;
691 INT32 nIndex, nLen, nAryLen;
693 rIStm >> aPt >> nIndex >> nLen >> nTmp >> nAryLen;
694 if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) )
696 rIStm.Read( aByteStr.AllocBuffer( (USHORT)nTmp ), nTmp + 1 );
697 UniString aStr( aByteStr, eActualCharSet );
699 if( nAryLen > 0L )
701 INT32 nStrLen( aStr.Len() );
703 pDXAry = new sal_Int32[ Max( nAryLen, nStrLen ) ];
705 for( long j = 0L; j < nAryLen; j++ )
706 rIStm >> nTmp, pDXAry[ j ] = nTmp;
708 // #106172# Add last DX array elem, if missing
709 if( nAryLen != nStrLen )
711 if( nAryLen+1 == nStrLen )
713 sal_Int32* pTmpAry = new sal_Int32[nStrLen];
715 aFontVDev.GetTextArray( aStr, pTmpAry, (USHORT) nIndex, (USHORT) nLen );
717 // now, the difference between the
718 // last and the second last DX array
719 // is the advancement for the last
720 // glyph. Thus, to complete our meta
721 // action's DX array, just add that
722 // difference to last elem and store
723 // in very last.
724 if( nStrLen > 1 )
725 pDXAry[ nStrLen-1 ] = pDXAry[ nStrLen-2 ] + pTmpAry[ nStrLen-1 ] - pTmpAry[ nStrLen-2 ];
726 else
727 pDXAry[ nStrLen-1 ] = pTmpAry[ nStrLen-1 ]; // len=1: 0th position taken to be 0
729 delete[] pTmpAry;
731 #ifdef DBG_UTIL
732 else
733 DBG_ERROR("More than one DX array element missing on SVM import");
734 #endif
737 if ( nUnicodeCommentActionNumber == i )
738 ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr );
739 rMtf.AddAction( new MetaTextArrayAction( aPt, aStr, pDXAry, (USHORT) nIndex, (USHORT) nLen ) );
741 if( pDXAry )
742 delete[] pDXAry;
744 rIStm.Seek( nActBegin + nActionSize );
746 break;
748 case( GDI_STRETCHTEXT_ACTION ):
750 ByteString aByteStr;
751 INT32 nIndex, nLen, nWidth;
753 rIStm >> aPt >> nIndex >> nLen >> nTmp >> nWidth;
754 if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_INT16 - 1 ) ) )
756 rIStm.Read( aByteStr.AllocBuffer( (USHORT)nTmp ), nTmp + 1 );
757 UniString aStr( aByteStr, eActualCharSet );
758 if ( nUnicodeCommentActionNumber == i )
759 ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr );
760 rMtf.AddAction( new MetaStretchTextAction( aPt, nWidth, aStr, (USHORT) nIndex, (USHORT) nLen ) );
762 rIStm.Seek( nActBegin + nActionSize );
764 break;
766 case( GDI_BITMAP_ACTION ):
768 Bitmap aBmp;
770 rIStm >> aPt >> aBmp;
771 rMtf.AddAction( new MetaBmpAction( aPt, aBmp ) );
773 break;
775 case( GDI_BITMAPSCALE_ACTION ):
777 Bitmap aBmp;
779 rIStm >> aPt >> aSz >> aBmp;
780 rMtf.AddAction( new MetaBmpScaleAction( aPt, aSz, aBmp ) );
782 break;
784 case( GDI_BITMAPSCALEPART_ACTION ):
786 Bitmap aBmp;
787 Size aSz2;
789 rIStm >> aPt >> aSz >> aPt1 >> aSz2 >> aBmp;
790 rMtf.AddAction( new MetaBmpScalePartAction( aPt, aSz, aPt1, aSz2, aBmp ) );
792 break;
794 case( GDI_PEN_ACTION ):
796 INT32 nPenWidth;
797 INT16 nPenStyle;
799 ImplReadColor( rIStm, aActionColor );
800 rIStm >> nPenWidth >> nPenStyle;
802 aLineInfo.SetStyle( nPenStyle ? LINE_SOLID : LINE_NONE );
803 aLineInfo.SetWidth( nPenWidth );
804 bFatLine = nPenStyle && !aLineInfo.IsDefault();
806 rMtf.AddAction( new MetaLineColorAction( aActionColor, nPenStyle != 0 ) );
808 break;
810 case( GDI_FILLBRUSH_ACTION ):
812 INT16 nBrushStyle;
814 ImplReadColor( rIStm, aActionColor );
815 rIStm.SeekRel( 6L );
816 rIStm >> nBrushStyle;
817 rMtf.AddAction( new MetaFillColorAction( aActionColor, nBrushStyle != 0 ) );
818 rIStm.SeekRel( 2L );
820 break;
822 case( GDI_MAPMODE_ACTION ):
824 ImplReadMapMode( rIStm, aMapMode );
825 rMtf.AddAction( new MetaMapModeAction( aMapMode ) );
827 // #106172# Track font relevant data in shadow VDev
828 aFontVDev.SetMapMode( aMapMode );
830 break;
832 case( GDI_CLIPREGION_ACTION ):
834 Region aRegion;
835 INT16 nRegType;
836 INT16 bIntersect;
837 BOOL bClip = FALSE;
839 rIStm >> nRegType >> bIntersect;
840 ImplReadRect( rIStm, aRect );
842 switch( nRegType )
844 case( 0 ):
845 break;
847 case( 1 ):
849 Rectangle aRegRect;
851 ImplReadRect( rIStm, aRegRect );
852 aRegion = Region( aRegRect );
853 bClip = TRUE;
855 break;
857 case( 2 ):
859 ImplReadPoly( rIStm, aActionPoly );
860 aRegion = Region( aActionPoly );
861 bClip = TRUE;
863 break;
865 case( 3 ):
867 PolyPolygon aPolyPoly;
868 INT32 nPolyCount;
870 rIStm >> nPolyCount;
872 for( USHORT j = 0; j < (USHORT) nPolyCount; j++ )
874 ImplReadPoly( rIStm, aActionPoly );
875 aPolyPoly.Insert( aActionPoly );
878 aRegion = Region( aPolyPoly );
879 bClip = TRUE;
881 break;
884 if( bIntersect )
885 aRegion.Intersect( aRect );
887 rMtf.AddAction( new MetaClipRegionAction( aRegion, bClip ) );
889 break;
891 case( GDI_MOVECLIPREGION_ACTION ):
893 rIStm >> nTmp >> nTmp1;
894 rMtf.AddAction( new MetaMoveClipRegionAction( nTmp, nTmp1 ) );
896 break;
898 case( GDI_ISECTCLIPREGION_ACTION ):
900 ImplReadRect( rIStm, aRect );
901 rMtf.AddAction( new MetaISectRectClipRegionAction( aRect ) );
903 break;
905 case( GDI_RASTEROP_ACTION ):
907 RasterOp eRasterOp;
908 INT16 nRasterOp;
910 rIStm >> nRasterOp;
912 switch( nRasterOp )
914 case( 1 ):
915 eRasterOp = ROP_INVERT;
916 break;
918 case( 4 ):
919 case( 5 ):
920 eRasterOp = ROP_XOR;
921 break;
923 default:
924 eRasterOp = ROP_OVERPAINT;
925 break;
928 rMtf.AddAction( new MetaRasterOpAction( eRasterOp ) );
930 break;
932 case( GDI_PUSH_ACTION ):
934 aLIStack.Push( new LineInfo( aLineInfo ) );
935 rMtf.AddAction( new MetaPushAction( PUSH_ALL ) );
937 // #106172# Track font relevant data in shadow VDev
938 aFontVDev.Push();
940 break;
942 case( GDI_POP_ACTION ):
945 LineInfo* pLineInfo = (LineInfo*) aLIStack.Pop();
947 // restore line info
948 if( pLineInfo )
950 aLineInfo = *pLineInfo;
951 delete pLineInfo;
952 bFatLine = ( LINE_NONE != aLineInfo.GetStyle() ) && !aLineInfo.IsDefault();
955 rMtf.AddAction( new MetaPopAction() );
957 // #106172# Track font relevant data in shadow VDev
958 aFontVDev.Pop();
960 break;
962 case( GDI_GRADIENT_ACTION ):
964 Color aStartCol;
965 Color aEndCol;
966 INT16 nStyle;
967 INT16 nAngle;
968 INT16 nBorder;
969 INT16 nOfsX;
970 INT16 nOfsY;
971 INT16 nIntensityStart;
972 INT16 nIntensityEnd;
974 ImplReadRect( rIStm, aRect );
975 rIStm >> nStyle;
976 ImplReadColor( rIStm, aStartCol );
977 ImplReadColor( rIStm, aEndCol );
978 rIStm >> nAngle >> nBorder >> nOfsX >> nOfsY >> nIntensityStart >> nIntensityEnd;
980 Gradient aGrad( (GradientStyle) nStyle, aStartCol, aEndCol );
982 aGrad.SetAngle( nAngle );
983 aGrad.SetBorder( nBorder );
984 aGrad.SetOfsX( nOfsX );
985 aGrad.SetOfsY( nOfsY );
986 aGrad.SetStartIntensity( nIntensityStart );
987 aGrad.SetEndIntensity( nIntensityEnd );
988 rMtf.AddAction( new MetaGradientAction( aRect, aGrad ) );
990 break;
992 case( GDI_TRANSPARENT_COMMENT ):
994 PolyPolygon aPolyPoly;
995 INT32 nFollowingActionCount;
996 INT16 nTrans;
998 rIStm >> aPolyPoly >> nTrans >> nFollowingActionCount;
999 ImplSkipActions( rIStm, nFollowingActionCount );
1000 rMtf.AddAction( new MetaTransparentAction( aPolyPoly, nTrans ) );
1002 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1003 i += nFollowingActionCount;
1004 #endif
1006 break;
1008 case( GDI_FLOATTRANSPARENT_COMMENT ):
1010 GDIMetaFile aMtf;
1011 Point aPos;
1012 Size aSize;
1013 Gradient aGradient;
1014 INT32 nFollowingActionCount;
1016 rIStm >> aMtf >> aPos >> aSize >> aGradient >> nFollowingActionCount;
1017 ImplSkipActions( rIStm, nFollowingActionCount );
1018 rMtf.AddAction( new MetaFloatTransparentAction( aMtf, aPos, aSize, aGradient ) );
1020 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1021 i += nFollowingActionCount;
1022 #endif
1024 break;
1026 case( GDI_HATCH_COMMENT ):
1028 PolyPolygon aPolyPoly;
1029 Hatch aHatch;
1030 INT32 nFollowingActionCount;
1032 rIStm >> aPolyPoly >> aHatch >> nFollowingActionCount;
1033 ImplSkipActions( rIStm, nFollowingActionCount );
1034 rMtf.AddAction( new MetaHatchAction( aPolyPoly, aHatch ) );
1036 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1037 i += nFollowingActionCount;
1038 #endif
1040 break;
1042 case( GDI_REFPOINT_COMMENT ):
1044 Point aRefPoint;
1045 BOOL bSet;
1046 INT32 nFollowingActionCount;
1048 rIStm >> aRefPoint >> bSet >> nFollowingActionCount;
1049 ImplSkipActions( rIStm, nFollowingActionCount );
1050 rMtf.AddAction( new MetaRefPointAction( aRefPoint, bSet ) );
1052 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1053 i += nFollowingActionCount;
1054 #endif
1056 // #106172# Track font relevant data in shadow VDev
1057 if( bSet )
1058 aFontVDev.SetRefPoint( aRefPoint );
1059 else
1060 aFontVDev.SetRefPoint();
1062 break;
1064 case( GDI_TEXTLINECOLOR_COMMENT ):
1066 Color aColor;
1067 BOOL bSet;
1068 INT32 nFollowingActionCount;
1070 rIStm >> aColor >> bSet >> nFollowingActionCount;
1071 ImplSkipActions( rIStm, nFollowingActionCount );
1072 rMtf.AddAction( new MetaTextLineColorAction( aColor, bSet ) );
1074 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1075 i += nFollowingActionCount;
1076 #endif
1078 break;
1080 case( GDI_TEXTLINE_COMMENT ):
1082 Point aStartPt;
1083 long nWidth;
1084 sal_uInt32 nStrikeout;
1085 sal_uInt32 nUnderline;
1086 INT32 nFollowingActionCount;
1088 rIStm >> aStartPt >> nWidth >> nStrikeout >> nUnderline >> nFollowingActionCount;
1089 ImplSkipActions( rIStm, nFollowingActionCount );
1090 rMtf.AddAction( new MetaTextLineAction( aStartPt, nWidth,
1091 (FontStrikeout) nStrikeout,
1092 (FontUnderline) nUnderline,
1093 UNDERLINE_NONE ) );
1095 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1096 i += nFollowingActionCount;
1097 #endif
1099 break;
1101 case( GDI_GRADIENTEX_COMMENT ):
1103 PolyPolygon aPolyPoly;
1104 Gradient aGradient;
1105 INT32 nFollowingActionCount;
1107 rIStm >> aPolyPoly >> aGradient >> nFollowingActionCount;
1108 ImplSkipActions( rIStm, nFollowingActionCount );
1109 rMtf.AddAction( new MetaGradientExAction( aPolyPoly, aGradient ) );
1111 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1112 i += nFollowingActionCount;
1113 #endif
1115 break;
1117 case( GDI_COMMENT_COMMENT ):
1119 ByteString aComment;
1120 sal_Int32 nValue;
1121 sal_uInt32 nDataSize;
1122 BYTE* pData;
1123 INT32 nFollowingActionCount;
1125 rIStm >> aComment >> nValue >> nDataSize;
1127 if( nDataSize )
1129 pData = new BYTE[ nDataSize ];
1130 rIStm.Read( pData, nDataSize );
1132 else
1133 pData = NULL;
1135 rIStm >> nFollowingActionCount;
1136 ImplSkipActions( rIStm, nFollowingActionCount );
1137 rMtf.AddAction( new MetaCommentAction( aComment, nValue, pData, nDataSize ) );
1139 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1140 i += nFollowingActionCount;
1141 #endif
1143 break;
1145 case ( GDI_UNICODE_COMMENT ):
1147 nUnicodeCommentActionNumber = i + 1;
1148 nUnicodeCommentStreamPos = rIStm.Tell() - 6;
1149 rIStm.SeekRel( nActionSize - 4 );
1151 break;
1153 default:
1154 rIStm.SeekRel( nActionSize - 4L );
1155 break;
1159 // cleanup push-pop stack if neccessary
1160 for( void* pLineInfo = aLIStack.Pop(); pLineInfo; pLineInfo = aLIStack.Pop() )
1161 delete (LineInfo*) pLineInfo;
1163 rIStm.SetNumberFormatInt( nOldFormat );
1166 // ------------------------------------------------------------------------
1168 void SVMConverter::ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile& rMtf )
1170 ULONG nPos;
1171 ULONG nCountPos;
1172 Font aSaveFont;
1173 const USHORT nOldFormat = rOStm.GetNumberFormatInt();
1174 rtl_TextEncoding eActualCharSet = gsl_getSystemTextEncoding();
1175 const Size aPrefSize( rMtf.GetPrefSize() );
1176 BOOL bRop_0_1 = FALSE;
1177 VirtualDevice aSaveVDev;
1178 Color aLineCol( COL_BLACK );
1179 Stack aLineColStack;
1181 rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
1183 //MagicCode schreiben
1184 rOStm << "SVGDI"; // Kennung
1185 nPos = rOStm.Tell();
1186 rOStm << (INT16) 42; // HeaderSize
1187 rOStm << (INT16) 200; // VERSION
1188 rOStm << (INT32) aPrefSize.Width();
1189 rOStm << (INT32) aPrefSize.Height();
1190 ImplWriteMapMode( rOStm, rMtf.GetPrefMapMode() );
1192 // ActionCount wird spaeter geschrieben
1193 nCountPos = rOStm.Tell();
1194 rOStm.SeekRel( 4L );
1196 const INT32 nActCount = ImplWriteActions( rOStm, rMtf, aSaveVDev, bRop_0_1, aLineCol, aLineColStack, eActualCharSet );
1197 const ULONG nActPos = rOStm.Tell();
1199 rOStm.Seek( nCountPos );
1200 rOStm << nActCount;
1201 rOStm.Seek( nActPos );
1202 rOStm.SetNumberFormatInt( nOldFormat );
1204 // cleanup push-pop stack if neccessary
1205 for( void* pCol = aLineColStack.Pop(); pCol; pCol = aLineColStack.Pop() )
1206 delete (Color*) pCol;
1209 // ------------------------------------------------------------------------
1211 ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf,
1212 VirtualDevice& rSaveVDev, BOOL& rRop_0_1,
1213 Color& rLineCol, Stack& rLineColStack,
1214 rtl_TextEncoding& rActualCharSet )
1216 ULONG nCount = 0;
1217 for( ULONG i = 0, nActionCount = rMtf.GetActionCount(); i < nActionCount; i++ )
1219 const MetaAction* pAction = rMtf.GetAction( i );
1221 switch( pAction->GetType() )
1223 case( META_PIXEL_ACTION ):
1225 MetaPixelAction* pAct = (MetaPixelAction*) pAction;
1227 rOStm << (INT16) GDI_PIXEL_ACTION;
1228 rOStm << (INT32) 18;
1229 rOStm << pAct->GetPoint();
1230 ImplWriteColor( rOStm, pAct->GetColor() );
1231 nCount++;
1233 break;
1235 case( META_POINT_ACTION ):
1237 MetaPointAction* pAct = (MetaPointAction*) pAction;
1239 rOStm << (INT16) GDI_POINT_ACTION;
1240 rOStm << (INT32) 12;
1241 rOStm << pAct->GetPoint();
1242 nCount++;
1244 break;
1246 case( META_LINE_ACTION ):
1248 MetaLineAction* pAct = (MetaLineAction*) pAction;
1249 const LineInfo& rInfo = pAct->GetLineInfo();
1250 const BOOL bFatLine = ( !rInfo.IsDefault() && ( LINE_NONE != rInfo.GetStyle() ) );
1252 if( bFatLine )
1254 ImplWritePushAction( rOStm );
1255 ImplWriteLineColor( rOStm, rLineCol, 1, rInfo.GetWidth() );
1258 rOStm << (INT16) GDI_LINE_ACTION;
1259 rOStm << (INT32) 20;
1260 rOStm << pAct->GetStartPoint();
1261 rOStm << pAct->GetEndPoint();
1262 nCount++;
1264 if( bFatLine )
1266 ImplWritePopAction( rOStm );
1267 nCount += 3;
1270 break;
1272 case( META_RECT_ACTION ):
1274 MetaRectAction* pAct = (MetaRectAction*) pAction;
1276 rOStm << (INT16) GDI_RECT_ACTION;
1277 rOStm << (INT32) 28;
1278 ImplWriteRect( rOStm, pAct->GetRect() );
1279 rOStm << (INT32) 0;
1280 rOStm << (INT32) 0;
1281 nCount++;
1283 break;
1285 case( META_ROUNDRECT_ACTION ):
1287 MetaRoundRectAction* pAct = (MetaRoundRectAction*) pAction;
1289 rOStm << (INT16) GDI_RECT_ACTION;
1290 rOStm << (INT32) 28;
1291 ImplWriteRect( rOStm, pAct->GetRect() );
1292 rOStm << (INT32) pAct->GetHorzRound();
1293 rOStm << (INT32) pAct->GetVertRound();
1294 nCount++;
1296 break;
1298 case( META_ELLIPSE_ACTION ):
1300 MetaEllipseAction* pAct = (MetaEllipseAction*) pAction;
1302 rOStm << (INT16) GDI_ELLIPSE_ACTION;
1303 rOStm << (INT32) 20;
1304 ImplWriteRect( rOStm, pAct->GetRect() );
1305 nCount++;
1307 break;
1309 case( META_ARC_ACTION ):
1311 MetaArcAction* pAct = (MetaArcAction*) pAction;
1313 rOStm << (INT16) GDI_ARC_ACTION;
1314 rOStm << (INT32) 36;
1315 ImplWriteRect( rOStm, pAct->GetRect() );
1316 rOStm << pAct->GetStartPoint();
1317 rOStm << pAct->GetEndPoint();
1318 nCount++;
1320 break;
1322 case( META_PIE_ACTION ):
1324 MetaPieAction* pAct = (MetaPieAction*) pAction;
1326 rOStm << (INT16) GDI_PIE_ACTION;
1327 rOStm << (INT32) 36;
1328 ImplWriteRect( rOStm, pAct->GetRect() );
1329 rOStm << pAct->GetStartPoint();
1330 rOStm << pAct->GetEndPoint();
1331 nCount++;
1333 break;
1335 case( META_CHORD_ACTION ):
1337 MetaChordAction* pAct = (MetaChordAction*) pAction;
1338 Polygon aChordPoly( pAct->GetRect(), pAct->GetStartPoint(),
1339 pAct->GetEndPoint(), POLY_CHORD );
1340 const USHORT nPoints = aChordPoly.GetSize();
1342 rOStm << (INT16) GDI_POLYGON_ACTION;
1343 rOStm << (INT32) ( 8 + ( nPoints << 3 ) );
1344 rOStm << (INT32) nPoints;
1346 for( USHORT n = 0; n < nPoints; n++ )
1347 rOStm << aChordPoly[ n ];
1349 nCount++;
1351 break;
1353 case( META_POLYLINE_ACTION ):
1355 MetaPolyLineAction* pAct = (MetaPolyLineAction*) pAction;
1356 const Polygon& rPoly = pAct->GetPolygon();
1357 const LineInfo& rInfo = pAct->GetLineInfo();
1358 const USHORT nPoints = rPoly.GetSize();
1359 const BOOL bFatLine = ( !rInfo.IsDefault() && ( LINE_NONE != rInfo.GetStyle() ) );
1361 if( bFatLine )
1363 ImplWritePushAction( rOStm );
1364 ImplWriteLineColor( rOStm, rLineCol, 1, rInfo.GetWidth() );
1367 rOStm << (INT16) GDI_POLYLINE_ACTION;
1368 rOStm << (INT32) ( 8 + ( nPoints << 3 ) );
1369 rOStm << (INT32) nPoints;
1371 for( USHORT n = 0; n < nPoints; n++ )
1372 rOStm << rPoly[ n ];
1374 nCount++;
1376 if( bFatLine )
1378 ImplWritePopAction( rOStm );
1379 nCount += 3;
1382 break;
1384 case( META_POLYGON_ACTION ):
1386 MetaPolygonAction* pAct = (MetaPolygonAction*) pAction;
1387 const Polygon& rPoly = pAct->GetPolygon();
1388 const USHORT nPoints = rPoly.GetSize();
1390 rOStm << (INT16) GDI_POLYGON_ACTION;
1391 rOStm << (INT32) ( 8 + ( nPoints << 3 ) );
1392 rOStm << (INT32) nPoints;
1394 for( USHORT n = 0; n < nPoints; n++ )
1395 rOStm << rPoly[ n ];
1397 nCount++;
1399 break;
1401 case( META_POLYPOLYGON_ACTION ):
1403 MetaPolyPolygonAction* pAct = (MetaPolyPolygonAction*) pAction;
1404 ImplWritePolyPolyAction( rOStm, pAct->GetPolyPolygon() );
1405 nCount++;
1407 break;
1409 case( META_TEXT_ACTION ):
1411 MetaTextAction* pAct = (MetaTextAction*) pAction;
1412 String aUniText( pAct->GetText() );
1413 ByteString aText( aUniText, rActualCharSet );
1414 const ULONG nStrLen = aText.Len();
1416 if ( ImplWriteUnicodeComment( rOStm, aUniText ) )
1417 nCount++;
1419 rOStm << (INT16) GDI_TEXT_ACTION;
1420 rOStm << (INT32) ( 24 + ( nStrLen + 1 ) );
1421 rOStm << pAct->GetPoint();
1422 rOStm << (INT32) pAct->GetIndex();
1423 rOStm << (INT32) pAct->GetLen();
1424 rOStm << (INT32) nStrLen;
1425 rOStm.Write( aText.GetBuffer(), nStrLen + 1 );
1426 nCount++;
1428 break;
1430 case( META_TEXTARRAY_ACTION ):
1432 MetaTextArrayAction* pAct = (MetaTextArrayAction*)pAction;
1433 ByteString aText( pAct->GetText(), rActualCharSet );
1434 String aUniText( pAct->GetText(), pAct->GetIndex(), pAct->GetLen() );
1435 ULONG nAryLen;
1436 ULONG nLen = pAct->GetLen();
1437 const ULONG nTextLen = aText.Len();
1438 sal_Int32* pDXArray = pAct->GetDXArray();
1440 if ( ImplWriteUnicodeComment( rOStm, aUniText ) )
1441 nCount++;
1443 if( ( nLen + pAct->GetIndex() ) > nTextLen )
1445 if( pAct->GetIndex() <= nTextLen )
1446 nLen = nTextLen - pAct->GetIndex();
1447 else
1448 nLen = 0UL;
1451 if( !pDXArray || !nLen )
1452 nAryLen = 0;
1453 else
1454 nAryLen = nLen; // #105987# Write out all of DX array
1456 rOStm << (INT16) GDI_TEXTARRAY_ACTION;
1457 rOStm << (INT32) ( 28 + ( nLen + 1 ) + ( nAryLen * 4 ) );
1458 rOStm << pAct->GetPoint();
1459 rOStm << (INT32) 0;
1460 rOStm << (INT32) nLen;
1461 rOStm << (INT32) nLen;
1462 rOStm << (INT32) nAryLen;
1463 rOStm.Write( aText.GetBuffer()+pAct->GetIndex(), nLen + 1 );
1465 for( ULONG n = 0UL ; n < nAryLen; n++ )
1466 rOStm << (INT32) pDXArray[ n ];
1468 nCount++;
1470 break;
1472 case( META_STRETCHTEXT_ACTION ):
1474 MetaStretchTextAction* pAct = (MetaStretchTextAction*) pAction;
1475 String aUniText( pAct->GetText() );
1476 ByteString aText( aUniText, rActualCharSet );
1477 const ULONG nStrLen = aText.Len();
1479 if ( ImplWriteUnicodeComment( rOStm, aUniText ) )
1480 nCount++;
1482 rOStm << (INT16) GDI_STRETCHTEXT_ACTION;
1483 rOStm << (INT32) ( 28 + ( nStrLen + 1 ) );
1484 rOStm << pAct->GetPoint();
1485 rOStm << (INT32) pAct->GetIndex();
1486 rOStm << (INT32) pAct->GetLen();
1487 rOStm << (INT32) nStrLen;
1488 rOStm << (INT32) pAct->GetWidth();
1489 rOStm.Write( aText.GetBuffer(), nStrLen + 1 );
1490 nCount++;
1492 break;
1494 case( META_BMP_ACTION ):
1496 MetaBmpAction* pAct = (MetaBmpAction*) pAction;
1498 rOStm << (INT16) GDI_BITMAP_ACTION;
1499 rOStm << (INT32) 12;
1500 rOStm << pAct->GetPoint();
1501 rOStm << pAct->GetBitmap();
1502 nCount++;
1504 break;
1506 case( META_BMPSCALE_ACTION ):
1508 MetaBmpScaleAction* pAct = (MetaBmpScaleAction*) pAction;
1510 rOStm << (INT16) GDI_BITMAPSCALE_ACTION;
1511 rOStm << (INT32) 20;
1512 rOStm << pAct->GetPoint();
1513 rOStm << pAct->GetSize();
1514 rOStm << pAct->GetBitmap();
1515 nCount++;
1517 break;
1519 case( META_BMPSCALEPART_ACTION ):
1521 MetaBmpScalePartAction* pAct = (MetaBmpScalePartAction*) pAction;
1523 rOStm << (INT16) GDI_BITMAPSCALEPART_ACTION;
1524 rOStm << (INT32) 36;
1525 rOStm << pAct->GetDestPoint();
1526 rOStm << pAct->GetDestSize();
1527 rOStm << pAct->GetSrcPoint();
1528 rOStm << pAct->GetSrcSize();
1529 rOStm << pAct->GetBitmap();
1530 nCount++;
1532 break;
1534 case( META_BMPEX_ACTION ):
1536 MetaBmpExAction* pAct = (MetaBmpExAction*) pAction;
1537 const Bitmap aBmp( Graphic( pAct->GetBitmapEx() ).GetBitmap() );
1539 rOStm << (INT16) GDI_BITMAP_ACTION;
1540 rOStm << (INT32) 12;
1541 rOStm << pAct->GetPoint();
1542 rOStm << aBmp;
1543 nCount++;
1545 break;
1547 case( META_BMPEXSCALE_ACTION ):
1549 MetaBmpExScaleAction* pAct = (MetaBmpExScaleAction*) pAction;
1550 const Bitmap aBmp( Graphic( pAct->GetBitmapEx() ).GetBitmap() );
1552 rOStm << (INT16) GDI_BITMAPSCALE_ACTION;
1553 rOStm << (INT32) 20;
1554 rOStm << pAct->GetPoint();
1555 rOStm << pAct->GetSize();
1556 rOStm << aBmp;
1557 nCount++;
1559 break;
1561 case( META_BMPEXSCALEPART_ACTION ):
1563 MetaBmpExScalePartAction* pAct = (MetaBmpExScalePartAction*) pAction;
1564 const Bitmap aBmp( Graphic( pAct->GetBitmapEx() ).GetBitmap() );
1566 rOStm << (INT16) GDI_BITMAPSCALEPART_ACTION;
1567 rOStm << (INT32) 36;
1568 rOStm << pAct->GetDestPoint();
1569 rOStm << pAct->GetDestSize();
1570 rOStm << pAct->GetSrcPoint();
1571 rOStm << pAct->GetSrcSize();
1572 rOStm << aBmp;
1573 nCount++;
1575 break;
1577 case( META_GRADIENT_ACTION ):
1579 MetaGradientAction* pAct = (MetaGradientAction*) pAction;
1580 const Gradient& rGrad = pAct->GetGradient();
1582 rOStm << (INT16) GDI_GRADIENT_ACTION;
1583 rOStm << (INT32) 46;
1584 ImplWriteRect( rOStm, pAct->GetRect() );
1585 rOStm << (INT16) rGrad.GetStyle();
1586 ImplWriteColor( rOStm, rGrad.GetStartColor() );
1587 ImplWriteColor( rOStm, rGrad.GetEndColor() );
1588 rOStm << (INT16) rGrad.GetAngle();
1589 rOStm << (INT16) rGrad.GetBorder();
1590 rOStm << (INT16) rGrad.GetOfsX();
1591 rOStm << (INT16) rGrad.GetOfsY();
1592 rOStm << (INT16) rGrad.GetStartIntensity();
1593 rOStm << (INT16) rGrad.GetEndIntensity();
1594 nCount++;
1596 break;
1598 case( META_GRADIENTEX_ACTION ):
1600 const MetaGradientExAction* pA = (MetaGradientExAction*) pAction;
1601 ULONG nOldPos, nNewPos;
1603 // write RefPoint comment
1604 rOStm << (INT16) GDI_GRADIENTEX_COMMENT;
1606 // we'll write the ActionSize later
1607 nOldPos = rOStm.Tell();
1608 rOStm.SeekRel( 4 );
1610 // write data
1611 rOStm << pA->GetPolyPolygon() << pA->GetGradient();
1612 rOStm << (INT32) 0; // number of actions that follow this comment
1614 // calculate and write ActionSize of comment
1615 nNewPos = rOStm.Tell();
1616 rOStm.Seek( nOldPos );
1617 rOStm << (INT32) ( nNewPos - nOldPos );
1618 rOStm.Seek( nNewPos );
1620 nCount++;
1622 break;
1624 case( META_WALLPAPER_ACTION ):
1626 MetaWallpaperAction* pAct = (MetaWallpaperAction*) pAction;
1627 const Color& rColor = pAct->GetWallpaper().GetColor();
1629 ImplWritePushAction( rOStm );
1630 ImplWriteLineColor( rOStm, rColor, 1 );
1631 ImplWriteFillColor( rOStm, rColor, 1 );
1633 rOStm << (INT16) GDI_RECT_ACTION;
1634 rOStm << (INT32) 28;
1635 ImplWriteRect( rOStm, pAct->GetRect() );
1636 rOStm << (INT32) 0;
1637 rOStm << (INT32) 0;
1639 ImplWritePopAction( rOStm );
1640 nCount += 5;
1642 break;
1644 case( META_CLIPREGION_ACTION ):
1646 MetaClipRegionAction* pAct = (MetaClipRegionAction*) pAction;
1647 const Region& rRegion = pAct->GetRegion();
1648 Rectangle aClipRect;
1650 rOStm << (INT16) GDI_CLIPREGION_ACTION;
1651 rOStm << (INT32) 24;
1653 if( pAct->IsClipping() )
1655 aClipRect = rRegion.GetBoundRect();
1656 rOStm << (INT16) 1;
1658 else
1659 rOStm << (INT16) 0;
1661 rOStm << (INT16) 0;
1662 ImplWriteRect( rOStm, aClipRect );
1664 if( pAct->IsClipping() )
1665 ImplWriteRect( rOStm, aClipRect );
1667 nCount++;
1669 break;
1671 case( META_ISECTRECTCLIPREGION_ACTION ):
1673 MetaISectRectClipRegionAction* pAct = (MetaISectRectClipRegionAction*) pAction;
1675 rOStm << (INT16) GDI_ISECTCLIPREGION_ACTION;
1676 rOStm << (INT32) 20;
1677 rOStm << pAct->GetRect();
1678 nCount++;
1680 break;
1682 case( META_MOVECLIPREGION_ACTION ):
1684 MetaMoveClipRegionAction* pAct = (MetaMoveClipRegionAction*) pAction;
1686 rOStm << (INT16) GDI_MOVECLIPREGION_ACTION;
1687 rOStm << (INT32) 12;
1688 rOStm << (INT32) pAct->GetHorzMove();
1689 rOStm << (INT32) pAct->GetVertMove();
1690 nCount++;
1692 break;
1694 case( META_LINECOLOR_ACTION ):
1696 MetaLineColorAction* pAct = (MetaLineColorAction*) pAction;
1697 ImplWriteLineColor( rOStm, rLineCol = pAct->GetColor(), pAct->IsSetting() ? 1 : 0 );
1698 nCount++;
1700 break;
1702 case( META_FILLCOLOR_ACTION ):
1704 MetaFillColorAction* pAct = (MetaFillColorAction*) pAction;
1705 ImplWriteFillColor( rOStm, pAct->GetColor(), pAct->IsSetting() ? 1 : 0 );
1706 nCount++;
1708 break;
1710 case( META_FONT_ACTION ):
1712 rSaveVDev.SetFont( ( (MetaFontAction*) pAction )->GetFont() );
1713 ImplWriteFont( rOStm, rSaveVDev.GetFont(), rActualCharSet );
1714 nCount++;
1716 break;
1718 case( META_TEXTCOLOR_ACTION ):
1720 Font aSaveFont( rSaveVDev.GetFont() );
1722 aSaveFont.SetColor( ( (MetaTextColorAction*) pAction )->GetColor() );
1723 rSaveVDev.SetFont( aSaveFont );
1724 ImplWriteFont( rOStm, rSaveVDev.GetFont(), rActualCharSet );
1725 nCount++;
1727 break;
1729 case( META_TEXTFILLCOLOR_ACTION ):
1731 MetaTextFillColorAction* pAct = (MetaTextFillColorAction*) pAction;
1732 Font aSaveFont( rSaveVDev.GetFont() );
1734 if( pAct->IsSetting() )
1735 aSaveFont.SetFillColor( pAct->GetColor() );
1736 else
1737 aSaveFont.SetFillColor( Color( COL_TRANSPARENT ) );
1739 rSaveVDev.SetFont( aSaveFont );
1740 ImplWriteFont( rOStm, rSaveVDev.GetFont(), rActualCharSet );
1741 nCount++;
1743 break;
1745 case( META_TEXTALIGN_ACTION ):
1747 Font aSaveFont( rSaveVDev.GetFont() );
1749 aSaveFont.SetAlign( ( (MetaTextAlignAction*) pAction )->GetTextAlign() );
1750 rSaveVDev.SetFont( aSaveFont );
1751 ImplWriteFont( rOStm, rSaveVDev.GetFont(), rActualCharSet );
1752 nCount++;
1754 break;
1756 case( META_MAPMODE_ACTION ):
1758 MetaMapModeAction* pAct = (MetaMapModeAction*) pAction;
1760 rOStm << (INT16) GDI_MAPMODE_ACTION;
1761 rOStm << (INT32) 30;
1762 ImplWriteMapMode( rOStm, pAct->GetMapMode() );
1763 nCount++;
1765 break;
1767 case( META_PUSH_ACTION ):
1769 ImplWritePushAction( rOStm );
1770 rLineColStack.Push( new Color( rLineCol ) );
1771 rSaveVDev.Push();
1772 nCount++;
1774 break;
1776 case( META_POP_ACTION ):
1778 Color* pCol = (Color*) rLineColStack.Pop();
1780 if( pCol )
1782 rLineCol = *pCol;
1783 delete pCol;
1786 ImplWritePopAction( rOStm );
1787 rSaveVDev.Pop();
1788 nCount++;
1790 break;
1792 case( META_RASTEROP_ACTION ):
1794 MetaRasterOpAction* pAct = (MetaRasterOpAction*) pAction;
1796 if( ( pAct->GetRasterOp() != ROP_0 ) && ( pAct->GetRasterOp() != ROP_1 ) )
1798 INT16 nRasterOp;
1800 // Falls vorher ROP_0/1 gesetzt war, alten
1801 // Zustand durch Pop erst wieder herstellen
1802 if( rRop_0_1 )
1804 ImplWritePopAction( rOStm );
1805 rSaveVDev.Pop();
1806 rRop_0_1 = FALSE;
1807 nCount++;
1810 switch( pAct->GetRasterOp() )
1812 case( ROP_OVERPAINT ) : nRasterOp = 0; break;
1813 case( ROP_XOR ) : nRasterOp = 4; break;
1814 case( ROP_INVERT ): nRasterOp = 1; break;
1815 default: nRasterOp = 0; break;
1818 ImplWriteRasterOpAction( rOStm, nRasterOp );
1819 nCount++;
1821 else
1823 ImplWritePushAction( rOStm );
1824 rSaveVDev.Push();
1826 if( pAct->GetRasterOp() == ROP_0 )
1828 ImplWriteLineColor( rOStm, COL_BLACK, 1 );
1829 ImplWriteFillColor( rOStm, COL_BLACK, 1 );
1831 else
1833 ImplWriteLineColor( rOStm, COL_WHITE, 1 );
1834 ImplWriteFillColor( rOStm, COL_WHITE, 1 );
1837 ImplWriteRasterOpAction( rOStm, 0 );
1838 rRop_0_1 = TRUE;
1839 nCount += 4;
1842 break;
1844 case( META_TRANSPARENT_ACTION ):
1846 const PolyPolygon& rPolyPoly = ( (MetaTransparentAction*) pAction )->GetPolyPolygon();
1847 const INT16 nTrans = ( (MetaTransparentAction*) pAction )->GetTransparence();
1848 const INT16 nBrushStyle = ( nTrans < 38 ) ? 8 : ( nTrans < 63 ) ? 9 : 10;
1849 ULONG nOldPos, nNewPos;
1851 // write transparence comment
1852 rOStm << (INT16) GDI_TRANSPARENT_COMMENT;
1854 // we'll write the ActionSize later
1855 nOldPos = rOStm.Tell();
1856 rOStm.SeekRel( 4 );
1858 // write comment data
1859 rOStm << rPolyPoly;
1860 rOStm << nTrans;
1861 rOStm << (INT32) 15; // number of actions that follow this comment
1863 // calculate and write ActionSize of comment
1864 nNewPos = rOStm.Tell();
1865 rOStm.Seek( nOldPos );
1866 rOStm << (INT32) ( nNewPos - nOldPos );
1867 rOStm.Seek( nNewPos );
1870 // write actions for transparence
1871 ImplWritePushAction( rOStm );
1873 ImplWriteRasterOpAction( rOStm, 4 );
1874 ImplWritePolyPolyAction( rOStm, rPolyPoly );
1876 ImplWritePushAction( rOStm );
1878 ImplWriteRasterOpAction( rOStm, 2 );
1879 ImplWriteFillColor( rOStm, COL_BLACK, nBrushStyle );
1880 ImplWritePolyPolyAction( rOStm, rPolyPoly );
1882 ImplWritePopAction( rOStm );
1884 ImplWriteRasterOpAction( rOStm, 4 );
1885 ImplWritePolyPolyAction( rOStm, rPolyPoly );
1887 ImplWritePopAction( rOStm );
1889 ImplWritePushAction( rOStm );
1891 ImplWriteFillColor( rOStm, Color(), 0 );
1892 ImplWritePolyPolyAction( rOStm, rPolyPoly );
1894 ImplWritePopAction( rOStm );
1896 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1897 nCount += 15;
1898 #endif
1901 nCount++;
1903 break;
1905 case( META_FLOATTRANSPARENT_ACTION ):
1907 const MetaFloatTransparentAction* pA = (MetaFloatTransparentAction*) pAction;
1908 const GDIMetaFile& rTransMtf = pA->GetGDIMetaFile();
1909 const Point& rPos = pA->GetPoint();
1910 const Size& rSize = pA->GetSize();
1911 const Gradient& rGradient = pA->GetGradient();
1912 ULONG nOldPos, nNewPos;
1914 // write RefPoint comment
1915 rOStm << (INT16) GDI_FLOATTRANSPARENT_COMMENT;
1917 // we'll write the ActionSize later
1918 nOldPos = rOStm.Tell();
1919 rOStm.SeekRel( 4 );
1921 // write comment data
1922 rOStm << rTransMtf << rPos << rSize << rGradient;
1924 // calculate and write ActionSize of comment
1925 nNewPos = rOStm.Tell();
1926 rOStm.Seek( nOldPos );
1927 rOStm << (INT32) ( nNewPos - nOldPos + 4 );
1928 rOStm.Seek( ( nOldPos = nNewPos ) + 4 );
1931 // write actions for float transparence
1932 ULONG nAddCount;
1933 GDIMetaFile aMtf( rTransMtf );
1934 const Size aSrcSize( rTransMtf.GetPrefSize() );
1935 Point aSrcPt( rTransMtf.GetPrefMapMode().GetOrigin() );
1936 const double fScaleX = aSrcSize.Width() ? (double) rSize.Width() / aSrcSize.Width() : 1.0;
1937 const double fScaleY = aSrcSize.Height() ? (double) rSize.Height() / aSrcSize.Height() : 1.0;
1938 long nMoveX, nMoveY;
1940 if( fScaleX != 1.0 || fScaleY != 1.0 )
1942 aMtf.Scale( fScaleX, fScaleY );
1943 aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
1946 nMoveX = rPos.X() - aSrcPt.X(), nMoveY = rPos.Y() - aSrcPt.Y();
1948 if( nMoveX || nMoveY )
1949 aMtf.Move( nMoveX, nMoveY );
1951 nAddCount = ImplWriteActions( rOStm, aMtf, rSaveVDev, rRop_0_1, rLineCol, rLineColStack, rActualCharSet );
1952 nNewPos = rOStm.Tell();
1953 rOStm.Seek( nOldPos );
1954 rOStm << (INT32) nAddCount;
1955 rOStm.Seek( nNewPos );
1957 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1958 nCount += nAddCount;
1959 #endif
1962 nCount++;
1964 break;
1966 case( META_HATCH_ACTION ):
1968 const MetaHatchAction* pA = (MetaHatchAction*) pAction;
1969 const PolyPolygon& rPolyPoly = pA->GetPolyPolygon();
1970 const Hatch& rHatch = pA->GetHatch();
1971 ULONG nOldPos, nNewPos, nAddCount;
1973 // write hatch comment
1974 rOStm << (INT16) GDI_HATCH_COMMENT;
1976 // we'll write the ActionSize later
1977 nOldPos = rOStm.Tell();
1978 rOStm.SeekRel( 4 );
1980 // write comment data
1981 rOStm << rPolyPoly;
1982 rOStm << rHatch;
1984 // calculate and write ActionSize of comment
1985 nNewPos = rOStm.Tell();
1986 rOStm.Seek( nOldPos );
1987 rOStm << (INT32) ( nNewPos - nOldPos + 4 );
1988 rOStm.Seek( ( nOldPos = nNewPos ) + 4 );
1991 // write actions for hatch
1992 VirtualDevice aVDev;
1993 GDIMetaFile aTmpMtf;
1995 aVDev.AddHatchActions( rPolyPoly, rHatch, aTmpMtf );
1996 nAddCount = ImplWriteActions( rOStm, aTmpMtf, rSaveVDev, rRop_0_1, rLineCol, rLineColStack, rActualCharSet );
1997 nNewPos = rOStm.Tell();
1998 rOStm.Seek( nOldPos );
1999 rOStm << (INT32) nAddCount;
2000 rOStm.Seek( nNewPos );
2002 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
2003 nCount += nAddCount;
2004 #endif
2007 nCount++;
2009 break;
2011 case( META_REFPOINT_ACTION ):
2013 const MetaRefPointAction* pA = (MetaRefPointAction*) pAction;
2014 const Point& rRefPoint = pA->GetRefPoint();
2015 const BOOL bSet = pA->IsSetting();
2016 ULONG nOldPos, nNewPos;
2018 // write RefPoint comment
2019 rOStm << (INT16) GDI_REFPOINT_COMMENT;
2021 // we'll write the ActionSize later
2022 nOldPos = rOStm.Tell();
2023 rOStm.SeekRel( 4 );
2025 // write data
2026 rOStm << rRefPoint << bSet;
2027 rOStm << (INT32) 0; // number of actions that follow this comment
2029 // calculate and write ActionSize of comment
2030 nNewPos = rOStm.Tell();
2031 rOStm.Seek( nOldPos );
2032 rOStm << (INT32) ( nNewPos - nOldPos );
2033 rOStm.Seek( nNewPos );
2035 nCount++;
2037 break;
2039 case( META_TEXTLINECOLOR_ACTION ):
2041 const MetaTextLineColorAction* pA = (MetaTextLineColorAction*) pAction;
2042 const Color& rColor = pA->GetColor();
2043 const BOOL bSet = pA->IsSetting();
2044 ULONG nOldPos, nNewPos;
2046 // write RefPoint comment
2047 rOStm << (INT16) GDI_TEXTLINECOLOR_COMMENT;
2049 // we'll write the ActionSize later
2050 nOldPos = rOStm.Tell();
2051 rOStm.SeekRel( 4 );
2053 // write data
2054 rOStm << rColor << bSet;
2055 rOStm << (INT32) 0; // number of actions that follow this comment
2057 // calculate and write ActionSize of comment
2058 nNewPos = rOStm.Tell();
2059 rOStm.Seek( nOldPos );
2060 rOStm << (INT32) ( nNewPos - nOldPos );
2061 rOStm.Seek( nNewPos );
2063 nCount++;
2065 break;
2067 #if 0
2068 case( META_OVERLINECOLOR_ACTION ):
2069 break;
2070 #endif
2072 case( META_TEXTLINE_ACTION ):
2074 const MetaTextLineAction* pA = (MetaTextLineAction*) pAction;
2075 const Point& rStartPt = pA->GetStartPoint();
2076 const long nWidth = pA->GetWidth();
2077 const FontStrikeout eStrikeout = pA->GetStrikeout();
2078 const FontUnderline eUnderline = pA->GetUnderline();
2079 ULONG nOldPos, nNewPos;
2081 // write RefPoint comment
2082 rOStm << (INT16) GDI_TEXTLINE_COMMENT;
2084 // we'll write the ActionSize later
2085 nOldPos = rOStm.Tell();
2086 rOStm.SeekRel( 4 );
2088 // write data
2089 rOStm << rStartPt << nWidth <<
2090 static_cast<sal_uInt32>(eStrikeout) <<
2091 static_cast<sal_uInt32>(eUnderline);
2092 rOStm << (INT32) 0; // number of actions that follow this comment
2094 // calculate and write ActionSize of comment
2095 nNewPos = rOStm.Tell();
2096 rOStm.Seek( nOldPos );
2097 rOStm << (INT32) ( nNewPos - nOldPos );
2098 rOStm.Seek( nNewPos );
2100 nCount++;
2102 break;
2104 case( META_EPS_ACTION ):
2105 break;
2107 case( META_COMMENT_ACTION ):
2109 const MetaCommentAction* pA = (MetaCommentAction*) pAction;
2110 const sal_uInt32 nDataSize = pA->GetDataSize();
2111 ULONG nOldPos, nNewPos;
2113 // write RefPoint comment
2114 rOStm << (INT16) GDI_COMMENT_COMMENT;
2116 // we'll write the ActionSize later
2117 nOldPos = rOStm.Tell();
2118 rOStm.SeekRel( 4 );
2120 // write data
2121 rOStm << pA->GetComment() << pA->GetValue() << nDataSize;
2123 if( nDataSize )
2124 rOStm.Write( pA->GetData(), nDataSize );
2126 rOStm << (INT32) 0; // number of actions that follow this comment
2128 // calculate and write ActionSize of comment
2129 nNewPos = rOStm.Tell();
2130 rOStm.Seek( nOldPos );
2131 rOStm << (INT32) ( nNewPos - nOldPos );
2132 rOStm.Seek( nNewPos );
2134 nCount++;
2136 break;
2138 #ifdef DBG_UTIL
2139 default:
2141 ByteString aStr( "Missing implementation for Action#: " );
2142 aStr += ByteString::CreateFromInt32( pAction->GetType() );
2143 aStr += '!';
2144 DBG_ERROR( aStr.GetBuffer() );
2146 break;
2147 #endif
2150 case( META_TEXTRECT_ACTION ):
2152 MetaTextRectAction* pAct = (MetaTextRectAction*) pAction;
2154 rOStm << ;
2155 rOStm << ;
2157 nCount++;
2159 break;
2163 case( META_MASK_ACTION ):
2165 MetaMaskAction* pAct = (MetaMaskAction*) pAction;
2167 rOStm << ;
2168 rOStm << ;
2170 nCount++;
2172 break;
2176 case( META_MASKSCALE_ACTION ):
2178 MetaMaskScaleAction* pAct = (MetaMaskScaleAction*) pAction;
2180 rOStm << ;
2181 rOStm << ;
2183 nCount++;
2185 break;
2189 case( META_MASKSCALEPART_ACTION ):
2191 MetaMaskScalePartAction* pAct = (MetaMaskScalePartAction*) pAction;
2193 rOStm << ;
2194 rOStm << ;
2196 nCount++;
2198 break;
2202 case( META_ISECTREGIONCLIPREGION_ACTION ):
2204 MetaISectRegionClipRegionAction* pAct = (MetaISectRegionClipRegionAction*) pAction;
2206 rOStm << ;
2207 rOStm << ;
2209 nCount++;
2211 break;
2216 return nCount;