xref: /aoo41x/main/vcl/source/gdi/graph.cxx (revision ddde725d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26 
27 #include <vcl/outdev.hxx>
28 #include <vcl/svapp.hxx>
29 #include <vcl/graph.hxx>
30 #include <vcl/metaact.hxx>
31 #include <impgraph.hxx>
32 #include <comphelper/processfactory.hxx>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/graphic/XGraphicProvider.hpp>
35 #include <com/sun/star/lang/XUnoTunnel.hpp>
36 #include <com/sun/star/lang/XTypeProvider.hpp>
37 #include <com/sun/star/graphic/XGraphic.hpp>
38 
39 // -----------------------
40 // - Compression defines -
41 // -----------------------
42 
43 #define COMPRESS_OWN                ('S'|('D'<<8UL))
44 #define COMPRESS_NONE               ( 0UL )
45 #define RLE_8                       ( 1UL )
46 #define RLE_4                       ( 2UL )
47 #define BITFIELDS                   ( 3UL )
48 #define ZCOMPRESS                   ( COMPRESS_OWN | 0x01000000UL ) /* == 'SD01' (binary) */
49 
50 using namespace ::com::sun::star;
51 
52 // -----------------------
53 // - Default-Drawmethode -
54 // -----------------------
55 
ImplDrawDefault(OutputDevice * pOutDev,const UniString * pText,Font * pFont,const Bitmap * pBitmap,const BitmapEx * pBitmapEx,const Point & rDestPt,const Size & rDestSize)56 static void ImplDrawDefault( OutputDevice* pOutDev, const UniString* pText,
57                              Font* pFont, const Bitmap* pBitmap, const BitmapEx* pBitmapEx,
58                              const Point& rDestPt, const Size& rDestSize )
59 {
60     sal_uInt16      nPixel = (sal_uInt16) pOutDev->PixelToLogic( Size( 1, 1 ) ).Width();
61     sal_uInt16      nPixelWidth = nPixel;
62     Point       aPoint( rDestPt.X() + nPixelWidth, rDestPt.Y() + nPixelWidth );
63     Size        aSize( rDestSize.Width() - ( nPixelWidth << 1 ), rDestSize.Height() - ( nPixelWidth << 1 ) );
64     sal_Bool        bFilled = ( pBitmap != NULL || pBitmapEx != NULL || pFont != NULL );
65     Rectangle   aBorderRect( aPoint, aSize );
66 
67     pOutDev->Push();
68 
69     pOutDev->SetFillColor();
70 
71     // Auf dem Drucker ein schwarzes Rechteck und auf dem Bildschirm eins mit 3D-Effekt
72     if ( pOutDev->GetOutDevType() == OUTDEV_PRINTER )
73         pOutDev->SetLineColor( COL_BLACK );
74     else
75     {
76         aBorderRect.Left() += nPixel;
77         aBorderRect.Top() += nPixel;
78 
79         pOutDev->SetLineColor( COL_LIGHTGRAY );
80         pOutDev->DrawRect( aBorderRect );
81 
82         aBorderRect.Left() -= nPixel;
83         aBorderRect.Top() -= nPixel;
84         aBorderRect.Right() -= nPixel;
85         aBorderRect.Bottom() -= nPixel;
86         pOutDev->SetLineColor( COL_GRAY );
87     }
88 
89     pOutDev->DrawRect( aBorderRect );
90 
91     aPoint.X() += nPixelWidth + 2*nPixel;
92     aPoint.Y() += nPixelWidth + 2*nPixel;
93     aSize.Width() -= 2*nPixelWidth + 4*nPixel;
94     aSize.Height() -= 2*nPixelWidth + 4*nPixel;
95 
96     if( aSize.Width() > 0 && aSize.Height() > 0
97         && (  ( pBitmap && !!*pBitmap ) || ( pBitmapEx && !!*pBitmapEx ) ) )
98     {
99         Size aBitmapSize( pOutDev->PixelToLogic( pBitmap ? pBitmap->GetSizePixel() : pBitmapEx->GetSizePixel() ) );
100 
101         if( aSize.Height() > aBitmapSize.Height() && aSize.Width() > aBitmapSize.Width() )
102         {
103             if ( pBitmap )
104                 pOutDev->DrawBitmap( aPoint, *pBitmap );
105             else
106                 pOutDev->DrawBitmapEx( aPoint, *pBitmapEx );
107             aPoint.X() += aBitmapSize.Width() + 2*nPixel;
108             aSize.Width() -= aBitmapSize.Width() + 2*nPixel;
109         }
110     }
111 
112     if ( aSize.Width() > 0 && aSize.Height() > 0 && pFont && pText && pText->Len()
113          && !(!pOutDev->IsOutputEnabled() /*&& pOutDev->GetConnectMetaFile() */) )
114     {
115         MapMode aMapMode( MAP_POINT );
116         Size    aSz = pOutDev->LogicToLogic( Size( 0, 12 ), &aMapMode, NULL );
117         long    nThreshold = aSz.Height() / 2;
118         long    nStep = nThreshold / 3;
119 
120         if ( !nStep )
121             nStep = aSz.Height() - nThreshold;
122 
123         for(;; aSz.Height() -= nStep )
124         {
125             pFont->SetSize( aSz );
126             pOutDev->SetFont( *pFont );
127 
128             long nTextHeight = pOutDev->GetTextHeight();
129             long nTextWidth = pOutDev->GetTextWidth( *pText );
130             if ( nTextHeight )
131             {
132                 // Die N"aherung ber"ucksichtigt keine Ungenauigkeiten durch
133                 // Wortumbr"uche
134                 long nLines = aSize.Height() / nTextHeight;
135                 long nWidth = aSize.Width() * nLines; // N"aherung!!!
136 
137                 if ( nTextWidth <= nWidth || aSz.Height() <= nThreshold )
138                 {
139                     sal_uInt16 nStart = 0;
140                     sal_uInt16 nLen = 0;
141 
142                     while( nStart < pText->Len() && pText->GetChar( nStart ) == ' ' )
143                         nStart++;
144                     while( nStart+nLen < pText->Len() && pText->GetChar( nStart+nLen ) != ' ' )
145                         nLen++;
146                     while( nStart < pText->Len() && nLines-- )
147                     {
148                         sal_uInt16 nNext = nLen;
149                         do
150                         {
151                             while ( nStart+nNext < pText->Len() && pText->GetChar( nStart+nNext ) == ' ' )
152                                 nNext++;
153                             while ( nStart+nNext < pText->Len() && pText->GetChar( nStart+nNext ) != ' ' )
154                                 nNext++;
155                             nTextWidth = pOutDev->GetTextWidth( *pText, nStart, nNext );
156                             if ( nTextWidth > aSize.Width() )
157                                 break;
158                             nLen = nNext;
159                         }
160                         while ( nStart+nNext < pText->Len() );
161 
162                         sal_uInt16 n = nLen;
163                         nTextWidth = pOutDev->GetTextWidth( *pText, nStart, n );
164                         while( nTextWidth > aSize.Width() )
165                             nTextWidth = pOutDev->GetTextWidth( *pText, nStart, --n );
166                         pOutDev->DrawText( aPoint, *pText, nStart, n );
167 
168                         aPoint.Y() += nTextHeight;
169                         nStart      = sal::static_int_cast<sal_uInt16>(nStart + nLen);
170                         nLen        = nNext-nLen;
171                         while( nStart < pText->Len() && pText->GetChar( nStart ) == ' ' )
172                         {
173                             nStart++;
174                             nLen--;
175                         }
176                     }
177                     break;
178                 }
179             }
180             else
181                 break;
182         }
183     }
184 
185     // Falls die Default-Graphik keinen Inhalt hat,
186     // malen wir ein rotes Kreuz
187     if( !bFilled )
188     {
189         aBorderRect.Left()++;
190         aBorderRect.Top()++;
191         aBorderRect.Right()--;
192         aBorderRect.Bottom()--;
193 
194         pOutDev->SetLineColor( COL_LIGHTRED );
195         pOutDev->DrawLine( aBorderRect.TopLeft(), aBorderRect.BottomRight() );
196         pOutDev->DrawLine( aBorderRect.TopRight(), aBorderRect.BottomLeft() );
197     }
198 
199     pOutDev->Pop();
200 }
201 
202 // -----------
203 // - Graphic -
204 // -----------
205 
206 TYPEINIT1_AUTOFACTORY( Graphic, SvDataCopyStream );
207 
208 // ------------------------------------------------------------------------
209 
Graphic()210 Graphic::Graphic()
211 {
212     mpImpGraphic = new ImpGraphic;
213 }
214 
215 // ------------------------------------------------------------------------
216 
Graphic(const Graphic & rGraphic)217 Graphic::Graphic( const Graphic& rGraphic ) :
218 SvDataCopyStream()
219 {
220     if( rGraphic.IsAnimated() )
221         mpImpGraphic = new ImpGraphic( *rGraphic.mpImpGraphic );
222     else
223     {
224         mpImpGraphic = rGraphic.mpImpGraphic;
225         mpImpGraphic->mnRefCount++;
226     }
227 }
228 
229 // ------------------------------------------------------------------------
230 
Graphic(const Bitmap & rBmp)231 Graphic::Graphic( const Bitmap& rBmp )
232 {
233     mpImpGraphic = new ImpGraphic( rBmp );
234 }
235 
236 // ------------------------------------------------------------------------
237 
Graphic(const BitmapEx & rBmpEx)238 Graphic::Graphic( const BitmapEx& rBmpEx )
239 {
240     mpImpGraphic = new ImpGraphic( rBmpEx );
241 }
242 
243 // ------------------------------------------------------------------------
244 
Graphic(const SvgDataPtr & rSvgDataPtr)245 Graphic::Graphic(const SvgDataPtr& rSvgDataPtr)
246 {
247     mpImpGraphic = new ImpGraphic(rSvgDataPtr);
248 }
249 
250 // ------------------------------------------------------------------------
251 
Graphic(const Animation & rAnimation)252 Graphic::Graphic( const Animation& rAnimation )
253 {
254     mpImpGraphic = new ImpGraphic( rAnimation );
255 }
256 
257 // ------------------------------------------------------------------------
258 
Graphic(const GDIMetaFile & rMtf)259 Graphic::Graphic( const GDIMetaFile& rMtf )
260 {
261     mpImpGraphic = new ImpGraphic( rMtf );
262 }
263 
264 // ------------------------------------------------------------------------
265 
Graphic(const::com::sun::star::uno::Reference<::com::sun::star::graphic::XGraphic> & rxGraphic)266 Graphic::Graphic( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic )
267 {
268 	uno::Reference< lang::XUnoTunnel >		xTunnel( rxGraphic, uno::UNO_QUERY );
269 	uno::Reference< lang::XTypeProvider	>	xProv( rxGraphic, uno::UNO_QUERY );
270 	const ::Graphic* 						pGraphic = ( ( xTunnel.is() && xProv.is() ) ?
271 														 reinterpret_cast< ::Graphic* >( xTunnel->getSomething( xProv->getImplementationId() ) ) :
272 													 	 NULL );
273 
274 	if( pGraphic )
275 	{
276 		if( pGraphic->IsAnimated() )
277 			mpImpGraphic = new ImpGraphic( *pGraphic->mpImpGraphic );
278 		else
279 		{
280 			mpImpGraphic = pGraphic->mpImpGraphic;
281 			mpImpGraphic->mnRefCount++;
282 		}
283 	}
284 	else
285 		mpImpGraphic = new ImpGraphic;
286 }
287 
288 // ------------------------------------------------------------------------
289 
~Graphic()290 Graphic::~Graphic()
291 {
292     if( mpImpGraphic->mnRefCount == 1UL )
293         delete mpImpGraphic;
294     else
295         mpImpGraphic->mnRefCount--;
296 }
297 
298 // ------------------------------------------------------------------------
299 
ImplTestRefCount()300 void Graphic::ImplTestRefCount()
301 {
302     if( mpImpGraphic->mnRefCount > 1UL )
303     {
304         mpImpGraphic->mnRefCount--;
305         mpImpGraphic = new ImpGraphic( *mpImpGraphic );
306     }
307 }
308 
309 // ------------------------------------------------------------------------
310 
operator =(const Graphic & rGraphic)311 Graphic& Graphic::operator=( const Graphic& rGraphic )
312 {
313     if( &rGraphic != this )
314     {
315         if( rGraphic.IsAnimated() )
316         {
317             if( mpImpGraphic->mnRefCount == 1UL )
318                 delete mpImpGraphic;
319             else
320                 mpImpGraphic->mnRefCount--;
321 
322             mpImpGraphic = new ImpGraphic( *rGraphic.mpImpGraphic );
323         }
324         else
325         {
326             rGraphic.mpImpGraphic->mnRefCount++;
327 
328             if( mpImpGraphic->mnRefCount == 1UL )
329                 delete mpImpGraphic;
330             else
331                 mpImpGraphic->mnRefCount--;
332 
333             mpImpGraphic = rGraphic.mpImpGraphic;
334         }
335     }
336 
337     return *this;
338 }
339 
340 // ------------------------------------------------------------------------
341 
operator ==(const Graphic & rGraphic) const342 sal_Bool Graphic::operator==( const Graphic& rGraphic ) const
343 {
344     return( *mpImpGraphic == *rGraphic.mpImpGraphic );
345 }
346 
347 // ------------------------------------------------------------------------
348 
operator !=(const Graphic & rGraphic) const349 sal_Bool Graphic::operator!=( const Graphic& rGraphic ) const
350 {
351     return( *mpImpGraphic != *rGraphic.mpImpGraphic );
352 }
353 
354 // ------------------------------------------------------------------------
355 
operator !() const356 sal_Bool Graphic::operator!() const
357 {
358     return( GRAPHIC_NONE == mpImpGraphic->ImplGetType() );
359 }
360 
361 // ------------------------------------------------------------------------
362 
Load(SvStream & rIStm)363 void Graphic::Load( SvStream& rIStm )
364 {
365     rIStm >> *this;
366 }
367 
368 // ------------------------------------------------------------------------
369 
Save(SvStream & rOStm)370 void Graphic::Save( SvStream& rOStm )
371 {
372     rOStm << *this;
373 }
374 
375 // ------------------------------------------------------------------------
376 
Assign(const SvDataCopyStream & rCopyStream)377 void Graphic::Assign( const SvDataCopyStream& rCopyStream )
378 {
379     *this = (const Graphic& ) rCopyStream;
380 }
381 
382 // ------------------------------------------------------------------------
383 
Clear()384 void Graphic::Clear()
385 {
386     ImplTestRefCount();
387     mpImpGraphic->ImplClear();
388 }
389 
390 // ------------------------------------------------------------------------
391 
GetType() const392 GraphicType Graphic::GetType() const
393 {
394     return mpImpGraphic->ImplGetType();
395 }
396 
397 // ------------------------------------------------------------------------
398 
SetDefaultType()399 void Graphic::SetDefaultType()
400 {
401     ImplTestRefCount();
402     mpImpGraphic->ImplSetDefaultType();
403 }
404 
405 // ------------------------------------------------------------------------
406 
IsSupportedGraphic() const407 sal_Bool Graphic::IsSupportedGraphic() const
408 {
409     return mpImpGraphic->ImplIsSupportedGraphic();
410 }
411 
412 // ------------------------------------------------------------------------
413 
IsTransparent() const414 sal_Bool Graphic::IsTransparent() const
415 {
416     return mpImpGraphic->ImplIsTransparent();
417 }
418 
419 // ------------------------------------------------------------------------
420 
IsAlpha() const421 sal_Bool Graphic::IsAlpha() const
422 {
423     return mpImpGraphic->ImplIsAlpha();
424 }
425 
426 // ------------------------------------------------------------------------
427 
IsAnimated() const428 sal_Bool Graphic::IsAnimated() const
429 {
430     return mpImpGraphic->ImplIsAnimated();
431 }
432 
433 // ------------------------------------------------------------------------
434 
IsEPS() const435 sal_Bool Graphic::IsEPS() const
436 {
437     return mpImpGraphic->ImplIsEPS();
438 }
439 
440 // ------------------------------------------------------------------------
441 
GetBitmap(const GraphicConversionParameters & rParameters) const442 Bitmap Graphic::GetBitmap(const GraphicConversionParameters& rParameters) const
443 {
444     return mpImpGraphic->ImplGetBitmap(rParameters);
445 }
446 
447 // ------------------------------------------------------------------------
448 
GetBitmapEx(const GraphicConversionParameters & rParameters) const449 BitmapEx Graphic::GetBitmapEx(const GraphicConversionParameters& rParameters) const
450 {
451     return mpImpGraphic->ImplGetBitmapEx(rParameters);
452 }
453 
454 // ------------------------------------------------------------------------
455 
GetAnimation() const456 Animation Graphic::GetAnimation() const
457 {
458     return mpImpGraphic->ImplGetAnimation();
459 }
460 
461 // ------------------------------------------------------------------------
462 
GetGDIMetaFile() const463 const GDIMetaFile& Graphic::GetGDIMetaFile() const
464 {
465     return mpImpGraphic->ImplGetGDIMetaFile();
466 }
467 
468 // ------------------------------------------------------------------------
469 
GetXGraphic() const470 uno::Reference< graphic::XGraphic > Graphic::GetXGraphic() const
471 {
472 	uno::Reference< graphic::XGraphic > xRet;
473 
474 	if( GetType() != GRAPHIC_NONE )
475 	{
476 		uno::Reference < lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
477 
478 		if( xMSF.is() )
479 		{
480 			uno::Reference< graphic::XGraphicProvider > xProv( xMSF->createInstance(
481 				::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ),
482 				uno::UNO_QUERY );
483 
484 			if( xProv.is() )
485 			{
486 				uno::Sequence< beans::PropertyValue > 	aLoadProps( 1 );
487 				::rtl::OUString							aURL( RTL_CONSTASCII_USTRINGPARAM( "private:memorygraphic/" ) );
488 
489 				aLoadProps[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
490 				aLoadProps[ 0 ].Value <<= ( aURL += ::rtl::OUString::valueOf( reinterpret_cast< sal_Int64 >( this ) ) );
491 
492 				xRet = xProv->queryGraphic( aLoadProps );
493 			}
494 		}
495 	}
496 
497 	return xRet;
498 }
499 
500 // ------------------------------------------------------------------------
501 
GetPrefSize() const502 Size Graphic::GetPrefSize() const
503 {
504     return mpImpGraphic->ImplGetPrefSize();
505 }
506 
507 // ------------------------------------------------------------------------
508 
SetPrefSize(const Size & rPrefSize)509 void Graphic::SetPrefSize( const Size& rPrefSize )
510 {
511     ImplTestRefCount();
512     mpImpGraphic->ImplSetPrefSize( rPrefSize );
513 }
514 
515 // ------------------------------------------------------------------------
516 
GetPrefMapMode() const517 MapMode Graphic::GetPrefMapMode() const
518 {
519     return mpImpGraphic->ImplGetPrefMapMode();
520 }
521 
522 // ------------------------------------------------------------------------
523 
SetPrefMapMode(const MapMode & rPrefMapMode)524 void Graphic::SetPrefMapMode( const MapMode& rPrefMapMode )
525 {
526     ImplTestRefCount();
527     mpImpGraphic->ImplSetPrefMapMode( rPrefMapMode );
528 }
529 
530 // ------------------------------------------------------------------
531 
GetSizePixel(const OutputDevice * pRefDevice) const532 Size Graphic::GetSizePixel( const OutputDevice* pRefDevice ) const
533 {
534     Size aRet;
535 
536     if( GRAPHIC_BITMAP == mpImpGraphic->ImplGetType() )
537         aRet = mpImpGraphic->ImplGetBitmapEx(GraphicConversionParameters()).GetSizePixel();
538     else
539         aRet = ( pRefDevice ? pRefDevice : Application::GetDefaultDevice() )->LogicToPixel( GetPrefSize(), GetPrefMapMode() );
540 
541     return aRet;
542 }
543 
544 // ------------------------------------------------------------------
545 
GetSizeBytes() const546 sal_uLong Graphic::GetSizeBytes() const
547 {
548     return mpImpGraphic->ImplGetSizeBytes();
549 }
550 
551 // ------------------------------------------------------------------------
552 
Draw(OutputDevice * pOutDev,const Point & rDestPt) const553 void Graphic::Draw( OutputDevice* pOutDev, const Point& rDestPt ) const
554 {
555     mpImpGraphic->ImplDraw( pOutDev, rDestPt );
556 }
557 
558 // ------------------------------------------------------------------------
559 
Draw(OutputDevice * pOutDev,const Point & rDestPt,const Size & rDestSz) const560 void Graphic::Draw( OutputDevice* pOutDev,
561                     const Point& rDestPt, const Size& rDestSz ) const
562 {
563     if( GRAPHIC_DEFAULT == mpImpGraphic->ImplGetType() )
564         ImplDrawDefault( pOutDev, NULL, NULL, NULL, NULL, rDestPt, rDestSz );
565     else
566         mpImpGraphic->ImplDraw( pOutDev, rDestPt, rDestSz );
567 }
568 
569 // ------------------------------------------------------------------------
570 
Draw(OutputDevice * pOutDev,const String & rText,Font & rFont,const Bitmap & rBitmap,const Point & rDestPt,const Size & rDestSz)571 void Graphic::Draw( OutputDevice* pOutDev, const String& rText,
572                     Font& rFont, const Bitmap& rBitmap,
573                     const Point& rDestPt, const Size& rDestSz )
574 {
575     ImplDrawDefault( pOutDev, &rText, &rFont, &rBitmap, NULL, rDestPt, rDestSz );
576 }
577 
578 // ------------------------------------------------------------------------
579 
DrawEx(OutputDevice * pOutDev,const String & rText,Font & rFont,const BitmapEx & rBitmap,const Point & rDestPt,const Size & rDestSz)580 void Graphic::DrawEx( OutputDevice* pOutDev, const String& rText,
581                     Font& rFont, const BitmapEx& rBitmap,
582                     const Point& rDestPt, const Size& rDestSz )
583 {
584     ImplDrawDefault( pOutDev, &rText, &rFont, NULL, &rBitmap, rDestPt, rDestSz );
585 }
586 
587 // ------------------------------------------------------------------------
588 
StartAnimation(OutputDevice * pOutDev,const Point & rDestPt,long nExtraData,OutputDevice * pFirstFrameOutDev)589 void Graphic::StartAnimation( OutputDevice* pOutDev, const Point& rDestPt, long nExtraData,
590                               OutputDevice* pFirstFrameOutDev )
591 {
592     ImplTestRefCount();
593     mpImpGraphic->ImplStartAnimation( pOutDev, rDestPt, nExtraData, pFirstFrameOutDev );
594 }
595 
596 // ------------------------------------------------------------------------
597 
StartAnimation(OutputDevice * pOutDev,const Point & rDestPt,const Size & rDestSz,long nExtraData,OutputDevice * pFirstFrameOutDev)598 void Graphic::StartAnimation( OutputDevice* pOutDev, const Point& rDestPt,
599                               const Size& rDestSz, long nExtraData,
600                               OutputDevice* pFirstFrameOutDev )
601 {
602     ImplTestRefCount();
603     mpImpGraphic->ImplStartAnimation( pOutDev, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev );
604 }
605 
606 // ------------------------------------------------------------------------
607 
StopAnimation(OutputDevice * pOutDev,long nExtraData)608 void Graphic::StopAnimation( OutputDevice* pOutDev, long nExtraData )
609 {
610     ImplTestRefCount();
611     mpImpGraphic->ImplStopAnimation( pOutDev, nExtraData );
612 }
613 
614 // ------------------------------------------------------------------------
615 
SetAnimationNotifyHdl(const Link & rLink)616 void Graphic::SetAnimationNotifyHdl( const Link& rLink )
617 {
618     mpImpGraphic->ImplSetAnimationNotifyHdl( rLink );
619 }
620 
621 // ------------------------------------------------------------------------
622 
GetAnimationNotifyHdl() const623 Link Graphic::GetAnimationNotifyHdl() const
624 {
625     return mpImpGraphic->ImplGetAnimationNotifyHdl();
626 }
627 
628 // ------------------------------------------------------------------------
629 
GetAnimationLoopCount() const630 sal_uLong Graphic::GetAnimationLoopCount() const
631 {
632     return mpImpGraphic->ImplGetAnimationLoopCount();
633 }
634 
635 // ------------------------------------------------------------------------
636 
ResetAnimationLoopCount()637 void Graphic::ResetAnimationLoopCount()
638 {
639     mpImpGraphic->ImplResetAnimationLoopCount();
640 }
641 
642 // ------------------------------------------------------------------------
643 
GetAnimationInfoList() const644 List* Graphic::GetAnimationInfoList() const
645 {
646     return mpImpGraphic->ImplGetAnimationInfoList();
647 }
648 
649 // ------------------------------------------------------------------------
650 
GetContext()651 GraphicReader* Graphic::GetContext()
652 {
653     return mpImpGraphic->ImplGetContext();
654 }
655 
656 // ------------------------------------------------------------------------
657 
SetContext(GraphicReader * pReader)658 void Graphic::SetContext( GraphicReader* pReader )
659 {
660     mpImpGraphic->ImplSetContext( pReader );
661 }
662 
663 // ------------------------------------------------------------------------
664 
GetGraphicsCompressMode(SvStream & rIStm)665 sal_uInt16 Graphic::GetGraphicsCompressMode( SvStream& rIStm )
666 {
667     const sal_uLong     nPos = rIStm.Tell();
668     const sal_uInt16    nOldFormat = rIStm.GetNumberFormatInt();
669     sal_uInt32          nTmp32;
670     sal_uInt16          nTmp16;
671     sal_uInt16          nCompressMode = COMPRESSMODE_NONE;
672 
673     rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
674 
675     rIStm >> nTmp32;
676 
677     // is it a swapped graphic with a bitmap?
678     rIStm.SeekRel( (nTmp32 == (sal_uInt32) GRAPHIC_BITMAP ) ? 40 : -4 );
679 
680     // try to read bitmap id
681     rIStm >> nTmp16;
682 
683     // check id of BitmapFileHeader
684     if( 0x4D42 == nTmp16 )
685     {
686         // seek to compress field of BitmapInfoHeader
687         rIStm.SeekRel( 28 );
688         rIStm >> nTmp32;
689 
690         // Compare with our own compressmode
691         if( ZCOMPRESS == nTmp32 )
692             nCompressMode = COMPRESSMODE_ZBITMAP;
693     }
694 
695     rIStm.SetNumberFormatInt( nOldFormat );
696     rIStm.Seek( nPos );
697 
698     return nCompressMode;
699 }
700 
701 // ------------------------------------------------------------------------
702 
SetDocFileName(const String & rName,sal_uLong nFilePos)703 void Graphic::SetDocFileName( const String& rName, sal_uLong nFilePos )
704 {
705     mpImpGraphic->ImplSetDocFileName( rName, nFilePos );
706 }
707 
708 // ------------------------------------------------------------------------
709 
GetDocFileName() const710 const String& Graphic::GetDocFileName() const
711 {
712     return mpImpGraphic->ImplGetDocFileName();
713 }
714 
715 // ------------------------------------------------------------------------
716 
GetDocFilePos() const717 sal_uLong Graphic::GetDocFilePos() const
718 {
719     return mpImpGraphic->ImplGetDocFilePos();
720 }
721 
722 // ------------------------------------------------------------------------
723 
ReadEmbedded(SvStream & rIStream,sal_Bool bSwap)724 sal_Bool Graphic::ReadEmbedded( SvStream& rIStream, sal_Bool bSwap )
725 {
726     ImplTestRefCount();
727     return mpImpGraphic->ImplReadEmbedded( rIStream, bSwap );
728 }
729 
730 // ------------------------------------------------------------------------
731 
WriteEmbedded(SvStream & rOStream)732 sal_Bool Graphic::WriteEmbedded( SvStream& rOStream )
733 {
734     ImplTestRefCount();
735     return mpImpGraphic->ImplWriteEmbedded( rOStream );
736 }
737 
738 // ------------------------------------------------------------------------
739 
SwapOut()740 sal_Bool Graphic::SwapOut()
741 {
742     ImplTestRefCount();
743     return mpImpGraphic->ImplSwapOut();
744 }
745 
746 // ------------------------------------------------------------------------
747 
SwapOut(SvStream * pOStream)748 sal_Bool Graphic::SwapOut( SvStream* pOStream )
749 {
750     ImplTestRefCount();
751     return mpImpGraphic->ImplSwapOut( pOStream );
752 }
753 
754 // ------------------------------------------------------------------------
755 
SwapIn()756 sal_Bool Graphic::SwapIn()
757 {
758     ImplTestRefCount();
759     return mpImpGraphic->ImplSwapIn();
760 }
761 
762 // ------------------------------------------------------------------------
763 
SwapIn(SvStream * pStrm)764 sal_Bool Graphic::SwapIn( SvStream* pStrm )
765 {
766     ImplTestRefCount();
767     return mpImpGraphic->ImplSwapIn( pStrm );
768 }
769 
770 // ------------------------------------------------------------------------
771 
IsSwapOut() const772 sal_Bool Graphic::IsSwapOut() const
773 {
774     return mpImpGraphic->ImplIsSwapOut();
775 }
776 
777 // ------------------------------------------------------------------------
778 
SetLink(const GfxLink & rGfxLink)779 void Graphic::SetLink( const GfxLink& rGfxLink )
780 {
781     ImplTestRefCount();
782     mpImpGraphic->ImplSetLink( rGfxLink );
783 }
784 
785 // ------------------------------------------------------------------------
786 
GetLink() const787 GfxLink Graphic::GetLink() const
788 {
789     return mpImpGraphic->ImplGetLink();
790 }
791 
792 // ------------------------------------------------------------------------
793 
IsLink() const794 sal_Bool Graphic::IsLink() const
795 {
796     return mpImpGraphic->ImplIsLink();
797 }
798 
799 // ------------------------------------------------------------------------
800 
GetChecksum() const801 sal_uLong Graphic::GetChecksum() const
802 {
803     return mpImpGraphic->ImplGetChecksum();
804 }
805 
806 // ------------------------------------------------------------------------
807 
ExportNative(SvStream & rOStream) const808 sal_Bool Graphic::ExportNative( SvStream& rOStream ) const
809 {
810 	return mpImpGraphic->ImplExportNative( rOStream );
811 }
812 
813 // ------------------------------------------------------------------------
814 
operator >>(SvStream & rIStream,Graphic & rGraphic)815 SvStream& operator>>( SvStream& rIStream, Graphic& rGraphic )
816 {
817     rGraphic.ImplTestRefCount();
818     return rIStream >> *rGraphic.mpImpGraphic;
819 }
820 
821 // ------------------------------------------------------------------------
822 
operator <<(SvStream & rOStream,const Graphic & rGraphic)823 SvStream& operator<<( SvStream& rOStream, const Graphic& rGraphic )
824 {
825     return rOStream << *rGraphic.mpImpGraphic;
826 }
827 
getSvgData() const828 const SvgDataPtr& Graphic::getSvgData() const
829 {
830     return mpImpGraphic->getSvgData();
831 }
832