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