19e0fc027SAndrew Rist /**************************************************************
29e0fc027SAndrew Rist *
39e0fc027SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49e0fc027SAndrew Rist * or more contributor license agreements. See the NOTICE file
59e0fc027SAndrew Rist * distributed with this work for additional information
69e0fc027SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79e0fc027SAndrew Rist * to you under the Apache License, Version 2.0 (the
89e0fc027SAndrew Rist * "License"); you may not use this file except in compliance
99e0fc027SAndrew Rist * with the License. You may obtain a copy of the License at
109e0fc027SAndrew Rist *
119e0fc027SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129e0fc027SAndrew Rist *
139e0fc027SAndrew Rist * Unless required by applicable law or agreed to in writing,
149e0fc027SAndrew Rist * software distributed under the License is distributed on an
159e0fc027SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169e0fc027SAndrew Rist * KIND, either express or implied. See the License for the
179e0fc027SAndrew Rist * specific language governing permissions and limitations
189e0fc027SAndrew Rist * under the License.
199e0fc027SAndrew Rist *
209e0fc027SAndrew Rist *************************************************************/
219e0fc027SAndrew Rist
229e0fc027SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_filter.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <vcl/sv.h>
28cdf0e10cSrcweir #include <tools/stream.hxx>
29cdf0e10cSrcweir #include <tools/bigint.hxx>
30cdf0e10cSrcweir #include <tools/poly.hxx>
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include <vcl/metaact.hxx>
33cdf0e10cSrcweir #include <vcl/graph.hxx>
34cdf0e10cSrcweir #include <vcl/bmpacc.hxx>
35cdf0e10cSrcweir #include <vcl/region.hxx>
36cdf0e10cSrcweir #include <vcl/metric.hxx>
37cdf0e10cSrcweir #include <vcl/font.hxx>
38cdf0e10cSrcweir #include <vcl/virdev.hxx>
39cdf0e10cSrcweir #include <vcl/msgbox.hxx>
40cdf0e10cSrcweir #include <vcl/cvtgrf.hxx>
41cdf0e10cSrcweir #include <vcl/gradient.hxx>
42cdf0e10cSrcweir #include <svl/solar.hrc>
43cdf0e10cSrcweir #include <svtools/fltcall.hxx>
44cdf0e10cSrcweir #include <svtools/FilterConfigItem.hxx>
45cdf0e10cSrcweir #include <vcl/graphictools.hxx>
46cdf0e10cSrcweir #include "strings.hrc"
47cdf0e10cSrcweir
48cdf0e10cSrcweir #include <math.h>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #define POSTSCRIPT_BOUNDINGSEARCH 0x1000 // we only try to get the BoundingBox
51cdf0e10cSrcweir // in the first 4096 bytes
52cdf0e10cSrcweir
53cdf0e10cSrcweir #define EPS_PREVIEW_TIFF 1
54cdf0e10cSrcweir #define EPS_PREVIEW_EPSI 2
55cdf0e10cSrcweir
56cdf0e10cSrcweir #define PS_LINESIZE 70 // maximum number of characters a line in the output
57cdf0e10cSrcweir
58cdf0e10cSrcweir #define PS_NONE 0 // formating mode: action which is inserted behind the output
59cdf0e10cSrcweir #define PS_SPACE 1
60cdf0e10cSrcweir #define PS_RET 2
61cdf0e10cSrcweir #define PS_WRAP 4
62cdf0e10cSrcweir
63cdf0e10cSrcweir // -----------------------------Feld-Typen-------------------------------
64cdf0e10cSrcweir
65cdf0e10cSrcweir struct ChrSet
66cdf0e10cSrcweir {
67cdf0e10cSrcweir struct ChrSet * pSucc;
68cdf0e10cSrcweir sal_uInt8 nSet;
69cdf0e10cSrcweir String aName;
70cdf0e10cSrcweir FontWeight eWeight;
71cdf0e10cSrcweir };
72cdf0e10cSrcweir
73cdf0e10cSrcweir struct StackMember
74cdf0e10cSrcweir {
75cdf0e10cSrcweir struct StackMember * pSucc;
76cdf0e10cSrcweir Color aGlobalCol;
77cdf0e10cSrcweir sal_Bool bLineCol;
78cdf0e10cSrcweir Color aLineCol;
79cdf0e10cSrcweir sal_Bool bFillCol;
80cdf0e10cSrcweir Color aFillCol;
81cdf0e10cSrcweir Color aTextCol;
82cdf0e10cSrcweir sal_Bool bTextFillCol;
83cdf0e10cSrcweir Color aTextFillCol;
84cdf0e10cSrcweir Color aBackgroundCol;
85cdf0e10cSrcweir Font aFont;
86cdf0e10cSrcweir TextAlign eTextAlign;
87cdf0e10cSrcweir
88cdf0e10cSrcweir double fLineWidth;
89cdf0e10cSrcweir double fMiterLimit;
90cdf0e10cSrcweir SvtGraphicStroke::CapType eLineCap;
91cdf0e10cSrcweir SvtGraphicStroke::JoinType eJoinType;
92cdf0e10cSrcweir SvtGraphicStroke::DashArray aDashArray;
93cdf0e10cSrcweir };
94cdf0e10cSrcweir
95cdf0e10cSrcweir struct PSLZWCTreeNode
96cdf0e10cSrcweir {
97cdf0e10cSrcweir
98cdf0e10cSrcweir PSLZWCTreeNode* pBrother; // naechster Knoten, der den selben Vater hat
99cdf0e10cSrcweir PSLZWCTreeNode* pFirstChild; // erster Sohn
100cdf0e10cSrcweir sal_uInt16 nCode; // Der Code fuer den String von Pixelwerten, der sich ergibt, wenn
101cdf0e10cSrcweir sal_uInt16 nValue; // Der Pixelwert
102cdf0e10cSrcweir };
103cdf0e10cSrcweir
104cdf0e10cSrcweir class PSWriter
105cdf0e10cSrcweir {
106cdf0e10cSrcweir private:
107cdf0e10cSrcweir sal_Bool mbStatus;
108cdf0e10cSrcweir sal_uLong mnLevelWarning; // number of embedded eps files which was not exported
109cdf0e10cSrcweir sal_uLong mnLastPercent; // Mit welcher Zahl pCallback zuletzt aufgerufen wurde.
110cdf0e10cSrcweir sal_uInt32 mnLatestPush; // offset auf streamposition, an der zuletzt gepusht wurde
111cdf0e10cSrcweir
112cdf0e10cSrcweir long mnLevel; // dialog options
113cdf0e10cSrcweir sal_Bool mbGrayScale;
114cdf0e10cSrcweir sal_Bool mbCompression;
115cdf0e10cSrcweir sal_Int32 mnPreview;
116cdf0e10cSrcweir sal_Int32 mnTextMode;
117cdf0e10cSrcweir
118cdf0e10cSrcweir SvStream* mpPS;
119cdf0e10cSrcweir const GDIMetaFile* pMTF;
120cdf0e10cSrcweir GDIMetaFile* pAMTF; // only created if Graphics is not a Metafile
121cdf0e10cSrcweir VirtualDevice aVDev;
122cdf0e10cSrcweir
123cdf0e10cSrcweir double nBoundingX1; // this represents the bounding box
124cdf0e10cSrcweir double nBoundingY1;
125cdf0e10cSrcweir double nBoundingX2;
126cdf0e10cSrcweir double nBoundingY2;
127cdf0e10cSrcweir //
128cdf0e10cSrcweir StackMember* pGDIStack;
129cdf0e10cSrcweir sal_uLong mnCursorPos; // aktuelle Cursorposition im Output
130cdf0e10cSrcweir Color aColor; // aktuelle Farbe die fuer den Output benutzt wird
131cdf0e10cSrcweir sal_Bool bLineColor;
132cdf0e10cSrcweir Color aLineColor; // aktuelle GDIMetafile Farbeinstellungen
133cdf0e10cSrcweir sal_Bool bFillColor; //
134cdf0e10cSrcweir Color aFillColor; //
135cdf0e10cSrcweir Color aTextColor; //
136cdf0e10cSrcweir sal_Bool bTextFillColor; //
137cdf0e10cSrcweir Color aTextFillColor; //
138cdf0e10cSrcweir Color aBackgroundColor; //
139cdf0e10cSrcweir sal_Bool bRegionChanged;
140cdf0e10cSrcweir TextAlign eTextAlign; //
141cdf0e10cSrcweir
142cdf0e10cSrcweir double fLineWidth;
143cdf0e10cSrcweir double fMiterLimit;
144cdf0e10cSrcweir SvtGraphicStroke::CapType eLineCap;
145cdf0e10cSrcweir SvtGraphicStroke::JoinType eJoinType;
146cdf0e10cSrcweir SvtGraphicStroke::DashArray aDashArray;
147cdf0e10cSrcweir
148cdf0e10cSrcweir Font maFont;
149cdf0e10cSrcweir Font maLastFont;
150cdf0e10cSrcweir sal_uInt8 nChrSet;
151cdf0e10cSrcweir ChrSet* pChrSetList; // Liste der Character-Sets
152cdf0e10cSrcweir sal_uInt8 nNextChrSetId; // die erste unbenutzte ChrSet-Id
153cdf0e10cSrcweir
154cdf0e10cSrcweir PSLZWCTreeNode* pTable; // LZW compression data
155cdf0e10cSrcweir PSLZWCTreeNode* pPrefix; // the compression is as same as the TIFF compression
156cdf0e10cSrcweir sal_uInt16 nDataSize;
157cdf0e10cSrcweir sal_uInt16 nClearCode;
158cdf0e10cSrcweir sal_uInt16 nEOICode;
159cdf0e10cSrcweir sal_uInt16 nTableSize;
160cdf0e10cSrcweir sal_uInt16 nCodeSize;
161cdf0e10cSrcweir sal_uLong nOffset;
162cdf0e10cSrcweir sal_uLong dwShift;
163cdf0e10cSrcweir
164cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
165cdf0e10cSrcweir
166cdf0e10cSrcweir void ImplWriteProlog( const Graphic* pPreviewEPSI = NULL );
167cdf0e10cSrcweir void ImplWriteEpilog();
168cdf0e10cSrcweir void ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev );
169cdf0e10cSrcweir
170cdf0e10cSrcweir // this method makes LF's, space inserting and word wrapping as used in all nMode
171cdf0e10cSrcweir // parameters
172cdf0e10cSrcweir inline void ImplExecMode( sal_uLong nMode );
173cdf0e10cSrcweir
174cdf0e10cSrcweir // writes char[] + LF to stream
175cdf0e10cSrcweir inline void ImplWriteLine( const char*, sal_uLong nMode = PS_RET );
176cdf0e10cSrcweir
177cdf0e10cSrcweir // writes ( nNumb / 10^nCount ) in ASCII format to stream
178cdf0e10cSrcweir void ImplWriteF( sal_Int32 nNumb, sal_uLong nCount = 3, sal_uLong nMode = PS_SPACE );
179cdf0e10cSrcweir
180cdf0e10cSrcweir // writes a double in ASCII format to stream
181cdf0e10cSrcweir void ImplWriteDouble( double, sal_uLong nMode = PS_SPACE );
182cdf0e10cSrcweir
183cdf0e10cSrcweir // writes a long in ASCII format to stream
184cdf0e10cSrcweir void ImplWriteLong( sal_Int32 nNumb, sal_uLong nMode = PS_SPACE );
185cdf0e10cSrcweir
186cdf0e10cSrcweir // writes a byte in ASCII format to stream
187cdf0e10cSrcweir void ImplWriteByte( sal_uInt8 nNumb, sal_uLong nMode = PS_SPACE );
188cdf0e10cSrcweir
189cdf0e10cSrcweir // writes a byte in ASCII (hex) format to stream
190cdf0e10cSrcweir void ImplWriteHexByte( sal_uInt8 nNumb, sal_uLong nMode = PS_WRAP );
191cdf0e10cSrcweir
192cdf0e10cSrcweir // writes nNumb as number from 0.000 till 1.000 in ASCII format to stream
193cdf0e10cSrcweir void ImplWriteB1( sal_uInt8 nNumb, sal_uLong nMode = PS_SPACE );
194cdf0e10cSrcweir
195cdf0e10cSrcweir inline void ImplWritePoint( const Point&, sal_uInt32 nMode = PS_SPACE );
196cdf0e10cSrcweir void ImplMoveTo( const Point&, sal_uInt32 nMode = PS_SPACE );
197cdf0e10cSrcweir void ImplLineTo( const Point&, sal_uInt32 nMode = PS_SPACE );
198cdf0e10cSrcweir void ImplCurveTo( const Point& rP1, const Point& rP2, const Point& rP3, sal_uInt32 nMode = PS_SPACE );
199cdf0e10cSrcweir void ImplTranslate( const double& fX, const double& fY, sal_uInt32 nMode = PS_RET );
200cdf0e10cSrcweir void ImplScale( const double& fX, const double& fY, sal_uInt32 nMode = PS_RET );
201cdf0e10cSrcweir
202cdf0e10cSrcweir void ImplWriteLine( const Polygon & rPolygon );
203cdf0e10cSrcweir void ImplAddPath( const Polygon & rPolygon );
204cdf0e10cSrcweir void ImplWriteLineInfo( double fLineWidth, double fMiterLimit, SvtGraphicStroke::CapType eLineCap,
205cdf0e10cSrcweir SvtGraphicStroke::JoinType eJoinType, SvtGraphicStroke::DashArray& rDashArray );
206cdf0e10cSrcweir void ImplWriteLineInfo( const LineInfo& rLineInfo );
207cdf0e10cSrcweir void ImplRect( const Rectangle & rRectangle );
208cdf0e10cSrcweir void ImplRectFill ( const Rectangle & rRectangle );
209cdf0e10cSrcweir void ImplWriteGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient, VirtualDevice& rVDev );
210cdf0e10cSrcweir void ImplIntersect( const PolyPolygon& rPolyPoly );
211cdf0e10cSrcweir void ImplPolyPoly( const PolyPolygon & rPolyPolygon, sal_Bool bTextOutline = sal_False );
212cdf0e10cSrcweir void ImplPolyLine( const Polygon & rPolygon );
213cdf0e10cSrcweir
214cdf0e10cSrcweir void ImplSetClipRegion( Region& rRegion );
215cdf0e10cSrcweir void ImplBmp( Bitmap*, Bitmap*, const Point &, double nWidth, double nHeight );
216cdf0e10cSrcweir void ImplText( const String& rUniString, const Point& rPos, const sal_Int32* pDXArry, sal_Int32 nWidth, VirtualDevice& rVDev );
217cdf0e10cSrcweir void ImplSetAttrForText( const Point & rPoint );
218cdf0e10cSrcweir void ImplWriteCharacter( sal_Char );
219cdf0e10cSrcweir void ImplWriteString( const ByteString&, VirtualDevice& rVDev, const sal_Int32* pDXArry = NULL, sal_Bool bStretch = sal_False );
220cdf0e10cSrcweir void ImplDefineFont( const char*, const char* );
221cdf0e10cSrcweir
222cdf0e10cSrcweir void ImplClosePathDraw( sal_uLong nMode = PS_RET );
223cdf0e10cSrcweir void ImplPathDraw();
224cdf0e10cSrcweir
225cdf0e10cSrcweir inline void ImplWriteLineColor( sal_uLong nMode = PS_RET );
226cdf0e10cSrcweir inline void ImplWriteFillColor( sal_uLong nMode = PS_RET );
227cdf0e10cSrcweir inline void ImplWriteTextColor( sal_uLong nMode = PS_RET );
228cdf0e10cSrcweir inline void ImplWriteTextFillColor( sal_uLong nMode = PS_RET );
229cdf0e10cSrcweir void ImplWriteColor( sal_uLong nMode );
230cdf0e10cSrcweir
231cdf0e10cSrcweir double ImplGetScaling( const MapMode& );
232cdf0e10cSrcweir void ImplGetMapMode( const MapMode& );
233cdf0e10cSrcweir sal_Bool ImplGetBoundingBox( double* nNumb, sal_uInt8* pSource, sal_uLong nSize );
234cdf0e10cSrcweir sal_uInt8* ImplSearchEntry( sal_uInt8* pSource, sal_uInt8* pDest, sal_uLong nComp, sal_uLong nSize );
235cdf0e10cSrcweir // LZW methods
236cdf0e10cSrcweir void StartCompression();
237cdf0e10cSrcweir void Compress( sal_uInt8 nSrc );
238cdf0e10cSrcweir void EndCompression();
239cdf0e10cSrcweir inline void WriteBits( sal_uInt16 nCode, sal_uInt16 nCodeLen );
240cdf0e10cSrcweir
241cdf0e10cSrcweir public:
242cdf0e10cSrcweir sal_Bool WritePS( const Graphic& rGraphic, SvStream& rTargetStream, FilterConfigItem* );
243cdf0e10cSrcweir PSWriter();
244cdf0e10cSrcweir ~PSWriter();
245cdf0e10cSrcweir };
246cdf0e10cSrcweir
247cdf0e10cSrcweir //========================== Methoden von PSWriter ==========================
248cdf0e10cSrcweir
249cdf0e10cSrcweir //---------------------------------------------------------------------------------
250cdf0e10cSrcweir
PSWriter()251cdf0e10cSrcweir PSWriter::PSWriter()
252cdf0e10cSrcweir {
253cdf0e10cSrcweir pAMTF = NULL;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir
256cdf0e10cSrcweir
~PSWriter()257cdf0e10cSrcweir PSWriter::~PSWriter()
258cdf0e10cSrcweir {
259cdf0e10cSrcweir delete pAMTF;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262cdf0e10cSrcweir //---------------------------------------------------------------------------------
263cdf0e10cSrcweir
WritePS(const Graphic & rGraphic,SvStream & rTargetStream,FilterConfigItem * pFilterConfigItem)264cdf0e10cSrcweir sal_Bool PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream, FilterConfigItem* pFilterConfigItem )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir sal_uInt32 nStreamPosition = 0, nPSPosition = 0; // -Wall warning, unset, check
267cdf0e10cSrcweir
268cdf0e10cSrcweir mbStatus = sal_True;
269cdf0e10cSrcweir mnPreview = 0;
270cdf0e10cSrcweir mnLevelWarning = 0;
271cdf0e10cSrcweir mnLastPercent = 0;
272cdf0e10cSrcweir mnLatestPush = 0xEFFFFFFE;
273cdf0e10cSrcweir
274cdf0e10cSrcweir if ( pFilterConfigItem )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir xStatusIndicator = pFilterConfigItem->GetStatusIndicator();
277cdf0e10cSrcweir if ( xStatusIndicator.is() )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir rtl::OUString aMsg;
280cdf0e10cSrcweir xStatusIndicator->start( aMsg, 100 );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
284cdf0e10cSrcweir mpPS = &rTargetStream;
285cdf0e10cSrcweir mpPS->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
286cdf0e10cSrcweir
287cdf0e10cSrcweir // default values for the dialog options
288cdf0e10cSrcweir mnLevel = 2;
289cdf0e10cSrcweir mbGrayScale = sal_False;
290cdf0e10cSrcweir mbCompression = sal_True;
291cdf0e10cSrcweir mnTextMode = 0; // default0 : export glyph outlines
292cdf0e10cSrcweir
293cdf0e10cSrcweir // try to get the dialog selection
294cdf0e10cSrcweir if ( pFilterConfigItem )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir ByteString aResMgrName( "eps" );
297cdf0e10cSrcweir ResMgr* pResMgr;
298cdf0e10cSrcweir
299cdf0e10cSrcweir pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
300cdf0e10cSrcweir
301cdf0e10cSrcweir if( pResMgr )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir String aPreviewStr( RTL_CONSTASCII_USTRINGPARAM( "Preview" ) );
304cdf0e10cSrcweir String aVersionStr( RTL_CONSTASCII_USTRINGPARAM( "Version" ) );
305cdf0e10cSrcweir String aColorStr( RTL_CONSTASCII_USTRINGPARAM( "ColorFormat" ) );
306cdf0e10cSrcweir String aComprStr( RTL_CONSTASCII_USTRINGPARAM( "CompressionMode" ) );
307cdf0e10cSrcweir mnPreview = pFilterConfigItem->ReadInt32( aPreviewStr, 1 );
308cdf0e10cSrcweir mnLevel = pFilterConfigItem->ReadInt32( aVersionStr, 2 );
309cdf0e10cSrcweir if ( mnLevel != 1 )
310cdf0e10cSrcweir mnLevel = 2;
311cdf0e10cSrcweir mbGrayScale = pFilterConfigItem->ReadInt32( aColorStr, 1 ) == 2;
312cdf0e10cSrcweir mbCompression = pFilterConfigItem->ReadInt32( aComprStr, 1 ) == 1;
313cdf0e10cSrcweir String sTextMode( RTL_CONSTASCII_USTRINGPARAM( "TextMode" ) );
314cdf0e10cSrcweir mnTextMode = pFilterConfigItem->ReadInt32( sTextMode, 0 );
315cdf0e10cSrcweir if ( mnTextMode > 2 )
316cdf0e10cSrcweir mnTextMode = 0;
317cdf0e10cSrcweir delete pResMgr;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir // compression is not available for Level 1
322cdf0e10cSrcweir if ( mnLevel == 1 )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir mbGrayScale = sal_True;
325cdf0e10cSrcweir mbCompression = sal_False;
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
328cdf0e10cSrcweir if ( mnPreview & EPS_PREVIEW_TIFF )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir rTargetStream << (sal_uInt32)0xC6D3D0C5;
331cdf0e10cSrcweir nStreamPosition = rTargetStream.Tell();
332cdf0e10cSrcweir rTargetStream << (sal_uInt32)0 << (sal_uInt32)0 << (sal_uInt32)0 << (sal_uInt32)0
333cdf0e10cSrcweir << nStreamPosition + 26 << (sal_uInt32)0 << (sal_uInt16)0xffff;
334cdf0e10cSrcweir
335cdf0e10cSrcweir sal_uInt32 nErrCode;
336cdf0e10cSrcweir if ( mbGrayScale )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir BitmapEx aTempBitmapEx( rGraphic.GetBitmapEx() );
339cdf0e10cSrcweir aTempBitmapEx.Convert( BMP_CONVERSION_8BIT_GREYS );
340cdf0e10cSrcweir nErrCode = GraphicConverter::Export( rTargetStream, aTempBitmapEx, CVT_TIF ) ;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir else
343cdf0e10cSrcweir nErrCode = GraphicConverter::Export( rTargetStream, rGraphic, CVT_TIF ) ;
344cdf0e10cSrcweir
345cdf0e10cSrcweir if ( nErrCode == ERRCODE_NONE )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir rTargetStream.Seek( STREAM_SEEK_TO_END );
348cdf0e10cSrcweir nPSPosition = rTargetStream.Tell();
349cdf0e10cSrcweir rTargetStream.Seek( nStreamPosition + 20 );
350cdf0e10cSrcweir rTargetStream << nPSPosition - 30; // size of tiff gfx
351cdf0e10cSrcweir rTargetStream.Seek( nPSPosition );
352cdf0e10cSrcweir }
353cdf0e10cSrcweir else
354cdf0e10cSrcweir {
355cdf0e10cSrcweir mnPreview &=~ EPS_PREVIEW_TIFF;
356cdf0e10cSrcweir rTargetStream.Seek( nStreamPosition - 4 );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
360cdf0e10cSrcweir // global default value setting
361cdf0e10cSrcweir ChrSet* pCS;
362cdf0e10cSrcweir StackMember* pGS;
363cdf0e10cSrcweir
364cdf0e10cSrcweir if ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE )
365cdf0e10cSrcweir pMTF = &rGraphic.GetGDIMetaFile();
366cdf0e10cSrcweir else
367cdf0e10cSrcweir pMTF = pAMTF = new GDIMetaFile( rGraphic.GetGDIMetaFile() );
368cdf0e10cSrcweir aVDev.SetMapMode( pMTF->GetPrefMapMode() );
369cdf0e10cSrcweir nBoundingX1 = nBoundingY1 = 0;
370cdf0e10cSrcweir nBoundingX2 = pMTF->GetPrefSize().Width();
371cdf0e10cSrcweir nBoundingY2 = pMTF->GetPrefSize().Height();
372cdf0e10cSrcweir
373cdf0e10cSrcweir pGDIStack = NULL;
374cdf0e10cSrcweir aColor = Color( COL_TRANSPARENT );
375cdf0e10cSrcweir bLineColor = sal_True;
376cdf0e10cSrcweir aLineColor = Color( COL_BLACK );
377cdf0e10cSrcweir bFillColor = sal_True;
378cdf0e10cSrcweir aFillColor = Color( COL_WHITE );
379cdf0e10cSrcweir bTextFillColor = sal_True;
380cdf0e10cSrcweir aTextFillColor = Color( COL_BLACK );
381cdf0e10cSrcweir fLineWidth = 1;
382cdf0e10cSrcweir fMiterLimit = 15; // use same limit as most graphic systems and basegfx
383cdf0e10cSrcweir eLineCap = SvtGraphicStroke::capButt;
384cdf0e10cSrcweir eJoinType = SvtGraphicStroke::joinMiter;
385cdf0e10cSrcweir aBackgroundColor = Color( COL_WHITE );
386cdf0e10cSrcweir eTextAlign = ALIGN_BASELINE;
387cdf0e10cSrcweir bRegionChanged = sal_False;
388cdf0e10cSrcweir
389cdf0e10cSrcweir nChrSet = 0x00;
390cdf0e10cSrcweir pChrSetList = NULL;
391cdf0e10cSrcweir nNextChrSetId = 1;
392cdf0e10cSrcweir
393cdf0e10cSrcweir if( pMTF->GetActionCount() )
394cdf0e10cSrcweir {
395cdf0e10cSrcweir ImplWriteProlog( ( mnPreview & EPS_PREVIEW_EPSI ) ? &rGraphic : NULL );
396cdf0e10cSrcweir mnCursorPos = 0;
397cdf0e10cSrcweir ImplWriteActions( *pMTF, aVDev );
398cdf0e10cSrcweir ImplWriteEpilog();
399cdf0e10cSrcweir if ( mnPreview & EPS_PREVIEW_TIFF )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir sal_uInt32 nPosition = rTargetStream.Tell();
402cdf0e10cSrcweir rTargetStream.Seek( nStreamPosition );
403cdf0e10cSrcweir rTargetStream << nPSPosition;
404cdf0e10cSrcweir rTargetStream << nPosition - nPSPosition;
405cdf0e10cSrcweir rTargetStream.Seek( nPosition );
406cdf0e10cSrcweir }
407cdf0e10cSrcweir while( pChrSetList )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir pCS=pChrSetList;
410cdf0e10cSrcweir pChrSetList=pCS->pSucc;
411cdf0e10cSrcweir delete pCS;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir while( pGDIStack )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir pGS=pGDIStack;
416cdf0e10cSrcweir pGDIStack=pGS->pSucc;
417cdf0e10cSrcweir delete pGS;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir }
420cdf0e10cSrcweir else
421cdf0e10cSrcweir mbStatus = sal_False;
422cdf0e10cSrcweir
423cdf0e10cSrcweir if ( mbStatus && mnLevelWarning && pFilterConfigItem )
424cdf0e10cSrcweir {
425cdf0e10cSrcweir ByteString aResMgrName( "eps" );
426cdf0e10cSrcweir ResMgr* pResMgr;
427cdf0e10cSrcweir pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
428cdf0e10cSrcweir if( pResMgr )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir InfoBox aInfoBox( NULL, String( ResId( KEY_VERSION_CHECK, *pResMgr ) ) );
431cdf0e10cSrcweir aInfoBox.Execute();
432cdf0e10cSrcweir delete pResMgr;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir }
435cdf0e10cSrcweir
436cdf0e10cSrcweir if ( xStatusIndicator.is() )
437cdf0e10cSrcweir xStatusIndicator->end();
438cdf0e10cSrcweir
439cdf0e10cSrcweir return mbStatus;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir //---------------------------------------------------------------------------------
443cdf0e10cSrcweir
ImplWriteProlog(const Graphic * pPreview)444cdf0e10cSrcweir void PSWriter::ImplWriteProlog( const Graphic* pPreview )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir ImplWriteLine( "%!PS-Adobe-3.0 EPSF-3.0 " );
447cdf0e10cSrcweir *mpPS << "%%BoundingBox: "; // BoundingBox
448cdf0e10cSrcweir ImplWriteLong( 0 );
449cdf0e10cSrcweir ImplWriteLong( 0 );
450cdf0e10cSrcweir Size aSizePoint = Application::GetDefaultDevice()->LogicToLogic( pMTF->GetPrefSize(),
451cdf0e10cSrcweir pMTF->GetPrefMapMode(), MAP_POINT );
452cdf0e10cSrcweir ImplWriteLong( aSizePoint.Width() );
453cdf0e10cSrcweir ImplWriteLong( aSizePoint.Height() ,PS_RET );
454cdf0e10cSrcweir ImplWriteLine( "%%Pages: 0" );
455cdf0e10cSrcweir ImplWriteLine( "%%Creator: Sun Microsystems, Inc." );
456cdf0e10cSrcweir ImplWriteLine( "%%Title: none" );
457cdf0e10cSrcweir ImplWriteLine( "%%CreationDate: none" );
458cdf0e10cSrcweir
459cdf0e10cSrcweir // defaults
460cdf0e10cSrcweir
461cdf0e10cSrcweir *mpPS << "%%LanguageLevel: "; // Language level
462cdf0e10cSrcweir ImplWriteLong( mnLevel, PS_RET );
463cdf0e10cSrcweir if ( !mbGrayScale && mnLevel == 1 )
464cdf0e10cSrcweir ImplWriteLine( "%%Extensions: CMYK" ); // CMYK extension is to set in color mode in level 1
465cdf0e10cSrcweir ImplWriteLine( "%%EndComments" );
466cdf0e10cSrcweir if ( pPreview && aSizePoint.Width() && aSizePoint.Height() )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir Size aSizeBitmap( ( aSizePoint.Width() + 7 ) & ~7, aSizePoint.Height() );
469cdf0e10cSrcweir Bitmap aTmpBitmap( pPreview->GetBitmap() );
470cdf0e10cSrcweir aTmpBitmap.Scale( aSizeBitmap, BMP_SCALE_INTERPOLATE );
471cdf0e10cSrcweir aTmpBitmap.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
472cdf0e10cSrcweir BitmapReadAccess* pAcc = aTmpBitmap.AcquireReadAccess();
473cdf0e10cSrcweir if ( pAcc )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir *mpPS << "%%BeginPreview: "; // BoundingBox
476cdf0e10cSrcweir ImplWriteLong( aSizeBitmap.Width() );
477cdf0e10cSrcweir ImplWriteLong( aSizeBitmap.Height() );
478cdf0e10cSrcweir *mpPS << "1 ";
479cdf0e10cSrcweir sal_Int32 nLines = aSizeBitmap.Width() / 312;
480cdf0e10cSrcweir if ( ( nLines * 312 ) != aSizeBitmap.Width() )
481cdf0e10cSrcweir nLines++;
482cdf0e10cSrcweir nLines *= aSizeBitmap.Height();
483cdf0e10cSrcweir ImplWriteLong( nLines );
484cdf0e10cSrcweir char nVal;
485cdf0e10cSrcweir sal_Int32 nX, nY, nCount2, nCount = 4;
486cdf0e10cSrcweir const BitmapColor aBlack( pAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
487cdf0e10cSrcweir for ( nY = 0; nY < aSizeBitmap.Height(); nY++ )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir nCount2 = 0;
490cdf0e10cSrcweir nVal = 0;
491cdf0e10cSrcweir for ( nX = 0; nX < aSizeBitmap.Width(); nX++ )
492cdf0e10cSrcweir {
493cdf0e10cSrcweir if ( !nCount2 )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir ImplExecMode( PS_RET );
496cdf0e10cSrcweir *mpPS << "%";
497cdf0e10cSrcweir nCount2 = 312;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir nVal <<= 1;
500cdf0e10cSrcweir if ( pAcc->GetPixel( nY, nX ) == aBlack )
501cdf0e10cSrcweir nVal |= 1;
502cdf0e10cSrcweir if ( ! ( --nCount ) )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir if ( nVal > 9 )
505cdf0e10cSrcweir nVal += 'A' - 10;
506cdf0e10cSrcweir else
507cdf0e10cSrcweir nVal += '0';
508cdf0e10cSrcweir *mpPS << nVal;
509cdf0e10cSrcweir nVal = 0;
510cdf0e10cSrcweir nCount += 4;
511cdf0e10cSrcweir }
512cdf0e10cSrcweir nCount2--;
513cdf0e10cSrcweir }
514cdf0e10cSrcweir }
515cdf0e10cSrcweir aTmpBitmap.ReleaseAccess( pAcc );
516cdf0e10cSrcweir ImplExecMode( PS_RET );
517cdf0e10cSrcweir ImplWriteLine( "%%EndPreview" );
518cdf0e10cSrcweir }
519cdf0e10cSrcweir }
520cdf0e10cSrcweir ImplWriteLine( "%%BeginProlog" );
521cdf0e10cSrcweir ImplWriteLine( "%%BeginResource: procset SDRes-Prolog 1.0 0" );
522cdf0e10cSrcweir
523cdf0e10cSrcweir // BEGIN EPSF
524cdf0e10cSrcweir ImplWriteLine( "/b4_inc_state save def\n/dict_count countdictstack def\n/op_count count 1 sub def\nuserdict begin" );
525cdf0e10cSrcweir ImplWriteLine( "0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit[] 0 setdash newpath" );
526cdf0e10cSrcweir ImplWriteLine( "/languagelevel where {pop languagelevel 1 ne {false setstrokeadjust false setoverprint} if} if" );
527cdf0e10cSrcweir
528cdf0e10cSrcweir ImplWriteLine( "/bdef {bind def} bind def" ); // der neue operator bdef wird erzeugt
529cdf0e10cSrcweir if ( mbGrayScale )
530cdf0e10cSrcweir ImplWriteLine( "/c {setgray} bdef" );
531cdf0e10cSrcweir else
532cdf0e10cSrcweir ImplWriteLine( "/c {setrgbcolor} bdef" );
533cdf0e10cSrcweir ImplWriteLine( "/l {neg lineto} bdef" );
534cdf0e10cSrcweir ImplWriteLine( "/rl {neg rlineto} bdef" );
535cdf0e10cSrcweir ImplWriteLine( "/lc {setlinecap} bdef" );
536cdf0e10cSrcweir ImplWriteLine( "/lj {setlinejoin} bdef" );
537cdf0e10cSrcweir ImplWriteLine( "/lw {setlinewidth} bdef" );
538cdf0e10cSrcweir ImplWriteLine( "/ml {setmiterlimit} bdef" );
539cdf0e10cSrcweir ImplWriteLine( "/ld {setdash} bdef" );
540cdf0e10cSrcweir ImplWriteLine( "/m {neg moveto} bdef" );
541cdf0e10cSrcweir ImplWriteLine( "/ct {6 2 roll neg 6 2 roll neg 6 2 roll neg curveto} bdef" );
542cdf0e10cSrcweir ImplWriteLine( "/r {rotate} bdef" );
543cdf0e10cSrcweir ImplWriteLine( "/t {neg translate} bdef" );
544cdf0e10cSrcweir ImplWriteLine( "/s {scale} bdef" );
545cdf0e10cSrcweir ImplWriteLine( "/sw {show} bdef" );
546cdf0e10cSrcweir ImplWriteLine( "/gs {gsave} bdef" );
547cdf0e10cSrcweir ImplWriteLine( "/gr {grestore} bdef" );
548cdf0e10cSrcweir
549cdf0e10cSrcweir ImplWriteLine( "/f {findfont dup length dict begin" ); // Setfont
550cdf0e10cSrcweir ImplWriteLine( "{1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def" );
551cdf0e10cSrcweir ImplWriteLine( "currentdict end /NFont exch definefont pop /NFont findfont} bdef" );
552cdf0e10cSrcweir
553cdf0e10cSrcweir ImplWriteLine( "/p {closepath} bdef" );
554cdf0e10cSrcweir ImplWriteLine( "/sf {scalefont setfont} bdef" );
555cdf0e10cSrcweir
556cdf0e10cSrcweir ImplWriteLine( "/ef {eofill}bdef" ); // close path and fill
557cdf0e10cSrcweir ImplWriteLine( "/pc {closepath stroke}bdef" ); // close path and draw
558cdf0e10cSrcweir ImplWriteLine( "/ps {stroke}bdef" ); // draw current path
559cdf0e10cSrcweir ImplWriteLine( "/pum {matrix currentmatrix}bdef" ); // pushes the current matrix
560cdf0e10cSrcweir ImplWriteLine( "/pom {setmatrix}bdef" ); // pops the matrix
561cdf0e10cSrcweir ImplWriteLine( "/bs {/aString exch def /nXOfs exch def /nWidth exch def currentpoint nXOfs 0 rmoveto pum nWidth aString stringwidth pop div 1 scale aString show pom moveto} bdef" );
562cdf0e10cSrcweir ImplWriteLine( "%%EndResource" );
563cdf0e10cSrcweir ImplWriteLine( "%%EndProlog" );
564cdf0e10cSrcweir ImplWriteLine( "%%BeginSetup" );
565cdf0e10cSrcweir ImplWriteLine( "%%EndSetup" );
566cdf0e10cSrcweir ImplWriteLine( "%%Page: 1 1" );
567cdf0e10cSrcweir ImplWriteLine( "%%BeginPageSetup" );
568cdf0e10cSrcweir ImplWriteLine( "%%EndPageSetup" );
569cdf0e10cSrcweir ImplWriteLine( "pum" );
570cdf0e10cSrcweir ImplScale( (double)aSizePoint.Width() / (double)pMTF->GetPrefSize().Width(), (double)aSizePoint.Height() / (double)pMTF->GetPrefSize().Height() );
571cdf0e10cSrcweir ImplWriteDouble( 0 );
572cdf0e10cSrcweir ImplWriteDouble( -pMTF->GetPrefSize().Height() );
573cdf0e10cSrcweir ImplWriteLine( "t" );
574cdf0e10cSrcweir ImplWriteLine( "/tm matrix currentmatrix def" );
575cdf0e10cSrcweir }
576cdf0e10cSrcweir
577cdf0e10cSrcweir //---------------------------------------------------------------------------------
578cdf0e10cSrcweir
ImplWriteEpilog()579cdf0e10cSrcweir void PSWriter::ImplWriteEpilog()
580cdf0e10cSrcweir {
581cdf0e10cSrcweir ImplTranslate( 0, nBoundingY2 );
582cdf0e10cSrcweir ImplWriteLine( "pom" );
583cdf0e10cSrcweir ImplWriteLine( "count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat b4_inc_state restore" );
584cdf0e10cSrcweir
585cdf0e10cSrcweir ImplWriteLine( "%%PageTrailer" );
586cdf0e10cSrcweir ImplWriteLine( "%%Trailer" );
587cdf0e10cSrcweir
588cdf0e10cSrcweir ImplWriteLine( "%%EOF" );
589cdf0e10cSrcweir }
590cdf0e10cSrcweir
591cdf0e10cSrcweir //---------------------------------------------------------------------------------
592cdf0e10cSrcweir //---------------------------------------------------------------------------------
593cdf0e10cSrcweir //---------------------------------------------------------------------------------
594cdf0e10cSrcweir
ImplWriteActions(const GDIMetaFile & rMtf,VirtualDevice & rVDev)595cdf0e10cSrcweir void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev )
596cdf0e10cSrcweir {
597cdf0e10cSrcweir PolyPolygon aFillPath;
598cdf0e10cSrcweir
599cdf0e10cSrcweir for( sal_uLong nCurAction = 0, nCount = rMtf.GetActionCount(); nCurAction < nCount; nCurAction++ )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir MetaAction* pMA = rMtf.GetAction( nCurAction );
602cdf0e10cSrcweir
603cdf0e10cSrcweir switch( pMA->GetType() )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir case META_NULL_ACTION :
606cdf0e10cSrcweir break;
607cdf0e10cSrcweir
608cdf0e10cSrcweir case META_PIXEL_ACTION :
609cdf0e10cSrcweir {
610cdf0e10cSrcweir Color aOldLineColor( aLineColor );
611cdf0e10cSrcweir aLineColor = ( (const MetaPixelAction*) pMA )->GetColor();
612cdf0e10cSrcweir ImplWriteLineColor( PS_SPACE );
613cdf0e10cSrcweir ImplMoveTo( ( (const MetaPixelAction*)pMA )->GetPoint() );
614cdf0e10cSrcweir ImplLineTo( ( (const MetaPixelAction*)pMA )->GetPoint() );
615cdf0e10cSrcweir ImplPathDraw();
616cdf0e10cSrcweir aLineColor = aOldLineColor;
617cdf0e10cSrcweir }
618cdf0e10cSrcweir break;
619cdf0e10cSrcweir
620cdf0e10cSrcweir case META_POINT_ACTION :
621cdf0e10cSrcweir {
622cdf0e10cSrcweir ImplWriteLineColor( PS_SPACE );
623cdf0e10cSrcweir ImplMoveTo( ( (const MetaPointAction*)pMA )->GetPoint() );
624cdf0e10cSrcweir ImplLineTo( ( (const MetaPointAction*)pMA )->GetPoint() );
625cdf0e10cSrcweir ImplPathDraw();
626cdf0e10cSrcweir }
627cdf0e10cSrcweir break;
628cdf0e10cSrcweir
629cdf0e10cSrcweir case META_LINE_ACTION :
630cdf0e10cSrcweir {
631cdf0e10cSrcweir const LineInfo& rLineInfo = ( ( const MetaLineAction*)pMA )->GetLineInfo();
632cdf0e10cSrcweir ImplWriteLineInfo( rLineInfo );
633cdf0e10cSrcweir if ( bLineColor )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir ImplWriteLineColor( PS_SPACE );
636cdf0e10cSrcweir ImplMoveTo( ( (const MetaLineAction*) pMA )->GetStartPoint() );
637cdf0e10cSrcweir ImplLineTo( ( (const MetaLineAction*) pMA )->GetEndPoint() );
638cdf0e10cSrcweir ImplPathDraw();
639cdf0e10cSrcweir }
640cdf0e10cSrcweir }
641cdf0e10cSrcweir break;
642cdf0e10cSrcweir
643cdf0e10cSrcweir case META_RECT_ACTION :
644cdf0e10cSrcweir {
645cdf0e10cSrcweir ImplRect( ( (const MetaRectAction*) pMA )->GetRect() );
646cdf0e10cSrcweir }
647cdf0e10cSrcweir break;
648cdf0e10cSrcweir
649cdf0e10cSrcweir case META_ROUNDRECT_ACTION :
650cdf0e10cSrcweir ImplRect( ( (const MetaRoundRectAction*) pMA )->GetRect() );
651cdf0e10cSrcweir break;
652cdf0e10cSrcweir
653cdf0e10cSrcweir case META_ELLIPSE_ACTION :
654cdf0e10cSrcweir {
655cdf0e10cSrcweir Rectangle aRect = ( ( (const MetaEllipseAction*) pMA )->GetRect() );
656cdf0e10cSrcweir Point aCenter = aRect.Center();
657cdf0e10cSrcweir Polygon aPoly( aCenter, aRect.GetWidth() / 2, aRect.GetHeight() / 2 );
658cdf0e10cSrcweir PolyPolygon aPolyPoly( aPoly );
659cdf0e10cSrcweir ImplPolyPoly( aPolyPoly );
660cdf0e10cSrcweir }
661cdf0e10cSrcweir break;
662cdf0e10cSrcweir
663cdf0e10cSrcweir case META_ARC_ACTION :
664cdf0e10cSrcweir {
665cdf0e10cSrcweir Polygon aPoly( ( (const MetaArcAction*)pMA )->GetRect(), ( (const MetaArcAction*)pMA )->GetStartPoint(),
666cdf0e10cSrcweir ( (const MetaArcAction*)pMA )->GetEndPoint(), POLY_ARC );
667cdf0e10cSrcweir PolyPolygon aPolyPoly( aPoly );
668cdf0e10cSrcweir ImplPolyPoly( aPolyPoly );
669cdf0e10cSrcweir }
670cdf0e10cSrcweir break;
671cdf0e10cSrcweir
672cdf0e10cSrcweir case META_PIE_ACTION :
673cdf0e10cSrcweir {
674cdf0e10cSrcweir Polygon aPoly( ( (const MetaPieAction*)pMA )->GetRect(), ( (const MetaPieAction*)pMA )->GetStartPoint(),
675cdf0e10cSrcweir ( (const MetaPieAction*)pMA )->GetEndPoint(), POLY_PIE );
676cdf0e10cSrcweir PolyPolygon aPolyPoly( aPoly );
677cdf0e10cSrcweir ImplPolyPoly( aPolyPoly );
678cdf0e10cSrcweir }
679cdf0e10cSrcweir break;
680cdf0e10cSrcweir
681cdf0e10cSrcweir case META_CHORD_ACTION :
682cdf0e10cSrcweir {
683cdf0e10cSrcweir Polygon aPoly( ( (const MetaChordAction*)pMA )->GetRect(), ( (const MetaChordAction*)pMA )->GetStartPoint(),
684cdf0e10cSrcweir ( (const MetaChordAction*)pMA )->GetEndPoint(), POLY_CHORD );
685cdf0e10cSrcweir PolyPolygon aPolyPoly( aPoly );
686cdf0e10cSrcweir ImplPolyPoly( aPolyPoly );
687cdf0e10cSrcweir }
688cdf0e10cSrcweir break;
689cdf0e10cSrcweir
690cdf0e10cSrcweir case META_POLYLINE_ACTION :
691cdf0e10cSrcweir {
692cdf0e10cSrcweir Polygon aPoly( ( (const MetaPolyLineAction*) pMA )->GetPolygon() );
693cdf0e10cSrcweir const LineInfo& rLineInfo = ( ( const MetaPolyLineAction*)pMA )->GetLineInfo();
694cdf0e10cSrcweir ImplWriteLineInfo( rLineInfo );
695cdf0e10cSrcweir
696cdf0e10cSrcweir if(basegfx::B2DLINEJOIN_NONE == rLineInfo.GetLineJoin()
697cdf0e10cSrcweir && rLineInfo.GetWidth() > 1)
698cdf0e10cSrcweir {
699cdf0e10cSrcweir // emulate B2DLINEJOIN_NONE by creating single edges
700cdf0e10cSrcweir const sal_uInt16 nPoints(aPoly.GetSize());
701cdf0e10cSrcweir const bool bCurve(aPoly.HasFlags());
702cdf0e10cSrcweir
703cdf0e10cSrcweir for(sal_uInt16 a(0); a + 1 < nPoints; a++)
704cdf0e10cSrcweir {
705cdf0e10cSrcweir if(bCurve
706cdf0e10cSrcweir && POLY_NORMAL != aPoly.GetFlags(a + 1)
707cdf0e10cSrcweir && a + 2 < nPoints
708cdf0e10cSrcweir && POLY_NORMAL != aPoly.GetFlags(a + 2)
709cdf0e10cSrcweir && a + 3 < nPoints)
710cdf0e10cSrcweir {
711cdf0e10cSrcweir const Polygon aSnippet(4,
712cdf0e10cSrcweir aPoly.GetConstPointAry() + a,
713cdf0e10cSrcweir aPoly.GetConstFlagAry() + a);
714cdf0e10cSrcweir ImplPolyLine(aSnippet);
715cdf0e10cSrcweir a += 2;
716cdf0e10cSrcweir }
717cdf0e10cSrcweir else
718cdf0e10cSrcweir {
719cdf0e10cSrcweir const Polygon aSnippet(2,
720cdf0e10cSrcweir aPoly.GetConstPointAry() + a);
721cdf0e10cSrcweir ImplPolyLine(aSnippet);
722cdf0e10cSrcweir }
723cdf0e10cSrcweir }
724cdf0e10cSrcweir }
725cdf0e10cSrcweir else
726cdf0e10cSrcweir {
727cdf0e10cSrcweir ImplPolyLine( aPoly );
728cdf0e10cSrcweir }
729cdf0e10cSrcweir }
730cdf0e10cSrcweir break;
731cdf0e10cSrcweir
732cdf0e10cSrcweir case META_POLYGON_ACTION :
733cdf0e10cSrcweir {
734cdf0e10cSrcweir PolyPolygon aPolyPoly( ( (const MetaPolygonAction*) pMA )->GetPolygon() );
735cdf0e10cSrcweir ImplPolyPoly( aPolyPoly );
736cdf0e10cSrcweir }
737cdf0e10cSrcweir break;
738cdf0e10cSrcweir
739cdf0e10cSrcweir case META_POLYPOLYGON_ACTION :
740cdf0e10cSrcweir {
741cdf0e10cSrcweir ImplPolyPoly( ( (const MetaPolyPolygonAction*) pMA )->GetPolyPolygon() );
742cdf0e10cSrcweir }
743cdf0e10cSrcweir break;
744cdf0e10cSrcweir
745cdf0e10cSrcweir case META_TEXT_ACTION:
746cdf0e10cSrcweir {
747cdf0e10cSrcweir const MetaTextAction * pA = (const MetaTextAction*) pMA;
748cdf0e10cSrcweir
749cdf0e10cSrcweir String aUniStr( pA->GetText(), pA->GetIndex(), pA->GetLen() );
750cdf0e10cSrcweir Point aPoint( pA->GetPoint() );
751cdf0e10cSrcweir
752cdf0e10cSrcweir ImplText( aUniStr, aPoint, NULL, 0, rVDev );
753cdf0e10cSrcweir }
754cdf0e10cSrcweir break;
755cdf0e10cSrcweir
756cdf0e10cSrcweir case META_TEXTRECT_ACTION:
757cdf0e10cSrcweir {
758cdf0e10cSrcweir DBG_ERROR( "Unsupported action: TextRect...Action!" );
759cdf0e10cSrcweir }
760cdf0e10cSrcweir break;
761cdf0e10cSrcweir
762cdf0e10cSrcweir case META_STRETCHTEXT_ACTION :
763cdf0e10cSrcweir {
764cdf0e10cSrcweir const MetaStretchTextAction* pA = (const MetaStretchTextAction*)pMA;
765cdf0e10cSrcweir String aUniStr( pA->GetText(), pA->GetIndex(), pA->GetLen() );
766cdf0e10cSrcweir Point aPoint( pA->GetPoint() );
767cdf0e10cSrcweir
768cdf0e10cSrcweir ImplText( aUniStr, aPoint, NULL, pA->GetWidth(), rVDev );
769cdf0e10cSrcweir }
770cdf0e10cSrcweir break;
771cdf0e10cSrcweir
772cdf0e10cSrcweir case META_TEXTARRAY_ACTION:
773cdf0e10cSrcweir {
774cdf0e10cSrcweir const MetaTextArrayAction* pA = (const MetaTextArrayAction*)pMA;
775cdf0e10cSrcweir String aUniStr( pA->GetText(), pA->GetIndex(), pA->GetLen() );
776cdf0e10cSrcweir Point aPoint( pA->GetPoint() );
777cdf0e10cSrcweir
778cdf0e10cSrcweir ImplText( aUniStr, aPoint, pA->GetDXArray(), 0, rVDev );
779cdf0e10cSrcweir }
780cdf0e10cSrcweir break;
781cdf0e10cSrcweir
782cdf0e10cSrcweir case META_BMP_ACTION :
783cdf0e10cSrcweir {
784cdf0e10cSrcweir Bitmap aBitmap = ( (const MetaBmpAction*)pMA )->GetBitmap();
785cdf0e10cSrcweir if ( mbGrayScale )
786cdf0e10cSrcweir aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
787cdf0e10cSrcweir Point aPoint = ( (const MetaBmpAction*) pMA )->GetPoint();
788cdf0e10cSrcweir Size aSize( rVDev.PixelToLogic( aBitmap.GetSizePixel() ) );
789cdf0e10cSrcweir ImplBmp( &aBitmap, NULL, aPoint, aSize.Width(), aSize.Height() );
790cdf0e10cSrcweir }
791cdf0e10cSrcweir break;
792cdf0e10cSrcweir
793cdf0e10cSrcweir case META_BMPSCALE_ACTION :
794cdf0e10cSrcweir {
795cdf0e10cSrcweir Bitmap aBitmap = ( (const MetaBmpScaleAction*)pMA )->GetBitmap();
796cdf0e10cSrcweir if ( mbGrayScale )
797cdf0e10cSrcweir aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
798cdf0e10cSrcweir Point aPoint = ( (const MetaBmpScaleAction*) pMA )->GetPoint();
799cdf0e10cSrcweir Size aSize = ( (const MetaBmpScaleAction*)pMA )->GetSize();
800cdf0e10cSrcweir ImplBmp( &aBitmap, NULL, aPoint, aSize.Width(), aSize.Height() );
801cdf0e10cSrcweir }
802cdf0e10cSrcweir break;
803cdf0e10cSrcweir
804cdf0e10cSrcweir case META_BMPSCALEPART_ACTION :
805cdf0e10cSrcweir {
806cdf0e10cSrcweir Bitmap aBitmap( ( (const MetaBmpScalePartAction*)pMA )->GetBitmap() );
807cdf0e10cSrcweir aBitmap.Crop( Rectangle( ( (const MetaBmpScalePartAction*)pMA )->GetSrcPoint(),
808cdf0e10cSrcweir ( (const MetaBmpScalePartAction*)pMA )->GetSrcSize() ) );
809cdf0e10cSrcweir if ( mbGrayScale )
810cdf0e10cSrcweir aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
811cdf0e10cSrcweir Point aPoint = ( (const MetaBmpScalePartAction*) pMA)->GetDestPoint();
812cdf0e10cSrcweir Size aSize = ( (const MetaBmpScalePartAction*)pMA )->GetDestSize();
813cdf0e10cSrcweir ImplBmp( &aBitmap, NULL, aPoint, aSize.Width(), aSize.Height() );
814cdf0e10cSrcweir }
815cdf0e10cSrcweir break;
816cdf0e10cSrcweir
817cdf0e10cSrcweir case META_BMPEX_ACTION :
818cdf0e10cSrcweir {
819cdf0e10cSrcweir BitmapEx aBitmapEx( ( (MetaBmpExAction*)pMA)->GetBitmapEx() );
820cdf0e10cSrcweir Bitmap aBitmap( aBitmapEx.GetBitmap() );
821cdf0e10cSrcweir if ( mbGrayScale )
822cdf0e10cSrcweir aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
823cdf0e10cSrcweir Bitmap aMask( aBitmapEx.GetMask() );
824cdf0e10cSrcweir Point aPoint( ( (const MetaBmpExAction*) pMA )->GetPoint() );
825cdf0e10cSrcweir Size aSize( rVDev.PixelToLogic( aBitmap.GetSizePixel() ) );
826cdf0e10cSrcweir ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
827cdf0e10cSrcweir }
828cdf0e10cSrcweir break;
829cdf0e10cSrcweir
830cdf0e10cSrcweir case META_BMPEXSCALE_ACTION :
831cdf0e10cSrcweir {
832cdf0e10cSrcweir BitmapEx aBitmapEx( ( (MetaBmpExScaleAction*)pMA)->GetBitmapEx() );
833cdf0e10cSrcweir Bitmap aBitmap( aBitmapEx.GetBitmap() );
834cdf0e10cSrcweir if ( mbGrayScale )
835cdf0e10cSrcweir aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
836cdf0e10cSrcweir Bitmap aMask( aBitmapEx.GetMask() );
837cdf0e10cSrcweir Point aPoint = ( (const MetaBmpExScaleAction*) pMA)->GetPoint();
838cdf0e10cSrcweir Size aSize( ( (const MetaBmpExScaleAction*)pMA )->GetSize() );
839cdf0e10cSrcweir ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
840cdf0e10cSrcweir }
841cdf0e10cSrcweir break;
842cdf0e10cSrcweir
843cdf0e10cSrcweir case META_BMPEXSCALEPART_ACTION :
844cdf0e10cSrcweir {
845cdf0e10cSrcweir BitmapEx aBitmapEx( ( (const MetaBmpExScalePartAction*)pMA )->GetBitmapEx() );
846cdf0e10cSrcweir aBitmapEx.Crop( Rectangle( ( (const MetaBmpExScalePartAction*)pMA )->GetSrcPoint(),
847cdf0e10cSrcweir ( (const MetaBmpExScalePartAction*)pMA )->GetSrcSize() ) );
848cdf0e10cSrcweir Bitmap aBitmap( aBitmapEx.GetBitmap() );
849cdf0e10cSrcweir if ( mbGrayScale )
850cdf0e10cSrcweir aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
851cdf0e10cSrcweir Bitmap aMask( aBitmapEx.GetMask() );
852cdf0e10cSrcweir Point aPoint = ( (const MetaBmpExScalePartAction*) pMA)->GetDestPoint();
853cdf0e10cSrcweir Size aSize = ( (const MetaBmpExScalePartAction*)pMA )->GetDestSize();
854cdf0e10cSrcweir ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
855cdf0e10cSrcweir }
856cdf0e10cSrcweir break;
857cdf0e10cSrcweir
858cdf0e10cSrcweir // Unsupported Actions
859cdf0e10cSrcweir case META_MASK_ACTION:
860cdf0e10cSrcweir case META_MASKSCALE_ACTION:
861cdf0e10cSrcweir case META_MASKSCALEPART_ACTION:
862cdf0e10cSrcweir {
863cdf0e10cSrcweir DBG_ERROR( "Unsupported action: MetaMask...Action!" );
864cdf0e10cSrcweir }
865cdf0e10cSrcweir break;
866cdf0e10cSrcweir
867cdf0e10cSrcweir case META_GRADIENT_ACTION :
868cdf0e10cSrcweir {
869cdf0e10cSrcweir PolyPolygon aPolyPoly( ( (const MetaGradientAction*)pMA)->GetRect() );
870cdf0e10cSrcweir ImplWriteGradient( aPolyPoly, ( (const MetaGradientAction*) pMA )->GetGradient(), rVDev );
871cdf0e10cSrcweir }
872cdf0e10cSrcweir break;
873cdf0e10cSrcweir
874cdf0e10cSrcweir case META_GRADIENTEX_ACTION :
875cdf0e10cSrcweir {
876cdf0e10cSrcweir PolyPolygon aPolyPoly( ( (const MetaGradientExAction*)pMA)->GetPolyPolygon() );
877cdf0e10cSrcweir ImplWriteGradient( aPolyPoly, ( (const MetaGradientExAction*) pMA )->GetGradient(), rVDev );
878cdf0e10cSrcweir }
879cdf0e10cSrcweir break;
880cdf0e10cSrcweir
881cdf0e10cSrcweir case META_HATCH_ACTION :
882cdf0e10cSrcweir {
883cdf0e10cSrcweir VirtualDevice l_aVDev;
884cdf0e10cSrcweir GDIMetaFile aTmpMtf;
885cdf0e10cSrcweir
886cdf0e10cSrcweir l_aVDev.SetMapMode( rVDev.GetMapMode() );
887cdf0e10cSrcweir l_aVDev.AddHatchActions( ( (const MetaHatchAction*)pMA)->GetPolyPolygon(),
888cdf0e10cSrcweir ( (const MetaHatchAction*)pMA )->GetHatch(), aTmpMtf );
889cdf0e10cSrcweir ImplWriteActions( aTmpMtf, rVDev );
890cdf0e10cSrcweir }
891cdf0e10cSrcweir break;
892cdf0e10cSrcweir
893cdf0e10cSrcweir case META_WALLPAPER_ACTION :
894cdf0e10cSrcweir {
895cdf0e10cSrcweir const MetaWallpaperAction* pA = (const MetaWallpaperAction*)pMA;
896cdf0e10cSrcweir Rectangle aRect = pA->GetRect();
897cdf0e10cSrcweir Wallpaper aWallpaper = pA->GetWallpaper();
898cdf0e10cSrcweir
899cdf0e10cSrcweir if ( aWallpaper.IsBitmap() )
900cdf0e10cSrcweir {
901cdf0e10cSrcweir BitmapEx aBitmapEx = aWallpaper.GetBitmap();
902cdf0e10cSrcweir Bitmap aBitmap( aBitmapEx.GetBitmap() );
903cdf0e10cSrcweir if ( aBitmapEx.IsTransparent() )
904cdf0e10cSrcweir {
905cdf0e10cSrcweir if ( aWallpaper.IsGradient() )
906cdf0e10cSrcweir {
907cdf0e10cSrcweir
908cdf0e10cSrcweir // gradient action
909cdf0e10cSrcweir
910cdf0e10cSrcweir }
911cdf0e10cSrcweir Bitmap aMask( aBitmapEx.GetMask() );
912cdf0e10cSrcweir ImplBmp( &aBitmap, &aMask, Point( aRect.Left(), aRect.Top() ), aRect.GetWidth(), aRect.GetHeight() );
913cdf0e10cSrcweir }
914cdf0e10cSrcweir else
915cdf0e10cSrcweir ImplBmp( &aBitmap, NULL, Point( aRect.Left(), aRect.Top() ), aRect.GetWidth(), aRect.GetHeight() );
916cdf0e10cSrcweir
917cdf0e10cSrcweir // wallpaper Style
918cdf0e10cSrcweir
919cdf0e10cSrcweir }
920cdf0e10cSrcweir else if ( aWallpaper.IsGradient() )
921cdf0e10cSrcweir {
922cdf0e10cSrcweir
923cdf0e10cSrcweir // gradient action
924cdf0e10cSrcweir
925cdf0e10cSrcweir }
926cdf0e10cSrcweir else
927cdf0e10cSrcweir {
928cdf0e10cSrcweir aColor = aWallpaper.GetColor();
929cdf0e10cSrcweir ImplRectFill( aRect );
930cdf0e10cSrcweir }
931cdf0e10cSrcweir }
932cdf0e10cSrcweir break;
933cdf0e10cSrcweir
934cdf0e10cSrcweir case META_ISECTRECTCLIPREGION_ACTION:
935cdf0e10cSrcweir {
936cdf0e10cSrcweir const MetaISectRectClipRegionAction* pA = (const MetaISectRectClipRegionAction*) pMA;
937cdf0e10cSrcweir Region aRegion( pA->GetRect() );
938cdf0e10cSrcweir ImplSetClipRegion( aRegion );
939cdf0e10cSrcweir }
940cdf0e10cSrcweir break;
941cdf0e10cSrcweir
942cdf0e10cSrcweir case META_CLIPREGION_ACTION:
943cdf0e10cSrcweir {
944cdf0e10cSrcweir const MetaClipRegionAction* pA = (const MetaClipRegionAction*) pMA;
945cdf0e10cSrcweir Region aRegion( pA->GetRegion() );
946cdf0e10cSrcweir ImplSetClipRegion( aRegion );
947cdf0e10cSrcweir }
948cdf0e10cSrcweir break;
949cdf0e10cSrcweir
950cdf0e10cSrcweir case META_ISECTREGIONCLIPREGION_ACTION:
951cdf0e10cSrcweir {
952cdf0e10cSrcweir const MetaISectRegionClipRegionAction* pA = (const MetaISectRegionClipRegionAction*) pMA;
953cdf0e10cSrcweir Region aRegion( pA->GetRegion() );
954cdf0e10cSrcweir ImplSetClipRegion( aRegion );
955cdf0e10cSrcweir }
956cdf0e10cSrcweir break;
957cdf0e10cSrcweir
958cdf0e10cSrcweir case META_MOVECLIPREGION_ACTION:
959cdf0e10cSrcweir {
960cdf0e10cSrcweir /*
961cdf0e10cSrcweir if ( !aClipRegion.IsEmpty() )
962cdf0e10cSrcweir {
963cdf0e10cSrcweir const MetaMoveClipRegionAction* pA = (const MetaMoveClipRegionAction*) pMA;
964cdf0e10cSrcweir aClipRegion.Move( pA->GetHorzMove(), pA->GetVertMove() );
965cdf0e10cSrcweir ImplSetClipRegion();
966cdf0e10cSrcweir }
967cdf0e10cSrcweir */
968cdf0e10cSrcweir }
969cdf0e10cSrcweir break;
970cdf0e10cSrcweir
971cdf0e10cSrcweir case META_LINECOLOR_ACTION :
972cdf0e10cSrcweir {
973cdf0e10cSrcweir if ( ( (const MetaLineColorAction*) pMA)->IsSetting() )
974cdf0e10cSrcweir {
975cdf0e10cSrcweir bLineColor = sal_True;
976cdf0e10cSrcweir aLineColor = ( (const MetaLineColorAction*) pMA )->GetColor();
977cdf0e10cSrcweir }
978cdf0e10cSrcweir else
979cdf0e10cSrcweir bLineColor = sal_False;
980cdf0e10cSrcweir }
981cdf0e10cSrcweir break;
982cdf0e10cSrcweir
983cdf0e10cSrcweir case META_FILLCOLOR_ACTION :
984cdf0e10cSrcweir {
985cdf0e10cSrcweir if ( ( (const MetaFillColorAction*) pMA )->IsSetting() )
986cdf0e10cSrcweir {
987cdf0e10cSrcweir bFillColor = sal_True;
988cdf0e10cSrcweir aFillColor = ( (const MetaFillColorAction*) pMA )->GetColor();
989cdf0e10cSrcweir }
990cdf0e10cSrcweir else
991cdf0e10cSrcweir bFillColor = sal_False;
992cdf0e10cSrcweir }
993cdf0e10cSrcweir break;
994cdf0e10cSrcweir
995cdf0e10cSrcweir case META_TEXTCOLOR_ACTION :
996cdf0e10cSrcweir {
997cdf0e10cSrcweir aTextColor = ( (const MetaTextColorAction*) pMA )->GetColor();
998cdf0e10cSrcweir }
999cdf0e10cSrcweir break;
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir case META_TEXTFILLCOLOR_ACTION :
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir if ( ( (const MetaTextFillColorAction*) pMA )->IsSetting() )
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir bTextFillColor = sal_True;
1006cdf0e10cSrcweir aTextFillColor = ( (const MetaTextFillColorAction*) pMA )->GetColor();
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir else
1009cdf0e10cSrcweir bTextFillColor = sal_False;
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir break;
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir case META_TEXTALIGN_ACTION :
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir eTextAlign = ( (const MetaTextAlignAction*) pMA )->GetTextAlign();
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir break;
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir case META_MAPMODE_ACTION :
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir pMA->Execute( &rVDev );
1022cdf0e10cSrcweir ImplGetMapMode( rVDev.GetMapMode() );
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir break;
1025cdf0e10cSrcweir
1026cdf0e10cSrcweir case META_FONT_ACTION :
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir maFont = ((const MetaFontAction*)pMA)->GetFont();
1029cdf0e10cSrcweir rVDev.SetFont( maFont );
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir break;
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir case META_PUSH_ACTION :
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir rVDev.Push(((const MetaPushAction*)pMA)->GetFlags() );
1036cdf0e10cSrcweir StackMember* pGS = new StackMember;
1037cdf0e10cSrcweir pGS->pSucc = pGDIStack;
1038cdf0e10cSrcweir pGDIStack = pGS;
1039cdf0e10cSrcweir pGS->aDashArray = aDashArray;
1040cdf0e10cSrcweir pGS->eJoinType = eJoinType;
1041cdf0e10cSrcweir pGS->eLineCap = eLineCap;
1042cdf0e10cSrcweir pGS->fLineWidth = fLineWidth;
1043cdf0e10cSrcweir pGS->fMiterLimit = fMiterLimit;
1044cdf0e10cSrcweir pGS->eTextAlign = eTextAlign;
1045cdf0e10cSrcweir pGS->aGlobalCol = aColor;
1046cdf0e10cSrcweir pGS->bLineCol = bLineColor;
1047cdf0e10cSrcweir pGS->aLineCol = aLineColor;
1048cdf0e10cSrcweir pGS->bFillCol = bFillColor;
1049cdf0e10cSrcweir pGS->aFillCol = aFillColor;
1050cdf0e10cSrcweir pGS->aTextCol = aTextColor;
1051cdf0e10cSrcweir pGS->bTextFillCol = bTextFillColor;
1052cdf0e10cSrcweir pGS->aTextFillCol = aTextFillColor;
1053cdf0e10cSrcweir pGS->aBackgroundCol = aBackgroundColor;
1054cdf0e10cSrcweir bRegionChanged = sal_False;
1055cdf0e10cSrcweir pGS->aFont = maFont;
1056cdf0e10cSrcweir mnLatestPush = mpPS->Tell();
1057cdf0e10cSrcweir ImplWriteLine( "gs" );
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir break;
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir case META_POP_ACTION :
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir rVDev.Pop();
1064cdf0e10cSrcweir StackMember* pGS;
1065cdf0e10cSrcweir if( pGDIStack )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir pGS = pGDIStack;
1068cdf0e10cSrcweir pGDIStack = pGS->pSucc;
1069cdf0e10cSrcweir aDashArray = pGS->aDashArray;
1070cdf0e10cSrcweir eJoinType = pGS->eJoinType;
1071cdf0e10cSrcweir eLineCap = pGS->eLineCap;
1072cdf0e10cSrcweir fLineWidth = pGS->fLineWidth;
1073cdf0e10cSrcweir fMiterLimit = pGS->fMiterLimit;
1074cdf0e10cSrcweir eTextAlign = pGS->eTextAlign;
1075cdf0e10cSrcweir aColor = pGS->aGlobalCol;
1076cdf0e10cSrcweir bLineColor = pGS->bLineCol;
1077cdf0e10cSrcweir aLineColor = pGS->aLineCol;
1078cdf0e10cSrcweir bFillColor = pGS->bFillCol;
1079cdf0e10cSrcweir aFillColor = pGS->aFillCol;
1080cdf0e10cSrcweir aTextColor = pGS->aTextCol;
1081cdf0e10cSrcweir bTextFillColor = pGS->bTextFillCol;
1082cdf0e10cSrcweir aTextFillColor = pGS->aTextFillCol;
1083cdf0e10cSrcweir aBackgroundColor = pGS->aBackgroundCol;
1084cdf0e10cSrcweir maFont = pGS->aFont;
1085cdf0e10cSrcweir maLastFont = Font(); // set maLastFont != maFont -> so that
1086cdf0e10cSrcweir delete pGS;
1087cdf0e10cSrcweir sal_uInt32 nCurrentPos = mpPS->Tell();
1088cdf0e10cSrcweir if ( nCurrentPos - 3 == mnLatestPush )
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir mpPS->Seek( mnLatestPush );
1091cdf0e10cSrcweir ImplWriteLine( " " );
1092cdf0e10cSrcweir mpPS->Seek( mnLatestPush );
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir else
1095cdf0e10cSrcweir ImplWriteLine( "gr" );
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir break;
1099cdf0e10cSrcweir
1100cdf0e10cSrcweir case META_EPS_ACTION :
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir GfxLink aGfxLink = ( (const MetaEPSAction*) pMA )->GetLink();
1103cdf0e10cSrcweir const GDIMetaFile aSubstitute( ( ( const MetaEPSAction*) pMA )->GetSubstitute() );
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir sal_Bool bLevelConflict = sal_False;
1106cdf0e10cSrcweir sal_uInt8* pSource = (sal_uInt8*) aGfxLink.GetData();
1107cdf0e10cSrcweir sal_uLong nSize = aGfxLink.GetDataSize();
1108cdf0e10cSrcweir sal_uLong nParseThis = POSTSCRIPT_BOUNDINGSEARCH;
1109cdf0e10cSrcweir if ( nSize < 64 ) // assuming eps is larger than 64 bytes
1110cdf0e10cSrcweir pSource = NULL;
1111cdf0e10cSrcweir if ( nParseThis > nSize )
1112cdf0e10cSrcweir nParseThis = nSize;
1113cdf0e10cSrcweir
1114cdf0e10cSrcweir if ( pSource && ( mnLevel == 1 ) )
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir sal_uInt8* pFound = ImplSearchEntry( pSource, (sal_uInt8*)"%%LanguageLevel:", nParseThis - 10, 16 );
1117cdf0e10cSrcweir if ( pFound )
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir sal_uInt8 k, i = 10;
1120cdf0e10cSrcweir pFound += 16;
1121cdf0e10cSrcweir while ( --i )
1122cdf0e10cSrcweir {
1123cdf0e10cSrcweir k = *pFound++;
1124cdf0e10cSrcweir if ( ( k > '0' ) && ( k <= '9' ) )
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir if ( k != '1' )
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir bLevelConflict = sal_True;
1129cdf0e10cSrcweir mnLevelWarning++;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir break;
1132cdf0e10cSrcweir }
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir if ( !bLevelConflict )
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir double nBoundingBox[4];
1139cdf0e10cSrcweir if ( pSource && ImplGetBoundingBox( nBoundingBox, pSource, nParseThis ) )
1140cdf0e10cSrcweir {
1141cdf0e10cSrcweir Point aPoint = ( (const MetaEPSAction*) pMA )->GetPoint();
1142cdf0e10cSrcweir Size aSize = ( (const MetaEPSAction*) pMA )->GetSize();
1143cdf0e10cSrcweir
1144cdf0e10cSrcweir MapMode aMapMode( aSubstitute.GetPrefMapMode() );
1145cdf0e10cSrcweir Size aOutSize( rVDev.LogicToLogic( aSize, rVDev.GetMapMode(), aMapMode ) );
1146cdf0e10cSrcweir Point aOrigin( rVDev.LogicToLogic( aPoint, rVDev.GetMapMode(), aMapMode ) );
1147cdf0e10cSrcweir aOrigin.Y() += aOutSize.Height();
1148cdf0e10cSrcweir aMapMode.SetOrigin( aOrigin );
1149cdf0e10cSrcweir aMapMode.SetScaleX( aOutSize.Width() / ( nBoundingBox[ 2 ] - nBoundingBox[ 0 ] ) );
1150cdf0e10cSrcweir aMapMode.SetScaleY( aOutSize.Height() / ( nBoundingBox[ 3 ] - nBoundingBox[ 1 ] ) );
1151cdf0e10cSrcweir ImplWriteLine( "gs" );
1152cdf0e10cSrcweir ImplGetMapMode( aMapMode );
1153cdf0e10cSrcweir ImplWriteLine( "%%BeginDocument:" );
1154cdf0e10cSrcweir mpPS->Write( pSource, aGfxLink.GetDataSize() );
1155cdf0e10cSrcweir ImplWriteLine( "%%EndDocument\ngr" );
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir break;
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir case META_TRANSPARENT_ACTION:
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir // ImplLine( ( (const MetaTransparentAction*) pMA )->GetPolyPolygon() );
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir break;
1166cdf0e10cSrcweir
1167cdf0e10cSrcweir case META_RASTEROP_ACTION:
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir pMA->Execute( &rVDev );
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir break;
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir case META_FLOATTRANSPARENT_ACTION:
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pMA;
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
1178cdf0e10cSrcweir Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
1179cdf0e10cSrcweir const Size aSrcSize( aTmpMtf.GetPrefSize() );
1180cdf0e10cSrcweir const Point aDestPt( pA->GetPoint() );
1181cdf0e10cSrcweir const Size aDestSize( pA->GetSize() );
1182cdf0e10cSrcweir const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0;
1183cdf0e10cSrcweir const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0;
1184cdf0e10cSrcweir long nMoveX, nMoveY;
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir if( fScaleX != 1.0 || fScaleY != 1.0 )
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir aTmpMtf.Scale( fScaleX, fScaleY );
1189cdf0e10cSrcweir aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir nMoveX = aDestPt.X() - aSrcPt.X(), nMoveY = aDestPt.Y() - aSrcPt.Y();
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir if( nMoveX || nMoveY )
1195cdf0e10cSrcweir aTmpMtf.Move( nMoveX, nMoveY );
1196cdf0e10cSrcweir
1197cdf0e10cSrcweir ImplWriteActions( aTmpMtf, rVDev );
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir break;
1200cdf0e10cSrcweir
1201cdf0e10cSrcweir case META_COMMENT_ACTION:
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir const MetaCommentAction* pA = (const MetaCommentAction*) pMA;
1204cdf0e10cSrcweir if ( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
1205cdf0e10cSrcweir {
1206cdf0e10cSrcweir const MetaGradientExAction* pGradAction = NULL;
1207cdf0e10cSrcweir while( ++nCurAction < nCount )
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir MetaAction* pAction = rMtf.GetAction( nCurAction );
1210cdf0e10cSrcweir if( pAction->GetType() == META_GRADIENTEX_ACTION )
1211cdf0e10cSrcweir pGradAction = (const MetaGradientExAction*) pAction;
1212cdf0e10cSrcweir else if( ( pAction->GetType() == META_COMMENT_ACTION ) &&
1213cdf0e10cSrcweir ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) )
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir break;
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir if( pGradAction )
1219cdf0e10cSrcweir ImplWriteGradient( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), rVDev );
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir else if ( pA->GetComment().Equals( "XPATHFILL_SEQ_END" ) )
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir if ( aFillPath.Count() )
1224cdf0e10cSrcweir {
1225cdf0e10cSrcweir aFillPath = PolyPolygon();
1226cdf0e10cSrcweir ImplWriteLine( "gr" );
1227cdf0e10cSrcweir }
1228cdf0e10cSrcweir }
1229cdf0e10cSrcweir else
1230cdf0e10cSrcweir {
1231cdf0e10cSrcweir const sal_uInt8* pData = pA->GetData();
1232cdf0e10cSrcweir if ( pData )
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir SvMemoryStream aMemStm( (void*)pData, pA->GetDataSize(), STREAM_READ );
1235cdf0e10cSrcweir sal_Bool bSkipSequence = sal_False;
1236cdf0e10cSrcweir ByteString sSeqEnd;
1237cdf0e10cSrcweir
1238cdf0e10cSrcweir if( pA->GetComment().Equals( "XPATHSTROKE_SEQ_BEGIN" ) )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir sSeqEnd = ByteString( "XPATHSTROKE_SEQ_END" );
1241cdf0e10cSrcweir SvtGraphicStroke aStroke;
1242cdf0e10cSrcweir aMemStm >> aStroke;
1243cdf0e10cSrcweir
1244cdf0e10cSrcweir Polygon aPath;
1245cdf0e10cSrcweir aStroke.getPath( aPath );
1246cdf0e10cSrcweir
1247cdf0e10cSrcweir PolyPolygon aStartArrow;
1248cdf0e10cSrcweir PolyPolygon aEndArrow;
1249cdf0e10cSrcweir // double fTransparency( aStroke.getTransparency() );
1250cdf0e10cSrcweir double fStrokeWidth( aStroke.getStrokeWidth() );
1251cdf0e10cSrcweir SvtGraphicStroke::JoinType eJT( aStroke.getJoinType() );
1252cdf0e10cSrcweir SvtGraphicStroke::DashArray l_aDashArray;
1253cdf0e10cSrcweir
1254cdf0e10cSrcweir aStroke.getStartArrow( aStartArrow );
1255cdf0e10cSrcweir aStroke.getEndArrow( aEndArrow );
1256cdf0e10cSrcweir aStroke.getDashArray( l_aDashArray );
1257cdf0e10cSrcweir
1258cdf0e10cSrcweir bSkipSequence = sal_True;
1259cdf0e10cSrcweir if ( l_aDashArray.size() > 11 ) // ps dasharray limit is 11
1260cdf0e10cSrcweir bSkipSequence = sal_False;
1261cdf0e10cSrcweir if ( aStartArrow.Count() || aEndArrow.Count() )
1262cdf0e10cSrcweir bSkipSequence = sal_False;
1263cdf0e10cSrcweir if ( (sal_uInt32)eJT > 2 )
1264cdf0e10cSrcweir bSkipSequence = sal_False;
1265cdf0e10cSrcweir if ( l_aDashArray.size() && ( fStrokeWidth != 0.0 ) )
1266cdf0e10cSrcweir bSkipSequence = sal_False;
1267cdf0e10cSrcweir if ( bSkipSequence )
1268cdf0e10cSrcweir {
1269cdf0e10cSrcweir ImplWriteLineInfo( fStrokeWidth, aStroke.getMiterLimit(),
1270cdf0e10cSrcweir aStroke.getCapType(), eJT, l_aDashArray );
1271cdf0e10cSrcweir ImplPolyLine( aPath );
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir else if( pA->GetComment().Equals( "XPATHFILL_SEQ_BEGIN" ) )
1275cdf0e10cSrcweir {
1276cdf0e10cSrcweir sSeqEnd = ByteString( "XPATHFILL_SEQ_END" );
1277cdf0e10cSrcweir SvtGraphicFill aFill;
1278cdf0e10cSrcweir aMemStm >> aFill;
1279cdf0e10cSrcweir switch( aFill.getFillType() )
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir case SvtGraphicFill::fillSolid :
1282cdf0e10cSrcweir {
1283cdf0e10cSrcweir bSkipSequence = sal_True;
1284cdf0e10cSrcweir PolyPolygon aPolyPoly;
1285cdf0e10cSrcweir aFill.getPath( aPolyPoly );
1286cdf0e10cSrcweir sal_uInt16 i, nPolyCount = aPolyPoly.Count();
1287cdf0e10cSrcweir if ( nPolyCount )
1288cdf0e10cSrcweir {
1289cdf0e10cSrcweir aFillColor = aFill.getFillColor();
1290cdf0e10cSrcweir ImplWriteFillColor( PS_SPACE );
1291cdf0e10cSrcweir for ( i = 0; i < nPolyCount; )
1292cdf0e10cSrcweir {
1293cdf0e10cSrcweir ImplAddPath( aPolyPoly.GetObject( i ) );
1294cdf0e10cSrcweir if ( ++i < nPolyCount )
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir *mpPS << "p";
1297cdf0e10cSrcweir mnCursorPos += 2;
1298cdf0e10cSrcweir ImplExecMode( PS_RET );
1299cdf0e10cSrcweir }
1300cdf0e10cSrcweir }
1301cdf0e10cSrcweir *mpPS << "p ef";
1302cdf0e10cSrcweir mnCursorPos += 4;
1303cdf0e10cSrcweir ImplExecMode( PS_RET );
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir }
1306cdf0e10cSrcweir break;
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir case SvtGraphicFill::fillTexture :
1309cdf0e10cSrcweir {
1310cdf0e10cSrcweir aFill.getPath( aFillPath );
1311cdf0e10cSrcweir
1312cdf0e10cSrcweir /* normally an object filling is consisting of three MetaActions:
1313cdf0e10cSrcweir MetaBitmapAction using RasterOp xor,
1314cdf0e10cSrcweir MetaPolyPolygonAction using RasterOp rop_0
1315cdf0e10cSrcweir MetaBitmapAction using RasterOp xor
1316cdf0e10cSrcweir
1317cdf0e10cSrcweir Because RasterOps cannot been used in Postscript, we have to
1318cdf0e10cSrcweir replace these actions. The MetaComment "XPATHFILL_SEQ_BEGIN" is
1319cdf0e10cSrcweir providing the clippath of the object. The following loop is
1320cdf0e10cSrcweir trying to find the bitmap that is matching the clippath, so that
1321cdf0e10cSrcweir only one bitmap is exported, otherwise if the bitmap is not
1322cdf0e10cSrcweir locatable, all metaactions are played normally.
1323cdf0e10cSrcweir */
1324cdf0e10cSrcweir sal_uInt32 nCommentStartAction = nCurAction;
1325cdf0e10cSrcweir sal_uInt32 nBitmapCount = 0;
1326cdf0e10cSrcweir sal_uInt32 nBitmapAction = 0;
1327cdf0e10cSrcweir
1328cdf0e10cSrcweir sal_Bool bOk = sal_True;
1329cdf0e10cSrcweir while( bOk && ( ++nCurAction < nCount ) )
1330cdf0e10cSrcweir {
1331cdf0e10cSrcweir MetaAction* pAction = rMtf.GetAction( nCurAction );
1332cdf0e10cSrcweir switch( pAction->GetType() )
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir case META_BMPSCALE_ACTION :
1335cdf0e10cSrcweir case META_BMPSCALEPART_ACTION :
1336cdf0e10cSrcweir case META_BMPEXSCALE_ACTION :
1337cdf0e10cSrcweir case META_BMPEXSCALEPART_ACTION :
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir nBitmapCount++;
1340cdf0e10cSrcweir nBitmapAction = nCurAction;
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir break;
1343cdf0e10cSrcweir case META_COMMENT_ACTION :
1344cdf0e10cSrcweir {
1345cdf0e10cSrcweir if (((const MetaCommentAction*)pAction)->GetComment().Equals( "XPATHFILL_SEQ_END" ))
1346cdf0e10cSrcweir bOk = sal_False;
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir break;
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir if( nBitmapCount == 2 )
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir ImplWriteLine( "gs" );
1354cdf0e10cSrcweir ImplIntersect( aFillPath );
1355cdf0e10cSrcweir GDIMetaFile aTempMtf;
1356cdf0e10cSrcweir aTempMtf.AddAction( rMtf.GetAction( nBitmapAction )->Clone() );
1357cdf0e10cSrcweir ImplWriteActions( aTempMtf, rVDev );
1358cdf0e10cSrcweir ImplWriteLine( "gr" );
1359cdf0e10cSrcweir aFillPath = PolyPolygon();
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir else
1362cdf0e10cSrcweir nCurAction = nCommentStartAction + 1;
1363cdf0e10cSrcweir }
1364cdf0e10cSrcweir break;
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir case SvtGraphicFill::fillGradient :
1367cdf0e10cSrcweir aFill.getPath( aFillPath );
1368cdf0e10cSrcweir break;
1369cdf0e10cSrcweir
1370cdf0e10cSrcweir case SvtGraphicFill::fillHatch :
1371cdf0e10cSrcweir break;
1372cdf0e10cSrcweir }
1373cdf0e10cSrcweir if ( aFillPath.Count() )
1374cdf0e10cSrcweir {
1375cdf0e10cSrcweir ImplWriteLine( "gs" );
1376cdf0e10cSrcweir ImplIntersect( aFillPath );
1377cdf0e10cSrcweir }
1378cdf0e10cSrcweir }
1379cdf0e10cSrcweir if ( bSkipSequence )
1380cdf0e10cSrcweir {
1381cdf0e10cSrcweir while( ++nCurAction < nCount )
1382cdf0e10cSrcweir {
1383cdf0e10cSrcweir pMA = rMtf.GetAction( nCurAction );
1384cdf0e10cSrcweir if ( pMA->GetType() == META_COMMENT_ACTION )
1385cdf0e10cSrcweir {
1386cdf0e10cSrcweir ByteString sComment( ((MetaCommentAction*)pMA)->GetComment() );
1387cdf0e10cSrcweir if ( sComment.Equals( sSeqEnd ) )
1388cdf0e10cSrcweir break;
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir }
1391cdf0e10cSrcweir }
1392cdf0e10cSrcweir }
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir }
1395cdf0e10cSrcweir break;
1396cdf0e10cSrcweir
1397cdf0e10cSrcweir }
1398cdf0e10cSrcweir }
1399cdf0e10cSrcweir }
1400cdf0e10cSrcweir
1401cdf0e10cSrcweir
1402cdf0e10cSrcweir
1403cdf0e10cSrcweir //---------------------------------------------------------------------------------
1404cdf0e10cSrcweir
ImplWritePoint(const Point & rPoint,sal_uInt32 nMode)1405cdf0e10cSrcweir inline void PSWriter::ImplWritePoint( const Point& rPoint, sal_uInt32 nMode )
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir ImplWriteDouble( rPoint.X() );
1408cdf0e10cSrcweir ImplWriteDouble( rPoint.Y(), nMode );
1409cdf0e10cSrcweir }
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir //---------------------------------------------------------------------------------
1412cdf0e10cSrcweir
ImplMoveTo(const Point & rPoint,sal_uInt32 nMode)1413cdf0e10cSrcweir void PSWriter::ImplMoveTo( const Point& rPoint, sal_uInt32 nMode )
1414cdf0e10cSrcweir {
1415cdf0e10cSrcweir ImplWritePoint( rPoint );
1416cdf0e10cSrcweir ImplWriteByte( 'm' );
1417cdf0e10cSrcweir ImplExecMode( nMode );
1418cdf0e10cSrcweir }
1419cdf0e10cSrcweir
1420cdf0e10cSrcweir //---------------------------------------------------------------------------------
1421cdf0e10cSrcweir
ImplLineTo(const Point & rPoint,sal_uInt32 nMode)1422cdf0e10cSrcweir void PSWriter::ImplLineTo( const Point& rPoint, sal_uInt32 nMode )
1423cdf0e10cSrcweir {
1424cdf0e10cSrcweir ImplWritePoint( rPoint );
1425cdf0e10cSrcweir ImplWriteByte( 'l' );
1426cdf0e10cSrcweir ImplExecMode( nMode );
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir
1429cdf0e10cSrcweir //---------------------------------------------------------------------------------
1430cdf0e10cSrcweir
ImplCurveTo(const Point & rP1,const Point & rP2,const Point & rP3,sal_uInt32 nMode)1431cdf0e10cSrcweir void PSWriter::ImplCurveTo( const Point& rP1, const Point& rP2, const Point& rP3, sal_uInt32 nMode )
1432cdf0e10cSrcweir {
1433cdf0e10cSrcweir ImplWritePoint( rP1 );
1434cdf0e10cSrcweir ImplWritePoint( rP2 );
1435cdf0e10cSrcweir ImplWritePoint( rP3 );
1436cdf0e10cSrcweir *mpPS << "ct ";
1437cdf0e10cSrcweir ImplExecMode( nMode );
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir
1440cdf0e10cSrcweir //---------------------------------------------------------------------------------
1441cdf0e10cSrcweir
ImplTranslate(const double & fX,const double & fY,sal_uInt32 nMode)1442cdf0e10cSrcweir void PSWriter::ImplTranslate( const double& fX, const double& fY, sal_uInt32 nMode )
1443cdf0e10cSrcweir {
1444cdf0e10cSrcweir ImplWriteDouble( fX );
1445cdf0e10cSrcweir ImplWriteDouble( fY );
1446cdf0e10cSrcweir ImplWriteByte( 't' );
1447cdf0e10cSrcweir ImplExecMode( nMode );
1448cdf0e10cSrcweir }
1449cdf0e10cSrcweir
1450cdf0e10cSrcweir //---------------------------------------------------------------------------------
1451cdf0e10cSrcweir
ImplScale(const double & fX,const double & fY,sal_uInt32 nMode)1452cdf0e10cSrcweir void PSWriter::ImplScale( const double& fX, const double& fY, sal_uInt32 nMode )
1453cdf0e10cSrcweir {
1454cdf0e10cSrcweir ImplWriteDouble( fX );
1455cdf0e10cSrcweir ImplWriteDouble( fY );
1456cdf0e10cSrcweir ImplWriteByte( 's' );
1457cdf0e10cSrcweir ImplExecMode( nMode );
1458cdf0e10cSrcweir }
1459cdf0e10cSrcweir
1460cdf0e10cSrcweir //---------------------------------------------------------------------------------
1461cdf0e10cSrcweir
ImplRect(const Rectangle & rRect)1462cdf0e10cSrcweir void PSWriter::ImplRect( const Rectangle & rRect )
1463cdf0e10cSrcweir {
1464cdf0e10cSrcweir if ( bFillColor )
1465cdf0e10cSrcweir ImplRectFill( rRect );
1466cdf0e10cSrcweir if ( bLineColor )
1467cdf0e10cSrcweir {
1468cdf0e10cSrcweir double nWidth = rRect.GetWidth();
1469cdf0e10cSrcweir double nHeight = rRect.GetHeight();
1470cdf0e10cSrcweir
1471cdf0e10cSrcweir ImplWriteLineColor( PS_SPACE );
1472cdf0e10cSrcweir ImplMoveTo( rRect.TopLeft() );
1473cdf0e10cSrcweir ImplWriteDouble( nWidth );
1474cdf0e10cSrcweir *mpPS << "0 rl 0 ";
1475cdf0e10cSrcweir ImplWriteDouble( nHeight );
1476cdf0e10cSrcweir *mpPS << "rl ";
1477cdf0e10cSrcweir ImplWriteDouble( nWidth );
1478cdf0e10cSrcweir *mpPS << "neg 0 rl ";
1479cdf0e10cSrcweir ImplClosePathDraw();
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir *mpPS << (sal_uInt8)10;
1482cdf0e10cSrcweir mnCursorPos = 0;
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir
1485cdf0e10cSrcweir //---------------------------------------------------------------------------------
1486cdf0e10cSrcweir
ImplRectFill(const Rectangle & rRect)1487cdf0e10cSrcweir void PSWriter::ImplRectFill( const Rectangle & rRect )
1488cdf0e10cSrcweir {
1489cdf0e10cSrcweir double nWidth = rRect.GetWidth();
1490cdf0e10cSrcweir double nHeight = rRect.GetHeight();
1491cdf0e10cSrcweir
1492cdf0e10cSrcweir ImplWriteFillColor( PS_SPACE );
1493cdf0e10cSrcweir ImplMoveTo( rRect.TopLeft() );
1494cdf0e10cSrcweir ImplWriteDouble( nWidth );
1495cdf0e10cSrcweir *mpPS << "0 rl 0 ";
1496cdf0e10cSrcweir ImplWriteDouble( nHeight );
1497cdf0e10cSrcweir *mpPS << "rl ";
1498cdf0e10cSrcweir ImplWriteDouble( nWidth );
1499cdf0e10cSrcweir *mpPS << "neg 0 rl ef ";
1500cdf0e10cSrcweir *mpPS << "p ef";
1501cdf0e10cSrcweir mnCursorPos += 2;
1502cdf0e10cSrcweir ImplExecMode( PS_RET );
1503cdf0e10cSrcweir }
1504cdf0e10cSrcweir
1505cdf0e10cSrcweir //---------------------------------------------------------------------------------
1506cdf0e10cSrcweir
ImplAddPath(const Polygon & rPolygon)1507cdf0e10cSrcweir void PSWriter::ImplAddPath( const Polygon & rPolygon )
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir sal_uInt16 i = 1;
1510cdf0e10cSrcweir sal_uInt16 nPointCount = rPolygon.GetSize();
1511cdf0e10cSrcweir if ( nPointCount > 1 )
1512cdf0e10cSrcweir {
1513cdf0e10cSrcweir ImplMoveTo( rPolygon.GetPoint( 0 ) );
1514cdf0e10cSrcweir while ( i < nPointCount )
1515cdf0e10cSrcweir {
1516cdf0e10cSrcweir if ( ( rPolygon.GetFlags( i ) == POLY_CONTROL )
1517cdf0e10cSrcweir && ( ( i + 2 ) < nPointCount )
1518cdf0e10cSrcweir && ( rPolygon.GetFlags( i + 1 ) == POLY_CONTROL )
1519cdf0e10cSrcweir && ( rPolygon.GetFlags( i + 2 ) != POLY_CONTROL ) )
1520cdf0e10cSrcweir {
1521cdf0e10cSrcweir ImplCurveTo( rPolygon[ i ], rPolygon[ i + 1 ], rPolygon[ i + 2 ], PS_WRAP );
1522cdf0e10cSrcweir i += 3;
1523cdf0e10cSrcweir }
1524cdf0e10cSrcweir else
1525cdf0e10cSrcweir ImplLineTo( rPolygon.GetPoint( i++ ), PS_SPACE | PS_WRAP );
1526cdf0e10cSrcweir }
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir
1530cdf0e10cSrcweir //---------------------------------------------------------------------------------
1531cdf0e10cSrcweir
ImplIntersect(const PolyPolygon & rPolyPoly)1532cdf0e10cSrcweir void PSWriter::ImplIntersect( const PolyPolygon& rPolyPoly )
1533cdf0e10cSrcweir {
1534cdf0e10cSrcweir sal_uInt16 i, nPolyCount = rPolyPoly.Count();
1535cdf0e10cSrcweir for ( i = 0; i < nPolyCount; )
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir ImplAddPath( rPolyPoly.GetObject( i ) );
1538cdf0e10cSrcweir if ( ++i < nPolyCount )
1539cdf0e10cSrcweir {
1540cdf0e10cSrcweir *mpPS << "p";
1541cdf0e10cSrcweir mnCursorPos += 2;
1542cdf0e10cSrcweir ImplExecMode( PS_RET );
1543cdf0e10cSrcweir }
1544cdf0e10cSrcweir }
1545cdf0e10cSrcweir ImplWriteLine( "eoclip newpath" );
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir
1548cdf0e10cSrcweir //---------------------------------------------------------------------------------
1549cdf0e10cSrcweir
ImplWriteGradient(const PolyPolygon & rPolyPoly,const Gradient & rGradient,VirtualDevice & rVDev)1550cdf0e10cSrcweir void PSWriter::ImplWriteGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient, VirtualDevice& rVDev )
1551cdf0e10cSrcweir {
1552cdf0e10cSrcweir VirtualDevice l_aVDev;
1553cdf0e10cSrcweir GDIMetaFile aTmpMtf;
1554cdf0e10cSrcweir l_aVDev.SetMapMode( rVDev.GetMapMode() );
1555cdf0e10cSrcweir l_aVDev.AddGradientActions( rPolyPoly.GetBoundRect(), rGradient, aTmpMtf );
1556cdf0e10cSrcweir ImplWriteActions( aTmpMtf, rVDev );
1557cdf0e10cSrcweir }
1558cdf0e10cSrcweir
1559cdf0e10cSrcweir //---------------------------------------------------------------------------------
1560cdf0e10cSrcweir
ImplPolyPoly(const PolyPolygon & rPolyPoly,sal_Bool bTextOutline)1561cdf0e10cSrcweir void PSWriter::ImplPolyPoly( const PolyPolygon & rPolyPoly, sal_Bool bTextOutline )
1562cdf0e10cSrcweir {
1563cdf0e10cSrcweir sal_uInt16 i, nPolyCount = rPolyPoly.Count();
1564cdf0e10cSrcweir if ( nPolyCount )
1565cdf0e10cSrcweir {
1566cdf0e10cSrcweir if ( bFillColor || bTextOutline )
1567cdf0e10cSrcweir {
1568cdf0e10cSrcweir if ( bTextOutline )
1569cdf0e10cSrcweir ImplWriteTextColor( PS_SPACE );
1570cdf0e10cSrcweir else
1571cdf0e10cSrcweir ImplWriteFillColor( PS_SPACE );
1572cdf0e10cSrcweir for ( i = 0; i < nPolyCount; )
1573cdf0e10cSrcweir {
1574cdf0e10cSrcweir ImplAddPath( rPolyPoly.GetObject( i ) );
1575cdf0e10cSrcweir if ( ++i < nPolyCount )
1576cdf0e10cSrcweir {
1577cdf0e10cSrcweir *mpPS << "p";
1578cdf0e10cSrcweir mnCursorPos += 2;
1579cdf0e10cSrcweir ImplExecMode( PS_RET );
1580cdf0e10cSrcweir }
1581cdf0e10cSrcweir }
1582cdf0e10cSrcweir *mpPS << "p ef";
1583cdf0e10cSrcweir mnCursorPos += 4;
1584cdf0e10cSrcweir ImplExecMode( PS_RET );
1585cdf0e10cSrcweir }
1586cdf0e10cSrcweir if ( bLineColor )
1587cdf0e10cSrcweir {
1588cdf0e10cSrcweir ImplWriteLineColor( PS_SPACE );
1589cdf0e10cSrcweir for ( i = 0; i < nPolyCount; i++ )
1590cdf0e10cSrcweir ImplAddPath( rPolyPoly.GetObject( i ) );
1591cdf0e10cSrcweir ImplClosePathDraw( PS_RET );
1592cdf0e10cSrcweir }
1593cdf0e10cSrcweir }
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir
1596cdf0e10cSrcweir //---------------------------------------------------------------------------------
1597cdf0e10cSrcweir
ImplPolyLine(const Polygon & rPoly)1598cdf0e10cSrcweir void PSWriter::ImplPolyLine( const Polygon & rPoly )
1599cdf0e10cSrcweir {
1600cdf0e10cSrcweir if ( bLineColor )
1601cdf0e10cSrcweir {
1602cdf0e10cSrcweir ImplWriteLineColor( PS_SPACE );
1603cdf0e10cSrcweir sal_uInt16 i, nPointCount = rPoly.GetSize();
1604cdf0e10cSrcweir if ( nPointCount )
1605cdf0e10cSrcweir {
1606cdf0e10cSrcweir if ( nPointCount > 1 )
1607cdf0e10cSrcweir {
1608cdf0e10cSrcweir ImplMoveTo( rPoly.GetPoint( 0 ) );
1609cdf0e10cSrcweir i = 1;
1610cdf0e10cSrcweir while ( i < nPointCount )
1611cdf0e10cSrcweir {
1612cdf0e10cSrcweir if ( ( rPoly.GetFlags( i ) == POLY_CONTROL )
1613cdf0e10cSrcweir && ( ( i + 2 ) < nPointCount )
1614cdf0e10cSrcweir && ( rPoly.GetFlags( i + 1 ) == POLY_CONTROL )
1615cdf0e10cSrcweir && ( rPoly.GetFlags( i + 2 ) != POLY_CONTROL ) )
1616cdf0e10cSrcweir {
1617cdf0e10cSrcweir ImplCurveTo( rPoly[ i ], rPoly[ i + 1 ], rPoly[ i + 2 ], PS_WRAP );
1618cdf0e10cSrcweir i += 3;
1619cdf0e10cSrcweir }
1620cdf0e10cSrcweir else
1621cdf0e10cSrcweir ImplLineTo( rPoly.GetPoint( i++ ), PS_SPACE | PS_WRAP );
1622cdf0e10cSrcweir }
1623cdf0e10cSrcweir }
1624cdf0e10cSrcweir
1625cdf0e10cSrcweir // #104645# explicitely close path if polygon is closed
1626cdf0e10cSrcweir if( rPoly[ 0 ] == rPoly[ nPointCount-1 ] )
1627cdf0e10cSrcweir ImplClosePathDraw( PS_RET );
1628cdf0e10cSrcweir else
1629cdf0e10cSrcweir ImplPathDraw();
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir }
1632cdf0e10cSrcweir }
1633cdf0e10cSrcweir
1634cdf0e10cSrcweir //---------------------------------------------------------------------------------
1635cdf0e10cSrcweir
ImplSetClipRegion(Region & rClipRegion)1636cdf0e10cSrcweir void PSWriter::ImplSetClipRegion( Region& rClipRegion )
1637cdf0e10cSrcweir {
1638cdf0e10cSrcweir if ( !rClipRegion.IsEmpty() )
1639cdf0e10cSrcweir {
1640*e6f63103SArmin Le Grand RectangleVector aRectangles;
1641*e6f63103SArmin Le Grand rClipRegion.GetRegionRectangles(aRectangles);
1642*e6f63103SArmin Le Grand
1643*e6f63103SArmin Le Grand for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
1644*e6f63103SArmin Le Grand {
1645*e6f63103SArmin Le Grand double nX1(aRectIter->Left());
1646*e6f63103SArmin Le Grand double nY1(aRectIter->Top());
1647*e6f63103SArmin Le Grand double nX2(aRectIter->Right());
1648*e6f63103SArmin Le Grand double nY2(aRectIter->Bottom());
1649*e6f63103SArmin Le Grand
1650*e6f63103SArmin Le Grand ImplWriteDouble( nX1 );
1651*e6f63103SArmin Le Grand ImplWriteDouble( nY1 );
1652*e6f63103SArmin Le Grand ImplWriteByte( 'm' );
1653*e6f63103SArmin Le Grand ImplWriteDouble( nX2 );
1654*e6f63103SArmin Le Grand ImplWriteDouble( nY1 );
1655*e6f63103SArmin Le Grand ImplWriteByte( 'l' );
1656*e6f63103SArmin Le Grand ImplWriteDouble( nX2 );
1657*e6f63103SArmin Le Grand ImplWriteDouble( nY2 );
1658*e6f63103SArmin Le Grand ImplWriteByte( 'l' );
1659*e6f63103SArmin Le Grand ImplWriteDouble( nX1 );
1660*e6f63103SArmin Le Grand ImplWriteDouble( nY2 );
1661*e6f63103SArmin Le Grand ImplWriteByte( 'l' );
1662*e6f63103SArmin Le Grand ImplWriteDouble( nX1 );
1663*e6f63103SArmin Le Grand ImplWriteDouble( nY1 );
1664*e6f63103SArmin Le Grand ImplWriteByte( 'l', PS_SPACE | PS_WRAP );
1665*e6f63103SArmin Le Grand }
1666*e6f63103SArmin Le Grand
1667*e6f63103SArmin Le Grand //Rectangle aRect;
1668*e6f63103SArmin Le Grand //RegionHandle hRegionHandle = rClipRegion.BeginEnumRects();
1669*e6f63103SArmin Le Grand //
1670*e6f63103SArmin Le Grand //while ( rClipRegion.GetEnumRects( hRegionHandle, aRect ) )
1671*e6f63103SArmin Le Grand //{
1672*e6f63103SArmin Le Grand // double nX1 = aRect.Left();
1673*e6f63103SArmin Le Grand // double nY1 = aRect.Top();
1674*e6f63103SArmin Le Grand // double nX2 = aRect.Right();
1675*e6f63103SArmin Le Grand // double nY2 = aRect.Bottom();
1676*e6f63103SArmin Le Grand // ImplWriteDouble( nX1 );
1677*e6f63103SArmin Le Grand // ImplWriteDouble( nY1 );
1678*e6f63103SArmin Le Grand // ImplWriteByte( 'm' );
1679*e6f63103SArmin Le Grand // ImplWriteDouble( nX2 );
1680*e6f63103SArmin Le Grand // ImplWriteDouble( nY1 );
1681*e6f63103SArmin Le Grand // ImplWriteByte( 'l' );
1682*e6f63103SArmin Le Grand // ImplWriteDouble( nX2 );
1683*e6f63103SArmin Le Grand // ImplWriteDouble( nY2 );
1684*e6f63103SArmin Le Grand // ImplWriteByte( 'l' );
1685*e6f63103SArmin Le Grand // ImplWriteDouble( nX1 );
1686*e6f63103SArmin Le Grand // ImplWriteDouble( nY2 );
1687*e6f63103SArmin Le Grand // ImplWriteByte( 'l' );
1688*e6f63103SArmin Le Grand // ImplWriteDouble( nX1 );
1689*e6f63103SArmin Le Grand // ImplWriteDouble( nY1 );
1690*e6f63103SArmin Le Grand // ImplWriteByte( 'l', PS_SPACE | PS_WRAP );
1691*e6f63103SArmin Le Grand //};
1692*e6f63103SArmin Le Grand //rClipRegion.EndEnumRects( hRegionHandle );
1693cdf0e10cSrcweir ImplWriteLine( "eoclip newpath" );
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir }
1696cdf0e10cSrcweir
1697cdf0e10cSrcweir //---------------------------------------------------------------------------------
1698cdf0e10cSrcweir // possible gfx formats:
1699cdf0e10cSrcweir //
1700cdf0e10cSrcweir // level 1: grayscale 8 bit
1701cdf0e10cSrcweir // color 24 bit
1702cdf0e10cSrcweir //
1703cdf0e10cSrcweir // level 2: grayscale 8 bit
1704cdf0e10cSrcweir // color 1(pal), 4(pal), 8(pal), 24 Bit
1705cdf0e10cSrcweir //
1706cdf0e10cSrcweir
ImplBmp(Bitmap * pBitmap,Bitmap * pMaskBitmap,const Point & rPoint,double nXWidth,double nYHeightOrg)1707cdf0e10cSrcweir void PSWriter::ImplBmp( Bitmap* pBitmap, Bitmap* pMaskBitmap, const Point & rPoint, double nXWidth, double nYHeightOrg )
1708cdf0e10cSrcweir {
1709cdf0e10cSrcweir if ( !pBitmap )
1710cdf0e10cSrcweir return;
1711cdf0e10cSrcweir
1712cdf0e10cSrcweir sal_Int32 nHeightOrg = pBitmap->GetSizePixel().Height();
1713cdf0e10cSrcweir sal_Int32 nHeightLeft = nHeightOrg;
1714cdf0e10cSrcweir long nWidth = pBitmap->GetSizePixel().Width();
1715cdf0e10cSrcweir Point aSourcePos( rPoint );
1716cdf0e10cSrcweir
1717cdf0e10cSrcweir while ( nHeightLeft )
1718cdf0e10cSrcweir {
1719cdf0e10cSrcweir Bitmap aTileBitmap( *pBitmap );
1720cdf0e10cSrcweir long nHeight = nHeightLeft;
1721cdf0e10cSrcweir double nYHeight = nYHeightOrg;
1722cdf0e10cSrcweir
1723cdf0e10cSrcweir sal_Bool bDoTrans = sal_False;
1724cdf0e10cSrcweir
1725cdf0e10cSrcweir Rectangle aRect;
1726cdf0e10cSrcweir Region aRegion;
1727cdf0e10cSrcweir
1728cdf0e10cSrcweir if ( pMaskBitmap )
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir bDoTrans = sal_True;
1731cdf0e10cSrcweir while (sal_True)
1732cdf0e10cSrcweir {
1733cdf0e10cSrcweir if ( mnLevel == 1 )
1734cdf0e10cSrcweir {
1735cdf0e10cSrcweir if ( nHeight > 10 )
1736cdf0e10cSrcweir nHeight = 8;
1737cdf0e10cSrcweir }
1738cdf0e10cSrcweir aRect = Rectangle( Point( 0, nHeightOrg - nHeightLeft ), Size( (long)nWidth, (long)nHeight ) );
1739cdf0e10cSrcweir aRegion = Region( pMaskBitmap->CreateRegion( COL_BLACK, aRect ) );
1740cdf0e10cSrcweir
1741*e6f63103SArmin Le Grand if( mnLevel == 1 )
1742cdf0e10cSrcweir {
1743*e6f63103SArmin Le Grand RectangleVector aRectangleVector;
1744*e6f63103SArmin Le Grand aRegion.GetRegionRectangles(aRectangleVector);
1745*e6f63103SArmin Le Grand
1746*e6f63103SArmin Le Grand if ( aRectangleVector.size() * 5 > 1000 )
1747*e6f63103SArmin Le Grand {
1748*e6f63103SArmin Le Grand nHeight >>= 1;
1749*e6f63103SArmin Le Grand if ( nHeight < 2 )
1750*e6f63103SArmin Le Grand return;
1751*e6f63103SArmin Le Grand continue;
1752*e6f63103SArmin Le Grand }
1753cdf0e10cSrcweir }
1754cdf0e10cSrcweir break;
1755cdf0e10cSrcweir }
1756cdf0e10cSrcweir }
1757cdf0e10cSrcweir if ( nHeight != nHeightOrg )
1758cdf0e10cSrcweir {
1759cdf0e10cSrcweir nYHeight = nYHeightOrg * nHeight / nHeightOrg;
1760cdf0e10cSrcweir aTileBitmap.Crop( Rectangle( Point( 0, nHeightOrg - nHeightLeft ), Size( nWidth, nHeight ) ) );
1761cdf0e10cSrcweir }
1762cdf0e10cSrcweir if ( bDoTrans )
1763cdf0e10cSrcweir {
1764cdf0e10cSrcweir ImplWriteLine( "gs\npum" );
1765cdf0e10cSrcweir ImplTranslate( aSourcePos.X(), aSourcePos.Y() );
1766cdf0e10cSrcweir ImplScale( nXWidth / nWidth, nYHeight / nHeight );
1767cdf0e10cSrcweir
1768*e6f63103SArmin Le Grand RectangleVector aRectangles;
1769*e6f63103SArmin Le Grand aRegion.GetRegionRectangles(aRectangles);
1770*e6f63103SArmin Le Grand const long nMoveVertical(nHeightLeft - nHeightOrg);
1771*e6f63103SArmin Le Grand
1772*e6f63103SArmin Le Grand for(RectangleVector::iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
1773*e6f63103SArmin Le Grand {
1774*e6f63103SArmin Le Grand aRectIter->Move(0, nMoveVertical);
1775*e6f63103SArmin Le Grand
1776*e6f63103SArmin Le Grand ImplWriteLong( aRectIter->Left() );
1777*e6f63103SArmin Le Grand ImplWriteLong( aRectIter->Top() );
1778*e6f63103SArmin Le Grand ImplWriteByte( 'm' );
1779*e6f63103SArmin Le Grand ImplWriteLong( aRectIter->Right() + 1 );
1780*e6f63103SArmin Le Grand ImplWriteLong( aRectIter->Top() );
1781*e6f63103SArmin Le Grand ImplWriteByte( 'l' );
1782*e6f63103SArmin Le Grand ImplWriteLong( aRectIter->Right() + 1 );
1783*e6f63103SArmin Le Grand ImplWriteLong( aRectIter->Bottom() + 1 );
1784*e6f63103SArmin Le Grand ImplWriteByte( 'l' );
1785*e6f63103SArmin Le Grand ImplWriteLong( aRectIter->Left() );
1786*e6f63103SArmin Le Grand ImplWriteLong( aRectIter->Bottom() + 1 );
1787*e6f63103SArmin Le Grand ImplWriteByte( 'l' );
1788*e6f63103SArmin Le Grand ImplWriteByte( 'p', PS_SPACE | PS_WRAP );
1789*e6f63103SArmin Le Grand }
1790*e6f63103SArmin Le Grand
1791*e6f63103SArmin Le Grand //RegionHandle hRegionHandle = aRegion.BeginEnumRects();
1792*e6f63103SArmin Le Grand //
1793*e6f63103SArmin Le Grand //while ( aRegion.GetEnumRects( hRegionHandle, aRect ) )
1794*e6f63103SArmin Le Grand //{
1795*e6f63103SArmin Le Grand // aRect.Move( 0, - ( nHeightOrg - nHeightLeft ) );
1796*e6f63103SArmin Le Grand // ImplWriteLong( aRect.Left() );
1797*e6f63103SArmin Le Grand // ImplWriteLong( aRect.Top() );
1798*e6f63103SArmin Le Grand // ImplWriteByte( 'm' );
1799*e6f63103SArmin Le Grand // ImplWriteLong( aRect.Right() + 1 );
1800*e6f63103SArmin Le Grand // ImplWriteLong( aRect.Top() );
1801*e6f63103SArmin Le Grand // ImplWriteByte( 'l' );
1802*e6f63103SArmin Le Grand // ImplWriteLong( aRect.Right() + 1 );
1803*e6f63103SArmin Le Grand // ImplWriteLong( aRect.Bottom() + 1 );
1804*e6f63103SArmin Le Grand // ImplWriteByte( 'l' );
1805*e6f63103SArmin Le Grand // ImplWriteLong( aRect.Left() );
1806*e6f63103SArmin Le Grand // ImplWriteLong( aRect.Bottom() + 1 );
1807*e6f63103SArmin Le Grand // ImplWriteByte( 'l' );
1808*e6f63103SArmin Le Grand // ImplWriteByte( 'p', PS_SPACE | PS_WRAP );
1809*e6f63103SArmin Le Grand //};
1810*e6f63103SArmin Le Grand //aRegion.EndEnumRects( hRegionHandle );
1811cdf0e10cSrcweir ImplWriteLine( "eoclip newpath" );
1812cdf0e10cSrcweir ImplWriteLine( "pom" );
1813cdf0e10cSrcweir }
1814cdf0e10cSrcweir BitmapReadAccess* pAcc = aTileBitmap.AcquireReadAccess();
1815cdf0e10cSrcweir
1816cdf0e10cSrcweir if (!bDoTrans )
1817cdf0e10cSrcweir ImplWriteLine( "pum" );
1818cdf0e10cSrcweir
1819cdf0e10cSrcweir ImplTranslate( aSourcePos.X(), aSourcePos.Y() + nYHeight );
1820cdf0e10cSrcweir ImplScale( nXWidth, nYHeight );
1821cdf0e10cSrcweir if ( mnLevel == 1 ) // level 1 is always grayscale !!!
1822cdf0e10cSrcweir {
1823cdf0e10cSrcweir ImplWriteLong( nWidth );
1824cdf0e10cSrcweir ImplWriteLong( nHeight );
1825cdf0e10cSrcweir *mpPS << "8 [";
1826cdf0e10cSrcweir ImplWriteLong( nWidth );
1827cdf0e10cSrcweir *mpPS << "0 0 ";
1828cdf0e10cSrcweir ImplWriteLong( -nHeight );
1829cdf0e10cSrcweir ImplWriteLong( 0 );
1830cdf0e10cSrcweir ImplWriteLong( nHeight );
1831cdf0e10cSrcweir ImplWriteLine( "]" );
1832cdf0e10cSrcweir *mpPS << "{currentfile ";
1833cdf0e10cSrcweir ImplWriteLong( nWidth );
1834cdf0e10cSrcweir ImplWriteLine( "string readhexstring pop}" );
1835cdf0e10cSrcweir ImplWriteLine( "image" );
1836cdf0e10cSrcweir for ( long y = 0; y < nHeight; y++ )
1837cdf0e10cSrcweir {
1838cdf0e10cSrcweir for ( long x = 0; x < nWidth; x++ )
1839cdf0e10cSrcweir {
184087bc88d3SHerbert Dürr ImplWriteHexByte( pAcc->GetPixelIndex( y, x ) );
1841cdf0e10cSrcweir }
1842cdf0e10cSrcweir }
1843cdf0e10cSrcweir *mpPS << (sal_uInt8)10;
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir else // Level 2
1846cdf0e10cSrcweir {
1847cdf0e10cSrcweir if ( mbGrayScale )
1848cdf0e10cSrcweir {
1849cdf0e10cSrcweir ImplWriteLine( "/DeviceGray setcolorspace" );
1850cdf0e10cSrcweir ImplWriteLine( "<<" );
1851cdf0e10cSrcweir ImplWriteLine( "/ImageType 1" );
1852cdf0e10cSrcweir *mpPS << "/Width ";
1853cdf0e10cSrcweir ImplWriteLong( nWidth, PS_RET );
1854cdf0e10cSrcweir *mpPS << "/Height ";
1855cdf0e10cSrcweir ImplWriteLong( nHeight, PS_RET );
1856cdf0e10cSrcweir ImplWriteLine( "/BitsPerComponent 8" );
1857cdf0e10cSrcweir ImplWriteLine( "/Decode[0 1]" );
1858cdf0e10cSrcweir *mpPS << "/ImageMatrix[";
1859cdf0e10cSrcweir ImplWriteLong( nWidth );
1860cdf0e10cSrcweir *mpPS << "0 0 ";
1861cdf0e10cSrcweir ImplWriteLong( -nHeight );
1862cdf0e10cSrcweir ImplWriteLong( 0 );
1863cdf0e10cSrcweir ImplWriteLong( nHeight, PS_NONE );
1864cdf0e10cSrcweir ImplWriteByte( ']', PS_RET );
1865cdf0e10cSrcweir ImplWriteLine( "/DataSource currentfile" );
1866cdf0e10cSrcweir ImplWriteLine( "/ASCIIHexDecode filter" );
1867cdf0e10cSrcweir if ( mbCompression )
1868cdf0e10cSrcweir ImplWriteLine( "/LZWDecode filter" );
1869cdf0e10cSrcweir ImplWriteLine( ">>" );
1870cdf0e10cSrcweir ImplWriteLine( "image" );
1871cdf0e10cSrcweir if ( mbCompression )
1872cdf0e10cSrcweir {
1873cdf0e10cSrcweir StartCompression();
1874cdf0e10cSrcweir for ( long y = 0; y < nHeight; y++ )
1875cdf0e10cSrcweir {
1876cdf0e10cSrcweir for ( long x = 0; x < nWidth; x++ )
1877cdf0e10cSrcweir {
187887bc88d3SHerbert Dürr Compress( pAcc->GetPixelIndex( y, x ) );
1879cdf0e10cSrcweir }
1880cdf0e10cSrcweir }
1881cdf0e10cSrcweir EndCompression();
1882cdf0e10cSrcweir }
1883cdf0e10cSrcweir else
1884cdf0e10cSrcweir {
1885cdf0e10cSrcweir for ( long y = 0; y < nHeight; y++ )
1886cdf0e10cSrcweir {
1887cdf0e10cSrcweir for ( long x = 0; x < nWidth; x++ )
1888cdf0e10cSrcweir {
188987bc88d3SHerbert Dürr ImplWriteHexByte( pAcc->GetPixelIndex( y, x ) );
1890cdf0e10cSrcweir }
1891cdf0e10cSrcweir }
1892cdf0e10cSrcweir }
1893cdf0e10cSrcweir }
1894cdf0e10cSrcweir else
1895cdf0e10cSrcweir {
1896cdf0e10cSrcweir // have we to write a palette ?
1897cdf0e10cSrcweir
1898cdf0e10cSrcweir if ( pAcc->HasPalette() )
1899cdf0e10cSrcweir {
1900cdf0e10cSrcweir ImplWriteLine( "[/Indexed /DeviceRGB " );
1901cdf0e10cSrcweir ImplWriteLong( pAcc->GetPaletteEntryCount() - 1, PS_RET );
1902cdf0e10cSrcweir ImplWriteByte( '<', PS_NONE );
1903cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < pAcc->GetPaletteEntryCount(); i++ )
1904cdf0e10cSrcweir {
1905cdf0e10cSrcweir BitmapColor aBitmapColor = pAcc->GetPaletteColor( i );
1906cdf0e10cSrcweir ImplWriteHexByte( aBitmapColor.GetRed(), PS_NONE );
1907cdf0e10cSrcweir ImplWriteHexByte( aBitmapColor.GetGreen(), PS_NONE );
1908cdf0e10cSrcweir ImplWriteHexByte( aBitmapColor.GetBlue(), PS_SPACE | PS_WRAP );
1909cdf0e10cSrcweir }
1910cdf0e10cSrcweir ImplWriteByte( '>', PS_RET );
1911cdf0e10cSrcweir
1912cdf0e10cSrcweir ImplWriteLine( "] setcolorspace" );
1913cdf0e10cSrcweir ImplWriteLine( "<<" );
1914cdf0e10cSrcweir ImplWriteLine( "/ImageType 1" );
1915cdf0e10cSrcweir *mpPS << "/Width ";
1916cdf0e10cSrcweir ImplWriteLong( nWidth, PS_RET );
1917cdf0e10cSrcweir *mpPS << "/Height ";
1918cdf0e10cSrcweir ImplWriteLong( nHeight, PS_RET );
1919cdf0e10cSrcweir ImplWriteLine( "/BitsPerComponent 8" );
1920cdf0e10cSrcweir ImplWriteLine( "/Decode[0 255]" );
1921cdf0e10cSrcweir *mpPS << "/ImageMatrix[";
1922cdf0e10cSrcweir ImplWriteLong( nWidth );
1923cdf0e10cSrcweir *mpPS << "0 0 ";
1924cdf0e10cSrcweir ImplWriteLong( -nHeight );
1925cdf0e10cSrcweir ImplWriteLong( 0);
1926cdf0e10cSrcweir ImplWriteLong( nHeight, PS_NONE );
1927cdf0e10cSrcweir ImplWriteByte( ']', PS_RET );
1928cdf0e10cSrcweir ImplWriteLine( "/DataSource currentfile" );
1929cdf0e10cSrcweir ImplWriteLine( "/ASCIIHexDecode filter" );
1930cdf0e10cSrcweir if ( mbCompression )
1931cdf0e10cSrcweir ImplWriteLine( "/LZWDecode filter" );
1932cdf0e10cSrcweir ImplWriteLine( ">>" );
1933cdf0e10cSrcweir ImplWriteLine( "image" );
1934cdf0e10cSrcweir if ( mbCompression )
1935cdf0e10cSrcweir {
1936cdf0e10cSrcweir StartCompression();
1937cdf0e10cSrcweir for ( long y = 0; y < nHeight; y++ )
1938cdf0e10cSrcweir {
1939cdf0e10cSrcweir for ( long x = 0; x < nWidth; x++ )
1940cdf0e10cSrcweir {
194187bc88d3SHerbert Dürr Compress( pAcc->GetPixelIndex( y, x ) );
1942cdf0e10cSrcweir }
1943cdf0e10cSrcweir }
1944cdf0e10cSrcweir EndCompression();
1945cdf0e10cSrcweir }
1946cdf0e10cSrcweir else
1947cdf0e10cSrcweir {
1948cdf0e10cSrcweir for ( long y = 0; y < nHeight; y++ )
1949cdf0e10cSrcweir {
1950cdf0e10cSrcweir for ( long x = 0; x < nWidth; x++ )
1951cdf0e10cSrcweir {
195287bc88d3SHerbert Dürr ImplWriteHexByte( pAcc->GetPixelIndex( y, x ) );
1953cdf0e10cSrcweir }
1954cdf0e10cSrcweir }
1955cdf0e10cSrcweir }
1956cdf0e10cSrcweir }
1957cdf0e10cSrcweir else // 24 bit color
1958cdf0e10cSrcweir {
1959cdf0e10cSrcweir ImplWriteLine( "/DeviceRGB setcolorspace" );
1960cdf0e10cSrcweir ImplWriteLine( "<<" );
1961cdf0e10cSrcweir ImplWriteLine( "/ImageType 1" );
1962cdf0e10cSrcweir *mpPS << "/Width ";
1963cdf0e10cSrcweir ImplWriteLong( nWidth, PS_RET );
1964cdf0e10cSrcweir *mpPS << "/Height ";
1965cdf0e10cSrcweir ImplWriteLong( nHeight, PS_RET );
1966cdf0e10cSrcweir ImplWriteLine( "/BitsPerComponent 8" );
1967cdf0e10cSrcweir ImplWriteLine( "/Decode[0 1 0 1 0 1]" );
1968cdf0e10cSrcweir *mpPS << "/ImageMatrix[";
1969cdf0e10cSrcweir ImplWriteLong( nWidth );
1970cdf0e10cSrcweir *mpPS << "0 0 ";
1971cdf0e10cSrcweir ImplWriteLong( -nHeight );
1972cdf0e10cSrcweir ImplWriteLong( 0 );
1973cdf0e10cSrcweir ImplWriteLong( nHeight, PS_NONE );
1974cdf0e10cSrcweir ImplWriteByte( ']', PS_RET );
1975cdf0e10cSrcweir ImplWriteLine( "/DataSource currentfile" );
1976cdf0e10cSrcweir ImplWriteLine( "/ASCIIHexDecode filter" );
1977cdf0e10cSrcweir if ( mbCompression )
1978cdf0e10cSrcweir ImplWriteLine( "/LZWDecode filter" );
1979cdf0e10cSrcweir ImplWriteLine( ">>" );
1980cdf0e10cSrcweir ImplWriteLine( "image" );
1981cdf0e10cSrcweir if ( mbCompression )
1982cdf0e10cSrcweir {
1983cdf0e10cSrcweir StartCompression();
1984cdf0e10cSrcweir for ( long y = 0; y < nHeight; y++ )
1985cdf0e10cSrcweir {
1986cdf0e10cSrcweir for ( long x = 0; x < nWidth; x++ )
1987cdf0e10cSrcweir {
1988cdf0e10cSrcweir const BitmapColor aBitmapColor( pAcc->GetPixel( y, x ) );
1989cdf0e10cSrcweir Compress( aBitmapColor.GetRed() );
1990cdf0e10cSrcweir Compress( aBitmapColor.GetGreen() );
1991cdf0e10cSrcweir Compress( aBitmapColor.GetBlue() );
1992cdf0e10cSrcweir }
1993cdf0e10cSrcweir }
1994cdf0e10cSrcweir EndCompression();
1995cdf0e10cSrcweir }
1996cdf0e10cSrcweir else
1997cdf0e10cSrcweir {
1998cdf0e10cSrcweir for ( long y = 0; y < nHeight; y++ )
1999cdf0e10cSrcweir {
2000cdf0e10cSrcweir for ( long x = 0; x < nWidth; x++ )
2001cdf0e10cSrcweir {
2002cdf0e10cSrcweir const BitmapColor aBitmapColor( pAcc->GetPixel( y, x ) );
2003cdf0e10cSrcweir ImplWriteHexByte( aBitmapColor.GetRed() );
2004cdf0e10cSrcweir ImplWriteHexByte( aBitmapColor.GetGreen() );
2005cdf0e10cSrcweir ImplWriteHexByte( aBitmapColor.GetBlue() );
2006cdf0e10cSrcweir }
2007cdf0e10cSrcweir }
2008cdf0e10cSrcweir }
2009cdf0e10cSrcweir }
2010cdf0e10cSrcweir }
2011cdf0e10cSrcweir ImplWriteLine( ">" ); // in Level 2 the dictionary needs to be closed (eod)
2012cdf0e10cSrcweir }
2013cdf0e10cSrcweir if ( bDoTrans )
2014cdf0e10cSrcweir ImplWriteLine( "gr" );
2015cdf0e10cSrcweir else
2016cdf0e10cSrcweir ImplWriteLine( "pom" );
2017cdf0e10cSrcweir
2018cdf0e10cSrcweir aTileBitmap.ReleaseAccess( pAcc );
2019cdf0e10cSrcweir nHeightLeft -= nHeight;
2020cdf0e10cSrcweir if ( nHeightLeft )
2021cdf0e10cSrcweir {
2022cdf0e10cSrcweir nHeightLeft++;
2023cdf0e10cSrcweir aSourcePos.Y() = (long) ( rPoint.Y() + ( nYHeightOrg * ( nHeightOrg - nHeightLeft ) ) / nHeightOrg );
2024cdf0e10cSrcweir }
2025cdf0e10cSrcweir }
2026cdf0e10cSrcweir }
2027cdf0e10cSrcweir
2028cdf0e10cSrcweir //---------------------------------------------------------------------------------
2029cdf0e10cSrcweir
ImplWriteCharacter(sal_Char nChar)2030cdf0e10cSrcweir void PSWriter::ImplWriteCharacter( sal_Char nChar )
2031cdf0e10cSrcweir {
2032cdf0e10cSrcweir switch( nChar )
2033cdf0e10cSrcweir {
2034cdf0e10cSrcweir case '(' :
2035cdf0e10cSrcweir case ')' :
2036cdf0e10cSrcweir case '\\' :
2037cdf0e10cSrcweir ImplWriteByte( (sal_uInt8)'\\', PS_NONE );
2038cdf0e10cSrcweir }
2039cdf0e10cSrcweir ImplWriteByte( (sal_uInt8)nChar, PS_NONE );
2040cdf0e10cSrcweir }
2041cdf0e10cSrcweir
2042cdf0e10cSrcweir //---------------------------------------------------------------------------------
2043cdf0e10cSrcweir
ImplWriteString(const ByteString & rString,VirtualDevice & rVDev,const sal_Int32 * pDXArry,sal_Bool bStretch)2044cdf0e10cSrcweir void PSWriter::ImplWriteString( const ByteString& rString, VirtualDevice& rVDev, const sal_Int32* pDXArry, sal_Bool bStretch )
2045cdf0e10cSrcweir {
2046cdf0e10cSrcweir sal_uInt16 nLen = rString.Len();
2047cdf0e10cSrcweir if ( nLen )
2048cdf0e10cSrcweir {
2049cdf0e10cSrcweir sal_uInt16 i;
2050cdf0e10cSrcweir if ( pDXArry )
2051cdf0e10cSrcweir {
2052cdf0e10cSrcweir double nx = 0;
2053cdf0e10cSrcweir
2054cdf0e10cSrcweir for( i = 0; i < nLen; i++ )
2055cdf0e10cSrcweir {
2056cdf0e10cSrcweir if ( i > 0 )
2057cdf0e10cSrcweir nx = pDXArry[ i - 1 ];
2058cdf0e10cSrcweir ImplWriteDouble( ( bStretch ) ? nx : rVDev.GetTextWidth( rString.GetChar( i ) ) );
2059cdf0e10cSrcweir ImplWriteDouble( nx );
2060cdf0e10cSrcweir ImplWriteLine( "(", PS_NONE );
2061cdf0e10cSrcweir ImplWriteCharacter( rString.GetChar( i ) );
2062cdf0e10cSrcweir ImplWriteLine( ") bs" );
2063cdf0e10cSrcweir }
2064cdf0e10cSrcweir }
2065cdf0e10cSrcweir else
2066cdf0e10cSrcweir {
2067cdf0e10cSrcweir ImplWriteByte( '(', PS_NONE );
2068cdf0e10cSrcweir for ( i = 0; i < nLen; i++ )
2069cdf0e10cSrcweir ImplWriteCharacter( rString.GetChar( i ) );
2070cdf0e10cSrcweir ImplWriteLine( ") sw" );
2071cdf0e10cSrcweir }
2072cdf0e10cSrcweir }
2073cdf0e10cSrcweir }
2074cdf0e10cSrcweir
2075cdf0e10cSrcweir // ------------------------------------------------------------------------
2076cdf0e10cSrcweir
ImplText(const String & rUniString,const Point & rPos,const sal_Int32 * pDXArry,sal_Int32 nWidth,VirtualDevice & rVDev)2077cdf0e10cSrcweir void PSWriter::ImplText( const String& rUniString, const Point& rPos, const sal_Int32* pDXArry, sal_Int32 nWidth, VirtualDevice& rVDev )
2078cdf0e10cSrcweir {
2079cdf0e10cSrcweir sal_uInt16 nLen = rUniString.Len();
2080cdf0e10cSrcweir if ( !nLen )
2081cdf0e10cSrcweir return;
2082cdf0e10cSrcweir if ( mnTextMode == 0 ) // using glpyh outlines
2083cdf0e10cSrcweir {
2084cdf0e10cSrcweir Font aNotRotatedFont( maFont );
2085cdf0e10cSrcweir aNotRotatedFont.SetOrientation( 0 );
2086cdf0e10cSrcweir
2087cdf0e10cSrcweir VirtualDevice aVirDev( 1 );
2088cdf0e10cSrcweir aVirDev.SetMapMode( rVDev.GetMapMode() );
2089cdf0e10cSrcweir aVirDev.SetFont( aNotRotatedFont );
2090cdf0e10cSrcweir aVirDev.SetTextAlign( eTextAlign );
2091cdf0e10cSrcweir
2092cdf0e10cSrcweir sal_Int16 nRotation = maFont.GetOrientation();
2093cdf0e10cSrcweir Polygon aPolyDummy( 1 );
2094cdf0e10cSrcweir
2095cdf0e10cSrcweir PolyPolygon aPolyPoly;
2096cdf0e10cSrcweir Point aPos( rPos );
2097cdf0e10cSrcweir if ( nRotation )
2098cdf0e10cSrcweir {
2099cdf0e10cSrcweir aPolyDummy.SetPoint( aPos, 0 );
2100cdf0e10cSrcweir aPolyDummy.Rotate( rPos, nRotation );
2101cdf0e10cSrcweir aPos = aPolyDummy.GetPoint( 0 );
2102cdf0e10cSrcweir }
2103cdf0e10cSrcweir sal_Bool bOldLineColor = bLineColor;
2104cdf0e10cSrcweir bLineColor = sal_False;
2105cdf0e10cSrcweir std::vector<PolyPolygon> aPolyPolyVec;
2106cdf0e10cSrcweir if ( aVirDev.GetTextOutlines( aPolyPolyVec, rUniString, 0, 0, STRING_LEN, sal_True, nWidth, pDXArry ) )
2107cdf0e10cSrcweir {
2108cdf0e10cSrcweir // always adjust text position to match baseline alignment
2109cdf0e10cSrcweir ImplWriteLine( "pum" );
2110cdf0e10cSrcweir ImplWriteDouble( aPos.X() );
2111cdf0e10cSrcweir ImplWriteDouble( aPos.Y() );
2112cdf0e10cSrcweir ImplWriteLine( "t" );
2113cdf0e10cSrcweir if ( nRotation )
2114cdf0e10cSrcweir {
2115cdf0e10cSrcweir ImplWriteF( nRotation, 1 );
2116cdf0e10cSrcweir *mpPS << "r ";
2117cdf0e10cSrcweir }
2118cdf0e10cSrcweir std::vector<PolyPolygon>::iterator aIter( aPolyPolyVec.begin() );
2119cdf0e10cSrcweir while ( aIter != aPolyPolyVec.end() )
2120cdf0e10cSrcweir ImplPolyPoly( *aIter++, sal_True );
2121cdf0e10cSrcweir ImplWriteLine( "pom" );
2122cdf0e10cSrcweir }
2123cdf0e10cSrcweir bLineColor = bOldLineColor;
2124cdf0e10cSrcweir }
2125cdf0e10cSrcweir else if ( ( mnTextMode == 1 ) || ( mnTextMode == 2 ) ) // normal text output
2126cdf0e10cSrcweir {
2127cdf0e10cSrcweir if ( mnTextMode == 2 ) // forcing output one complete text packet, by
2128cdf0e10cSrcweir pDXArry = NULL; // ignoring the kerning array
2129cdf0e10cSrcweir ImplSetAttrForText( rPos );
2130cdf0e10cSrcweir ByteString aStr( rUniString, maFont.GetCharSet() );
2131cdf0e10cSrcweir ImplWriteString( aStr, rVDev, pDXArry, nWidth != 0 );
2132cdf0e10cSrcweir if ( maFont.GetOrientation() )
2133cdf0e10cSrcweir ImplWriteLine( "gr" );
2134cdf0e10cSrcweir }
2135cdf0e10cSrcweir }
2136cdf0e10cSrcweir
2137cdf0e10cSrcweir // ------------------------------------------------------------------------
2138cdf0e10cSrcweir
ImplSetAttrForText(const Point & rPoint)2139cdf0e10cSrcweir void PSWriter::ImplSetAttrForText( const Point& rPoint )
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir Point aPoint( rPoint );
2142cdf0e10cSrcweir
2143cdf0e10cSrcweir long nRotation = maFont.GetOrientation();
2144cdf0e10cSrcweir ImplWriteTextColor();
2145cdf0e10cSrcweir
2146cdf0e10cSrcweir Size aSize = maFont.GetSize();
2147cdf0e10cSrcweir
2148cdf0e10cSrcweir if ( maLastFont != maFont )
2149cdf0e10cSrcweir {
2150cdf0e10cSrcweir if ( maFont.GetPitch() == PITCH_FIXED ) // a little bit font selection
2151cdf0e10cSrcweir ImplDefineFont( "Courier", "Oblique" );
2152cdf0e10cSrcweir else if ( maFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
2153cdf0e10cSrcweir ImplWriteLine( "/Symbol findfont" );
2154cdf0e10cSrcweir else if ( maFont.GetFamily() == FAMILY_SWISS )
2155cdf0e10cSrcweir ImplDefineFont( "Helvetica", "Oblique" );
2156cdf0e10cSrcweir else
2157cdf0e10cSrcweir ImplDefineFont( "Times", "Italic" );
2158cdf0e10cSrcweir
2159cdf0e10cSrcweir maLastFont = maFont;
2160cdf0e10cSrcweir aSize = maFont.GetSize();
2161cdf0e10cSrcweir ImplWriteDouble( aSize.Height() );
2162cdf0e10cSrcweir *mpPS << "sf ";
2163cdf0e10cSrcweir }
2164cdf0e10cSrcweir if ( eTextAlign != ALIGN_BASELINE )
2165cdf0e10cSrcweir { // PostScript kennt kein FontAlignment
2166cdf0e10cSrcweir if ( eTextAlign == ALIGN_TOP ) // -> ich gehe daher davon aus, dass
2167cdf0e10cSrcweir aPoint.Y() += ( aSize.Height() * 4 / 5 ); // der Bereich unter der Baseline
2168cdf0e10cSrcweir else if ( eTextAlign == ALIGN_BOTTOM ) // in etwa 20% der Fontsize ausmacht
2169cdf0e10cSrcweir aPoint.Y() -= ( aSize.Height() / 5 );
2170cdf0e10cSrcweir }
2171cdf0e10cSrcweir ImplMoveTo( aPoint );
2172cdf0e10cSrcweir if ( nRotation )
2173cdf0e10cSrcweir {
2174cdf0e10cSrcweir *mpPS << "gs ";
2175cdf0e10cSrcweir ImplWriteF( nRotation, 1 );
2176cdf0e10cSrcweir *mpPS << "r ";
2177cdf0e10cSrcweir }
2178cdf0e10cSrcweir }
2179cdf0e10cSrcweir
2180cdf0e10cSrcweir //---------------------------------------------------------------------------------
2181cdf0e10cSrcweir
ImplDefineFont(const char * pOriginalName,const char * pItalic)2182cdf0e10cSrcweir void PSWriter::ImplDefineFont( const char* pOriginalName, const char* pItalic )
2183cdf0e10cSrcweir {
2184cdf0e10cSrcweir *mpPS << (sal_uInt8)'/'; //convert the font pOriginalName using ISOLatin1Encoding
2185cdf0e10cSrcweir *mpPS << pOriginalName;
2186cdf0e10cSrcweir switch ( maFont.GetWeight() )
2187cdf0e10cSrcweir {
2188cdf0e10cSrcweir case WEIGHT_SEMIBOLD :
2189cdf0e10cSrcweir case WEIGHT_BOLD :
2190cdf0e10cSrcweir case WEIGHT_ULTRABOLD :
2191cdf0e10cSrcweir case WEIGHT_BLACK :
2192cdf0e10cSrcweir *mpPS << "-Bold";
2193cdf0e10cSrcweir if ( maFont.GetItalic() != ITALIC_NONE )
2194cdf0e10cSrcweir *mpPS << pItalic;
2195cdf0e10cSrcweir break;
2196cdf0e10cSrcweir default:
2197cdf0e10cSrcweir if ( maFont.GetItalic() != ITALIC_NONE )
2198cdf0e10cSrcweir *mpPS << pItalic;
2199cdf0e10cSrcweir break;
2200cdf0e10cSrcweir }
2201cdf0e10cSrcweir ImplWriteLine( " f" );
2202cdf0e10cSrcweir }
2203cdf0e10cSrcweir
2204cdf0e10cSrcweir //---------------------------------------------------------------------------------
2205cdf0e10cSrcweir //---------------------------------------------------------------------------------
2206cdf0e10cSrcweir //---------------------------------------------------------------------------------
2207cdf0e10cSrcweir
ImplClosePathDraw(sal_uLong nMode)2208cdf0e10cSrcweir void PSWriter::ImplClosePathDraw( sal_uLong nMode )
2209cdf0e10cSrcweir {
2210cdf0e10cSrcweir *mpPS << "pc";
2211cdf0e10cSrcweir mnCursorPos += 2;
2212cdf0e10cSrcweir ImplExecMode( nMode );
2213cdf0e10cSrcweir }
2214cdf0e10cSrcweir
ImplPathDraw()2215cdf0e10cSrcweir void PSWriter::ImplPathDraw()
2216cdf0e10cSrcweir {
2217cdf0e10cSrcweir *mpPS << "ps";
2218cdf0e10cSrcweir mnCursorPos += 2;
2219cdf0e10cSrcweir ImplExecMode( PS_RET );
2220cdf0e10cSrcweir }
2221cdf0e10cSrcweir
2222cdf0e10cSrcweir //---------------------------------------------------------------------------------
2223cdf0e10cSrcweir
ImplWriteLineColor(sal_uLong nMode)2224cdf0e10cSrcweir inline void PSWriter::ImplWriteLineColor( sal_uLong nMode )
2225cdf0e10cSrcweir {
2226cdf0e10cSrcweir if ( aColor != aLineColor )
2227cdf0e10cSrcweir {
2228cdf0e10cSrcweir aColor = aLineColor;
2229cdf0e10cSrcweir ImplWriteColor( nMode );
2230cdf0e10cSrcweir }
2231cdf0e10cSrcweir }
ImplWriteFillColor(sal_uLong nMode)2232cdf0e10cSrcweir inline void PSWriter::ImplWriteFillColor( sal_uLong nMode )
2233cdf0e10cSrcweir {
2234cdf0e10cSrcweir if ( aColor != aFillColor )
2235cdf0e10cSrcweir {
2236cdf0e10cSrcweir aColor = aFillColor;
2237cdf0e10cSrcweir ImplWriteColor( nMode );
2238cdf0e10cSrcweir }
2239cdf0e10cSrcweir }
ImplWriteTextColor(sal_uLong nMode)2240cdf0e10cSrcweir inline void PSWriter::ImplWriteTextColor( sal_uLong nMode )
2241cdf0e10cSrcweir {
2242cdf0e10cSrcweir if ( aColor != aTextColor )
2243cdf0e10cSrcweir {
2244cdf0e10cSrcweir aColor = aTextColor;
2245cdf0e10cSrcweir ImplWriteColor( nMode );
2246cdf0e10cSrcweir }
2247cdf0e10cSrcweir }
ImplWriteTextFillColor(sal_uLong nMode)2248cdf0e10cSrcweir inline void PSWriter::ImplWriteTextFillColor( sal_uLong nMode )
2249cdf0e10cSrcweir {
2250cdf0e10cSrcweir if ( aColor != aTextFillColor )
2251cdf0e10cSrcweir {
2252cdf0e10cSrcweir aColor = aTextFillColor;
2253cdf0e10cSrcweir ImplWriteColor( nMode );
2254cdf0e10cSrcweir }
2255cdf0e10cSrcweir }
2256cdf0e10cSrcweir
2257cdf0e10cSrcweir //---------------------------------------------------------------------------------
2258cdf0e10cSrcweir
ImplWriteColor(sal_uLong nMode)2259cdf0e10cSrcweir void PSWriter::ImplWriteColor( sal_uLong nMode )
2260cdf0e10cSrcweir {
2261cdf0e10cSrcweir if ( mbGrayScale )
2262cdf0e10cSrcweir {
2263cdf0e10cSrcweir // writes the Color (grayscale) as a Number from 0.000 up to 1.000
2264cdf0e10cSrcweir
2265cdf0e10cSrcweir ImplWriteF( 1000 * ( (sal_uInt8)aColor.GetRed() * 77 + (sal_uInt8)aColor.GetGreen() * 151 +
2266cdf0e10cSrcweir (sal_uInt8)aColor.GetBlue() * 28 + 1 ) / 65536, 3, nMode );
2267cdf0e10cSrcweir }
2268cdf0e10cSrcweir else
2269cdf0e10cSrcweir {
2270cdf0e10cSrcweir ImplWriteB1 ( (sal_uInt8)aColor.GetRed() );
2271cdf0e10cSrcweir ImplWriteB1 ( (sal_uInt8)aColor.GetGreen() );
2272cdf0e10cSrcweir ImplWriteB1 ( (sal_uInt8)aColor.GetBlue() );
2273cdf0e10cSrcweir }
2274cdf0e10cSrcweir *mpPS << "c"; // ( c is defined as setrgbcolor or setgray )
2275cdf0e10cSrcweir ImplExecMode( nMode );
2276cdf0e10cSrcweir }
2277cdf0e10cSrcweir
2278cdf0e10cSrcweir //---------------------------------------------------------------------------------
2279cdf0e10cSrcweir
ImplGetScaling(const MapMode & rMapMode)2280cdf0e10cSrcweir double PSWriter::ImplGetScaling( const MapMode& rMapMode )
2281cdf0e10cSrcweir {
2282cdf0e10cSrcweir double nMul;
2283cdf0e10cSrcweir switch ( rMapMode.GetMapUnit() )
2284cdf0e10cSrcweir {
2285cdf0e10cSrcweir case MAP_PIXEL :
2286cdf0e10cSrcweir case MAP_SYSFONT :
2287cdf0e10cSrcweir case MAP_APPFONT :
2288cdf0e10cSrcweir
2289cdf0e10cSrcweir case MAP_100TH_MM :
2290cdf0e10cSrcweir nMul = 1;
2291cdf0e10cSrcweir break;
2292cdf0e10cSrcweir case MAP_10TH_MM :
2293cdf0e10cSrcweir nMul = 10;
2294cdf0e10cSrcweir break;
2295cdf0e10cSrcweir case MAP_MM :
2296cdf0e10cSrcweir nMul = 100;
2297cdf0e10cSrcweir break;
2298cdf0e10cSrcweir case MAP_CM :
2299cdf0e10cSrcweir nMul = 1000;
2300cdf0e10cSrcweir break;
2301cdf0e10cSrcweir case MAP_1000TH_INCH :
2302cdf0e10cSrcweir nMul = 2.54;
2303cdf0e10cSrcweir break;
2304cdf0e10cSrcweir case MAP_100TH_INCH :
2305cdf0e10cSrcweir nMul = 25.4;
2306cdf0e10cSrcweir break;
2307cdf0e10cSrcweir case MAP_10TH_INCH :
2308cdf0e10cSrcweir nMul = 254;
2309cdf0e10cSrcweir break;
2310cdf0e10cSrcweir case MAP_INCH :
2311cdf0e10cSrcweir nMul = 2540;
2312cdf0e10cSrcweir break;
2313cdf0e10cSrcweir case MAP_TWIP :
2314cdf0e10cSrcweir nMul = 1.76388889;
2315cdf0e10cSrcweir break;
2316cdf0e10cSrcweir case MAP_POINT :
2317cdf0e10cSrcweir nMul = 35.27777778;
2318cdf0e10cSrcweir break;
2319cdf0e10cSrcweir default:
2320cdf0e10cSrcweir nMul = 1.0;
2321cdf0e10cSrcweir break;
2322cdf0e10cSrcweir }
2323cdf0e10cSrcweir return nMul;
2324cdf0e10cSrcweir }
2325cdf0e10cSrcweir
2326cdf0e10cSrcweir //---------------------------------------------------------------------------------
2327cdf0e10cSrcweir
ImplGetMapMode(const MapMode & rMapMode)2328cdf0e10cSrcweir void PSWriter::ImplGetMapMode( const MapMode& rMapMode )
2329cdf0e10cSrcweir {
2330cdf0e10cSrcweir ImplWriteLine( "tm setmatrix" );
2331cdf0e10cSrcweir double fMul = ImplGetScaling( rMapMode );
2332cdf0e10cSrcweir double fScaleX = (double)rMapMode.GetScaleX() * fMul;
2333cdf0e10cSrcweir double fScaleY = (double)rMapMode.GetScaleY() * fMul;
2334cdf0e10cSrcweir ImplTranslate( rMapMode.GetOrigin().X() * fScaleX, rMapMode.GetOrigin().Y() * fScaleY );
2335cdf0e10cSrcweir ImplScale( fScaleX, fScaleY );
2336cdf0e10cSrcweir }
2337cdf0e10cSrcweir
2338cdf0e10cSrcweir //---------------------------------------------------------------------------------
2339cdf0e10cSrcweir
ImplExecMode(sal_uLong nMode)2340cdf0e10cSrcweir inline void PSWriter::ImplExecMode( sal_uLong nMode )
2341cdf0e10cSrcweir {
2342cdf0e10cSrcweir if ( nMode & PS_WRAP )
2343cdf0e10cSrcweir {
2344cdf0e10cSrcweir if ( mnCursorPos >= PS_LINESIZE )
2345cdf0e10cSrcweir {
2346cdf0e10cSrcweir mnCursorPos = 0;
2347cdf0e10cSrcweir *mpPS << (sal_uInt8)0xa;
2348cdf0e10cSrcweir return;
2349cdf0e10cSrcweir }
2350cdf0e10cSrcweir }
2351cdf0e10cSrcweir if ( nMode & PS_SPACE )
2352cdf0e10cSrcweir {
2353cdf0e10cSrcweir *mpPS << (sal_uInt8)32;
2354cdf0e10cSrcweir mnCursorPos++;
2355cdf0e10cSrcweir }
2356cdf0e10cSrcweir if ( nMode & PS_RET )
2357cdf0e10cSrcweir {
2358cdf0e10cSrcweir *mpPS << (sal_uInt8)0xa;
2359cdf0e10cSrcweir mnCursorPos = 0;
2360cdf0e10cSrcweir }
2361cdf0e10cSrcweir }
2362cdf0e10cSrcweir
2363cdf0e10cSrcweir //---------------------------------------------------------------------------------
2364cdf0e10cSrcweir
ImplWriteLine(const char * pString,sal_uLong nMode)2365cdf0e10cSrcweir inline void PSWriter::ImplWriteLine( const char* pString, sal_uLong nMode )
2366cdf0e10cSrcweir {
2367cdf0e10cSrcweir sal_uLong i = 0;
2368cdf0e10cSrcweir while ( pString[ i ] )
2369cdf0e10cSrcweir {
2370cdf0e10cSrcweir *mpPS << (sal_uInt8)pString[ i++ ];
2371cdf0e10cSrcweir }
2372cdf0e10cSrcweir mnCursorPos += i;
2373cdf0e10cSrcweir ImplExecMode( nMode );
2374cdf0e10cSrcweir }
2375cdf0e10cSrcweir
2376cdf0e10cSrcweir //---------------------------------------------------------------------------------
2377cdf0e10cSrcweir
ImplWriteLineInfo(double fLWidth,double fMLimit,SvtGraphicStroke::CapType eLCap,SvtGraphicStroke::JoinType eJoin,SvtGraphicStroke::DashArray & rLDash)2378cdf0e10cSrcweir void PSWriter::ImplWriteLineInfo( double fLWidth, double fMLimit,
2379cdf0e10cSrcweir SvtGraphicStroke::CapType eLCap,
2380cdf0e10cSrcweir SvtGraphicStroke::JoinType eJoin,
2381cdf0e10cSrcweir SvtGraphicStroke::DashArray& rLDash )
2382cdf0e10cSrcweir {
2383cdf0e10cSrcweir if ( fLineWidth != fLWidth )
2384cdf0e10cSrcweir {
2385cdf0e10cSrcweir fLineWidth = fLWidth;
2386cdf0e10cSrcweir ImplWriteDouble( fLineWidth );
2387cdf0e10cSrcweir ImplWriteLine( "lw", PS_SPACE );
2388cdf0e10cSrcweir }
2389cdf0e10cSrcweir if ( eLineCap != eLCap )
2390cdf0e10cSrcweir {
2391cdf0e10cSrcweir eLineCap = eLCap;
2392cdf0e10cSrcweir ImplWriteLong( (sal_Int32)eLineCap, PS_SPACE );
2393cdf0e10cSrcweir ImplWriteLine( "lc", PS_SPACE );
2394cdf0e10cSrcweir }
2395cdf0e10cSrcweir if ( eJoinType != eJoin )
2396cdf0e10cSrcweir {
2397cdf0e10cSrcweir eJoinType = eJoin;
2398cdf0e10cSrcweir ImplWriteLong( (sal_Int32)eJoinType, PS_SPACE );
2399cdf0e10cSrcweir ImplWriteLine( "lj", PS_SPACE );
2400cdf0e10cSrcweir }
2401cdf0e10cSrcweir if ( eJoinType == SvtGraphicStroke::joinMiter )
2402cdf0e10cSrcweir {
2403cdf0e10cSrcweir if ( fMiterLimit != fMLimit )
2404cdf0e10cSrcweir {
2405cdf0e10cSrcweir fMiterLimit = fMLimit;
2406cdf0e10cSrcweir ImplWriteDouble( fMiterLimit );
2407cdf0e10cSrcweir ImplWriteLine( "ml", PS_SPACE );
2408cdf0e10cSrcweir }
2409cdf0e10cSrcweir }
2410cdf0e10cSrcweir if ( aDashArray != rLDash )
2411cdf0e10cSrcweir {
2412cdf0e10cSrcweir aDashArray = rLDash;
2413cdf0e10cSrcweir sal_uInt32 j, i = aDashArray.size();
2414cdf0e10cSrcweir ImplWriteLine( "[", PS_SPACE );
2415cdf0e10cSrcweir for ( j = 0; j < i; j++ )
2416cdf0e10cSrcweir ImplWriteDouble( aDashArray[ j ] );
2417cdf0e10cSrcweir ImplWriteLine( "] 0 ld" );
2418cdf0e10cSrcweir }
2419cdf0e10cSrcweir }
2420cdf0e10cSrcweir
2421cdf0e10cSrcweir //---------------------------------------------------------------------------------
2422cdf0e10cSrcweir
ImplWriteLineInfo(const LineInfo & rLineInfo)2423cdf0e10cSrcweir void PSWriter::ImplWriteLineInfo( const LineInfo& rLineInfo )
2424cdf0e10cSrcweir {
2425cdf0e10cSrcweir SvtGraphicStroke::DashArray l_aDashArray;
2426cdf0e10cSrcweir if ( rLineInfo.GetStyle() == LINE_DASH )
2427cdf0e10cSrcweir l_aDashArray.push_back( 2 );
2428cdf0e10cSrcweir const double fLWidth(( ( rLineInfo.GetWidth() + 1 ) + ( rLineInfo.GetWidth() + 1 ) ) * 0.5);
2429cdf0e10cSrcweir SvtGraphicStroke::JoinType aJoinType(SvtGraphicStroke::joinMiter);
24305aaf853bSArmin Le Grand SvtGraphicStroke::CapType aCapType(SvtGraphicStroke::capButt);
2431cdf0e10cSrcweir
2432cdf0e10cSrcweir switch(rLineInfo.GetLineJoin())
2433cdf0e10cSrcweir {
2434cdf0e10cSrcweir default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE
2435cdf0e10cSrcweir // do NOT use SvtGraphicStroke::joinNone here
2436cdf0e10cSrcweir // since it will be written as numerical value directly
2437cdf0e10cSrcweir // and is NOT a valid EPS value
2438cdf0e10cSrcweir break;
2439cdf0e10cSrcweir case basegfx::B2DLINEJOIN_MITER:
2440cdf0e10cSrcweir aJoinType = SvtGraphicStroke::joinMiter;
2441cdf0e10cSrcweir break;
2442cdf0e10cSrcweir case basegfx::B2DLINEJOIN_BEVEL:
2443cdf0e10cSrcweir aJoinType = SvtGraphicStroke::joinBevel;
2444cdf0e10cSrcweir break;
2445cdf0e10cSrcweir case basegfx::B2DLINEJOIN_ROUND:
2446cdf0e10cSrcweir aJoinType = SvtGraphicStroke::joinRound;
2447cdf0e10cSrcweir break;
2448cdf0e10cSrcweir }
2449cdf0e10cSrcweir
24505aaf853bSArmin Le Grand switch(rLineInfo.GetLineCap())
24515aaf853bSArmin Le Grand {
24525aaf853bSArmin Le Grand default: /* com::sun::star::drawing::LineCap_BUTT */
24535aaf853bSArmin Le Grand {
24545aaf853bSArmin Le Grand aCapType = SvtGraphicStroke::capButt;
24555aaf853bSArmin Le Grand break;
24565aaf853bSArmin Le Grand }
24575aaf853bSArmin Le Grand case com::sun::star::drawing::LineCap_ROUND:
24585aaf853bSArmin Le Grand {
24595aaf853bSArmin Le Grand aCapType = SvtGraphicStroke::capRound;
24605aaf853bSArmin Le Grand break;
24615aaf853bSArmin Le Grand }
24625aaf853bSArmin Le Grand case com::sun::star::drawing::LineCap_SQUARE:
24635aaf853bSArmin Le Grand {
24645aaf853bSArmin Le Grand aCapType = SvtGraphicStroke::capSquare;
24655aaf853bSArmin Le Grand break;
24665aaf853bSArmin Le Grand }
24675aaf853bSArmin Le Grand }
24685aaf853bSArmin Le Grand
24695aaf853bSArmin Le Grand ImplWriteLineInfo( fLWidth, fMiterLimit, aCapType, aJoinType, l_aDashArray );
2470cdf0e10cSrcweir }
2471cdf0e10cSrcweir
2472cdf0e10cSrcweir //---------------------------------------------------------------------------------
2473cdf0e10cSrcweir
ImplWriteLong(sal_Int32 nNumber,sal_uLong nMode)2474cdf0e10cSrcweir void PSWriter::ImplWriteLong( sal_Int32 nNumber, sal_uLong nMode )
2475cdf0e10cSrcweir {
2476cdf0e10cSrcweir const ByteString aNumber( ByteString::CreateFromInt32( nNumber ) );
2477cdf0e10cSrcweir sal_uLong nLen = aNumber.Len();
2478cdf0e10cSrcweir mnCursorPos += nLen;
2479cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nLen; n++ )
2480cdf0e10cSrcweir *mpPS << aNumber.GetChar( n );
2481cdf0e10cSrcweir ImplExecMode( nMode );
2482cdf0e10cSrcweir }
2483cdf0e10cSrcweir
2484cdf0e10cSrcweir //---------------------------------------------------------------------------------
2485cdf0e10cSrcweir
ImplWriteDouble(double fNumber,sal_uLong nMode)2486cdf0e10cSrcweir void PSWriter::ImplWriteDouble( double fNumber, sal_uLong nMode )
2487cdf0e10cSrcweir {
2488cdf0e10cSrcweir sal_Int32 nLength;
2489cdf0e10cSrcweir
2490cdf0e10cSrcweir sal_Int32 nPTemp = (sal_Int32)fNumber;
2491cdf0e10cSrcweir sal_Int32 nATemp = labs( (sal_Int32)( ( fNumber - nPTemp ) * 100000 ) );
2492cdf0e10cSrcweir
2493cdf0e10cSrcweir if ( !nPTemp && nATemp && ( fNumber < 0.0 ) )
2494cdf0e10cSrcweir *mpPS << (sal_Char)'-';
2495cdf0e10cSrcweir
2496cdf0e10cSrcweir ByteString aNumber1( ByteString::CreateFromInt32( nPTemp ) );
2497cdf0e10cSrcweir nLength = aNumber1.Len();
2498cdf0e10cSrcweir mnCursorPos += nLength;
2499cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nLength; n++ )
2500cdf0e10cSrcweir *mpPS << aNumber1.GetChar( (sal_uInt16)n );
2501cdf0e10cSrcweir
2502cdf0e10cSrcweir int zCount = 0;
2503cdf0e10cSrcweir if ( nATemp )
2504cdf0e10cSrcweir {
2505cdf0e10cSrcweir *mpPS << (sal_uInt8)'.';
2506cdf0e10cSrcweir mnCursorPos++;
2507cdf0e10cSrcweir const ByteString aNumber2( ByteString::CreateFromInt32( nATemp ) );
2508cdf0e10cSrcweir
2509cdf0e10cSrcweir sal_Int16 n, nLen = aNumber2.Len();
2510cdf0e10cSrcweir if ( nLen < 8 )
2511cdf0e10cSrcweir {
2512cdf0e10cSrcweir mnCursorPos += 6 - nLen;
2513cdf0e10cSrcweir for ( n = 0; n < ( 5 - nLen ); n++ )
2514cdf0e10cSrcweir {
2515cdf0e10cSrcweir *mpPS << (sal_uInt8)'0';
2516cdf0e10cSrcweir }
2517cdf0e10cSrcweir }
2518cdf0e10cSrcweir mnCursorPos += nLen;
2519cdf0e10cSrcweir for ( n = 0; n < nLen; n++ )
2520cdf0e10cSrcweir {
2521cdf0e10cSrcweir *mpPS << aNumber2.GetChar( n );
2522cdf0e10cSrcweir zCount--;
2523cdf0e10cSrcweir if ( aNumber2.GetChar( n ) != '0' )
2524cdf0e10cSrcweir zCount = 0;
2525cdf0e10cSrcweir }
2526cdf0e10cSrcweir if ( zCount )
2527cdf0e10cSrcweir mpPS->SeekRel( zCount );
2528cdf0e10cSrcweir }
2529cdf0e10cSrcweir ImplExecMode( nMode );
2530cdf0e10cSrcweir }
2531cdf0e10cSrcweir
2532cdf0e10cSrcweir //---------------------------------------------------------------------------------
2533cdf0e10cSrcweir
2534cdf0e10cSrcweir // writes the number to stream: nNumber / ( 10^nCount )
2535cdf0e10cSrcweir
ImplWriteF(sal_Int32 nNumber,sal_uLong nCount,sal_uLong nMode)2536cdf0e10cSrcweir void PSWriter::ImplWriteF( sal_Int32 nNumber, sal_uLong nCount, sal_uLong nMode )
2537cdf0e10cSrcweir {
2538cdf0e10cSrcweir if ( nNumber < 0 )
2539cdf0e10cSrcweir {
2540cdf0e10cSrcweir *mpPS << (sal_uInt8)'-';
2541cdf0e10cSrcweir nNumber = -nNumber;
2542cdf0e10cSrcweir mnCursorPos++;
2543cdf0e10cSrcweir }
2544cdf0e10cSrcweir const ByteString aScaleFactor( ByteString::CreateFromInt32( nNumber ) );
2545cdf0e10cSrcweir sal_uLong nLen = aScaleFactor.Len();
2546cdf0e10cSrcweir long nStSize = ( nCount + 1 ) - nLen;
2547cdf0e10cSrcweir if ( nStSize >= 1 )
2548cdf0e10cSrcweir {
2549cdf0e10cSrcweir *mpPS << (sal_uInt8)'0';
2550cdf0e10cSrcweir mnCursorPos++;
2551cdf0e10cSrcweir }
2552cdf0e10cSrcweir if ( nStSize >= 2 )
2553cdf0e10cSrcweir {
2554cdf0e10cSrcweir *mpPS << (sal_uInt8)'.';
2555cdf0e10cSrcweir for ( long i = 1; i < nStSize; i++ )
2556cdf0e10cSrcweir {
2557cdf0e10cSrcweir *mpPS << (sal_uInt8)'0';
2558cdf0e10cSrcweir mnCursorPos++;
2559cdf0e10cSrcweir }
2560cdf0e10cSrcweir }
2561cdf0e10cSrcweir mnCursorPos += nLen;
2562cdf0e10cSrcweir for( sal_uInt16 n = 0UL; n < nLen; n++ )
2563cdf0e10cSrcweir {
2564cdf0e10cSrcweir if ( n == nLen - nCount )
2565cdf0e10cSrcweir {
2566cdf0e10cSrcweir *mpPS << (sal_uInt8)'.';
2567cdf0e10cSrcweir mnCursorPos++;
2568cdf0e10cSrcweir }
2569cdf0e10cSrcweir *mpPS << aScaleFactor.GetChar( n );
2570cdf0e10cSrcweir }
2571cdf0e10cSrcweir ImplExecMode( nMode );
2572cdf0e10cSrcweir }
2573cdf0e10cSrcweir
2574cdf0e10cSrcweir //---------------------------------------------------------------------------------
2575cdf0e10cSrcweir
ImplWriteByte(sal_uInt8 nNumb,sal_uLong nMode)2576cdf0e10cSrcweir void PSWriter::ImplWriteByte( sal_uInt8 nNumb, sal_uLong nMode )
2577cdf0e10cSrcweir {
2578cdf0e10cSrcweir *mpPS << ( nNumb );
2579cdf0e10cSrcweir mnCursorPos++;
2580cdf0e10cSrcweir ImplExecMode( nMode );
2581cdf0e10cSrcweir }
2582cdf0e10cSrcweir
2583cdf0e10cSrcweir //---------------------------------------------------------------------------------
2584cdf0e10cSrcweir
ImplWriteHexByte(sal_uInt8 nNumb,sal_uLong nMode)2585cdf0e10cSrcweir void PSWriter::ImplWriteHexByte( sal_uInt8 nNumb, sal_uLong nMode )
2586cdf0e10cSrcweir {
2587cdf0e10cSrcweir if ( ( nNumb >> 4 ) > 9 )
2588cdf0e10cSrcweir *mpPS << (sal_uInt8)( ( nNumb >> 4 ) + 'A' - 10 );
2589cdf0e10cSrcweir else
2590cdf0e10cSrcweir *mpPS << (sal_uInt8)( ( nNumb >> 4 ) + '0' );
2591cdf0e10cSrcweir
2592cdf0e10cSrcweir if ( ( nNumb & 0xf ) > 9 )
2593cdf0e10cSrcweir *mpPS << (sal_uInt8)( ( nNumb & 0xf ) + 'A' - 10 );
2594cdf0e10cSrcweir else
2595cdf0e10cSrcweir *mpPS << (sal_uInt8)( ( nNumb & 0xf ) + '0' );
2596cdf0e10cSrcweir mnCursorPos += 2;
2597cdf0e10cSrcweir ImplExecMode( nMode );
2598cdf0e10cSrcweir }
2599cdf0e10cSrcweir
2600cdf0e10cSrcweir //---------------------------------------------------------------------------------
2601cdf0e10cSrcweir
2602cdf0e10cSrcweir // writes the sal_uInt8 nNumb as a Number from 0.000 up to 1.000
2603cdf0e10cSrcweir
ImplWriteB1(sal_uInt8 nNumb,sal_uLong nMode)2604cdf0e10cSrcweir void PSWriter::ImplWriteB1( sal_uInt8 nNumb, sal_uLong nMode )
2605cdf0e10cSrcweir {
2606cdf0e10cSrcweir ImplWriteF( 1000 * ( nNumb + 1 ) / 256 , 3, nMode );
2607cdf0e10cSrcweir }
2608cdf0e10cSrcweir
2609cdf0e10cSrcweir
2610cdf0e10cSrcweir // ------------------------------------------------------------------------
2611cdf0e10cSrcweir
WriteBits(sal_uInt16 nCode,sal_uInt16 nCodeLen)2612cdf0e10cSrcweir inline void PSWriter::WriteBits( sal_uInt16 nCode, sal_uInt16 nCodeLen )
2613cdf0e10cSrcweir {
2614cdf0e10cSrcweir dwShift |= ( nCode << ( nOffset - nCodeLen ) );
2615cdf0e10cSrcweir nOffset -= nCodeLen;
2616cdf0e10cSrcweir while ( nOffset < 24 )
2617cdf0e10cSrcweir {
2618cdf0e10cSrcweir ImplWriteHexByte( (sal_uInt8)( dwShift >> 24 ) );
2619cdf0e10cSrcweir dwShift <<= 8;
2620cdf0e10cSrcweir nOffset += 8;
2621cdf0e10cSrcweir }
2622cdf0e10cSrcweir if ( nCode == 257 && nOffset != 32 )
2623cdf0e10cSrcweir ImplWriteHexByte( (sal_uInt8)( dwShift >> 24 ) );
2624cdf0e10cSrcweir }
2625cdf0e10cSrcweir
2626cdf0e10cSrcweir // ------------------------------------------------------------------------
2627cdf0e10cSrcweir
StartCompression()2628cdf0e10cSrcweir void PSWriter::StartCompression()
2629cdf0e10cSrcweir {
2630cdf0e10cSrcweir sal_uInt16 i;
2631cdf0e10cSrcweir nDataSize = 8;
2632cdf0e10cSrcweir
2633cdf0e10cSrcweir nClearCode = 1 << nDataSize;
2634cdf0e10cSrcweir nEOICode = nClearCode + 1;
2635cdf0e10cSrcweir nTableSize = nEOICode + 1;
2636cdf0e10cSrcweir nCodeSize = nDataSize + 1;
2637cdf0e10cSrcweir
2638cdf0e10cSrcweir nOffset = 32; // anzahl freier bits in dwShift
2639cdf0e10cSrcweir dwShift = 0;
2640cdf0e10cSrcweir
2641cdf0e10cSrcweir pTable = new PSLZWCTreeNode[ 4096 ];
2642cdf0e10cSrcweir
2643cdf0e10cSrcweir for ( i = 0; i < 4096; i++ )
2644cdf0e10cSrcweir {
2645cdf0e10cSrcweir pTable[ i ].pBrother = pTable[ i ].pFirstChild = NULL;
2646cdf0e10cSrcweir pTable[ i ].nValue = (sal_uInt8)( pTable[ i ].nCode = i );
2647cdf0e10cSrcweir }
2648cdf0e10cSrcweir pPrefix = NULL;
2649cdf0e10cSrcweir WriteBits( nClearCode, nCodeSize );
2650cdf0e10cSrcweir }
2651cdf0e10cSrcweir
2652cdf0e10cSrcweir // ------------------------------------------------------------------------
2653cdf0e10cSrcweir
Compress(sal_uInt8 nCompThis)2654cdf0e10cSrcweir void PSWriter::Compress( sal_uInt8 nCompThis )
2655cdf0e10cSrcweir {
2656cdf0e10cSrcweir PSLZWCTreeNode* p;
2657cdf0e10cSrcweir sal_uInt16 i;
2658cdf0e10cSrcweir sal_uInt8 nV;
2659cdf0e10cSrcweir
2660cdf0e10cSrcweir if( !pPrefix )
2661cdf0e10cSrcweir {
2662cdf0e10cSrcweir pPrefix = pTable + nCompThis;
2663cdf0e10cSrcweir }
2664cdf0e10cSrcweir else
2665cdf0e10cSrcweir {
2666cdf0e10cSrcweir nV = nCompThis;
2667cdf0e10cSrcweir for( p = pPrefix->pFirstChild; p != NULL; p = p->pBrother )
2668cdf0e10cSrcweir {
2669cdf0e10cSrcweir if ( p->nValue == nV )
2670cdf0e10cSrcweir break;
2671cdf0e10cSrcweir }
2672cdf0e10cSrcweir
2673cdf0e10cSrcweir if( p )
2674cdf0e10cSrcweir pPrefix = p;
2675cdf0e10cSrcweir else
2676cdf0e10cSrcweir {
2677cdf0e10cSrcweir WriteBits( pPrefix->nCode, nCodeSize );
2678cdf0e10cSrcweir
2679cdf0e10cSrcweir if ( nTableSize == 409 )
2680cdf0e10cSrcweir {
2681cdf0e10cSrcweir WriteBits( nClearCode, nCodeSize );
2682cdf0e10cSrcweir
2683cdf0e10cSrcweir for ( i = 0; i < nClearCode; i++ )
2684cdf0e10cSrcweir pTable[ i ].pFirstChild = NULL;
2685cdf0e10cSrcweir
2686cdf0e10cSrcweir nCodeSize = nDataSize + 1;
2687cdf0e10cSrcweir nTableSize = nEOICode + 1;
2688cdf0e10cSrcweir }
2689cdf0e10cSrcweir else
2690cdf0e10cSrcweir {
2691cdf0e10cSrcweir if( nTableSize == (sal_uInt16)( ( 1 << nCodeSize ) - 1 ) )
2692cdf0e10cSrcweir nCodeSize++;
2693cdf0e10cSrcweir
2694cdf0e10cSrcweir p = pTable + ( nTableSize++ );
2695cdf0e10cSrcweir p->pBrother = pPrefix->pFirstChild;
2696cdf0e10cSrcweir pPrefix->pFirstChild = p;
2697cdf0e10cSrcweir p->nValue = nV;
2698cdf0e10cSrcweir p->pFirstChild = NULL;
2699cdf0e10cSrcweir }
2700cdf0e10cSrcweir
2701cdf0e10cSrcweir pPrefix = pTable + nV;
2702cdf0e10cSrcweir }
2703cdf0e10cSrcweir }
2704cdf0e10cSrcweir }
2705cdf0e10cSrcweir
2706cdf0e10cSrcweir // ------------------------------------------------------------------------
2707cdf0e10cSrcweir
EndCompression()2708cdf0e10cSrcweir void PSWriter::EndCompression()
2709cdf0e10cSrcweir {
2710cdf0e10cSrcweir if( pPrefix )
2711cdf0e10cSrcweir WriteBits( pPrefix->nCode, nCodeSize );
2712cdf0e10cSrcweir
2713cdf0e10cSrcweir WriteBits( nEOICode, nCodeSize );
2714cdf0e10cSrcweir delete[] pTable;
2715cdf0e10cSrcweir }
2716cdf0e10cSrcweir
2717cdf0e10cSrcweir // ------------------------------------------------------------------------
2718cdf0e10cSrcweir
ImplSearchEntry(sal_uInt8 * pSource,sal_uInt8 * pDest,sal_uLong nComp,sal_uLong nSize)2719cdf0e10cSrcweir sal_uInt8* PSWriter::ImplSearchEntry( sal_uInt8* pSource, sal_uInt8* pDest, sal_uLong nComp, sal_uLong nSize )
2720cdf0e10cSrcweir {
2721cdf0e10cSrcweir while ( nComp-- >= nSize )
2722cdf0e10cSrcweir {
2723cdf0e10cSrcweir sal_uLong i;
2724cdf0e10cSrcweir for ( i = 0; i < nSize; i++ )
2725cdf0e10cSrcweir {
2726cdf0e10cSrcweir if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
2727cdf0e10cSrcweir break;
2728cdf0e10cSrcweir }
2729cdf0e10cSrcweir if ( i == nSize )
2730cdf0e10cSrcweir return pSource;
2731cdf0e10cSrcweir pSource++;
2732cdf0e10cSrcweir }
2733cdf0e10cSrcweir return NULL;
2734cdf0e10cSrcweir }
2735cdf0e10cSrcweir
2736cdf0e10cSrcweir // ------------------------------------------------------------------------
2737cdf0e10cSrcweir
ImplGetBoundingBox(double * nNumb,sal_uInt8 * pSource,sal_uLong nSize)2738cdf0e10cSrcweir sal_Bool PSWriter::ImplGetBoundingBox( double* nNumb, sal_uInt8* pSource, sal_uLong nSize )
2739cdf0e10cSrcweir {
2740cdf0e10cSrcweir sal_Bool bRetValue = sal_False;
2741cdf0e10cSrcweir sal_uLong nBytesRead;
2742cdf0e10cSrcweir
2743cdf0e10cSrcweir if ( nSize < 256 ) // we assume that the file is greater than 256 bytes
2744cdf0e10cSrcweir return sal_False;
2745cdf0e10cSrcweir
2746cdf0e10cSrcweir if ( nSize < POSTSCRIPT_BOUNDINGSEARCH )
2747cdf0e10cSrcweir nBytesRead = nSize;
2748cdf0e10cSrcweir else
2749cdf0e10cSrcweir nBytesRead = POSTSCRIPT_BOUNDINGSEARCH;
2750cdf0e10cSrcweir
2751cdf0e10cSrcweir sal_uInt8* pDest = ImplSearchEntry( pSource, (sal_uInt8*)"%%BoundingBox:", nBytesRead, 14 );
2752cdf0e10cSrcweir if ( pDest )
2753cdf0e10cSrcweir {
2754cdf0e10cSrcweir int nSecurityCount = 100; // only 100 bytes following the bounding box will be checked
2755cdf0e10cSrcweir nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
2756cdf0e10cSrcweir pDest += 14;
2757cdf0e10cSrcweir for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ )
2758cdf0e10cSrcweir {
2759cdf0e10cSrcweir int nDivision = 1;
2760cdf0e10cSrcweir sal_Bool bDivision = sal_False;
2761cdf0e10cSrcweir sal_Bool bNegative = sal_False;
2762cdf0e10cSrcweir sal_Bool bValid = sal_True;
2763cdf0e10cSrcweir
2764cdf0e10cSrcweir while ( ( --nSecurityCount ) && ( ( *pDest == ' ' ) || ( *pDest == 0x9 ) ) )
2765cdf0e10cSrcweir pDest++;
2766cdf0e10cSrcweir sal_uInt8 nByte = *pDest;
2767cdf0e10cSrcweir while ( nSecurityCount && ( nByte != ' ' ) && ( nByte != 0x9 ) && ( nByte != 0xd ) && ( nByte != 0xa ) )
2768cdf0e10cSrcweir {
2769cdf0e10cSrcweir switch ( nByte )
2770cdf0e10cSrcweir {
2771cdf0e10cSrcweir case '.' :
2772cdf0e10cSrcweir if ( bDivision )
2773cdf0e10cSrcweir bValid = sal_False;
2774cdf0e10cSrcweir else
2775cdf0e10cSrcweir bDivision = sal_True;
2776cdf0e10cSrcweir break;
2777cdf0e10cSrcweir case '-' :
2778cdf0e10cSrcweir bNegative = sal_True;
2779cdf0e10cSrcweir break;
2780cdf0e10cSrcweir default :
2781cdf0e10cSrcweir if ( ( nByte < '0' ) || ( nByte > '9' ) )
2782cdf0e10cSrcweir nSecurityCount = 1; // error parsing the bounding box values
2783cdf0e10cSrcweir else if ( bValid )
2784cdf0e10cSrcweir {
2785cdf0e10cSrcweir if ( bDivision )
2786cdf0e10cSrcweir nDivision*=10;
2787cdf0e10cSrcweir nNumb[i] *= 10;
2788cdf0e10cSrcweir nNumb[i] += nByte - '0';
2789cdf0e10cSrcweir }
2790cdf0e10cSrcweir break;
2791cdf0e10cSrcweir }
2792cdf0e10cSrcweir nSecurityCount--;
2793cdf0e10cSrcweir nByte = *(++pDest);
2794cdf0e10cSrcweir }
2795cdf0e10cSrcweir if ( bNegative )
2796cdf0e10cSrcweir nNumb[i] = -nNumb[i];
2797cdf0e10cSrcweir if ( bDivision && ( nDivision != 1 ) )
2798cdf0e10cSrcweir nNumb[i] /= nDivision;
2799cdf0e10cSrcweir }
2800cdf0e10cSrcweir if ( nSecurityCount)
2801cdf0e10cSrcweir bRetValue = sal_True;
2802cdf0e10cSrcweir }
2803cdf0e10cSrcweir return bRetValue;
2804cdf0e10cSrcweir }
2805cdf0e10cSrcweir
2806cdf0e10cSrcweir //================== GraphicExport - die exportierte Funktion ================
2807cdf0e10cSrcweir
GraphicExport(SvStream & rStream,Graphic & rGraphic,FilterConfigItem * pFilterConfigItem,sal_Bool)2808cdf0e10cSrcweir extern "C" sal_Bool __LOADONCALLAPI GraphicExport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pFilterConfigItem, sal_Bool)
2809cdf0e10cSrcweir {
2810cdf0e10cSrcweir PSWriter aPSWriter;
2811cdf0e10cSrcweir return aPSWriter.WritePS( rGraphic, rStream, pFilterConfigItem );
2812cdf0e10cSrcweir }
2813cdf0e10cSrcweir
2814