1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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
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>
51 #define CVTSVM_WRITE_SUBACTIONCOUNT 1
57 void ImplReadRect( SvStream
& rIStm
, Rectangle
& rRect
)
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
)
83 rPoly
= Polygon( (USHORT
) nSize
);
85 for( USHORT i
= 0; i
< (USHORT
) nSize
; i
++ )
89 // ------------------------------------------------------------------------
91 void ImplWritePoly( SvStream
& rOStm
, const Polygon
& rPoly
)
93 INT32 nSize
= rPoly
.GetSize();
97 for( INT32 i
= 0; i
< nSize
; i
++ )
98 rOStm
<< rPoly
[ (USHORT
) i
];
101 // ------------------------------------------------------------------------
103 void ImplReadPolyPoly( SvStream
& rIStm
, PolyPolygon
& rPolyPoly
)
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();
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
++ )
144 // ------------------------------------------------------------------------
146 void ImplReadColor( SvStream
& rIStm
, Color
& rColor
)
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
)
161 nVal
= ( (INT16
) rColor
.GetRed() << 8 ) | rColor
.GetRed();
164 nVal
= ( (INT16
) rColor
.GetGreen() << 8 ) | rColor
.GetGreen();
167 nVal
= ( (INT16
) rColor
.GetBlue() << 8 ) | rColor
.GetBlue();
171 // ------------------------------------------------------------------------
173 void ImplReadMapMode( SvStream
& rIStm
, MapMode
& rMapMode
)
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
;
206 // ------------------------------------------------------------------------
208 void ImplWritePopAction( SvStream
& rOStm
)
210 rOStm
<< (INT16
) GDI_POP_ACTION
;
214 // ------------------------------------------------------------------------
216 void ImplWriteLineColor( SvStream
& rOStm
, const Color
& rColor
, INT16 nStyle
, INT32 nWidth
= 0L )
218 if( rColor
.GetTransparency() > 127 )
221 rOStm
<< (INT16
) GDI_PEN_ACTION
;
223 ImplWriteColor( rOStm
, rColor
);
228 // ------------------------------------------------------------------------
230 void ImplWriteFillColor( SvStream
& rOStm
, const Color
& rColor
, INT16 nStyle
)
232 rOStm
<< (INT16
) GDI_FILLBRUSH_ACTION
;
234 ImplWriteColor( rOStm
, rColor
);
236 if( rColor
.GetTransparency() > 127 )
241 ImplWriteColor( rOStm
, COL_WHITE
);
247 ImplWriteColor( rOStm
, COL_BLACK
);
253 // ------------------------------------------------------------------------
255 void ImplWriteFont( SvStream
& rOStm
, const Font
& rFont
,
256 rtl_TextEncoding
& rActualCharSet
)
261 ByteString
aByteName( rFont
.GetName(), rOStm
.GetStreamCharSet() );
262 strncpy( aName
, aByteName
.GetBuffer(), 32 );
264 switch ( rFont
.GetWeight() )
267 case WEIGHT_ULTRALIGHT
:
278 case WEIGHT_ULTRABOLD
:
288 rOStm
<< (INT16
) GDI_FONT_ACTION
;
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();
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
);
337 return nStringLen
!= 0;
340 // ------------------------------------------------------------------------
342 void ImplReadUnicodeComment( sal_uInt32 nStrmPos
, SvStream
& rIStm
, String
& rString
)
344 sal_uInt32 nOld
= rIStm
.Tell();
348 sal_uInt32 nActionSize
;
349 xub_StrLen nStringLen
;
351 rIStm
.Seek( nStrmPos
);
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
-- )
367 // ------------------------------------------------------------------------
369 void ImplSkipActions( SvStream
& rIStm
, ULONG nSkipCount
)
374 for( ULONG i
= 0UL; i
< nSkipCount
; i
++ )
376 rIStm
>> nType
>> nActionSize
;
377 rIStm
.SeekRel( nActionSize
- 4L );
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
);
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
419 || ( memcmp( aCode
, "SVGDI", sizeof( aCode
) ) != 0 )
420 || ( nVersion
!= 200 ) )
422 rIStm
.SetError( SVSTREAM_FILEFORMAT_ERROR
);
423 rIStm
.SetNumberFormatInt( nOldFormat
);
428 LineInfo
aLineInfo( LINE_NONE
, 0 );
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
441 INT32 nTmp
, nTmp1
, nActionSize
;
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
++ )
457 sal_Int32 nActBegin
= rIStm
.Tell();
458 rIStm
>> nActionSize
;
460 DBG_ASSERT( ( nType
<= 33 ) || ( nType
>= 1024 ), "Unknown GDIMetaAction while converting!" );
464 case( GDI_PIXEL_ACTION
):
467 ImplReadColor( rIStm
, aActionColor
);
468 rMtf
.AddAction( new MetaPixelAction( aPt
, aActionColor
) );
472 case( GDI_POINT_ACTION
):
475 rMtf
.AddAction( new MetaPointAction( aPt
) );
479 case( GDI_LINE_ACTION
):
481 rIStm
>> aPt
>> aPt1
;
482 rMtf
.AddAction( new MetaLineAction( aPt
, aPt1
, aLineInfo
) );
486 case( GDI_RECT_ACTION
):
488 ImplReadRect( rIStm
, aRect
);
489 rIStm
>> nTmp
>> nTmp1
;
492 rMtf
.AddAction( new MetaRoundRectAction( aRect
, nTmp
, nTmp1
) );
495 rMtf
.AddAction( new MetaRectAction( aRect
) );
498 rMtf
.AddAction( new MetaPolyLineAction( aRect
, aLineInfo
) );
503 case( GDI_ELLIPSE_ACTION
):
505 ImplReadRect( rIStm
, aRect
);
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
) );
518 rMtf
.AddAction( new MetaEllipseAction( aRect
) );
522 case( GDI_ARC_ACTION
):
524 ImplReadRect( rIStm
, aRect
);
525 rIStm
>> aPt
>> aPt1
;
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
) );
538 rMtf
.AddAction( new MetaArcAction( aRect
, aPt
, aPt1
) );
542 case( GDI_PIE_ACTION
):
544 ImplReadRect( rIStm
, aRect
);
545 rIStm
>> aPt
>> aPt1
;
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
) );
558 rMtf
.AddAction( new MetaPieAction( aRect
, aPt
, aPt1
) );
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() );
573 case( GDI_POLYLINE_ACTION
):
575 ImplReadPoly( rIStm
, aActionPoly
);
578 rMtf
.AddAction( new MetaPolyLineAction( aActionPoly
, aLineInfo
) );
580 rMtf
.AddAction( new MetaPolyLineAction( aActionPoly
) );
584 case( GDI_POLYGON_ACTION
):
586 ImplReadPoly( rIStm
, aActionPoly
);
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
) );
597 rMtf
.AddAction( new MetaPolygonAction( aActionPoly
) );
601 case( GDI_POLYPOLYGON_ACTION
):
603 PolyPolygon aPolyPoly
;
605 ImplReadPolyPoly( rIStm
, aPolyPoly
);
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
) );
618 rMtf
.AddAction( new MetaPolyPolygonAction( aPolyPoly
) );
622 case( GDI_FONT_ACTION
):
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
);
669 case( GDI_TEXT_ACTION
):
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
);
687 case( GDI_TEXTARRAY_ACTION
):
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
);
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
725 pDXAry
[ nStrLen
-1 ] = pDXAry
[ nStrLen
-2 ] + pTmpAry
[ nStrLen
-1 ] - pTmpAry
[ nStrLen
-2 ];
727 pDXAry
[ nStrLen
-1 ] = pTmpAry
[ nStrLen
-1 ]; // len=1: 0th position taken to be 0
733 DBG_ERROR("More than one DX array element missing on SVM import");
737 if ( nUnicodeCommentActionNumber
== i
)
738 ImplReadUnicodeComment( nUnicodeCommentStreamPos
, rIStm
, aStr
);
739 rMtf
.AddAction( new MetaTextArrayAction( aPt
, aStr
, pDXAry
, (USHORT
) nIndex
, (USHORT
) nLen
) );
744 rIStm
.Seek( nActBegin
+ nActionSize
);
748 case( GDI_STRETCHTEXT_ACTION
):
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
);
766 case( GDI_BITMAP_ACTION
):
770 rIStm
>> aPt
>> aBmp
;
771 rMtf
.AddAction( new MetaBmpAction( aPt
, aBmp
) );
775 case( GDI_BITMAPSCALE_ACTION
):
779 rIStm
>> aPt
>> aSz
>> aBmp
;
780 rMtf
.AddAction( new MetaBmpScaleAction( aPt
, aSz
, aBmp
) );
784 case( GDI_BITMAPSCALEPART_ACTION
):
789 rIStm
>> aPt
>> aSz
>> aPt1
>> aSz2
>> aBmp
;
790 rMtf
.AddAction( new MetaBmpScalePartAction( aPt
, aSz
, aPt1
, aSz2
, aBmp
) );
794 case( GDI_PEN_ACTION
):
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 ) );
810 case( GDI_FILLBRUSH_ACTION
):
814 ImplReadColor( rIStm
, aActionColor
);
816 rIStm
>> nBrushStyle
;
817 rMtf
.AddAction( new MetaFillColorAction( aActionColor
, nBrushStyle
!= 0 ) );
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
);
832 case( GDI_CLIPREGION_ACTION
):
839 rIStm
>> nRegType
>> bIntersect
;
840 ImplReadRect( rIStm
, aRect
);
851 ImplReadRect( rIStm
, aRegRect
);
852 aRegion
= Region( aRegRect
);
859 ImplReadPoly( rIStm
, aActionPoly
);
860 aRegion
= Region( aActionPoly
);
867 PolyPolygon aPolyPoly
;
872 for( USHORT j
= 0; j
< (USHORT
) nPolyCount
; j
++ )
874 ImplReadPoly( rIStm
, aActionPoly
);
875 aPolyPoly
.Insert( aActionPoly
);
878 aRegion
= Region( aPolyPoly
);
885 aRegion
.Intersect( aRect
);
887 rMtf
.AddAction( new MetaClipRegionAction( aRegion
, bClip
) );
891 case( GDI_MOVECLIPREGION_ACTION
):
893 rIStm
>> nTmp
>> nTmp1
;
894 rMtf
.AddAction( new MetaMoveClipRegionAction( nTmp
, nTmp1
) );
898 case( GDI_ISECTCLIPREGION_ACTION
):
900 ImplReadRect( rIStm
, aRect
);
901 rMtf
.AddAction( new MetaISectRectClipRegionAction( aRect
) );
905 case( GDI_RASTEROP_ACTION
):
915 eRasterOp
= ROP_INVERT
;
924 eRasterOp
= ROP_OVERPAINT
;
928 rMtf
.AddAction( new MetaRasterOpAction( eRasterOp
) );
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
942 case( GDI_POP_ACTION
):
945 LineInfo
* pLineInfo
= (LineInfo
*) aLIStack
.Pop();
950 aLineInfo
= *pLineInfo
;
952 bFatLine
= ( LINE_NONE
!= aLineInfo
.GetStyle() ) && !aLineInfo
.IsDefault();
955 rMtf
.AddAction( new MetaPopAction() );
957 // #106172# Track font relevant data in shadow VDev
962 case( GDI_GRADIENT_ACTION
):
971 INT16 nIntensityStart
;
974 ImplReadRect( rIStm
, aRect
);
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
) );
992 case( GDI_TRANSPARENT_COMMENT
):
994 PolyPolygon aPolyPoly
;
995 INT32 nFollowingActionCount
;
998 rIStm
>> aPolyPoly
>> nTrans
>> nFollowingActionCount
;
999 ImplSkipActions( rIStm
, nFollowingActionCount
);
1000 rMtf
.AddAction( new MetaTransparentAction( aPolyPoly
, nTrans
) );
1002 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1003 i
+= nFollowingActionCount
;
1008 case( GDI_FLOATTRANSPARENT_COMMENT
):
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
;
1026 case( GDI_HATCH_COMMENT
):
1028 PolyPolygon aPolyPoly
;
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
;
1042 case( GDI_REFPOINT_COMMENT
):
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
;
1056 // #106172# Track font relevant data in shadow VDev
1058 aFontVDev
.SetRefPoint( aRefPoint
);
1060 aFontVDev
.SetRefPoint();
1064 case( GDI_TEXTLINECOLOR_COMMENT
):
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
;
1080 case( GDI_TEXTLINE_COMMENT
):
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
,
1095 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1096 i
+= nFollowingActionCount
;
1101 case( GDI_GRADIENTEX_COMMENT
):
1103 PolyPolygon aPolyPoly
;
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
;
1117 case( GDI_COMMENT_COMMENT
):
1119 ByteString aComment
;
1121 sal_uInt32 nDataSize
;
1123 INT32 nFollowingActionCount
;
1125 rIStm
>> aComment
>> nValue
>> nDataSize
;
1129 pData
= new BYTE
[ nDataSize
];
1130 rIStm
.Read( pData
, nDataSize
);
1135 rIStm
>> nFollowingActionCount
;
1136 ImplSkipActions( rIStm
, nFollowingActionCount
);
1137 rMtf
.AddAction( new MetaCommentAction( aComment
, nValue
, pData
, nDataSize
) );
1139 #ifdef CVTSVM_WRITE_SUBACTIONCOUNT
1140 i
+= nFollowingActionCount
;
1145 case ( GDI_UNICODE_COMMENT
):
1147 nUnicodeCommentActionNumber
= i
+ 1;
1148 nUnicodeCommentStreamPos
= rIStm
.Tell() - 6;
1149 rIStm
.SeekRel( nActionSize
- 4 );
1154 rIStm
.SeekRel( nActionSize
- 4L );
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
)
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
);
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
)
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() );
1235 case( META_POINT_ACTION
):
1237 MetaPointAction
* pAct
= (MetaPointAction
*) pAction
;
1239 rOStm
<< (INT16
) GDI_POINT_ACTION
;
1240 rOStm
<< (INT32
) 12;
1241 rOStm
<< pAct
->GetPoint();
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() ) );
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();
1266 ImplWritePopAction( rOStm
);
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() );
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();
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() );
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();
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();
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
];
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() ) );
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
];
1378 ImplWritePopAction( rOStm
);
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
];
1401 case( META_POLYPOLYGON_ACTION
):
1403 MetaPolyPolygonAction
* pAct
= (MetaPolyPolygonAction
*) pAction
;
1404 ImplWritePolyPolyAction( rOStm
, pAct
->GetPolyPolygon() );
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
) )
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 );
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() );
1436 ULONG nLen
= pAct
->GetLen();
1437 const ULONG nTextLen
= aText
.Len();
1438 sal_Int32
* pDXArray
= pAct
->GetDXArray();
1440 if ( ImplWriteUnicodeComment( rOStm
, aUniText
) )
1443 if( ( nLen
+ pAct
->GetIndex() ) > nTextLen
)
1445 if( pAct
->GetIndex() <= nTextLen
)
1446 nLen
= nTextLen
- pAct
->GetIndex();
1451 if( !pDXArray
|| !nLen
)
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();
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
];
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
) )
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 );
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();
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();
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();
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();
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();
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();
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();
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();
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
);
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() );
1639 ImplWritePopAction( rOStm
);
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();
1662 ImplWriteRect( rOStm
, aClipRect
);
1664 if( pAct
->IsClipping() )
1665 ImplWriteRect( rOStm
, aClipRect
);
1671 case( META_ISECTRECTCLIPREGION_ACTION
):
1673 MetaISectRectClipRegionAction
* pAct
= (MetaISectRectClipRegionAction
*) pAction
;
1675 rOStm
<< (INT16
) GDI_ISECTCLIPREGION_ACTION
;
1676 rOStm
<< (INT32
) 20;
1677 rOStm
<< pAct
->GetRect();
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();
1694 case( META_LINECOLOR_ACTION
):
1696 MetaLineColorAction
* pAct
= (MetaLineColorAction
*) pAction
;
1697 ImplWriteLineColor( rOStm
, rLineCol
= pAct
->GetColor(), pAct
->IsSetting() ? 1 : 0 );
1702 case( META_FILLCOLOR_ACTION
):
1704 MetaFillColorAction
* pAct
= (MetaFillColorAction
*) pAction
;
1705 ImplWriteFillColor( rOStm
, pAct
->GetColor(), pAct
->IsSetting() ? 1 : 0 );
1710 case( META_FONT_ACTION
):
1712 rSaveVDev
.SetFont( ( (MetaFontAction
*) pAction
)->GetFont() );
1713 ImplWriteFont( rOStm
, rSaveVDev
.GetFont(), rActualCharSet
);
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
);
1729 case( META_TEXTFILLCOLOR_ACTION
):
1731 MetaTextFillColorAction
* pAct
= (MetaTextFillColorAction
*) pAction
;
1732 Font
aSaveFont( rSaveVDev
.GetFont() );
1734 if( pAct
->IsSetting() )
1735 aSaveFont
.SetFillColor( pAct
->GetColor() );
1737 aSaveFont
.SetFillColor( Color( COL_TRANSPARENT
) );
1739 rSaveVDev
.SetFont( aSaveFont
);
1740 ImplWriteFont( rOStm
, rSaveVDev
.GetFont(), rActualCharSet
);
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
);
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() );
1767 case( META_PUSH_ACTION
):
1769 ImplWritePushAction( rOStm
);
1770 rLineColStack
.Push( new Color( rLineCol
) );
1776 case( META_POP_ACTION
):
1778 Color
* pCol
= (Color
*) rLineColStack
.Pop();
1786 ImplWritePopAction( rOStm
);
1792 case( META_RASTEROP_ACTION
):
1794 MetaRasterOpAction
* pAct
= (MetaRasterOpAction
*) pAction
;
1796 if( ( pAct
->GetRasterOp() != ROP_0
) && ( pAct
->GetRasterOp() != ROP_1
) )
1800 // Falls vorher ROP_0/1 gesetzt war, alten
1801 // Zustand durch Pop erst wieder herstellen
1804 ImplWritePopAction( rOStm
);
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
);
1823 ImplWritePushAction( rOStm
);
1826 if( pAct
->GetRasterOp() == ROP_0
)
1828 ImplWriteLineColor( rOStm
, COL_BLACK
, 1 );
1829 ImplWriteFillColor( rOStm
, COL_BLACK
, 1 );
1833 ImplWriteLineColor( rOStm
, COL_WHITE
, 1 );
1834 ImplWriteFillColor( rOStm
, COL_WHITE
, 1 );
1837 ImplWriteRasterOpAction( rOStm
, 0 );
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();
1858 // write comment data
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
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();
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
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
;
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();
1980 // write comment data
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
;
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();
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
);
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();
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
);
2068 case( META_OVERLINECOLOR_ACTION
):
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();
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
);
2104 case( META_EPS_ACTION
):
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();
2121 rOStm
<< pA
->GetComment() << pA
->GetValue() << 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
);
2141 ByteString
aStr( "Missing implementation for Action#: " );
2142 aStr
+= ByteString::CreateFromInt32( pAction
->GetType() );
2144 DBG_ERROR( aStr
.GetBuffer() );
2150 case( META_TEXTRECT_ACTION ):
2152 MetaTextRectAction* pAct = (MetaTextRectAction*) pAction;
2163 case( META_MASK_ACTION ):
2165 MetaMaskAction* pAct = (MetaMaskAction*) pAction;
2176 case( META_MASKSCALE_ACTION ):
2178 MetaMaskScaleAction* pAct = (MetaMaskScaleAction*) pAction;
2189 case( META_MASKSCALEPART_ACTION ):
2191 MetaMaskScalePartAction* pAct = (MetaMaskScalePartAction*) pAction;
2202 case( META_ISECTREGIONCLIPREGION_ACTION ):
2204 MetaISectRegionClipRegionAction* pAct = (MetaISectRegionClipRegionAction*) pAction;