19f62ea84SAndrew Rist /**************************************************************
29f62ea84SAndrew Rist *
39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
59f62ea84SAndrew Rist * distributed with this work for additional information
69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
109f62ea84SAndrew Rist *
119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129f62ea84SAndrew Rist *
139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist * software distributed under the License is distributed on an
159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
179f62ea84SAndrew Rist * specific language governing permissions and limitations
189f62ea84SAndrew Rist * under the License.
199f62ea84SAndrew Rist *
209f62ea84SAndrew Rist *************************************************************/
219f62ea84SAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_vcl.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include <tools/vcompat.hxx>
26cdf0e10cSrcweir #include <tools/urlobj.hxx>
27cdf0e10cSrcweir #include <tools/debug.hxx>
28cdf0e10cSrcweir #include <tools/stream.hxx>
29cdf0e10cSrcweir #include <ucbhelper/content.hxx>
30cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
31cdf0e10cSrcweir #include <unotools/tempfile.hxx>
32cdf0e10cSrcweir #include <vcl/outdev.hxx>
33cdf0e10cSrcweir #include <vcl/virdev.hxx>
34cdf0e10cSrcweir #include <vcl/gfxlink.hxx>
35cdf0e10cSrcweir #include <vcl/cvtgrf.hxx>
36cdf0e10cSrcweir #include <vcl/salbtype.hxx>
37cdf0e10cSrcweir #include <vcl/graph.hxx>
38cdf0e10cSrcweir #include <vcl/metaact.hxx>
39cdf0e10cSrcweir #include <impgraph.hxx>
40cdf0e10cSrcweir #include <com/sun/star/ucb/CommandAbortedException.hpp>
4145fd3b9aSArmin Le Grand #include <vcl/dibtools.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir // -----------
44cdf0e10cSrcweir // - Defines -
45cdf0e10cSrcweir // -----------
46cdf0e10cSrcweir
47cdf0e10cSrcweir #define GRAPHIC_MAXPARTLEN 256000L
48cdf0e10cSrcweir #define GRAPHIC_MTFTOBMP_MAXEXT 2048
49cdf0e10cSrcweir #define GRAPHIC_STREAMBUFSIZE 8192UL
50cdf0e10cSrcweir
51cdf0e10cSrcweir #define SYS_WINMETAFILE 0x00000003L
52cdf0e10cSrcweir #define SYS_WNTMETAFILE 0x00000004L
53cdf0e10cSrcweir #define SYS_OS2METAFILE 0x00000005L
54cdf0e10cSrcweir #define SYS_MACMETAFILE 0x00000006L
55cdf0e10cSrcweir
56cdf0e10cSrcweir #define GRAPHIC_FORMAT_50 static_cast<sal_uInt32>(COMPAT_FORMAT( 'G', 'R', 'F', '5' ))
57cdf0e10cSrcweir #define NATIVE_FORMAT_50 static_cast<sal_uInt32>(COMPAT_FORMAT( 'N', 'A', 'T', '5' ))
58cdf0e10cSrcweir
59cdf0e10cSrcweir // ---------------
60cdf0e10cSrcweir // - ImpSwapFile -
61cdf0e10cSrcweir // ---------------
62cdf0e10cSrcweir
63cdf0e10cSrcweir struct ImpSwapFile
64cdf0e10cSrcweir {
65cdf0e10cSrcweir INetURLObject aSwapURL;
66cdf0e10cSrcweir sal_uLong nRefCount;
67cdf0e10cSrcweir };
68cdf0e10cSrcweir
69cdf0e10cSrcweir // -----------------
70cdf0e10cSrcweir // - Graphicreader -
71cdf0e10cSrcweir // -----------------
72cdf0e10cSrcweir
73cdf0e10cSrcweir class ReaderData
74cdf0e10cSrcweir {
75cdf0e10cSrcweir public:
76cdf0e10cSrcweir Size maPreviewSize;
77cdf0e10cSrcweir };
78cdf0e10cSrcweir
~GraphicReader()79cdf0e10cSrcweir GraphicReader::~GraphicReader()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir delete mpReaderData;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir // ------------------------------------------------------------------------
85cdf0e10cSrcweir
IsPreviewModeEnabled() const86cdf0e10cSrcweir sal_Bool GraphicReader::IsPreviewModeEnabled() const
87cdf0e10cSrcweir {
88cdf0e10cSrcweir if( !mpReaderData )
89cdf0e10cSrcweir return sal_False;
90cdf0e10cSrcweir if( mpReaderData->maPreviewSize.Width() )
91cdf0e10cSrcweir return sal_True;
92cdf0e10cSrcweir if( mpReaderData->maPreviewSize.Height() )
93cdf0e10cSrcweir return sal_True;
94cdf0e10cSrcweir return sal_False;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
97cdf0e10cSrcweir // ------------------------------------------------------------------------
98cdf0e10cSrcweir
DisablePreviewMode()99cdf0e10cSrcweir void GraphicReader::DisablePreviewMode()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir if( mpReaderData )
102cdf0e10cSrcweir mpReaderData->maPreviewSize = Size( 0, 0 );
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir // ------------------------------------------------------------------------
106cdf0e10cSrcweir
SetPreviewSize(const Size & rSize)107cdf0e10cSrcweir void GraphicReader::SetPreviewSize( const Size& rSize )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir if( !mpReaderData )
110cdf0e10cSrcweir mpReaderData = new ReaderData;
111cdf0e10cSrcweir mpReaderData->maPreviewSize = rSize;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir // ------------------------------------------------------------------------
115cdf0e10cSrcweir
GetPreviewSize() const116cdf0e10cSrcweir Size GraphicReader::GetPreviewSize() const
117cdf0e10cSrcweir {
118cdf0e10cSrcweir Size aSize( 0, 0 );
119cdf0e10cSrcweir if( mpReaderData )
120cdf0e10cSrcweir aSize = mpReaderData->maPreviewSize;
121cdf0e10cSrcweir return aSize;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir // --------------
125cdf0e10cSrcweir // - ImpGraphic -
126cdf0e10cSrcweir // --------------
127cdf0e10cSrcweir
ImpGraphic()128cdf0e10cSrcweir ImpGraphic::ImpGraphic() :
129cdf0e10cSrcweir mpAnimation ( NULL ),
130cdf0e10cSrcweir mpContext ( NULL ),
131cdf0e10cSrcweir mpSwapFile ( NULL ),
132cdf0e10cSrcweir mpGfxLink ( NULL ),
133cdf0e10cSrcweir meType ( GRAPHIC_NONE ),
134cdf0e10cSrcweir mnDocFilePos ( 0UL ),
135cdf0e10cSrcweir mnSizeBytes ( 0UL ),
136cdf0e10cSrcweir mnRefCount ( 1UL ),
137cdf0e10cSrcweir mbSwapOut ( sal_False ),
138cdf0e10cSrcweir mbSwapUnderway ( sal_False )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
142cdf0e10cSrcweir // ------------------------------------------------------------------------
143cdf0e10cSrcweir
ImpGraphic(const ImpGraphic & rImpGraphic)144cdf0e10cSrcweir ImpGraphic::ImpGraphic( const ImpGraphic& rImpGraphic ) :
145cdf0e10cSrcweir maMetaFile ( rImpGraphic.maMetaFile ),
146cdf0e10cSrcweir maEx ( rImpGraphic.maEx ),
147cdf0e10cSrcweir mpContext ( NULL ),
148cdf0e10cSrcweir mpSwapFile ( rImpGraphic.mpSwapFile ),
149cdf0e10cSrcweir meType ( rImpGraphic.meType ),
150cdf0e10cSrcweir maDocFileURLStr ( rImpGraphic.maDocFileURLStr ),
151cdf0e10cSrcweir mnDocFilePos ( rImpGraphic.mnDocFilePos ),
152cdf0e10cSrcweir mnSizeBytes ( rImpGraphic.mnSizeBytes ),
153cdf0e10cSrcweir mnRefCount ( 1UL ),
154cdf0e10cSrcweir mbSwapOut ( rImpGraphic.mbSwapOut ),
155cdf0e10cSrcweir mbSwapUnderway ( sal_False )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir if( mpSwapFile )
158cdf0e10cSrcweir mpSwapFile->nRefCount++;
159cdf0e10cSrcweir
160cdf0e10cSrcweir if( rImpGraphic.mpGfxLink )
161cdf0e10cSrcweir mpGfxLink = new GfxLink( *rImpGraphic.mpGfxLink );
162cdf0e10cSrcweir else
163cdf0e10cSrcweir mpGfxLink = NULL;
164cdf0e10cSrcweir
165cdf0e10cSrcweir if( rImpGraphic.mpAnimation )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir mpAnimation = new Animation( *rImpGraphic.mpAnimation );
168cdf0e10cSrcweir maEx = mpAnimation->GetBitmapEx();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir else
171cdf0e10cSrcweir mpAnimation = NULL;
172ddde725dSArmin Le Grand
173ddde725dSArmin Le Grand maSvgData = rImpGraphic.maSvgData;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir // ------------------------------------------------------------------------
177cdf0e10cSrcweir
ImpGraphic(const Bitmap & rBitmap)178cdf0e10cSrcweir ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
179cdf0e10cSrcweir maEx ( rBitmap ),
180cdf0e10cSrcweir mpAnimation ( NULL ),
181cdf0e10cSrcweir mpContext ( NULL ),
182cdf0e10cSrcweir mpSwapFile ( NULL ),
183cdf0e10cSrcweir mpGfxLink ( NULL ),
184cdf0e10cSrcweir meType ( !rBitmap ? GRAPHIC_NONE : GRAPHIC_BITMAP ),
185cdf0e10cSrcweir mnDocFilePos ( 0UL ),
186cdf0e10cSrcweir mnSizeBytes ( 0UL ),
187cdf0e10cSrcweir mnRefCount ( 1UL ),
188cdf0e10cSrcweir mbSwapOut ( sal_False ),
189cdf0e10cSrcweir mbSwapUnderway ( sal_False )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir // ------------------------------------------------------------------------
194cdf0e10cSrcweir
ImpGraphic(const BitmapEx & rBitmapEx)195cdf0e10cSrcweir ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
196cdf0e10cSrcweir maEx ( rBitmapEx ),
197cdf0e10cSrcweir mpAnimation ( NULL ),
198cdf0e10cSrcweir mpContext ( NULL ),
199cdf0e10cSrcweir mpSwapFile ( NULL ),
200cdf0e10cSrcweir mpGfxLink ( NULL ),
201cdf0e10cSrcweir meType ( !rBitmapEx ? GRAPHIC_NONE : GRAPHIC_BITMAP ),
202cdf0e10cSrcweir mnDocFilePos ( 0UL ),
203cdf0e10cSrcweir mnSizeBytes ( 0UL ),
204cdf0e10cSrcweir mnRefCount ( 1UL ),
205cdf0e10cSrcweir mbSwapOut ( sal_False ),
206cdf0e10cSrcweir mbSwapUnderway ( sal_False )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir }
209cdf0e10cSrcweir
210cdf0e10cSrcweir // ------------------------------------------------------------------------
211cdf0e10cSrcweir
ImpGraphic(const SvgDataPtr & rSvgDataPtr)212ddde725dSArmin Le Grand ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr)
213ddde725dSArmin Le Grand : mpAnimation( NULL ),
214ddde725dSArmin Le Grand mpContext( NULL ),
215ddde725dSArmin Le Grand mpSwapFile( NULL ),
216ddde725dSArmin Le Grand mpGfxLink( NULL ),
217ddde725dSArmin Le Grand meType( rSvgDataPtr.get() ? GRAPHIC_BITMAP : GRAPHIC_NONE ),
218ddde725dSArmin Le Grand mnDocFilePos( 0UL ),
219ddde725dSArmin Le Grand mnSizeBytes( 0UL ),
220ddde725dSArmin Le Grand mnRefCount( 1UL ),
221ddde725dSArmin Le Grand mbSwapOut( sal_False ),
222ddde725dSArmin Le Grand mbSwapUnderway( sal_False ),
223ddde725dSArmin Le Grand maSvgData(rSvgDataPtr)
224ddde725dSArmin Le Grand {
225ddde725dSArmin Le Grand }
226ddde725dSArmin Le Grand
227ddde725dSArmin Le Grand // ------------------------------------------------------------------------
228ddde725dSArmin Le Grand
ImpGraphic(const Animation & rAnimation)229cdf0e10cSrcweir ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
230cdf0e10cSrcweir maEx ( rAnimation.GetBitmapEx() ),
231cdf0e10cSrcweir mpAnimation ( new Animation( rAnimation ) ),
232cdf0e10cSrcweir mpContext ( NULL ),
233cdf0e10cSrcweir mpSwapFile ( NULL ),
234cdf0e10cSrcweir mpGfxLink ( NULL ),
235cdf0e10cSrcweir meType ( GRAPHIC_BITMAP ),
236cdf0e10cSrcweir mnDocFilePos ( 0UL ),
237cdf0e10cSrcweir mnSizeBytes ( 0UL ),
238cdf0e10cSrcweir mnRefCount ( 1UL ),
239cdf0e10cSrcweir mbSwapOut ( sal_False ),
240cdf0e10cSrcweir mbSwapUnderway ( sal_False )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
244cdf0e10cSrcweir // ------------------------------------------------------------------------
245cdf0e10cSrcweir
ImpGraphic(const GDIMetaFile & rMtf)246cdf0e10cSrcweir ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
247cdf0e10cSrcweir maMetaFile ( rMtf ),
248cdf0e10cSrcweir mpAnimation ( NULL ),
249cdf0e10cSrcweir mpContext ( NULL ),
250cdf0e10cSrcweir mpSwapFile ( NULL ),
251cdf0e10cSrcweir mpGfxLink ( NULL ),
252cdf0e10cSrcweir meType ( GRAPHIC_GDIMETAFILE ),
253cdf0e10cSrcweir mnDocFilePos ( 0UL ),
254cdf0e10cSrcweir mnSizeBytes ( 0UL ),
255cdf0e10cSrcweir mnRefCount ( 1UL ),
256cdf0e10cSrcweir mbSwapOut ( sal_False ),
257cdf0e10cSrcweir mbSwapUnderway ( sal_False )
258cdf0e10cSrcweir {
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
261cdf0e10cSrcweir // ------------------------------------------------------------------------
262cdf0e10cSrcweir
~ImpGraphic()263cdf0e10cSrcweir ImpGraphic::~ImpGraphic()
264cdf0e10cSrcweir {
265cdf0e10cSrcweir ImplClear();
266cdf0e10cSrcweir
267cdf0e10cSrcweir if( (sal_uLong) mpContext > 1UL )
268cdf0e10cSrcweir delete mpContext;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
271cdf0e10cSrcweir // ------------------------------------------------------------------------
272cdf0e10cSrcweir
operator =(const ImpGraphic & rImpGraphic)273cdf0e10cSrcweir ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir if( &rImpGraphic != this )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir if( !mbSwapUnderway )
278cdf0e10cSrcweir ImplClear();
279cdf0e10cSrcweir
280cdf0e10cSrcweir maMetaFile = rImpGraphic.maMetaFile;
281cdf0e10cSrcweir meType = rImpGraphic.meType;
282cdf0e10cSrcweir mnSizeBytes = rImpGraphic.mnSizeBytes;
283cdf0e10cSrcweir
284cdf0e10cSrcweir delete mpAnimation;
285cdf0e10cSrcweir
286cdf0e10cSrcweir if ( rImpGraphic.mpAnimation )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir mpAnimation = new Animation( *rImpGraphic.mpAnimation );
289cdf0e10cSrcweir maEx = mpAnimation->GetBitmapEx();
290cdf0e10cSrcweir }
291cdf0e10cSrcweir else
292cdf0e10cSrcweir {
293cdf0e10cSrcweir mpAnimation = NULL;
294cdf0e10cSrcweir maEx = rImpGraphic.maEx;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
297cdf0e10cSrcweir if( !mbSwapUnderway )
298cdf0e10cSrcweir {
299cdf0e10cSrcweir maDocFileURLStr = rImpGraphic.maDocFileURLStr;
300cdf0e10cSrcweir mnDocFilePos = rImpGraphic.mnDocFilePos;
301cdf0e10cSrcweir mbSwapOut = rImpGraphic.mbSwapOut;
302cdf0e10cSrcweir mpSwapFile = rImpGraphic.mpSwapFile;
303cdf0e10cSrcweir
304cdf0e10cSrcweir if( mpSwapFile )
305cdf0e10cSrcweir mpSwapFile->nRefCount++;
306cdf0e10cSrcweir }
307cdf0e10cSrcweir
308cdf0e10cSrcweir delete mpGfxLink;
309cdf0e10cSrcweir
310cdf0e10cSrcweir if( rImpGraphic.mpGfxLink )
311cdf0e10cSrcweir mpGfxLink = new GfxLink( *rImpGraphic.mpGfxLink );
312cdf0e10cSrcweir else
313cdf0e10cSrcweir mpGfxLink = NULL;
314ddde725dSArmin Le Grand
315ddde725dSArmin Le Grand maSvgData = rImpGraphic.maSvgData;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir return *this;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir // ------------------------------------------------------------------------
322cdf0e10cSrcweir
operator ==(const ImpGraphic & rImpGraphic) const323cdf0e10cSrcweir sal_Bool ImpGraphic::operator==( const ImpGraphic& rImpGraphic ) const
324cdf0e10cSrcweir {
325cdf0e10cSrcweir sal_Bool bRet = sal_False;
326cdf0e10cSrcweir
327cdf0e10cSrcweir if( this == &rImpGraphic )
328cdf0e10cSrcweir bRet = sal_True;
329cdf0e10cSrcweir else if( !ImplIsSwapOut() && ( rImpGraphic.meType == meType ) )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir switch( meType )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir case( GRAPHIC_NONE ):
334cdf0e10cSrcweir bRet = sal_True;
335cdf0e10cSrcweir break;
336cdf0e10cSrcweir
337cdf0e10cSrcweir case( GRAPHIC_GDIMETAFILE ):
338cdf0e10cSrcweir {
339cdf0e10cSrcweir if( rImpGraphic.maMetaFile == maMetaFile )
340cdf0e10cSrcweir bRet = sal_True;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir break;
343cdf0e10cSrcweir
344cdf0e10cSrcweir case( GRAPHIC_BITMAP ):
345cdf0e10cSrcweir {
346ddde725dSArmin Le Grand if(maSvgData.get())
347ddde725dSArmin Le Grand {
348ddde725dSArmin Le Grand if(maSvgData == rImpGraphic.maSvgData)
349ddde725dSArmin Le Grand {
350ddde725dSArmin Le Grand bRet = sal_True;
351ddde725dSArmin Le Grand }
352ddde725dSArmin Le Grand else if(rImpGraphic.maSvgData)
353ddde725dSArmin Le Grand {
354ddde725dSArmin Le Grand if(maSvgData->getSvgDataArrayLength() == rImpGraphic.maSvgData->getSvgDataArrayLength())
355ddde725dSArmin Le Grand {
356ddde725dSArmin Le Grand if(0 == memcmp(
357ddde725dSArmin Le Grand maSvgData->getSvgDataArray().get(),
358ddde725dSArmin Le Grand rImpGraphic.maSvgData->getSvgDataArray().get(),
359ddde725dSArmin Le Grand maSvgData->getSvgDataArrayLength()))
360ddde725dSArmin Le Grand {
361ddde725dSArmin Le Grand bRet = sal_True;
362ddde725dSArmin Le Grand }
363ddde725dSArmin Le Grand }
364ddde725dSArmin Le Grand }
365ddde725dSArmin Le Grand }
366ddde725dSArmin Le Grand else if( mpAnimation )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir if( rImpGraphic.mpAnimation && ( *rImpGraphic.mpAnimation == *mpAnimation ) )
369cdf0e10cSrcweir bRet = sal_True;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir else if( !rImpGraphic.mpAnimation && ( rImpGraphic.maEx == maEx ) )
372ddde725dSArmin Le Grand {
373cdf0e10cSrcweir bRet = sal_True;
374ddde725dSArmin Le Grand }
375cdf0e10cSrcweir }
376cdf0e10cSrcweir break;
377cdf0e10cSrcweir
378cdf0e10cSrcweir default:
379cdf0e10cSrcweir break;
380cdf0e10cSrcweir }
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir return bRet;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
386cdf0e10cSrcweir // ------------------------------------------------------------------------
387cdf0e10cSrcweir
ImplClearGraphics(sal_Bool bCreateSwapInfo)388cdf0e10cSrcweir void ImpGraphic::ImplClearGraphics( sal_Bool bCreateSwapInfo )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir if( bCreateSwapInfo && !ImplIsSwapOut() )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir maSwapInfo.maPrefMapMode = ImplGetPrefMapMode();
393cdf0e10cSrcweir maSwapInfo.maPrefSize = ImplGetPrefSize();
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
396cdf0e10cSrcweir maEx.Clear();
397cdf0e10cSrcweir maMetaFile.Clear();
398cdf0e10cSrcweir
399cdf0e10cSrcweir if( mpAnimation )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir mpAnimation->Clear();
402cdf0e10cSrcweir delete mpAnimation;
403cdf0e10cSrcweir mpAnimation = NULL;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir if( mpGfxLink )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir delete mpGfxLink;
409cdf0e10cSrcweir mpGfxLink = NULL;
410cdf0e10cSrcweir }
411ddde725dSArmin Le Grand
412ddde725dSArmin Le Grand maSvgData.reset();
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir // ------------------------------------------------------------------------
416cdf0e10cSrcweir
ImplClear()417cdf0e10cSrcweir void ImpGraphic::ImplClear()
418cdf0e10cSrcweir {
419cdf0e10cSrcweir if( mpSwapFile )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir if( mpSwapFile->nRefCount > 1 )
422cdf0e10cSrcweir mpSwapFile->nRefCount--;
423cdf0e10cSrcweir else
424cdf0e10cSrcweir {
425cdf0e10cSrcweir try
426cdf0e10cSrcweir {
427cdf0e10cSrcweir ::ucbhelper::Content aCnt( mpSwapFile->aSwapURL.GetMainURL( INetURLObject::NO_DECODE ),
428cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
429cdf0e10cSrcweir
430cdf0e10cSrcweir aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ),
431cdf0e10cSrcweir ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
432cdf0e10cSrcweir }
433cdf0e10cSrcweir catch( const ::com::sun::star::ucb::ContentCreationException& )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir }
436cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir }
439cdf0e10cSrcweir catch( const ::com::sun::star::ucb::CommandAbortedException& )
440cdf0e10cSrcweir {
441cdf0e10cSrcweir }
442cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
446cdf0e10cSrcweir delete mpSwapFile;
447cdf0e10cSrcweir }
448cdf0e10cSrcweir
449cdf0e10cSrcweir mpSwapFile = NULL;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
452cdf0e10cSrcweir mbSwapOut = sal_False;
453cdf0e10cSrcweir mnDocFilePos = 0UL;
454cdf0e10cSrcweir maDocFileURLStr.Erase();
455cdf0e10cSrcweir
456cdf0e10cSrcweir // cleanup
457cdf0e10cSrcweir ImplClearGraphics( sal_False );
458cdf0e10cSrcweir meType = GRAPHIC_NONE;
459cdf0e10cSrcweir mnSizeBytes = 0;
460cdf0e10cSrcweir }
461cdf0e10cSrcweir
462cdf0e10cSrcweir // ------------------------------------------------------------------------
463cdf0e10cSrcweir
ImplGetType() const464cdf0e10cSrcweir GraphicType ImpGraphic::ImplGetType() const
465cdf0e10cSrcweir {
466cdf0e10cSrcweir return meType;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir
469cdf0e10cSrcweir // ------------------------------------------------------------------------
470cdf0e10cSrcweir
ImplSetDefaultType()471cdf0e10cSrcweir void ImpGraphic::ImplSetDefaultType()
472cdf0e10cSrcweir {
473cdf0e10cSrcweir ImplClear();
474cdf0e10cSrcweir meType = GRAPHIC_DEFAULT;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
477cdf0e10cSrcweir // ------------------------------------------------------------------------
478cdf0e10cSrcweir
ImplIsSupportedGraphic() const479cdf0e10cSrcweir sal_Bool ImpGraphic::ImplIsSupportedGraphic() const
480cdf0e10cSrcweir {
481cdf0e10cSrcweir return( meType != GRAPHIC_NONE );
482cdf0e10cSrcweir }
483cdf0e10cSrcweir
484cdf0e10cSrcweir // ------------------------------------------------------------------------
485cdf0e10cSrcweir
ImplIsTransparent() const486cdf0e10cSrcweir sal_Bool ImpGraphic::ImplIsTransparent() const
487cdf0e10cSrcweir {
488ddde725dSArmin Le Grand sal_Bool bRet(sal_True);
489cdf0e10cSrcweir
490ddde725dSArmin Le Grand if( meType == GRAPHIC_BITMAP && !maSvgData.get())
491ddde725dSArmin Le Grand {
492cdf0e10cSrcweir bRet = ( mpAnimation ? mpAnimation->IsTransparent() : maEx.IsTransparent() );
493ddde725dSArmin Le Grand }
494cdf0e10cSrcweir
495cdf0e10cSrcweir return bRet;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir
498cdf0e10cSrcweir // ------------------------------------------------------------------------
499cdf0e10cSrcweir
ImplIsAlpha() const500cdf0e10cSrcweir sal_Bool ImpGraphic::ImplIsAlpha() const
501cdf0e10cSrcweir {
502ddde725dSArmin Le Grand sal_Bool bRet(sal_False);
503cdf0e10cSrcweir
504ddde725dSArmin Le Grand if(maSvgData.get())
505ddde725dSArmin Le Grand {
506ddde725dSArmin Le Grand bRet = sal_True;
507ddde725dSArmin Le Grand }
508ddde725dSArmin Le Grand else if( meType == GRAPHIC_BITMAP )
509ddde725dSArmin Le Grand {
510cdf0e10cSrcweir bRet = ( NULL == mpAnimation ) && maEx.IsAlpha();
511ddde725dSArmin Le Grand }
512cdf0e10cSrcweir
513cdf0e10cSrcweir return bRet;
514cdf0e10cSrcweir }
515cdf0e10cSrcweir
516cdf0e10cSrcweir // ------------------------------------------------------------------------
517cdf0e10cSrcweir
ImplIsAnimated() const518cdf0e10cSrcweir sal_Bool ImpGraphic::ImplIsAnimated() const
519cdf0e10cSrcweir {
520cdf0e10cSrcweir return( mpAnimation != NULL );
521cdf0e10cSrcweir }
522cdf0e10cSrcweir
523cdf0e10cSrcweir // ------------------------------------------------------------------------
524cdf0e10cSrcweir
ImplIsEPS() const525cdf0e10cSrcweir sal_Bool ImpGraphic::ImplIsEPS() const
526cdf0e10cSrcweir {
527cdf0e10cSrcweir return( ( meType == GRAPHIC_GDIMETAFILE ) &&
528cdf0e10cSrcweir ( maMetaFile.GetActionCount() > 0 ) &&
529cdf0e10cSrcweir ( maMetaFile.GetAction( 0 )->GetType() == META_EPS_ACTION ) );
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir // ------------------------------------------------------------------------
533cdf0e10cSrcweir
ImplGetBitmap(const GraphicConversionParameters & rParameters) const534cdf0e10cSrcweir Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) const
535cdf0e10cSrcweir {
536cdf0e10cSrcweir Bitmap aRetBmp;
537cdf0e10cSrcweir
538cdf0e10cSrcweir if( meType == GRAPHIC_BITMAP )
539cdf0e10cSrcweir {
540ddde725dSArmin Le Grand if(maSvgData.get() && maEx.IsEmpty())
541ddde725dSArmin Le Grand {
542ddde725dSArmin Le Grand // use maEx as local buffer for rendered svg
543ddde725dSArmin Le Grand const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
544ddde725dSArmin Le Grand }
545ddde725dSArmin Le Grand
546cdf0e10cSrcweir const BitmapEx& rRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
547cdf0e10cSrcweir const Color aReplaceColor( COL_WHITE );
548cdf0e10cSrcweir
549cdf0e10cSrcweir aRetBmp = rRetBmpEx.GetBitmap( &aReplaceColor );
550cdf0e10cSrcweir
551cdf0e10cSrcweir if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
552cdf0e10cSrcweir aRetBmp.Scale(rParameters.getSizePixel());
553cdf0e10cSrcweir }
554cdf0e10cSrcweir else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
555cdf0e10cSrcweir {
556ff494be3SArmin Le Grand if(maEx.IsEmpty())
557cdf0e10cSrcweir {
558ff494be3SArmin Le Grand // calculate size
559ff494be3SArmin Le Grand VirtualDevice aVDev;
560ff494be3SArmin Le Grand Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
561bb18ee55SArmin Le Grand
562ff494be3SArmin Le Grand if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
563bb18ee55SArmin Le Grand {
564ff494be3SArmin Le Grand // apply given size if exists
565ff494be3SArmin Le Grand aDrawSize = rParameters.getSizePixel();
566bb18ee55SArmin Le Grand }
567ff494be3SArmin Le Grand
568ff494be3SArmin Le Grand if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize()
569ff494be3SArmin Le Grand && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT))
570bb18ee55SArmin Le Grand {
571ff494be3SArmin Le Grand // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT
572ff494be3SArmin Le Grand double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height());
573ff494be3SArmin Le Grand
574ff494be3SArmin Le Grand if(fWH <= 1.0)
575ff494be3SArmin Le Grand {
576ff494be3SArmin Le Grand aDrawSize.setWidth(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT * fWH));
577ff494be3SArmin Le Grand aDrawSize.setHeight(GRAPHIC_MTFTOBMP_MAXEXT);
578ff494be3SArmin Le Grand }
579ff494be3SArmin Le Grand else
580ff494be3SArmin Le Grand {
581ff494be3SArmin Le Grand aDrawSize.setWidth(GRAPHIC_MTFTOBMP_MAXEXT);
582ff494be3SArmin Le Grand aDrawSize.setHeight(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT / fWH));
583ff494be3SArmin Le Grand }
584bb18ee55SArmin Le Grand }
585cdf0e10cSrcweir
586ff494be3SArmin Le Grand // calculate pixel size. Normally, it's the same as aDrawSize, but may
587ff494be3SArmin Le Grand // need to be extended when hairlines are on the right or bottom edge
588ff494be3SArmin Le Grand Size aPixelSize(aDrawSize);
589bb18ee55SArmin Le Grand
590ff494be3SArmin Le Grand if(GRAPHIC_GDIMETAFILE == ImplGetType())
591ff494be3SArmin Le Grand {
592ff494be3SArmin Le Grand // get hairline and full bound rect
593ff494be3SArmin Le Grand Rectangle aHairlineRect;
594ff494be3SArmin Le Grand const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect));
595ff494be3SArmin Le Grand
596ff494be3SArmin Le Grand if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty())
597ff494be3SArmin Le Grand {
598ff494be3SArmin Le Grand // expand if needed to allow bottom and right hairlines to be added
599ff494be3SArmin Le Grand if(aRect.Right() == aHairlineRect.Right())
600ff494be3SArmin Le Grand {
601ff494be3SArmin Le Grand aPixelSize.setWidth(aPixelSize.getWidth() + 1);
602ff494be3SArmin Le Grand }
603cdf0e10cSrcweir
604ff494be3SArmin Le Grand if(aRect.Bottom() == aHairlineRect.Bottom())
605ff494be3SArmin Le Grand {
606ff494be3SArmin Le Grand aPixelSize.setHeight(aPixelSize.getHeight() + 1);
607ff494be3SArmin Le Grand }
608ff494be3SArmin Le Grand }
609ff494be3SArmin Le Grand }
610ff494be3SArmin Le Grand
611ff494be3SArmin Le Grand if(aVDev.SetOutputSizePixel(aPixelSize))
612bb18ee55SArmin Le Grand {
613ff494be3SArmin Le Grand if(rParameters.getAntiAliase())
614bb18ee55SArmin Le Grand {
615ff494be3SArmin Le Grand aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
616bb18ee55SArmin Le Grand }
617cdf0e10cSrcweir
618ff494be3SArmin Le Grand if(rParameters.getSnapHorVerLines())
619bb18ee55SArmin Le Grand {
620ff494be3SArmin Le Grand aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE);
621bb18ee55SArmin Le Grand }
622cdf0e10cSrcweir
623ff494be3SArmin Le Grand ImplDraw( &aVDev, Point(), aDrawSize );
624cdf0e10cSrcweir
625ff494be3SArmin Le Grand // use maEx as local buffer for rendered metafile
626ff494be3SArmin Le Grand const_cast< ImpGraphic* >(this)->maEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
627cdf0e10cSrcweir }
628cdf0e10cSrcweir }
629ff494be3SArmin Le Grand
630ff494be3SArmin Le Grand aRetBmp = maEx.GetBitmap();
631cdf0e10cSrcweir }
632cdf0e10cSrcweir
633cdf0e10cSrcweir if( !!aRetBmp )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir aRetBmp.SetPrefMapMode( ImplGetPrefMapMode() );
636cdf0e10cSrcweir aRetBmp.SetPrefSize( ImplGetPrefSize() );
637cdf0e10cSrcweir }
638cdf0e10cSrcweir
639cdf0e10cSrcweir return aRetBmp;
640cdf0e10cSrcweir }
641cdf0e10cSrcweir
642cdf0e10cSrcweir // ------------------------------------------------------------------------
643cdf0e10cSrcweir
ImplGetBitmapEx(const GraphicConversionParameters & rParameters) const644cdf0e10cSrcweir BitmapEx ImpGraphic::ImplGetBitmapEx(const GraphicConversionParameters& rParameters) const
645cdf0e10cSrcweir {
646cdf0e10cSrcweir BitmapEx aRetBmpEx;
647cdf0e10cSrcweir
648cdf0e10cSrcweir if( meType == GRAPHIC_BITMAP )
649cdf0e10cSrcweir {
650ddde725dSArmin Le Grand if(maSvgData.get() && maEx.IsEmpty())
651ddde725dSArmin Le Grand {
652ddde725dSArmin Le Grand // use maEx as local buffer for rendered svg
653ddde725dSArmin Le Grand const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
654ddde725dSArmin Le Grand }
655ddde725dSArmin Le Grand
656cdf0e10cSrcweir aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
657cdf0e10cSrcweir
658cdf0e10cSrcweir if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
659035a2f44SArmin Le Grand {
660035a2f44SArmin Le Grand aRetBmpEx.Scale(
661035a2f44SArmin Le Grand rParameters.getSizePixel(),
66237ab0f2dSArmin Le Grand rParameters.getScaleHighQuality() ? BMP_SCALE_BESTQUALITY : BMP_SCALE_FASTESTINTERPOLATE);
663035a2f44SArmin Le Grand }
664cdf0e10cSrcweir }
665cdf0e10cSrcweir else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
666cdf0e10cSrcweir {
667ff494be3SArmin Le Grand if(maEx.IsEmpty())
668ff494be3SArmin Le Grand {
669ff494be3SArmin Le Grand const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) );
670ff494be3SArmin Le Grand
671ff494be3SArmin Le Grand // use maEx as local buffer for rendered metafile
672ff494be3SArmin Le Grand const_cast< ImpGraphic* >(this)->maEx = BitmapEx(ImplGetBitmap(rParameters), aMonoMask.ImplGetBitmap(rParameters));
673ff494be3SArmin Le Grand }
674ff494be3SArmin Le Grand
675ff494be3SArmin Le Grand aRetBmpEx = maEx;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir
678cdf0e10cSrcweir return aRetBmpEx;
679cdf0e10cSrcweir }
680cdf0e10cSrcweir
681cdf0e10cSrcweir // ------------------------------------------------------------------------
682cdf0e10cSrcweir
ImplGetAnimation() const683cdf0e10cSrcweir Animation ImpGraphic::ImplGetAnimation() const
684cdf0e10cSrcweir {
685cdf0e10cSrcweir Animation aAnimation;
686cdf0e10cSrcweir
687cdf0e10cSrcweir if( mpAnimation )
688cdf0e10cSrcweir aAnimation = *mpAnimation;
689cdf0e10cSrcweir
690cdf0e10cSrcweir return aAnimation;
691cdf0e10cSrcweir }
692cdf0e10cSrcweir
693cdf0e10cSrcweir // ------------------------------------------------------------------------
694cdf0e10cSrcweir
ImplGetGDIMetaFile() const695cdf0e10cSrcweir const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const
696cdf0e10cSrcweir {
697cb0a2370SArmin Le Grand if(GRAPHIC_BITMAP == meType && !maMetaFile.GetActionCount())
698cb0a2370SArmin Le Grand {
699cb0a2370SArmin Le Grand // #119735#
700cb0a2370SArmin Le Grand // Use the local maMetaFile as container for a metafile-representation
701cb0a2370SArmin Le Grand // of the bitmap graphic. This will be done only once, thus be buffered.
702cb0a2370SArmin Le Grand // I checked all usages of maMetaFile, it is only used when type is not
703cb0a2370SArmin Le Grand // GRAPHIC_BITMAP. In operator= it will get copied, thus buffering will
704cb0a2370SArmin Le Grand // survive copying (change this if not wanted)
705cb0a2370SArmin Le Grand ImpGraphic* pThat = const_cast< ImpGraphic* >(this);
706cb0a2370SArmin Le Grand
707cb0a2370SArmin Le Grand if(maSvgData.get() && !maEx)
708cb0a2370SArmin Le Grand {
709cb0a2370SArmin Le Grand // use maEx as local buffer for rendered svg
710cb0a2370SArmin Le Grand pThat->maEx = maSvgData->getReplacement();
711cb0a2370SArmin Le Grand }
712cb0a2370SArmin Le Grand
713*16ea1aebSArmin Le Grand // #123983# directly create a metafile with the same PrefSize and PrefMapMode
714*16ea1aebSArmin Le Grand // the bitmap has, this will be an always correct metafile
715cb0a2370SArmin Le Grand if(maEx.IsTransparent())
716cb0a2370SArmin Le Grand {
717*16ea1aebSArmin Le Grand pThat->maMetaFile.AddAction(new MetaBmpExScaleAction(Point(), maEx.GetPrefSize(), maEx));
718cb0a2370SArmin Le Grand }
719cb0a2370SArmin Le Grand else
720cb0a2370SArmin Le Grand {
721*16ea1aebSArmin Le Grand pThat->maMetaFile.AddAction(new MetaBmpScaleAction(Point(), maEx.GetPrefSize(), maEx.GetBitmap()));
722cb0a2370SArmin Le Grand }
723cb0a2370SArmin Le Grand
724*16ea1aebSArmin Le Grand pThat->maMetaFile.Stop();
725*16ea1aebSArmin Le Grand pThat->maMetaFile.WindStart();
726*16ea1aebSArmin Le Grand pThat->maMetaFile.SetPrefSize(maEx.GetPrefSize());
727*16ea1aebSArmin Le Grand pThat->maMetaFile.SetPrefMapMode(maEx.GetPrefMapMode());
728cb0a2370SArmin Le Grand }
729cb0a2370SArmin Le Grand
730cb0a2370SArmin Le Grand return maMetaFile;
731cdf0e10cSrcweir }
732cdf0e10cSrcweir
733cdf0e10cSrcweir // ------------------------------------------------------------------------
734cdf0e10cSrcweir
ImplGetPrefSize() const735cdf0e10cSrcweir Size ImpGraphic::ImplGetPrefSize() const
736cdf0e10cSrcweir {
737cdf0e10cSrcweir Size aSize;
738cdf0e10cSrcweir
739cdf0e10cSrcweir if( ImplIsSwapOut() )
740cdf0e10cSrcweir aSize = maSwapInfo.maPrefSize;
741cdf0e10cSrcweir else
742cdf0e10cSrcweir {
743cdf0e10cSrcweir switch( meType )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir case( GRAPHIC_NONE ):
746cdf0e10cSrcweir case( GRAPHIC_DEFAULT ):
747cdf0e10cSrcweir break;
748cdf0e10cSrcweir
749cdf0e10cSrcweir case( GRAPHIC_BITMAP ):
750cdf0e10cSrcweir {
751ddde725dSArmin Le Grand if(maSvgData.get() && maEx.IsEmpty())
752ddde725dSArmin Le Grand {
753ddde725dSArmin Le Grand // svg not yet buffered in maEx, return size derived from range
754ddde725dSArmin Le Grand const basegfx::B2DRange& rRange = maSvgData->getRange();
755ddde725dSArmin Le Grand
756ddde725dSArmin Le Grand aSize = Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight()));
757ddde725dSArmin Le Grand }
758ddde725dSArmin Le Grand else
759ddde725dSArmin Le Grand {
760ddde725dSArmin Le Grand aSize = maEx.GetPrefSize();
761ddde725dSArmin Le Grand
762ddde725dSArmin Le Grand if( !aSize.Width() || !aSize.Height() )
763ddde725dSArmin Le Grand {
764ddde725dSArmin Le Grand aSize = maEx.GetSizePixel();
765ddde725dSArmin Le Grand }
766ddde725dSArmin Le Grand }
767cdf0e10cSrcweir }
768cdf0e10cSrcweir break;
769cdf0e10cSrcweir
770cdf0e10cSrcweir default:
771cdf0e10cSrcweir {
772cdf0e10cSrcweir if( ImplIsSupportedGraphic() )
773cdf0e10cSrcweir aSize = maMetaFile.GetPrefSize();
774cdf0e10cSrcweir }
775cdf0e10cSrcweir break;
776cdf0e10cSrcweir }
777cdf0e10cSrcweir }
778cdf0e10cSrcweir
779cdf0e10cSrcweir return aSize;
780cdf0e10cSrcweir }
781cdf0e10cSrcweir
782cdf0e10cSrcweir // ------------------------------------------------------------------------
783cdf0e10cSrcweir
ImplSetPrefSize(const Size & rPrefSize)784cdf0e10cSrcweir void ImpGraphic::ImplSetPrefSize( const Size& rPrefSize )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir switch( meType )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir case( GRAPHIC_NONE ):
789cdf0e10cSrcweir case( GRAPHIC_DEFAULT ):
790cdf0e10cSrcweir break;
791cdf0e10cSrcweir
792cdf0e10cSrcweir case( GRAPHIC_BITMAP ):
793ddde725dSArmin Le Grand {
794cdf0e10cSrcweir // #108077# Push through pref size to animation object,
795cdf0e10cSrcweir // will be lost on copy otherwise
796ddde725dSArmin Le Grand if(maSvgData.get())
797ddde725dSArmin Le Grand {
798ddde725dSArmin Le Grand // ignore for Svg. If this is really used (except the grfcache)
799ddde725dSArmin Le Grand // it can be extended by using maEx as buffer for maSvgData->getReplacement()
800ddde725dSArmin Le Grand }
801ddde725dSArmin Le Grand else
802ddde725dSArmin Le Grand {
803ddde725dSArmin Le Grand if( ImplIsAnimated() )
804ddde725dSArmin Le Grand {
805ddde725dSArmin Le Grand const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefSize( rPrefSize );
806ddde725dSArmin Le Grand }
807cdf0e10cSrcweir
808ddde725dSArmin Le Grand maEx.SetPrefSize( rPrefSize );
809ddde725dSArmin Le Grand }
810ddde725dSArmin Le Grand }
811cdf0e10cSrcweir break;
812cdf0e10cSrcweir
813cdf0e10cSrcweir default:
814cdf0e10cSrcweir {
815cdf0e10cSrcweir if( ImplIsSupportedGraphic() )
816cdf0e10cSrcweir maMetaFile.SetPrefSize( rPrefSize );
817cdf0e10cSrcweir }
818cdf0e10cSrcweir break;
819cdf0e10cSrcweir }
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
822cdf0e10cSrcweir // ------------------------------------------------------------------------
823cdf0e10cSrcweir
ImplGetPrefMapMode() const824cdf0e10cSrcweir MapMode ImpGraphic::ImplGetPrefMapMode() const
825cdf0e10cSrcweir {
826cdf0e10cSrcweir MapMode aMapMode;
827cdf0e10cSrcweir
828cdf0e10cSrcweir if( ImplIsSwapOut() )
829cdf0e10cSrcweir aMapMode = maSwapInfo.maPrefMapMode;
830cdf0e10cSrcweir else
831cdf0e10cSrcweir {
832cdf0e10cSrcweir switch( meType )
833cdf0e10cSrcweir {
834cdf0e10cSrcweir case( GRAPHIC_NONE ):
835cdf0e10cSrcweir case( GRAPHIC_DEFAULT ):
836cdf0e10cSrcweir break;
837cdf0e10cSrcweir
838cdf0e10cSrcweir case( GRAPHIC_BITMAP ):
839cdf0e10cSrcweir {
840ddde725dSArmin Le Grand if(maSvgData.get() && maEx.IsEmpty())
841ddde725dSArmin Le Grand {
842ddde725dSArmin Le Grand // svg not yet buffered in maEx, return default PrefMapMode
843ddde725dSArmin Le Grand aMapMode = MapMode(MAP_100TH_MM);
844ddde725dSArmin Le Grand }
845ddde725dSArmin Le Grand else
846ddde725dSArmin Le Grand {
847ddde725dSArmin Le Grand const Size aSize( maEx.GetPrefSize() );
848ddde725dSArmin Le Grand
849ddde725dSArmin Le Grand if ( aSize.Width() && aSize.Height() )
850ddde725dSArmin Le Grand aMapMode = maEx.GetPrefMapMode();
851ddde725dSArmin Le Grand }
852cdf0e10cSrcweir }
853cdf0e10cSrcweir break;
854cdf0e10cSrcweir
855cdf0e10cSrcweir default:
856cdf0e10cSrcweir {
857cdf0e10cSrcweir if( ImplIsSupportedGraphic() )
858cdf0e10cSrcweir return maMetaFile.GetPrefMapMode();
859cdf0e10cSrcweir }
860cdf0e10cSrcweir break;
861cdf0e10cSrcweir }
862cdf0e10cSrcweir }
863cdf0e10cSrcweir
864cdf0e10cSrcweir return aMapMode;
865cdf0e10cSrcweir }
866cdf0e10cSrcweir
867cdf0e10cSrcweir // ------------------------------------------------------------------------
868cdf0e10cSrcweir
ImplSetPrefMapMode(const MapMode & rPrefMapMode)869cdf0e10cSrcweir void ImpGraphic::ImplSetPrefMapMode( const MapMode& rPrefMapMode )
870cdf0e10cSrcweir {
871cdf0e10cSrcweir switch( meType )
872cdf0e10cSrcweir {
873cdf0e10cSrcweir case( GRAPHIC_NONE ):
874cdf0e10cSrcweir case( GRAPHIC_DEFAULT ):
875cdf0e10cSrcweir break;
876cdf0e10cSrcweir
877cdf0e10cSrcweir case( GRAPHIC_BITMAP ):
878ddde725dSArmin Le Grand {
879ddde725dSArmin Le Grand if(maSvgData.get())
880ddde725dSArmin Le Grand {
881ddde725dSArmin Le Grand // ignore for Svg. If this is really used (except the grfcache)
882ddde725dSArmin Le Grand // it can be extended by using maEx as buffer for maSvgData->getReplacement()
883ddde725dSArmin Le Grand }
884ddde725dSArmin Le Grand else
885ddde725dSArmin Le Grand {
886ddde725dSArmin Le Grand // #108077# Push through pref mapmode to animation object,
887ddde725dSArmin Le Grand // will be lost on copy otherwise
888ddde725dSArmin Le Grand if( ImplIsAnimated() )
889ddde725dSArmin Le Grand {
890ddde725dSArmin Le Grand const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefMapMode( rPrefMapMode );
891ddde725dSArmin Le Grand }
892ddde725dSArmin Le Grand
893ddde725dSArmin Le Grand maEx.SetPrefMapMode( rPrefMapMode );
894ddde725dSArmin Le Grand }
895ddde725dSArmin Le Grand }
896cdf0e10cSrcweir break;
897cdf0e10cSrcweir
898cdf0e10cSrcweir default:
899cdf0e10cSrcweir {
900cdf0e10cSrcweir if( ImplIsSupportedGraphic() )
901cdf0e10cSrcweir maMetaFile.SetPrefMapMode( rPrefMapMode );
902cdf0e10cSrcweir }
903cdf0e10cSrcweir break;
904cdf0e10cSrcweir }
905cdf0e10cSrcweir }
906cdf0e10cSrcweir
907cdf0e10cSrcweir // ------------------------------------------------------------------------
908cdf0e10cSrcweir
ImplGetSizeBytes() const909cdf0e10cSrcweir sal_uLong ImpGraphic::ImplGetSizeBytes() const
910cdf0e10cSrcweir {
911cdf0e10cSrcweir if( 0 == mnSizeBytes )
912cdf0e10cSrcweir {
913cdf0e10cSrcweir if( meType == GRAPHIC_BITMAP )
914cdf0e10cSrcweir {
915ddde725dSArmin Le Grand if(maSvgData.get())
916ddde725dSArmin Le Grand {
917ddde725dSArmin Le Grand mnSizeBytes = maSvgData->getSvgDataArrayLength();
918ddde725dSArmin Le Grand }
919ddde725dSArmin Le Grand else
920ddde725dSArmin Le Grand {
921ddde725dSArmin Le Grand mnSizeBytes = mpAnimation ? mpAnimation->GetSizeBytes() : maEx.GetSizeBytes();
922ddde725dSArmin Le Grand }
923cdf0e10cSrcweir }
924cdf0e10cSrcweir else if( meType == GRAPHIC_GDIMETAFILE )
925cdf0e10cSrcweir {
926cdf0e10cSrcweir mnSizeBytes = maMetaFile.GetSizeBytes();
927cdf0e10cSrcweir }
928cdf0e10cSrcweir }
929cdf0e10cSrcweir
930cdf0e10cSrcweir return( mnSizeBytes );
931cdf0e10cSrcweir }
932cdf0e10cSrcweir
933cdf0e10cSrcweir // ------------------------------------------------------------------------
934cdf0e10cSrcweir
ImplDraw(OutputDevice * pOutDev,const Point & rDestPt) const935cdf0e10cSrcweir void ImpGraphic::ImplDraw( OutputDevice* pOutDev, const Point& rDestPt ) const
936cdf0e10cSrcweir {
937cdf0e10cSrcweir if( ImplIsSupportedGraphic() && !ImplIsSwapOut() )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir switch( meType )
940cdf0e10cSrcweir {
941cdf0e10cSrcweir case( GRAPHIC_DEFAULT ):
942cdf0e10cSrcweir break;
943cdf0e10cSrcweir
944cdf0e10cSrcweir case( GRAPHIC_BITMAP ):
945cdf0e10cSrcweir {
946ddde725dSArmin Le Grand if(maSvgData.get() && !maEx)
947ddde725dSArmin Le Grand {
948ddde725dSArmin Le Grand // use maEx as local buffer for rendered svg
949ddde725dSArmin Le Grand const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
950ddde725dSArmin Le Grand }
951ddde725dSArmin Le Grand
952ddde725dSArmin Le Grand if ( mpAnimation )
953ddde725dSArmin Le Grand {
954cdf0e10cSrcweir mpAnimation->Draw( pOutDev, rDestPt );
955ddde725dSArmin Le Grand }
956cdf0e10cSrcweir else
957ddde725dSArmin Le Grand {
958cdf0e10cSrcweir maEx.Draw( pOutDev, rDestPt );
959ddde725dSArmin Le Grand }
960cdf0e10cSrcweir }
961cdf0e10cSrcweir break;
962cdf0e10cSrcweir
963cdf0e10cSrcweir default:
964cdf0e10cSrcweir ImplDraw( pOutDev, rDestPt, maMetaFile.GetPrefSize() );
965cdf0e10cSrcweir break;
966cdf0e10cSrcweir }
967cdf0e10cSrcweir }
968cdf0e10cSrcweir }
969cdf0e10cSrcweir
970cdf0e10cSrcweir // ------------------------------------------------------------------------
971cdf0e10cSrcweir
ImplDraw(OutputDevice * pOutDev,const Point & rDestPt,const Size & rDestSize) const972cdf0e10cSrcweir void ImpGraphic::ImplDraw( OutputDevice* pOutDev,
973cdf0e10cSrcweir const Point& rDestPt, const Size& rDestSize ) const
974cdf0e10cSrcweir {
975cdf0e10cSrcweir if( ImplIsSupportedGraphic() && !ImplIsSwapOut() )
976cdf0e10cSrcweir {
977cdf0e10cSrcweir switch( meType )
978cdf0e10cSrcweir {
979cdf0e10cSrcweir case( GRAPHIC_DEFAULT ):
980cdf0e10cSrcweir break;
981cdf0e10cSrcweir
982cdf0e10cSrcweir case( GRAPHIC_BITMAP ):
983cdf0e10cSrcweir {
984ddde725dSArmin Le Grand if(maSvgData.get() && maEx.IsEmpty())
985ddde725dSArmin Le Grand {
986ddde725dSArmin Le Grand // use maEx as local buffer for rendered svg
987ddde725dSArmin Le Grand const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
988ddde725dSArmin Le Grand }
989ddde725dSArmin Le Grand
990ddde725dSArmin Le Grand if( mpAnimation )
991ddde725dSArmin Le Grand {
992cdf0e10cSrcweir mpAnimation->Draw( pOutDev, rDestPt, rDestSize );
993ddde725dSArmin Le Grand }
994cdf0e10cSrcweir else
995ddde725dSArmin Le Grand {
996cdf0e10cSrcweir maEx.Draw( pOutDev, rDestPt, rDestSize );
997ddde725dSArmin Le Grand }
998cdf0e10cSrcweir }
999cdf0e10cSrcweir break;
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir default:
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir ( (ImpGraphic*) this )->maMetaFile.WindStart();
1004cdf0e10cSrcweir ( (ImpGraphic*) this )->maMetaFile.Play( pOutDev, rDestPt, rDestSize );
1005cdf0e10cSrcweir ( (ImpGraphic*) this )->maMetaFile.WindStart();
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir break;
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir
1012cdf0e10cSrcweir // ------------------------------------------------------------------------
1013cdf0e10cSrcweir
ImplStartAnimation(OutputDevice * pOutDev,const Point & rDestPt,long nExtraData,OutputDevice * pFirstFrameOutDev)1014cdf0e10cSrcweir void ImpGraphic::ImplStartAnimation( OutputDevice* pOutDev,
1015cdf0e10cSrcweir const Point& rDestPt,
1016cdf0e10cSrcweir long nExtraData,
1017cdf0e10cSrcweir OutputDevice* pFirstFrameOutDev )
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir if( ImplIsSupportedGraphic() && !ImplIsSwapOut() && mpAnimation )
1020cdf0e10cSrcweir mpAnimation->Start( pOutDev, rDestPt, nExtraData, pFirstFrameOutDev );
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir
1023cdf0e10cSrcweir // ------------------------------------------------------------------------
1024cdf0e10cSrcweir
ImplStartAnimation(OutputDevice * pOutDev,const Point & rDestPt,const Size & rDestSize,long nExtraData,OutputDevice * pFirstFrameOutDev)1025cdf0e10cSrcweir void ImpGraphic::ImplStartAnimation( OutputDevice* pOutDev, const Point& rDestPt,
1026cdf0e10cSrcweir const Size& rDestSize, long nExtraData,
1027cdf0e10cSrcweir OutputDevice* pFirstFrameOutDev )
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir if( ImplIsSupportedGraphic() && !ImplIsSwapOut() && mpAnimation )
1030cdf0e10cSrcweir mpAnimation->Start( pOutDev, rDestPt, rDestSize, nExtraData, pFirstFrameOutDev );
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir // ------------------------------------------------------------------------
1034cdf0e10cSrcweir
ImplStopAnimation(OutputDevice * pOutDev,long nExtraData)1035cdf0e10cSrcweir void ImpGraphic::ImplStopAnimation( OutputDevice* pOutDev, long nExtraData )
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir if( ImplIsSupportedGraphic() && !ImplIsSwapOut() && mpAnimation )
1038cdf0e10cSrcweir mpAnimation->Stop( pOutDev, nExtraData );
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir // ------------------------------------------------------------------------
1042cdf0e10cSrcweir
ImplSetAnimationNotifyHdl(const Link & rLink)1043cdf0e10cSrcweir void ImpGraphic::ImplSetAnimationNotifyHdl( const Link& rLink )
1044cdf0e10cSrcweir {
1045cdf0e10cSrcweir if( mpAnimation )
1046cdf0e10cSrcweir mpAnimation->SetNotifyHdl( rLink );
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir // ------------------------------------------------------------------------
1050cdf0e10cSrcweir
ImplGetAnimationNotifyHdl() const1051cdf0e10cSrcweir Link ImpGraphic::ImplGetAnimationNotifyHdl() const
1052cdf0e10cSrcweir {
1053cdf0e10cSrcweir Link aLink;
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir if( mpAnimation )
1056cdf0e10cSrcweir aLink = mpAnimation->GetNotifyHdl();
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir return aLink;
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir // ------------------------------------------------------------------------
1062cdf0e10cSrcweir
ImplGetAnimationLoopCount() const1063cdf0e10cSrcweir sal_uLong ImpGraphic::ImplGetAnimationLoopCount() const
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir return( mpAnimation ? mpAnimation->GetLoopCount() : 0UL );
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir // ------------------------------------------------------------------------
1069cdf0e10cSrcweir
ImplResetAnimationLoopCount()1070cdf0e10cSrcweir void ImpGraphic::ImplResetAnimationLoopCount()
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir if( mpAnimation )
1073cdf0e10cSrcweir mpAnimation->ResetLoopCount();
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir // ------------------------------------------------------------------------
1077cdf0e10cSrcweir
ImplGetAnimationInfoList() const1078cdf0e10cSrcweir List* ImpGraphic::ImplGetAnimationInfoList() const
1079cdf0e10cSrcweir {
1080cdf0e10cSrcweir return( mpAnimation ? mpAnimation->GetAInfoList() : NULL );
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir // ------------------------------------------------------------------------
1084cdf0e10cSrcweir
ImplGetContext()1085cdf0e10cSrcweir GraphicReader* ImpGraphic::ImplGetContext()
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir return mpContext;
1088cdf0e10cSrcweir }
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir // ------------------------------------------------------------------------
1091cdf0e10cSrcweir
ImplSetContext(GraphicReader * pReader)1092cdf0e10cSrcweir void ImpGraphic::ImplSetContext( GraphicReader* pReader )
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir mpContext = pReader;
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir // ------------------------------------------------------------------------
1098cdf0e10cSrcweir
ImplSetDocFileName(const String & rName,sal_uLong nFilePos)1099cdf0e10cSrcweir void ImpGraphic::ImplSetDocFileName( const String& rName, sal_uLong nFilePos )
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir const INetURLObject aURL( rName );
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir DBG_ASSERT( !rName.Len() || ( aURL.GetProtocol() != INET_PROT_NOT_VALID ), "Graphic::SetDocFileName(...): invalid URL" );
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir maDocFileURLStr = aURL.GetMainURL( INetURLObject::NO_DECODE );
1106cdf0e10cSrcweir mnDocFilePos = nFilePos;
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir // ------------------------------------------------------------------------
1110cdf0e10cSrcweir
ImplGetDocFileName() const1111cdf0e10cSrcweir const String& ImpGraphic::ImplGetDocFileName() const
1112cdf0e10cSrcweir {
1113cdf0e10cSrcweir return maDocFileURLStr;
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir // ------------------------------------------------------------------------
1117cdf0e10cSrcweir
ImplGetDocFilePos() const1118cdf0e10cSrcweir sal_uLong ImpGraphic::ImplGetDocFilePos() const
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir return mnDocFilePos;
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir
1123cdf0e10cSrcweir // ------------------------------------------------------------------------
1124cdf0e10cSrcweir
ImplReadEmbedded(SvStream & rIStm,sal_Bool bSwap)1125cdf0e10cSrcweir sal_Bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm, sal_Bool bSwap )
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir MapMode aMapMode;
1128cdf0e10cSrcweir Size aSize;
1129cdf0e10cSrcweir const sal_uLong nStartPos = rIStm.Tell();
1130cdf0e10cSrcweir sal_uInt32 nId;
1131cdf0e10cSrcweir sal_uLong nHeaderLen;
1132cdf0e10cSrcweir long nType;
1133cdf0e10cSrcweir long nLen;
1134cdf0e10cSrcweir const sal_uInt16 nOldFormat = rIStm.GetNumberFormatInt();
1135cdf0e10cSrcweir sal_Bool bRet = sal_False;
1136cdf0e10cSrcweir
1137cdf0e10cSrcweir if( !mbSwapUnderway )
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir const String aTempURLStr( maDocFileURLStr );
1140cdf0e10cSrcweir const sal_uLong nTempPos = mnDocFilePos;
1141cdf0e10cSrcweir
1142cdf0e10cSrcweir ImplClear();
1143cdf0e10cSrcweir
1144cdf0e10cSrcweir maDocFileURLStr = aTempURLStr;
1145cdf0e10cSrcweir mnDocFilePos = nTempPos;
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
1149cdf0e10cSrcweir rIStm >> nId;
1150cdf0e10cSrcweir
1151cdf0e10cSrcweir // check version
1152cdf0e10cSrcweir if( GRAPHIC_FORMAT_50 == nId )
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir // read new style header
1155cdf0e10cSrcweir VersionCompat* pCompat = new VersionCompat( rIStm, STREAM_READ );
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir rIStm >> nType;
1158cdf0e10cSrcweir rIStm >> nLen;
1159cdf0e10cSrcweir rIStm >> aSize;
1160cdf0e10cSrcweir rIStm >> aMapMode;
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir delete pCompat;
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir else
1165cdf0e10cSrcweir {
1166cdf0e10cSrcweir // read old style header
1167cdf0e10cSrcweir long nWidth, nHeight;
1168cdf0e10cSrcweir long nMapMode, nScaleNumX, nScaleDenomX;
1169cdf0e10cSrcweir long nScaleNumY, nScaleDenomY, nOffsX, nOffsY;
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir rIStm.SeekRel( -4L );
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir rIStm >> nType >> nLen >> nWidth >> nHeight;
1174cdf0e10cSrcweir rIStm >> nMapMode >> nScaleNumX >> nScaleDenomX >> nScaleNumY;
1175cdf0e10cSrcweir rIStm >> nScaleDenomY >> nOffsX >> nOffsY;
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir // swapped
1178cdf0e10cSrcweir if( nType > 100L )
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir nType = SWAPLONG( nType );
1181cdf0e10cSrcweir nLen = SWAPLONG( nLen );
1182cdf0e10cSrcweir nWidth = SWAPLONG( nWidth );
1183cdf0e10cSrcweir nHeight = SWAPLONG( nHeight );
1184cdf0e10cSrcweir nMapMode = SWAPLONG( nMapMode );
1185cdf0e10cSrcweir nScaleNumX = SWAPLONG( nScaleNumX );
1186cdf0e10cSrcweir nScaleDenomX = SWAPLONG( nScaleDenomX );
1187cdf0e10cSrcweir nScaleNumY = SWAPLONG( nScaleNumY );
1188cdf0e10cSrcweir nScaleDenomY = SWAPLONG( nScaleDenomY );
1189cdf0e10cSrcweir nOffsX = SWAPLONG( nOffsX );
1190cdf0e10cSrcweir nOffsY = SWAPLONG( nOffsY );
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir
1193cdf0e10cSrcweir aSize = Size( nWidth, nHeight );
1194cdf0e10cSrcweir aMapMode = MapMode( (MapUnit) nMapMode, Point( nOffsX, nOffsY ),
1195cdf0e10cSrcweir Fraction( nScaleNumX, nScaleDenomX ),
1196cdf0e10cSrcweir Fraction( nScaleNumY, nScaleDenomY ) );
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir
1199cdf0e10cSrcweir nHeaderLen = rIStm.Tell() - nStartPos;
1200cdf0e10cSrcweir meType = (GraphicType) nType;
1201cdf0e10cSrcweir
1202cdf0e10cSrcweir if( meType )
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir if( meType == GRAPHIC_BITMAP )
1205cdf0e10cSrcweir {
1206ddde725dSArmin Le Grand if(maSvgData.get() && maEx.IsEmpty())
1207ddde725dSArmin Le Grand {
1208ddde725dSArmin Le Grand // use maEx as local buffer for rendered svg
1209ddde725dSArmin Le Grand maEx = maSvgData->getReplacement();
1210ddde725dSArmin Le Grand }
1211ddde725dSArmin Le Grand
1212ddde725dSArmin Le Grand maEx.aBitmapSize = aSize;
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir if( aMapMode != MapMode() )
1215cdf0e10cSrcweir {
1216cdf0e10cSrcweir maEx.SetPrefMapMode( aMapMode );
1217cdf0e10cSrcweir maEx.SetPrefSize( aSize );
1218cdf0e10cSrcweir }
1219cdf0e10cSrcweir }
1220cdf0e10cSrcweir else
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir maMetaFile.SetPrefMapMode( aMapMode );
1223cdf0e10cSrcweir maMetaFile.SetPrefSize( aSize );
1224cdf0e10cSrcweir }
1225cdf0e10cSrcweir
1226cdf0e10cSrcweir if( bSwap )
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir if( maDocFileURLStr.Len() )
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir rIStm.Seek( nStartPos + nHeaderLen + nLen );
1231cdf0e10cSrcweir bRet = mbSwapOut = sal_True;
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir else
1234cdf0e10cSrcweir {
1235cdf0e10cSrcweir ::utl::TempFile aTempFile;
1236cdf0e10cSrcweir const INetURLObject aTmpURL( aTempFile.GetURL() );
1237cdf0e10cSrcweir
1238cdf0e10cSrcweir if( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir if( pOStm )
1243cdf0e10cSrcweir {
1244cdf0e10cSrcweir sal_uLong nFullLen = nHeaderLen + nLen;
1245cdf0e10cSrcweir sal_uLong nPartLen = Min( nFullLen, (sal_uLong) GRAPHIC_MAXPARTLEN );
1246cdf0e10cSrcweir sal_uInt8* pBuffer = (sal_uInt8*) rtl_allocateMemory( nPartLen );
1247cdf0e10cSrcweir
1248cdf0e10cSrcweir pOStm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
1249cdf0e10cSrcweir
1250cdf0e10cSrcweir if( pBuffer )
1251cdf0e10cSrcweir {
1252cdf0e10cSrcweir rIStm.Seek( nStartPos );
1253cdf0e10cSrcweir
1254cdf0e10cSrcweir while( nFullLen )
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir rIStm.Read( (char*) pBuffer, nPartLen );
1257cdf0e10cSrcweir pOStm->Write( (char*) pBuffer, nPartLen );
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir nFullLen -= nPartLen;
1260cdf0e10cSrcweir
1261cdf0e10cSrcweir if( nFullLen < GRAPHIC_MAXPARTLEN )
1262cdf0e10cSrcweir nPartLen = nFullLen;
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir rtl_freeMemory( pBuffer );
1266cdf0e10cSrcweir sal_uLong nReadErr = rIStm.GetError(), nWriteErr = pOStm->GetError();
1267cdf0e10cSrcweir delete pOStm, pOStm = NULL;
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir if( !nReadErr && !nWriteErr )
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir bRet = mbSwapOut = sal_True;
1272cdf0e10cSrcweir mpSwapFile = new ImpSwapFile;
1273cdf0e10cSrcweir mpSwapFile->nRefCount = 1;
1274cdf0e10cSrcweir mpSwapFile->aSwapURL = aTmpURL;
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir else
1277cdf0e10cSrcweir {
1278cdf0e10cSrcweir try
1279cdf0e10cSrcweir {
1280cdf0e10cSrcweir ::ucbhelper::Content aCnt( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ),
1281cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ),
1284cdf0e10cSrcweir ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
1285cdf0e10cSrcweir }
1286cdf0e10cSrcweir catch( const ::com::sun::star::ucb::ContentCreationException& )
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir }
1292cdf0e10cSrcweir catch( const ::com::sun::star::ucb::CommandAbortedException& )
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir }
1295cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir }
1300cdf0e10cSrcweir
1301cdf0e10cSrcweir delete pOStm;
1302cdf0e10cSrcweir }
1303cdf0e10cSrcweir }
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir }
1306cdf0e10cSrcweir else if( meType == GRAPHIC_BITMAP || meType == GRAPHIC_GDIMETAFILE )
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir rIStm >> *this;
1309cdf0e10cSrcweir bRet = ( rIStm.GetError() == 0UL );
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir else if( meType >= SYS_WINMETAFILE && meType <= SYS_MACMETAFILE )
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir Graphic aSysGraphic;
1314cdf0e10cSrcweir sal_uLong nCvtType;
1315cdf0e10cSrcweir
1316cdf0e10cSrcweir switch( sal::static_int_cast<sal_uLong>(meType) )
1317cdf0e10cSrcweir {
1318cdf0e10cSrcweir case( SYS_WINMETAFILE ):
1319cdf0e10cSrcweir case( SYS_WNTMETAFILE ): nCvtType = CVT_WMF; break;
1320cdf0e10cSrcweir case( SYS_OS2METAFILE ): nCvtType = CVT_MET; break;
1321cdf0e10cSrcweir case( SYS_MACMETAFILE ): nCvtType = CVT_PCT; break;
1322cdf0e10cSrcweir
1323cdf0e10cSrcweir default:
1324cdf0e10cSrcweir nCvtType = CVT_UNKNOWN;
1325cdf0e10cSrcweir break;
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir
1328cdf0e10cSrcweir if( nType && GraphicConverter::Import( rIStm, aSysGraphic, nCvtType ) == ERRCODE_NONE )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir *this = ImpGraphic( aSysGraphic.GetGDIMetaFile() );
1331cdf0e10cSrcweir bRet = ( rIStm.GetError() == 0UL );
1332cdf0e10cSrcweir }
1333cdf0e10cSrcweir else
1334cdf0e10cSrcweir meType = GRAPHIC_DEFAULT;
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir
1337cdf0e10cSrcweir if( bRet )
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir ImplSetPrefMapMode( aMapMode );
1340cdf0e10cSrcweir ImplSetPrefSize( aSize );
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir }
1343cdf0e10cSrcweir else
1344cdf0e10cSrcweir bRet = sal_True;
1345cdf0e10cSrcweir
1346cdf0e10cSrcweir rIStm.SetNumberFormatInt( nOldFormat );
1347cdf0e10cSrcweir
1348cdf0e10cSrcweir return bRet;
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir
1351cdf0e10cSrcweir // ------------------------------------------------------------------------
1352cdf0e10cSrcweir
ImplWriteEmbedded(SvStream & rOStm)1353cdf0e10cSrcweir sal_Bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm )
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir sal_Bool bRet = sal_False;
1356cdf0e10cSrcweir
1357cdf0e10cSrcweir if( ( meType != GRAPHIC_NONE ) && ( meType != GRAPHIC_DEFAULT ) && !ImplIsSwapOut() )
1358cdf0e10cSrcweir {
1359cdf0e10cSrcweir const MapMode aMapMode( ImplGetPrefMapMode() );
1360cdf0e10cSrcweir const Size aSize( ImplGetPrefSize() );
1361cdf0e10cSrcweir const sal_uInt16 nOldFormat = rOStm.GetNumberFormatInt();
1362cdf0e10cSrcweir sal_uLong nDataFieldPos;
1363cdf0e10cSrcweir
1364cdf0e10cSrcweir rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir // write correct version ( old style/new style header )
1367cdf0e10cSrcweir if( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 )
1368cdf0e10cSrcweir {
1369cdf0e10cSrcweir // write ID for new format (5.0)
1370cdf0e10cSrcweir rOStm << GRAPHIC_FORMAT_50;
1371cdf0e10cSrcweir
1372cdf0e10cSrcweir // write new style header
1373cdf0e10cSrcweir VersionCompat* pCompat = new VersionCompat( rOStm, STREAM_WRITE, 1 );
1374cdf0e10cSrcweir
1375cdf0e10cSrcweir rOStm << (long) meType;
1376cdf0e10cSrcweir
1377cdf0e10cSrcweir // data size is updated later
1378cdf0e10cSrcweir nDataFieldPos = rOStm.Tell();
1379cdf0e10cSrcweir rOStm << (long) 0;
1380cdf0e10cSrcweir
1381cdf0e10cSrcweir rOStm << aSize;
1382cdf0e10cSrcweir rOStm << aMapMode;
1383cdf0e10cSrcweir
1384cdf0e10cSrcweir delete pCompat;
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir else
1387cdf0e10cSrcweir {
1388cdf0e10cSrcweir // write old style (<=4.0) header
1389cdf0e10cSrcweir rOStm << (long) meType;
1390cdf0e10cSrcweir
1391cdf0e10cSrcweir // data size is updated later
1392cdf0e10cSrcweir nDataFieldPos = rOStm.Tell();
1393cdf0e10cSrcweir rOStm << (long) 0;
1394cdf0e10cSrcweir
1395cdf0e10cSrcweir rOStm << (long) aSize.Width();
1396cdf0e10cSrcweir rOStm << (long) aSize.Height();
1397cdf0e10cSrcweir rOStm << (long) aMapMode.GetMapUnit();
1398cdf0e10cSrcweir rOStm << (long) aMapMode.GetScaleX().GetNumerator();
1399cdf0e10cSrcweir rOStm << (long) aMapMode.GetScaleX().GetDenominator();
1400cdf0e10cSrcweir rOStm << (long) aMapMode.GetScaleY().GetNumerator();
1401cdf0e10cSrcweir rOStm << (long) aMapMode.GetScaleY().GetDenominator();
1402cdf0e10cSrcweir rOStm << (long) aMapMode.GetOrigin().X();
1403cdf0e10cSrcweir rOStm << (long) aMapMode.GetOrigin().Y();
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir
1406cdf0e10cSrcweir // write data block
1407cdf0e10cSrcweir if( !rOStm.GetError() )
1408cdf0e10cSrcweir {
1409cdf0e10cSrcweir const sal_uLong nDataStart = rOStm.Tell();
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir if( ImplIsSupportedGraphic() )
1412cdf0e10cSrcweir rOStm << *this;
1413cdf0e10cSrcweir
1414cdf0e10cSrcweir if( !rOStm.GetError() )
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir const sal_uLong nStmPos2 = rOStm.Tell();
1417cdf0e10cSrcweir rOStm.Seek( nDataFieldPos );
1418cdf0e10cSrcweir rOStm << (long) ( nStmPos2 - nDataStart );
1419cdf0e10cSrcweir rOStm.Seek( nStmPos2 );
1420cdf0e10cSrcweir bRet = sal_True;
1421cdf0e10cSrcweir }
1422cdf0e10cSrcweir }
1423cdf0e10cSrcweir
1424cdf0e10cSrcweir rOStm.SetNumberFormatInt( nOldFormat );
1425cdf0e10cSrcweir }
1426cdf0e10cSrcweir
1427cdf0e10cSrcweir return bRet;
1428cdf0e10cSrcweir }
1429cdf0e10cSrcweir
1430cdf0e10cSrcweir // ------------------------------------------------------------------------
1431cdf0e10cSrcweir
ImplSwapOut()1432cdf0e10cSrcweir sal_Bool ImpGraphic::ImplSwapOut()
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir sal_Bool bRet = sal_False;
1435cdf0e10cSrcweir
1436cdf0e10cSrcweir if( !ImplIsSwapOut() )
1437cdf0e10cSrcweir {
1438cdf0e10cSrcweir if( !maDocFileURLStr.Len() )
1439cdf0e10cSrcweir {
1440cdf0e10cSrcweir ::utl::TempFile aTempFile;
1441cdf0e10cSrcweir const INetURLObject aTmpURL( aTempFile.GetURL() );
1442cdf0e10cSrcweir
1443cdf0e10cSrcweir if( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() )
1444cdf0e10cSrcweir {
1445cdf0e10cSrcweir SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
1446cdf0e10cSrcweir
1447cdf0e10cSrcweir if( pOStm )
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir pOStm->SetVersion( SOFFICE_FILEFORMAT_50 );
1450cdf0e10cSrcweir pOStm->SetCompressMode( COMPRESSMODE_NATIVE );
1451cdf0e10cSrcweir
1452cdf0e10cSrcweir if( ( bRet = ImplSwapOut( pOStm ) ) == sal_True )
1453cdf0e10cSrcweir {
1454cdf0e10cSrcweir mpSwapFile = new ImpSwapFile;
1455cdf0e10cSrcweir mpSwapFile->nRefCount = 1;
1456cdf0e10cSrcweir mpSwapFile->aSwapURL = aTmpURL;
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir else
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir delete pOStm, pOStm = NULL;
1461cdf0e10cSrcweir
1462cdf0e10cSrcweir try
1463cdf0e10cSrcweir {
1464cdf0e10cSrcweir ::ucbhelper::Content aCnt( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ),
1465cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
1466cdf0e10cSrcweir
1467cdf0e10cSrcweir aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ),
1468cdf0e10cSrcweir ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir catch( const ::com::sun::star::ucb::ContentCreationException& )
1471cdf0e10cSrcweir {
1472cdf0e10cSrcweir }
1473cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
1474cdf0e10cSrcweir {
1475cdf0e10cSrcweir }
1476cdf0e10cSrcweir catch( const ::com::sun::star::ucb::CommandAbortedException& )
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir }
1479cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
1480cdf0e10cSrcweir {
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir }
1483cdf0e10cSrcweir
1484cdf0e10cSrcweir delete pOStm;
1485cdf0e10cSrcweir }
1486cdf0e10cSrcweir }
1487cdf0e10cSrcweir }
1488cdf0e10cSrcweir else
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir ImplClearGraphics( sal_True );
1491cdf0e10cSrcweir bRet = mbSwapOut = sal_True;
1492cdf0e10cSrcweir }
1493cdf0e10cSrcweir }
1494cdf0e10cSrcweir
1495cdf0e10cSrcweir return bRet;
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir
1498cdf0e10cSrcweir // ------------------------------------------------------------------------
1499cdf0e10cSrcweir
ImplSwapOut(SvStream * pOStm)1500cdf0e10cSrcweir sal_Bool ImpGraphic::ImplSwapOut( SvStream* pOStm )
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir sal_Bool bRet = sal_False;
1503cdf0e10cSrcweir
1504cdf0e10cSrcweir if( pOStm )
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir pOStm->SetBufferSize( GRAPHIC_STREAMBUFSIZE );
1507cdf0e10cSrcweir
1508cdf0e10cSrcweir if( !pOStm->GetError() && ImplWriteEmbedded( *pOStm ) )
1509cdf0e10cSrcweir {
1510cdf0e10cSrcweir pOStm->Flush();
1511cdf0e10cSrcweir
1512cdf0e10cSrcweir if( !pOStm->GetError() )
1513cdf0e10cSrcweir {
1514cdf0e10cSrcweir ImplClearGraphics( sal_True );
1515cdf0e10cSrcweir bRet = mbSwapOut = sal_True;
1516cdf0e10cSrcweir }
1517cdf0e10cSrcweir }
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir else
1520cdf0e10cSrcweir {
1521cdf0e10cSrcweir ImplClearGraphics( sal_True );
1522cdf0e10cSrcweir bRet = mbSwapOut = sal_True;
1523cdf0e10cSrcweir }
1524cdf0e10cSrcweir
1525cdf0e10cSrcweir return bRet;
1526cdf0e10cSrcweir }
1527cdf0e10cSrcweir
1528cdf0e10cSrcweir // ------------------------------------------------------------------------
1529cdf0e10cSrcweir
ImplSwapIn()1530cdf0e10cSrcweir sal_Bool ImpGraphic::ImplSwapIn()
1531cdf0e10cSrcweir {
1532cdf0e10cSrcweir sal_Bool bRet = sal_False;
1533cdf0e10cSrcweir
1534cdf0e10cSrcweir if( ImplIsSwapOut() )
1535cdf0e10cSrcweir {
1536cdf0e10cSrcweir String aSwapURL;
1537cdf0e10cSrcweir
1538cdf0e10cSrcweir if( mpSwapFile )
1539cdf0e10cSrcweir aSwapURL = mpSwapFile->aSwapURL.GetMainURL( INetURLObject::NO_DECODE );
1540cdf0e10cSrcweir else
1541cdf0e10cSrcweir aSwapURL = maDocFileURLStr;
1542cdf0e10cSrcweir
1543cdf0e10cSrcweir if( aSwapURL.Len() )
1544cdf0e10cSrcweir {
1545cdf0e10cSrcweir SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aSwapURL, STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
1546cdf0e10cSrcweir
1547cdf0e10cSrcweir if( pIStm )
1548cdf0e10cSrcweir {
1549cdf0e10cSrcweir pIStm->SetVersion( SOFFICE_FILEFORMAT_50 );
1550cdf0e10cSrcweir pIStm->SetCompressMode( COMPRESSMODE_NATIVE );
1551cdf0e10cSrcweir
1552cdf0e10cSrcweir if( !mpSwapFile )
1553cdf0e10cSrcweir pIStm->Seek( mnDocFilePos );
1554cdf0e10cSrcweir
1555cdf0e10cSrcweir bRet = ImplSwapIn( pIStm );
1556cdf0e10cSrcweir delete pIStm;
1557cdf0e10cSrcweir
1558cdf0e10cSrcweir if( mpSwapFile )
1559cdf0e10cSrcweir {
1560cdf0e10cSrcweir if( mpSwapFile->nRefCount > 1 )
1561cdf0e10cSrcweir mpSwapFile->nRefCount--;
1562cdf0e10cSrcweir else
1563cdf0e10cSrcweir {
1564cdf0e10cSrcweir try
1565cdf0e10cSrcweir {
1566cdf0e10cSrcweir ::ucbhelper::Content aCnt( aSwapURL,
1567cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
1568cdf0e10cSrcweir
1569cdf0e10cSrcweir aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ),
1570cdf0e10cSrcweir ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
1571cdf0e10cSrcweir }
1572cdf0e10cSrcweir catch( const ::com::sun::star::ucb::ContentCreationException& )
1573cdf0e10cSrcweir {
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir catch( const ::com::sun::star::uno::RuntimeException& )
1576cdf0e10cSrcweir {
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir catch( const ::com::sun::star::ucb::CommandAbortedException& )
1579cdf0e10cSrcweir {
1580cdf0e10cSrcweir }
1581cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
1582cdf0e10cSrcweir {
1583cdf0e10cSrcweir }
1584cdf0e10cSrcweir
1585cdf0e10cSrcweir delete mpSwapFile;
1586cdf0e10cSrcweir }
1587cdf0e10cSrcweir
1588cdf0e10cSrcweir mpSwapFile = NULL;
1589cdf0e10cSrcweir }
1590cdf0e10cSrcweir }
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir }
1593cdf0e10cSrcweir
1594cdf0e10cSrcweir return bRet;
1595cdf0e10cSrcweir }
1596cdf0e10cSrcweir
1597cdf0e10cSrcweir // ------------------------------------------------------------------------
1598cdf0e10cSrcweir
ImplSwapIn(SvStream * pIStm)1599cdf0e10cSrcweir sal_Bool ImpGraphic::ImplSwapIn( SvStream* pIStm )
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir sal_Bool bRet = sal_False;
1602cdf0e10cSrcweir
1603cdf0e10cSrcweir if( pIStm )
1604cdf0e10cSrcweir {
1605cdf0e10cSrcweir pIStm->SetBufferSize( GRAPHIC_STREAMBUFSIZE );
1606cdf0e10cSrcweir
1607cdf0e10cSrcweir if( !pIStm->GetError() )
1608cdf0e10cSrcweir {
1609cdf0e10cSrcweir mbSwapUnderway = sal_True;
1610cdf0e10cSrcweir bRet = ImplReadEmbedded( *pIStm );
1611cdf0e10cSrcweir mbSwapUnderway = sal_False;
1612cdf0e10cSrcweir
1613cdf0e10cSrcweir if( !bRet )
1614cdf0e10cSrcweir ImplClear();
1615cdf0e10cSrcweir else
1616cdf0e10cSrcweir mbSwapOut = sal_False;
1617cdf0e10cSrcweir }
1618cdf0e10cSrcweir }
1619cdf0e10cSrcweir
1620cdf0e10cSrcweir return bRet;
1621cdf0e10cSrcweir }
1622cdf0e10cSrcweir
1623cdf0e10cSrcweir // ------------------------------------------------------------------------
1624cdf0e10cSrcweir
ImplIsSwapOut() const1625cdf0e10cSrcweir sal_Bool ImpGraphic::ImplIsSwapOut() const
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir return mbSwapOut;
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir
1630cdf0e10cSrcweir // ------------------------------------------------------------------------
1631cdf0e10cSrcweir
ImplSetLink(const GfxLink & rGfxLink)1632cdf0e10cSrcweir void ImpGraphic::ImplSetLink( const GfxLink& rGfxLink )
1633cdf0e10cSrcweir {
1634cdf0e10cSrcweir delete mpGfxLink;
1635cdf0e10cSrcweir mpGfxLink = new GfxLink( rGfxLink );
1636cdf0e10cSrcweir
1637cdf0e10cSrcweir if( mpGfxLink->IsNative() )
1638cdf0e10cSrcweir mpGfxLink->SwapOut();
1639cdf0e10cSrcweir }
1640cdf0e10cSrcweir
1641cdf0e10cSrcweir // ------------------------------------------------------------------------
1642cdf0e10cSrcweir
ImplGetLink()1643cdf0e10cSrcweir GfxLink ImpGraphic::ImplGetLink()
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir return( mpGfxLink ? *mpGfxLink : GfxLink() );
1646cdf0e10cSrcweir }
1647cdf0e10cSrcweir
1648cdf0e10cSrcweir // ------------------------------------------------------------------------
1649cdf0e10cSrcweir
ImplIsLink() const1650cdf0e10cSrcweir sal_Bool ImpGraphic::ImplIsLink() const
1651cdf0e10cSrcweir {
1652cdf0e10cSrcweir return ( mpGfxLink != NULL ) ? sal_True : sal_False;
1653cdf0e10cSrcweir }
1654cdf0e10cSrcweir
1655cdf0e10cSrcweir // ------------------------------------------------------------------------
1656cdf0e10cSrcweir
ImplGetChecksum() const1657cdf0e10cSrcweir sal_uLong ImpGraphic::ImplGetChecksum() const
1658cdf0e10cSrcweir {
1659cdf0e10cSrcweir sal_uLong nRet = 0;
1660cdf0e10cSrcweir
1661cdf0e10cSrcweir if( ImplIsSupportedGraphic() && !ImplIsSwapOut() )
1662cdf0e10cSrcweir {
1663cdf0e10cSrcweir switch( meType )
1664cdf0e10cSrcweir {
1665cdf0e10cSrcweir case( GRAPHIC_DEFAULT ):
1666cdf0e10cSrcweir break;
1667cdf0e10cSrcweir
1668cdf0e10cSrcweir case( GRAPHIC_BITMAP ):
1669cdf0e10cSrcweir {
1670ddde725dSArmin Le Grand if(maSvgData.get() && maEx.IsEmpty())
1671ddde725dSArmin Le Grand {
1672ddde725dSArmin Le Grand // use maEx as local buffer for rendered svg
1673ddde725dSArmin Le Grand const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
1674ddde725dSArmin Le Grand }
1675ddde725dSArmin Le Grand
1676ddde725dSArmin Le Grand if( mpAnimation )
1677ddde725dSArmin Le Grand {
1678cdf0e10cSrcweir nRet = mpAnimation->GetChecksum();
1679ddde725dSArmin Le Grand }
1680cdf0e10cSrcweir else
1681ddde725dSArmin Le Grand {
1682cdf0e10cSrcweir nRet = maEx.GetChecksum();
1683ddde725dSArmin Le Grand }
1684cdf0e10cSrcweir }
1685cdf0e10cSrcweir break;
1686cdf0e10cSrcweir
1687cdf0e10cSrcweir default:
1688cdf0e10cSrcweir nRet = maMetaFile.GetChecksum();
1689cdf0e10cSrcweir break;
1690cdf0e10cSrcweir }
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir
1693cdf0e10cSrcweir return nRet;
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir
1696cdf0e10cSrcweir // ------------------------------------------------------------------------
1697cdf0e10cSrcweir
ImplExportNative(SvStream & rOStm) const1698cdf0e10cSrcweir sal_Bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const
1699cdf0e10cSrcweir {
1700cdf0e10cSrcweir sal_Bool bResult = sal_False;
1701cdf0e10cSrcweir
1702cdf0e10cSrcweir if( !rOStm.GetError() )
1703cdf0e10cSrcweir {
1704cdf0e10cSrcweir if( !ImplIsSwapOut() )
1705cdf0e10cSrcweir {
1706cdf0e10cSrcweir if( mpGfxLink && mpGfxLink->IsNative() )
1707cdf0e10cSrcweir bResult = mpGfxLink->ExportNative( rOStm );
1708cdf0e10cSrcweir else
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir rOStm << *this;
1711cdf0e10cSrcweir bResult = ( rOStm.GetError() == ERRCODE_NONE );
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir }
1714cdf0e10cSrcweir else
1715cdf0e10cSrcweir rOStm.SetError( SVSTREAM_GENERALERROR );
1716cdf0e10cSrcweir }
1717cdf0e10cSrcweir
1718cdf0e10cSrcweir return bResult;
1719cdf0e10cSrcweir }
1720cdf0e10cSrcweir
1721cdf0e10cSrcweir // ------------------------------------------------------------------------
1722cdf0e10cSrcweir
getSvgData() const1723ddde725dSArmin Le Grand const SvgDataPtr& ImpGraphic::getSvgData() const
1724ddde725dSArmin Le Grand {
1725ddde725dSArmin Le Grand return maSvgData;
1726ddde725dSArmin Le Grand }
1727ddde725dSArmin Le Grand
1728ddde725dSArmin Le Grand // ------------------------------------------------------------------------
1729ddde725dSArmin Le Grand
operator >>(SvStream & rIStm,ImpGraphic & rImpGraphic)1730cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStm, ImpGraphic& rImpGraphic )
1731cdf0e10cSrcweir {
1732cdf0e10cSrcweir if( !rIStm.GetError() )
1733cdf0e10cSrcweir {
1734cdf0e10cSrcweir const sal_uLong nStmPos1 = rIStm.Tell();
1735cdf0e10cSrcweir sal_uInt32 nTmp;
1736cdf0e10cSrcweir
1737cdf0e10cSrcweir if ( !rImpGraphic.mbSwapUnderway )
1738cdf0e10cSrcweir rImpGraphic.ImplClear();
1739cdf0e10cSrcweir
1740cdf0e10cSrcweir // read Id
1741cdf0e10cSrcweir rIStm >> nTmp;
1742cdf0e10cSrcweir
1743cdf0e10cSrcweir // if there is no more data, avoid further expensive
1744cdf0e10cSrcweir // reading which will create VDevs and other stuff, just to
1745cdf0e10cSrcweir // read nothing. CAUTION: Eof is only true AFTER reading another
1746cdf0e10cSrcweir // byte, a speciality of SvMemoryStream (!)
1747cdf0e10cSrcweir if(!rIStm.GetError() && !rIStm.IsEof())
1748cdf0e10cSrcweir {
1749cdf0e10cSrcweir if( NATIVE_FORMAT_50 == nTmp )
1750cdf0e10cSrcweir {
1751cdf0e10cSrcweir Graphic aGraphic;
1752cdf0e10cSrcweir GfxLink aLink;
1753cdf0e10cSrcweir VersionCompat* pCompat;
1754cdf0e10cSrcweir
1755cdf0e10cSrcweir // read compat info
1756cdf0e10cSrcweir pCompat = new VersionCompat( rIStm, STREAM_READ );
1757cdf0e10cSrcweir delete pCompat;
1758cdf0e10cSrcweir
1759cdf0e10cSrcweir rIStm >> aLink;
1760cdf0e10cSrcweir
1761cdf0e10cSrcweir // set dummy link to avoid creation of additional link after filtering;
1762cdf0e10cSrcweir // we set a default link to avoid unnecessary swapping of native data
1763cdf0e10cSrcweir aGraphic.SetLink( GfxLink() );
1764cdf0e10cSrcweir
1765cdf0e10cSrcweir if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) )
1766cdf0e10cSrcweir {
1767cdf0e10cSrcweir // set link only, if no other link was set
1768cdf0e10cSrcweir const sal_Bool bSetLink = ( rImpGraphic.mpGfxLink == NULL );
1769cdf0e10cSrcweir
1770cdf0e10cSrcweir // assign graphic
1771cdf0e10cSrcweir rImpGraphic = *aGraphic.ImplGetImpGraphic();
1772cdf0e10cSrcweir
1773cdf0e10cSrcweir if( aLink.IsPrefMapModeValid() )
1774cdf0e10cSrcweir rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() );
1775cdf0e10cSrcweir
1776cdf0e10cSrcweir if( aLink.IsPrefSizeValid() )
1777cdf0e10cSrcweir rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() );
1778cdf0e10cSrcweir
1779cdf0e10cSrcweir if( bSetLink )
1780cdf0e10cSrcweir rImpGraphic.ImplSetLink( aLink );
1781cdf0e10cSrcweir }
1782cdf0e10cSrcweir else
1783cdf0e10cSrcweir {
1784cdf0e10cSrcweir rIStm.Seek( nStmPos1 );
1785cdf0e10cSrcweir rIStm.SetError( ERRCODE_IO_WRONGFORMAT );
1786cdf0e10cSrcweir }
1787cdf0e10cSrcweir }
1788cdf0e10cSrcweir else
1789cdf0e10cSrcweir {
1790cdf0e10cSrcweir BitmapEx aBmpEx;
1791cdf0e10cSrcweir const sal_uInt16 nOldFormat = rIStm.GetNumberFormatInt();
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir rIStm.SeekRel( -4 );
1794cdf0e10cSrcweir rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
179545fd3b9aSArmin Le Grand ReadDIBBitmapEx(aBmpEx, rIStm);
1796cdf0e10cSrcweir
1797cdf0e10cSrcweir if( !rIStm.GetError() )
1798cdf0e10cSrcweir {
1799cdf0e10cSrcweir sal_uInt32 nMagic1(0), nMagic2(0);
1800cdf0e10cSrcweir sal_uLong nActPos = rIStm.Tell();
1801cdf0e10cSrcweir
1802cdf0e10cSrcweir rIStm >> nMagic1 >> nMagic2;
1803cdf0e10cSrcweir rIStm.Seek( nActPos );
1804cdf0e10cSrcweir
1805cdf0e10cSrcweir rImpGraphic = ImpGraphic( aBmpEx );
1806cdf0e10cSrcweir
1807cdf0e10cSrcweir if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) )
1808cdf0e10cSrcweir {
1809cdf0e10cSrcweir delete rImpGraphic.mpAnimation;
1810cdf0e10cSrcweir rImpGraphic.mpAnimation = new Animation;
1811cdf0e10cSrcweir rIStm >> *rImpGraphic.mpAnimation;
1812cdf0e10cSrcweir
1813cdf0e10cSrcweir // #108077# manually set loaded BmpEx to Animation
1814cdf0e10cSrcweir // (which skips loading its BmpEx if already done)
1815cdf0e10cSrcweir rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx);
1816cdf0e10cSrcweir }
1817cdf0e10cSrcweir else
1818cdf0e10cSrcweir rIStm.ResetError();
1819cdf0e10cSrcweir }
1820cdf0e10cSrcweir else
1821cdf0e10cSrcweir {
1822cdf0e10cSrcweir GDIMetaFile aMtf;
1823cdf0e10cSrcweir
1824cdf0e10cSrcweir rIStm.Seek( nStmPos1 );
1825cdf0e10cSrcweir rIStm.ResetError();
1826cdf0e10cSrcweir rIStm >> aMtf;
1827cdf0e10cSrcweir
1828cdf0e10cSrcweir if( !rIStm.GetError() )
182970577dceSArmin Le Grand {
1830cdf0e10cSrcweir rImpGraphic = aMtf;
183170577dceSArmin Le Grand }
1832cdf0e10cSrcweir else
183370577dceSArmin Le Grand {
183470577dceSArmin Le Grand // try to stream in Svg defining data (length, byte array and evtl. path)
183570577dceSArmin Le Grand // See below (operator<<) for more information
183670577dceSArmin Le Grand const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
183770577dceSArmin Le Grand sal_uInt32 nMagic;
183870577dceSArmin Le Grand rIStm.Seek(nStmPos1);
183970577dceSArmin Le Grand rIStm.ResetError();
184070577dceSArmin Le Grand rIStm >> nMagic;
184170577dceSArmin Le Grand
184270577dceSArmin Le Grand if(nSvgMagic == nMagic)
184370577dceSArmin Le Grand {
184470577dceSArmin Le Grand sal_uInt32 mnSvgDataArrayLength(0);
184570577dceSArmin Le Grand rIStm >> mnSvgDataArrayLength;
184670577dceSArmin Le Grand
184770577dceSArmin Le Grand if(mnSvgDataArrayLength)
184870577dceSArmin Le Grand {
184970577dceSArmin Le Grand SvgDataArray aNewData(new sal_uInt8[mnSvgDataArrayLength]);
185070577dceSArmin Le Grand UniString aPath;
185170577dceSArmin Le Grand
185270577dceSArmin Le Grand rIStm.Read(aNewData.get(), mnSvgDataArrayLength);
185370577dceSArmin Le Grand rIStm.ReadByteString(aPath);
185470577dceSArmin Le Grand
185570577dceSArmin Le Grand if(!rIStm.GetError())
185670577dceSArmin Le Grand {
185770577dceSArmin Le Grand SvgDataPtr aSvgDataPtr(
185870577dceSArmin Le Grand new SvgData(
185970577dceSArmin Le Grand aNewData,
186070577dceSArmin Le Grand mnSvgDataArrayLength,
186170577dceSArmin Le Grand rtl::OUString(aPath)));
186270577dceSArmin Le Grand
186370577dceSArmin Le Grand rImpGraphic = aSvgDataPtr;
186470577dceSArmin Le Grand }
186570577dceSArmin Le Grand }
186670577dceSArmin Le Grand }
186770577dceSArmin Le Grand
186870577dceSArmin Le Grand rIStm.Seek(nStmPos1);
186970577dceSArmin Le Grand }
1870cdf0e10cSrcweir }
1871cdf0e10cSrcweir
1872cdf0e10cSrcweir rIStm.SetNumberFormatInt( nOldFormat );
1873cdf0e10cSrcweir }
1874cdf0e10cSrcweir }
1875cdf0e10cSrcweir }
1876cdf0e10cSrcweir
1877cdf0e10cSrcweir return rIStm;
1878cdf0e10cSrcweir }
1879cdf0e10cSrcweir
1880cdf0e10cSrcweir // ------------------------------------------------------------------------
1881cdf0e10cSrcweir
operator <<(SvStream & rOStm,const ImpGraphic & rImpGraphic)1882cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStm, const ImpGraphic& rImpGraphic )
1883cdf0e10cSrcweir {
1884cdf0e10cSrcweir if( !rOStm.GetError() )
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir if( !rImpGraphic.ImplIsSwapOut() )
1887cdf0e10cSrcweir {
1888cdf0e10cSrcweir if( ( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 ) &&
1889cdf0e10cSrcweir ( rOStm.GetCompressMode() & COMPRESSMODE_NATIVE ) &&
1890cdf0e10cSrcweir rImpGraphic.mpGfxLink && rImpGraphic.mpGfxLink->IsNative() )
1891cdf0e10cSrcweir {
1892cdf0e10cSrcweir VersionCompat* pCompat;
1893cdf0e10cSrcweir
1894cdf0e10cSrcweir // native format
1895cdf0e10cSrcweir rOStm << NATIVE_FORMAT_50;
1896cdf0e10cSrcweir
1897cdf0e10cSrcweir // write compat info
1898cdf0e10cSrcweir pCompat = new VersionCompat( rOStm, STREAM_WRITE, 1 );
1899cdf0e10cSrcweir delete pCompat;
1900cdf0e10cSrcweir
1901cdf0e10cSrcweir rImpGraphic.mpGfxLink->SetPrefMapMode( rImpGraphic.ImplGetPrefMapMode() );
1902cdf0e10cSrcweir rImpGraphic.mpGfxLink->SetPrefSize( rImpGraphic.ImplGetPrefSize() );
1903cdf0e10cSrcweir rOStm << *rImpGraphic.mpGfxLink;
1904cdf0e10cSrcweir }
1905cdf0e10cSrcweir else
1906cdf0e10cSrcweir {
1907cdf0e10cSrcweir // own format
1908cdf0e10cSrcweir const sal_uInt16 nOldFormat = rOStm.GetNumberFormatInt();
1909cdf0e10cSrcweir rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
1910cdf0e10cSrcweir
1911cdf0e10cSrcweir switch( rImpGraphic.ImplGetType() )
1912cdf0e10cSrcweir {
1913cdf0e10cSrcweir case( GRAPHIC_NONE ):
1914cdf0e10cSrcweir case( GRAPHIC_DEFAULT ):
1915cdf0e10cSrcweir break;
1916cdf0e10cSrcweir
1917cdf0e10cSrcweir case GRAPHIC_BITMAP:
1918cdf0e10cSrcweir {
1919ddde725dSArmin Le Grand if(rImpGraphic.getSvgData().get())
1920ddde725dSArmin Le Grand {
192170577dceSArmin Le Grand // stream out Svg defining data (length, byte array and evtl. path)
192270577dceSArmin Le Grand // this is used e.g. in swapping out graphic data and in transporting it over UNO API
192370577dceSArmin Le Grand // as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
192470577dceSArmin Le Grand // no problem to extend it; only used at runtime
192570577dceSArmin Le Grand const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
192670577dceSArmin Le Grand
192770577dceSArmin Le Grand rOStm << nSvgMagic;
192870577dceSArmin Le Grand rOStm << rImpGraphic.getSvgData()->getSvgDataArrayLength();
192970577dceSArmin Le Grand rOStm.Write(rImpGraphic.getSvgData()->getSvgDataArray().get(), rImpGraphic.getSvgData()->getSvgDataArrayLength());
193070577dceSArmin Le Grand rOStm.WriteByteString(rImpGraphic.getSvgData()->getPath());
1931ddde725dSArmin Le Grand }
1932ddde725dSArmin Le Grand else if( rImpGraphic.ImplIsAnimated())
1933ddde725dSArmin Le Grand {
1934cdf0e10cSrcweir rOStm << *rImpGraphic.mpAnimation;
1935ddde725dSArmin Le Grand }
1936cdf0e10cSrcweir else
1937ddde725dSArmin Le Grand {
193845fd3b9aSArmin Le Grand WriteDIBBitmapEx(rImpGraphic.maEx, rOStm);
1939ddde725dSArmin Le Grand }
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir break;
1942cdf0e10cSrcweir
1943cdf0e10cSrcweir default:
1944cdf0e10cSrcweir {
1945cdf0e10cSrcweir if( rImpGraphic.ImplIsSupportedGraphic() )
1946cdf0e10cSrcweir rOStm << rImpGraphic.maMetaFile;
1947cdf0e10cSrcweir }
1948cdf0e10cSrcweir break;
1949cdf0e10cSrcweir }
1950cdf0e10cSrcweir
1951cdf0e10cSrcweir rOStm.SetNumberFormatInt( nOldFormat );
1952cdf0e10cSrcweir }
1953cdf0e10cSrcweir }
1954cdf0e10cSrcweir else
1955cdf0e10cSrcweir rOStm.SetError( SVSTREAM_GENERALERROR );
1956cdf0e10cSrcweir }
1957cdf0e10cSrcweir
1958cdf0e10cSrcweir return rOStm;
1959cdf0e10cSrcweir }
1960