LCOV - code coverage report
Current view: top level - libreoffice/svx/source/gallery2 - galtheme.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 749 0.0 %
Date: 2012-12-17 Functions: 0 50 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "sal/config.h"
      21             : 
      22             : #include <comphelper/processfactory.hxx>
      23             : #include <tools/urlobj.hxx>
      24             : #include <tools/vcompat.hxx>
      25             : #include <unotools/streamwrap.hxx>
      26             : #include <unotools/ucbstreamhelper.hxx>
      27             : #include <unotools/tempfile.hxx>
      28             : #include <unotools/localfilehelper.hxx>
      29             : #include <ucbhelper/content.hxx>
      30             : #include <sot/storage.hxx>
      31             : #include <sot/formats.hxx>
      32             : #include <sot/filelist.hxx>
      33             : #include <vcl/virdev.hxx>
      34             : #include <vcl/cvtgrf.hxx>
      35             : #include <svl/itempool.hxx>
      36             : #include <sfx2/docfile.hxx>
      37             : #include <avmedia/mediawindow.hxx>
      38             : #include <svx/svdograf.hxx>
      39             : #include <svx/fmpage.hxx>
      40             : #include "codec.hxx"
      41             : #include <svx/unomodel.hxx>
      42             : #include <svx/fmmodel.hxx>
      43             : #include <svx/fmview.hxx>
      44             : #include "svx/galmisc.hxx"
      45             : #include "svx/galtheme.hxx"
      46             : #include <com/sun/star/sdbc/XResultSet.hpp>
      47             : #include <com/sun/star/ucb/XContentAccess.hpp>
      48             : #include <com/sun/star/io/XInputStream.hpp>
      49             : #include "galobj.hxx"
      50             : #include <svx/gallery1.hxx>
      51             : #include "galtheme.hrc"
      52             : #include <vcl/lstbox.hxx>
      53             : #include "gallerydrawmodel.hxx"
      54             : 
      55             : // --------------
      56             : // - Namespaces -
      57             : // --------------
      58             : 
      59             : using namespace ::rtl;
      60             : using namespace ::com::sun::star;
      61             : 
      62             : // ------------
      63             : // - SgaTheme -
      64             : // ------------
      65             : DBG_NAME(GalleryTheme)
      66             : 
      67           0 : GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry ) :
      68             :         pParent               ( pGallery ),
      69             :         pThm                  ( pThemeEntry ),
      70             :         mnThemeLockCount      ( 0 ),
      71             :         mnBroadcasterLockCount( 0 ),
      72             :         nDragPos              ( 0 ),
      73           0 :         bDragging             ( sal_False )
      74             : {
      75             :     DBG_CTOR(GalleryTheme,NULL);
      76             : 
      77           0 :     ImplCreateSvDrawStorage();
      78           0 : }
      79             : 
      80             : // ------------------------------------------------------------------------
      81             : 
      82           0 : GalleryTheme::~GalleryTheme()
      83             : {
      84           0 :     ImplWrite();
      85             : 
      86           0 :     for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
      87             :     {
      88           0 :         GalleryObject* pEntry = aObjectList[ i ];
      89           0 :         Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) );
      90           0 :         delete pEntry;
      91           0 :         Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) );
      92             :     }
      93           0 :     aObjectList.clear();
      94             : 
      95             :     DBG_DTOR(GalleryTheme,NULL);
      96           0 : }
      97             : 
      98             : // ------------------------------------------------------------------------
      99             : 
     100           0 : void GalleryTheme::ImplCreateSvDrawStorage()
     101             : {
     102           0 :     aSvDrawStorageRef = new SvStorage( sal_False, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), pThm->IsReadOnly() ? STREAM_READ : STREAM_STD_READWRITE );
     103             :     // #i50423# ReadOnly may not been set though the file can't be written (because of security reasons)
     104           0 :     if ( ( aSvDrawStorageRef->GetError() != ERRCODE_NONE ) && !pThm->IsReadOnly() )
     105           0 :         aSvDrawStorageRef = new SvStorage( sal_False, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
     106           0 : }
     107             : 
     108             : // ------------------------------------------------------------------------
     109             : 
     110           0 : sal_Bool GalleryTheme::ImplWriteSgaObject( const SgaObject& rObj, size_t nPos, GalleryObject* pExistentEntry )
     111             : {
     112           0 :     SvStream*   pOStm = ::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
     113           0 :     sal_Bool        bRet = sal_False;
     114             : 
     115           0 :     if( pOStm )
     116             :     {
     117           0 :         const sal_uInt32 nOffset = pOStm->Seek( STREAM_SEEK_TO_END );
     118             : 
     119           0 :         rObj.WriteData( *pOStm, m_aDestDir );
     120             : 
     121           0 :         if( !pOStm->GetError() )
     122             :         {
     123             :             GalleryObject* pEntry;
     124             : 
     125           0 :             if( !pExistentEntry )
     126             :             {
     127           0 :                 pEntry = new GalleryObject;
     128           0 :                 if ( nPos < aObjectList.size() )
     129             :                 {
     130           0 :                     GalleryObjectList::iterator it = aObjectList.begin();
     131           0 :                     ::std::advance( it, nPos );
     132           0 :                     aObjectList.insert( it, pEntry );
     133             :                 }
     134             :                 else
     135           0 :                     aObjectList.push_back( pEntry );
     136             :             }
     137             :             else
     138           0 :                 pEntry = pExistentEntry;
     139             : 
     140           0 :             pEntry->aURL = rObj.GetURL();
     141           0 :             pEntry->nOffset = nOffset;
     142           0 :             pEntry->eObjKind = rObj.GetObjKind();
     143           0 :             bRet = sal_True;
     144             :         }
     145             : 
     146           0 :         delete pOStm;
     147             :     }
     148             : 
     149           0 :     return bRet;
     150             : }
     151             : 
     152             : // ------------------------------------------------------------------------
     153             : 
     154           0 : SgaObject* GalleryTheme::ImplReadSgaObject( GalleryObject* pEntry )
     155             : {
     156           0 :     SgaObject* pSgaObj = NULL;
     157             : 
     158           0 :     if( pEntry )
     159             :     {
     160           0 :         SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
     161             : 
     162           0 :         if( pIStm )
     163             :         {
     164             :             sal_uInt32 nInventor;
     165             : 
     166             :             // Ueberpruefen, ob das File ein gueltiges SGA-File ist
     167           0 :             pIStm->Seek( pEntry->nOffset );
     168           0 :             *pIStm >> nInventor;
     169             : 
     170           0 :             if( nInventor == COMPAT_FORMAT( 'S', 'G', 'A', '3' ) )
     171             :             {
     172           0 :                 pIStm->Seek( pEntry->nOffset );
     173             : 
     174           0 :                 switch( pEntry->eObjKind )
     175             :                 {
     176           0 :                     case( SGA_OBJ_BMP ):    pSgaObj = new SgaObjectBmp(); break;
     177           0 :                     case( SGA_OBJ_ANIM ):   pSgaObj = new SgaObjectAnim(); break;
     178           0 :                     case( SGA_OBJ_INET ):   pSgaObj = new SgaObjectINet(); break;
     179           0 :                     case( SGA_OBJ_SVDRAW ): pSgaObj = new SgaObjectSvDraw(); break;
     180           0 :                     case( SGA_OBJ_SOUND ):  pSgaObj = new SgaObjectSound(); break;
     181             : 
     182             :                     default:
     183           0 :                     break;
     184             :                 }
     185             : 
     186           0 :                 if( pSgaObj )
     187             :                 {
     188           0 :                     *pIStm >> *pSgaObj;
     189           0 :                     pSgaObj->ImplUpdateURL( pEntry->aURL );
     190             :                 }
     191             :             }
     192             : 
     193           0 :             delete pIStm;
     194             :         }
     195             :     }
     196             : 
     197           0 :     return pSgaObj;
     198             : }
     199             : 
     200             : // ------------------------------------------------------------------------
     201             : 
     202           0 : void GalleryTheme::ImplWrite()
     203             : {
     204           0 :     if( IsModified() )
     205             :     {
     206           0 :         INetURLObject aPathURL( GetThmURL() );
     207             : 
     208           0 :         aPathURL.removeSegment();
     209           0 :         aPathURL.removeFinalSlash();
     210             : 
     211             :         DBG_ASSERT( aPathURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     212             : 
     213           0 :         if( FileExists( aPathURL ) || CreateDir( aPathURL ) )
     214             :         {
     215             : #ifdef UNX
     216           0 :             SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_COPY_ON_SYMLINK | STREAM_TRUNC );
     217             : #else
     218             :             SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
     219             : #endif
     220             : 
     221           0 :             if( pOStm )
     222             :             {
     223           0 :                 *pOStm << *this;
     224           0 :                 delete pOStm;
     225             :             }
     226             : 
     227           0 :             ImplSetModified( sal_False );
     228           0 :         }
     229             :     }
     230           0 : }
     231             : 
     232             : // ------------------------------------------------------------------------
     233             : 
     234           0 : const GalleryObject* GalleryTheme::ImplGetGalleryObject( const INetURLObject& rURL )
     235             : {
     236           0 :     for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
     237           0 :         if ( aObjectList[ i ]->aURL == rURL )
     238           0 :             return aObjectList[ i ];
     239           0 :     return NULL;
     240             : }
     241             : 
     242             : // ------------------------------------------------------------------------
     243             : 
     244           0 : INetURLObject GalleryTheme::ImplGetURL( const GalleryObject* pObject ) const
     245             : {
     246           0 :     INetURLObject aURL;
     247             : 
     248           0 :     if( pObject )
     249           0 :         aURL = pObject->aURL;
     250             : 
     251           0 :     return aURL;
     252             : }
     253             : 
     254             : // ------------------------------------------------------------------------
     255             : 
     256           0 : INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, sal_uIntPtr nFormat )
     257             : {
     258           0 :     INetURLObject   aDir( GetParent()->GetUserURL() );
     259           0 :     INetURLObject   aInfoFileURL( GetParent()->GetUserURL() );
     260           0 :     INetURLObject   aNewURL;
     261           0 :     sal_uInt32      nNextNumber = 1999;
     262           0 :     sal_Char const* pExt = NULL;
     263             :     sal_Bool            bExists;
     264             : 
     265           0 :     aDir.Append( String( RTL_CONSTASCII_USTRINGPARAM( "dragdrop" ) ) );
     266           0 :     CreateDir( aDir );
     267             : 
     268           0 :     aInfoFileURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( "sdddndx1" ) ) );
     269             : 
     270             :     // read next possible number
     271           0 :     if( FileExists( aInfoFileURL ) )
     272             :     {
     273           0 :         SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aInfoFileURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
     274             : 
     275           0 :         if( pIStm )
     276             :         {
     277           0 :             *pIStm >> nNextNumber;
     278           0 :             delete pIStm;
     279             :         }
     280             :     }
     281             : 
     282             :     // create extension
     283           0 :     if( nFormat )
     284             :     {
     285           0 :         switch( nFormat )
     286             :         {
     287           0 :             case( CVT_BMP ): pExt = ".bmp"; break;
     288           0 :             case( CVT_GIF ): pExt = ".gif"; break;
     289           0 :             case( CVT_JPG ): pExt = ".jpg"; break;
     290           0 :             case( CVT_MET ): pExt = ".met"; break;
     291           0 :             case( CVT_PCT ): pExt = ".pct"; break;
     292           0 :             case( CVT_PNG ): pExt = ".png"; break;
     293           0 :             case( CVT_SVM ): pExt = ".svm"; break;
     294           0 :             case( CVT_TIF ): pExt = ".tif"; break;
     295           0 :             case( CVT_WMF ): pExt = ".wmf"; break;
     296           0 :             case( CVT_EMF ): pExt = ".emf"; break;
     297             : 
     298             :             default:
     299           0 :                 pExt = ".grf";
     300           0 :             break;
     301             :         }
     302             :     }
     303             : 
     304           0 :     do
     305             :     {
     306             :         // get URL
     307           0 :         if( SGA_OBJ_SVDRAW == eObjKind )
     308             :         {
     309           0 :             String aFileName( RTL_CONSTASCII_USTRINGPARAM( "gallery/svdraw/dd" ) );
     310           0 :             aNewURL = INetURLObject( aFileName += String::CreateFromInt32( ++nNextNumber % 99999999 ), INET_PROT_PRIV_SOFFICE );
     311             : 
     312           0 :             bExists = sal_False;
     313             : 
     314           0 :             for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
     315           0 :                 if ( aObjectList[ i ]->aURL == aNewURL )
     316             :                 {
     317           0 :                     bExists = sal_True;
     318           0 :                     break;
     319           0 :                 }
     320             :         }
     321             :         else
     322             :         {
     323           0 :             String aFileName( RTL_CONSTASCII_USTRINGPARAM( "dd" ) );
     324             : 
     325           0 :             aFileName += String::CreateFromInt32( ++nNextNumber % 999999 );
     326           0 :             aFileName += String( pExt, RTL_TEXTENCODING_ASCII_US );
     327             : 
     328           0 :             aNewURL = aDir;
     329           0 :             aNewURL.Append( aFileName );
     330             : 
     331           0 :             bExists = FileExists( aNewURL );
     332             :         }
     333             :     }
     334             :     while( bExists );
     335             : 
     336             :     // write updated number
     337           0 :     SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aInfoFileURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
     338             : 
     339           0 :     if( pOStm )
     340             :     {
     341           0 :         *pOStm << nNextNumber;
     342           0 :         delete pOStm;
     343             :     }
     344             : 
     345           0 :     return aNewURL;
     346             : }
     347             : 
     348             : // ------------------------------------------------------------------------
     349             : 
     350           0 : void GalleryTheme::ImplBroadcast( sal_uIntPtr nUpdatePos )
     351             : {
     352           0 :     if( !IsBroadcasterLocked() )
     353             :     {
     354           0 :         if( GetObjectCount() && ( nUpdatePos >= GetObjectCount() ) )
     355           0 :             nUpdatePos = GetObjectCount() - 1;
     356             : 
     357           0 :         Broadcast( GalleryHint( GALLERY_HINT_THEME_UPDATEVIEW, GetName(), nUpdatePos ) );
     358             :     }
     359           0 : }
     360             : 
     361             : // ------------------------------------------------------------------------
     362             : 
     363           0 : sal_Bool GalleryTheme::UnlockTheme()
     364             : {
     365             :     DBG_ASSERT( mnThemeLockCount, "Theme is not locked" );
     366             : 
     367           0 :     sal_Bool bRet = sal_False;
     368             : 
     369           0 :     if( mnThemeLockCount )
     370             :     {
     371           0 :         --mnThemeLockCount;
     372           0 :         bRet = sal_True;
     373             :     }
     374             : 
     375           0 :     return bRet;
     376             : }
     377             : 
     378             : // ------------------------------------------------------------------------
     379             : 
     380           0 : void GalleryTheme::UnlockBroadcaster( sal_uIntPtr nUpdatePos )
     381             : {
     382             :     DBG_ASSERT( mnBroadcasterLockCount, "Broadcaster is not locked" );
     383             : 
     384           0 :     if( mnBroadcasterLockCount && !--mnBroadcasterLockCount )
     385           0 :         ImplBroadcast( nUpdatePos );
     386           0 : }
     387             : 
     388             : // ------------------------------------------------------------------------
     389             : 
     390           0 : bool GalleryTheme::InsertObject( const SgaObject& rObj, sal_uIntPtr nInsertPos )
     391             : {
     392           0 :     sal_Bool bRet = sal_False;
     393             : 
     394           0 :     if( rObj.IsValid() )
     395             :     {
     396           0 :         GalleryObject*  pFoundEntry = NULL;
     397           0 :         size_t iFoundPos = 0;
     398           0 :         for ( size_t n = aObjectList.size(); iFoundPos < n; ++iFoundPos )
     399             :         {
     400           0 :             if ( aObjectList[ iFoundPos ]->aURL == rObj.GetURL() )
     401             :             {
     402           0 :                 pFoundEntry = aObjectList[ iFoundPos ];
     403           0 :                 break;
     404             :             }
     405             :         }
     406             : 
     407           0 :         if( pFoundEntry )
     408             :         {
     409           0 :             GalleryObject aNewEntry;
     410             : 
     411             :             // update title of new object if neccessary
     412           0 :             if( !rObj.GetTitle().Len() )
     413             :             {
     414           0 :                 SgaObject* pOldObj = ImplReadSgaObject( pFoundEntry );
     415             : 
     416           0 :                 if( pOldObj )
     417             :                 {
     418           0 :                     ( (SgaObject&) rObj ).SetTitle( pOldObj->GetTitle() );
     419           0 :                     delete pOldObj;
     420             :                 }
     421             :             }
     422           0 :             else if( rObj.GetTitle() == String( RTL_CONSTASCII_USTRINGPARAM( "__<empty>__" ) ) )
     423           0 :                 ( (SgaObject&) rObj ).SetTitle( String() );
     424             : 
     425           0 :             ImplWriteSgaObject( rObj, nInsertPos, &aNewEntry );
     426           0 :             pFoundEntry->nOffset = aNewEntry.nOffset;
     427             :         }
     428             :         else
     429           0 :             ImplWriteSgaObject( rObj, nInsertPos, NULL );
     430             : 
     431           0 :         ImplSetModified( bRet = sal_True );
     432           0 :         ImplBroadcast( pFoundEntry ? iFoundPos : nInsertPos );
     433             :     }
     434             : 
     435           0 :     return bRet;
     436             : }
     437             : 
     438             : // ------------------------------------------------------------------------
     439             : 
     440           0 : SgaObject* GalleryTheme::AcquireObject( size_t nPos )
     441             : {
     442           0 :     return ImplReadSgaObject( aObjectList[ nPos ] );
     443             : }
     444             : 
     445             : // ------------------------------------------------------------------------
     446             : 
     447           0 : void GalleryTheme::ReleaseObject( SgaObject* pObject )
     448             : {
     449           0 :     delete pObject;
     450           0 : }
     451             : 
     452             : // ------------------------------------------------------------------------
     453             : 
     454           0 : bool GalleryTheme::RemoveObject( size_t nPos )
     455             : {
     456           0 :     GalleryObject* pEntry = NULL;
     457           0 :     if ( nPos < aObjectList.size() )
     458             :     {
     459           0 :         GalleryObjectList::iterator it = aObjectList.begin();
     460           0 :         ::std::advance( it, nPos );
     461           0 :         pEntry = *it;
     462           0 :         aObjectList.erase( it );
     463             :     }
     464             : 
     465           0 :     if( aObjectList.empty() )
     466           0 :         KillFile( GetSdgURL() );
     467             : 
     468           0 :     if( pEntry )
     469             :     {
     470           0 :         if( SGA_OBJ_SVDRAW == pEntry->eObjKind )
     471           0 :             aSvDrawStorageRef->Remove( pEntry->aURL.GetMainURL( INetURLObject::NO_DECODE ) );
     472             : 
     473           0 :         Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) );
     474           0 :         delete pEntry;
     475           0 :         Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) );
     476             : 
     477           0 :         ImplSetModified( sal_True );
     478           0 :         ImplBroadcast( nPos );
     479             :     }
     480             : 
     481           0 :     return( pEntry != NULL );
     482             : }
     483             : 
     484             : // ------------------------------------------------------------------------
     485             : 
     486           0 : bool GalleryTheme::ChangeObjectPos( size_t nOldPos, size_t nNewPos )
     487             : {
     488           0 :     sal_Bool bRet = sal_False;
     489             : 
     490           0 :     if(  nOldPos != nNewPos
     491           0 :       && nOldPos < aObjectList.size()
     492             :       )
     493             :     {
     494           0 :         GalleryObject* pEntry = aObjectList[ nOldPos ];
     495             : 
     496           0 :         GalleryObjectList::iterator it = aObjectList.begin();
     497           0 :         ::std::advance( it, nNewPos );
     498           0 :         aObjectList.insert( it, pEntry );
     499             : 
     500           0 :         if( nNewPos < nOldPos ) nOldPos++;
     501             : 
     502           0 :         it = aObjectList.begin();
     503           0 :         ::std::advance( it, nOldPos );
     504           0 :         aObjectList.erase( it );
     505             : 
     506           0 :         ImplSetModified( bRet = sal_True );
     507           0 :         ImplBroadcast( ( nNewPos < nOldPos ) ? nNewPos : ( nNewPos - 1 ) );
     508             :     }
     509             : 
     510           0 :     return bRet;
     511             : }
     512             : 
     513             : // ------------------------------------------------------------------------
     514             : 
     515           0 : void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProgress )
     516             : {
     517           0 :     if( !IsReadOnly() )
     518             :     {
     519           0 :         Graphic         aGraphic;
     520           0 :         String          aFormat;
     521             :         GalleryObject*  pEntry;
     522           0 :         const size_t    nCount = aObjectList.size();
     523             : 
     524           0 :         LockBroadcaster();
     525           0 :         bAbortActualize = sal_False;
     526             : 
     527             :         // LoeschFlag zuruecksetzen
     528           0 :         for (size_t i = 0; i < nCount; i++)
     529           0 :             aObjectList[ i ]->bDummy = sal_False;
     530             : 
     531           0 :         for(size_t i = 0; ( i < nCount ) && !bAbortActualize; i++)
     532             :         {
     533           0 :             if( pProgress )
     534           0 :                 pProgress->Update( i, nCount - 1 );
     535             : 
     536           0 :             pEntry = aObjectList[ i ];
     537             : 
     538           0 :             const INetURLObject aURL( pEntry->aURL );
     539             : 
     540           0 :             rActualizeLink.Call( (void*) &aURL );
     541             : 
     542             :             // SvDraw-Objekte werden spaeter aktualisiert
     543           0 :             if( pEntry->eObjKind != SGA_OBJ_SVDRAW )
     544             :             {
     545             :                 // Hier muss noch etwas eingebaut werden,
     546             :                 // das Files auf den ensprechenden Eintrag matched
     547             :                 // Grafiken als Grafik-Objekte in die Gallery aufnehmen
     548           0 :                 if( pEntry->eObjKind == SGA_OBJ_SOUND )
     549             :                 {
     550           0 :                     SgaObjectSound aObjSound( aURL );
     551           0 :                     if( !InsertObject( aObjSound ) )
     552           0 :                         pEntry->bDummy = sal_True;
     553             :                 }
     554             :                 else
     555             :                 {
     556           0 :                     aGraphic.Clear();
     557             : 
     558           0 :                     if ( GalleryGraphicImport( aURL, aGraphic, aFormat ) )
     559             :                     {
     560             :                         SgaObject* pNewObj;
     561             : 
     562           0 :                         if ( SGA_OBJ_INET == pEntry->eObjKind )
     563           0 :                             pNewObj = (SgaObject*) new SgaObjectINet( aGraphic, aURL, aFormat );
     564           0 :                         else if ( aGraphic.IsAnimated() )
     565           0 :                             pNewObj = (SgaObject*) new SgaObjectAnim( aGraphic, aURL, aFormat );
     566             :                         else
     567           0 :                             pNewObj = (SgaObject*) new SgaObjectBmp( aGraphic, aURL, aFormat );
     568             : 
     569           0 :                         if( !InsertObject( *pNewObj ) )
     570           0 :                             pEntry->bDummy = sal_True;
     571             : 
     572           0 :                         delete pNewObj;
     573             :                     }
     574             :                     else
     575           0 :                         pEntry->bDummy = sal_True; // Loesch-Flag setzen
     576             :                 }
     577             :             }
     578             :             else
     579             :             {
     580           0 :                 if ( aSvDrawStorageRef.Is() )
     581             :                 {
     582           0 :                     const String        aStmName( GetSvDrawStreamNameFromURL( pEntry->aURL ) );
     583           0 :                     SvStorageStreamRef  pIStm = aSvDrawStorageRef->OpenSotStream( aStmName, STREAM_READ );
     584             : 
     585           0 :                     if( pIStm && !pIStm->GetError() )
     586             :                     {
     587           0 :                         pIStm->SetBufferSize( 16384 );
     588             : 
     589           0 :                         SgaObjectSvDraw aNewObj( *pIStm, pEntry->aURL );
     590             : 
     591           0 :                         if( !InsertObject( aNewObj ) )
     592           0 :                             pEntry->bDummy = sal_True;
     593             : 
     594           0 :                         pIStm->SetBufferSize( 0L );
     595           0 :                     }
     596             :                 }
     597             :             }
     598           0 :         }
     599             : 
     600             :         // remove all entries with set flag
     601           0 :         for ( size_t i = 0; i < aObjectList.size(); )
     602             :         {
     603           0 :             pEntry = aObjectList[ i ];
     604           0 :             if( pEntry->bDummy )
     605             :             {
     606           0 :                 Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) );
     607           0 :                 GalleryObjectList::iterator it = aObjectList.begin();
     608           0 :                 ::std::advance( it, i );
     609           0 :                 aObjectList.erase( it );
     610           0 :                 delete pEntry;
     611           0 :                 Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uLong >( pEntry ) ) );
     612             :             }
     613           0 :             else ++i;
     614             :         }
     615             : 
     616             :         // update theme
     617           0 :         ::utl::TempFile aTmp;
     618           0 :         INetURLObject   aInURL( GetSdgURL() );
     619           0 :         INetURLObject   aTmpURL( aTmp.GetURL() );
     620             : 
     621             :         DBG_ASSERT( aInURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     622             :         DBG_ASSERT( aTmpURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     623             : 
     624           0 :         SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aInURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
     625           0 :         SvStream* pTmpStm = ::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
     626             : 
     627           0 :         if( pIStm && pTmpStm )
     628             :         {
     629           0 :             for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
     630             :             {
     631           0 :                 pEntry = aObjectList[ i ];
     632             :                 SgaObject* pObj;
     633             : 
     634           0 :                 switch( pEntry->eObjKind )
     635             :                 {
     636           0 :                     case( SGA_OBJ_BMP ):    pObj = new SgaObjectBmp();      break;
     637           0 :                     case( SGA_OBJ_ANIM ):   pObj = new SgaObjectAnim();     break;
     638           0 :                     case( SGA_OBJ_INET ):   pObj = new SgaObjectINet();     break;
     639           0 :                     case( SGA_OBJ_SVDRAW ): pObj = new SgaObjectSvDraw();   break;
     640           0 :                     case (SGA_OBJ_SOUND):   pObj = new SgaObjectSound();    break;
     641             : 
     642             :                     default:
     643           0 :                         pObj = NULL;
     644           0 :                     break;
     645             :                 }
     646             : 
     647           0 :                 if( pObj )
     648             :                 {
     649           0 :                     pIStm->Seek( pEntry->nOffset );
     650           0 :                     *pIStm >> *pObj;
     651           0 :                     pEntry->nOffset = pTmpStm->Tell();
     652           0 :                     *pTmpStm << *pObj;
     653           0 :                     delete pObj;
     654             :                 }
     655             :             }
     656             :         }
     657             :         else
     658             :         {
     659             :             OSL_FAIL( "File(s) could not be opened" );
     660             :         }
     661             : 
     662           0 :         delete pIStm;
     663           0 :         delete pTmpStm;
     664             : 
     665           0 :         CopyFile( aTmpURL, aInURL );
     666           0 :         KillFile( aTmpURL );
     667             : 
     668           0 :         sal_uIntPtr nStorErr = 0;
     669             : 
     670             :         {
     671           0 :             SvStorageRef aTempStorageRef( new SvStorage( sal_False, aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READWRITE ) );
     672           0 :             aSvDrawStorageRef->CopyTo( aTempStorageRef );
     673           0 :             nStorErr = aSvDrawStorageRef->GetError();
     674             :         }
     675             : 
     676           0 :         if( !nStorErr )
     677             :         {
     678           0 :             aSvDrawStorageRef.Clear();
     679           0 :             CopyFile( aTmpURL, GetSdvURL() );
     680           0 :             ImplCreateSvDrawStorage();
     681             :         }
     682             : 
     683           0 :         KillFile( aTmpURL );
     684           0 :         ImplSetModified( sal_True );
     685           0 :         ImplWrite();
     686           0 :         UnlockBroadcaster();
     687             :     }
     688           0 : }
     689             : 
     690             : // ------------------------------------------------------------------------
     691             : 
     692           0 : GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sal_Bool bReadOnly )
     693             : {
     694             :     DBG_ASSERT( rURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     695             : 
     696           0 :     GalleryThemeEntry*  pRet = NULL;
     697             : 
     698           0 :     if( FileExists( rURL ) )
     699             :     {
     700           0 :         SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( rURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
     701             : 
     702           0 :         if( pIStm )
     703             :         {
     704           0 :             String          aThemeName;
     705             :             sal_uInt16      nVersion;
     706           0 :             sal_Bool            bThemeNameFromResource = sal_False;
     707             : 
     708           0 :             *pIStm >> nVersion;
     709             : 
     710           0 :             if( nVersion <= 0x00ff )
     711             :             {
     712           0 :                 sal_uInt32      nThemeId = 0;
     713             : 
     714           0 :                 rtl::OString aTmpStr = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(*pIStm);
     715           0 :                 aThemeName = rtl::OStringToOUString(aTmpStr, RTL_TEXTENCODING_UTF8);
     716             : 
     717             :                 // Charakterkonvertierung durchfuehren
     718           0 :                 if( nVersion >= 0x0004 )
     719             :                 {
     720             :                     sal_uInt32  nCount;
     721             :                     sal_uInt16  nTemp16;
     722             : 
     723           0 :                     *pIStm >> nCount >> nTemp16;
     724           0 :                     pIStm->Seek( STREAM_SEEK_TO_END );
     725             : 
     726             :                     // pruefen, ob es sich um eine neuere Version handelt;
     727             :                     // daher um 520Bytes (8Bytes Kennung + 512Bytes Reserverpuffer ) zurueckspringen,
     728             :                     // falls dies ueberhaupt moeglich ist
     729           0 :                     if( pIStm->Tell() >= 520 )
     730             :                     {
     731             :                         sal_uInt32 nId1, nId2;
     732             : 
     733           0 :                         pIStm->SeekRel( -520 );
     734           0 :                         *pIStm >> nId1 >> nId2;
     735             : 
     736           0 :                         if( nId1 == COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) &&
     737             :                             nId2 == COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) )
     738             :                         {
     739           0 :                             VersionCompat* pCompat = new VersionCompat( *pIStm, STREAM_READ );
     740             : 
     741           0 :                             *pIStm >> nThemeId;
     742             : 
     743           0 :                             if( pCompat->GetVersion() >= 2 )
     744             :                             {
     745           0 :                                 *pIStm >> bThemeNameFromResource;
     746             :                             }
     747             : 
     748           0 :                             delete pCompat;
     749             :                         }
     750             :                     }
     751             :                 }
     752             : 
     753           0 :                 INetURLObject aPathURL( rURL );
     754             : 
     755           0 :                 aPathURL.removeSegment();
     756           0 :                 aPathURL.removeFinalSlash();
     757             :                 pRet = new GalleryThemeEntry( aPathURL, aThemeName,
     758           0 :                                               String(rURL.GetBase()).Copy( 2, 6 ).ToInt32(),
     759             :                                               bReadOnly, sal_False, nThemeId,
     760           0 :                                               bThemeNameFromResource );
     761             :             }
     762             : 
     763           0 :             delete pIStm;
     764             :         }
     765             :     }
     766             : 
     767           0 :     return pRet;
     768             : }
     769             : 
     770             : // -----------------------------------------------------------------------------
     771             : 
     772           0 : sal_Bool GalleryTheme::GetThumb( sal_uIntPtr nPos, Bitmap& rBmp, sal_Bool )
     773             : {
     774           0 :     SgaObject*  pObj = AcquireObject( nPos );
     775           0 :     sal_Bool        bRet = sal_False;
     776             : 
     777           0 :     if( pObj )
     778             :     {
     779           0 :         rBmp = pObj->GetThumbBmp();
     780           0 :         ReleaseObject( pObj );
     781           0 :         bRet = sal_True;
     782             :     }
     783             : 
     784           0 :     return bRet;
     785             : }
     786             : 
     787             : // -----------------------------------------------------------------------------
     788             : 
     789           0 : sal_Bool GalleryTheme::GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, sal_Bool bProgress )
     790             : {
     791           0 :     const GalleryObject*    pObject = ImplGetGalleryObject( nPos );
     792           0 :     sal_Bool                    bRet = sal_False;
     793             : 
     794           0 :     if( pObject )
     795             :     {
     796           0 :         const INetURLObject aURL( ImplGetURL( pObject ) );
     797             : 
     798           0 :         switch( pObject->eObjKind )
     799             :         {
     800             :             case( SGA_OBJ_BMP ):
     801             :             case( SGA_OBJ_ANIM ):
     802             :             case( SGA_OBJ_INET ):
     803             :             {
     804           0 :                 String aFilterDummy;
     805           0 :                 bRet = ( GalleryGraphicImport( aURL, rGraphic, aFilterDummy, bProgress ) != SGA_IMPORT_NONE );
     806             :             }
     807           0 :             break;
     808             : 
     809             :             case( SGA_OBJ_SVDRAW ):
     810             :             {
     811           0 :                 SvxGalleryDrawModel aModel;
     812             : 
     813           0 :                 if( aModel.GetModel() )
     814             :                 {
     815           0 :                     if( GetModel( nPos, *aModel.GetModel(), bProgress ) )
     816             :                     {
     817           0 :                         ImageMap aIMap;
     818             : 
     819           0 :                         if( CreateIMapGraphic( *aModel.GetModel(), rGraphic, aIMap ) )
     820           0 :                             bRet = sal_True;
     821             :                         else
     822             :                         {
     823           0 :                             VirtualDevice aVDev;
     824           0 :                             aVDev.SetMapMode( MapMode( MAP_100TH_MM ) );
     825           0 :                             FmFormView aView( aModel.GetModel(), &aVDev );
     826             : 
     827           0 :                             aView.hideMarkHandles();
     828           0 :                             aView.ShowSdrPage(aView.GetModel()->GetPage(0));
     829           0 :                             aView.MarkAll();
     830           0 :                             rGraphic = aView.GetAllMarkedGraphic();
     831           0 :                             bRet = sal_True;
     832           0 :                         }
     833             :                     }
     834           0 :                 }
     835             :             }
     836           0 :             break;
     837             : 
     838             :             case( SGA_OBJ_SOUND ):
     839             :             {
     840           0 :                 SgaObject* pObj = AcquireObject( nPos );
     841             : 
     842           0 :                 if( pObj )
     843             :                 {
     844           0 :                     Bitmap aBmp( pObj->GetThumbBmp() );
     845           0 :                     aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
     846           0 :                     rGraphic = aBmp;
     847           0 :                     ReleaseObject( pObj );
     848           0 :                     bRet = sal_True;
     849             :                 }
     850             :             }
     851           0 :             break;
     852             : 
     853             :             default:
     854           0 :             break;
     855           0 :         }
     856             :     }
     857             : 
     858           0 :     return bRet;
     859             : }
     860             : 
     861             : // -----------------------------------------------------------------------------
     862             : 
     863           0 : sal_Bool GalleryTheme::InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos )
     864             : {
     865           0 :     sal_Bool bRet = sal_False;
     866             : 
     867           0 :     if( rGraphic.GetType() != GRAPHIC_NONE )
     868             :     {
     869           0 :         sal_uIntPtr           nExportFormat = CVT_UNKNOWN;
     870           0 :         const GfxLink   aGfxLink( ( (Graphic&) rGraphic ).GetLink() );
     871             : 
     872           0 :         if( aGfxLink.GetDataSize() )
     873             :         {
     874           0 :             switch( aGfxLink.GetType() )
     875             :             {
     876           0 :                 case( GFX_LINK_TYPE_EPS_BUFFER ): nExportFormat = CVT_SVM; break;
     877           0 :                 case( GFX_LINK_TYPE_NATIVE_GIF ): nExportFormat = CVT_GIF; break;
     878           0 :                 case( GFX_LINK_TYPE_NATIVE_JPG ): nExportFormat = CVT_JPG; break;
     879           0 :                 case( GFX_LINK_TYPE_NATIVE_PNG ): nExportFormat = CVT_PNG; break;
     880           0 :                 case( GFX_LINK_TYPE_NATIVE_TIF ): nExportFormat = CVT_TIF; break;
     881           0 :                 case( GFX_LINK_TYPE_NATIVE_WMF ): nExportFormat = CVT_WMF; break;
     882           0 :                 case( GFX_LINK_TYPE_NATIVE_MET ): nExportFormat = CVT_MET; break;
     883           0 :                 case( GFX_LINK_TYPE_NATIVE_PCT ): nExportFormat = CVT_PCT; break;
     884           0 :                 case( GFX_LINK_TYPE_NATIVE_SVG ): nExportFormat = CVT_SVG; break;
     885             :                 default:
     886           0 :                     break;
     887             :             }
     888             :         }
     889             :         else
     890             :         {
     891           0 :             if( rGraphic.GetType() == GRAPHIC_BITMAP )
     892             :             {
     893           0 :                 if( rGraphic.IsAnimated() )
     894           0 :                     nExportFormat = CVT_GIF;
     895             :                 else
     896           0 :                     nExportFormat = CVT_PNG;
     897             :             }
     898             :             else
     899           0 :                 nExportFormat = CVT_SVM;
     900             :         }
     901             : 
     902           0 :         const INetURLObject aURL( ImplCreateUniqueURL( SGA_OBJ_BMP, nExportFormat ) );
     903           0 :         SvStream*           pOStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
     904             : 
     905           0 :         if( pOStm )
     906             :         {
     907           0 :             pOStm->SetVersion( SOFFICE_FILEFORMAT_50 );
     908             : 
     909           0 :             if( CVT_SVM == nExportFormat )
     910             :             {
     911           0 :                 GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() );
     912             : 
     913           0 :                 aMtf.Write( *pOStm );
     914           0 :                 bRet = ( pOStm->GetError() == ERRCODE_NONE );
     915             :             }
     916             :             else
     917             :             {
     918           0 :                 if( aGfxLink.GetDataSize() && aGfxLink.GetData() )
     919             :                 {
     920           0 :                     pOStm->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() );
     921           0 :                     bRet = ( pOStm->GetError() == ERRCODE_NONE );
     922             :                 }
     923             :                 else
     924           0 :                     bRet = ( GraphicConverter::Export( *pOStm, rGraphic, nExportFormat ) == ERRCODE_NONE );
     925             :             }
     926             : 
     927           0 :             delete pOStm;
     928             :         }
     929             : 
     930           0 :         if( bRet )
     931             :         {
     932           0 :             const SgaObjectBmp aObjBmp( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
     933           0 :             InsertObject( aObjBmp, nInsertPos );
     934           0 :         }
     935             :     }
     936             : 
     937           0 :     return bRet;
     938             : }
     939             : 
     940             : // -----------------------------------------------------------------------------
     941             : 
     942           0 : sal_Bool GalleryTheme::GetModel( sal_uIntPtr nPos, SdrModel& rModel, sal_Bool )
     943             : {
     944           0 :     const GalleryObject*    pObject = ImplGetGalleryObject( nPos );
     945           0 :     sal_Bool                    bRet = sal_False;
     946             : 
     947           0 :     if( pObject && ( SGA_OBJ_SVDRAW == pObject->eObjKind ) )
     948             :     {
     949           0 :         const INetURLObject aURL( ImplGetURL( pObject ) );
     950           0 :         SvStorageRef        xStor( GetSvDrawStorage() );
     951             : 
     952           0 :         if( xStor.Is() )
     953             :         {
     954           0 :             const String        aStmName( GetSvDrawStreamNameFromURL( aURL ) );
     955           0 :             SvStorageStreamRef  xIStm( xStor->OpenSotStream( aStmName, STREAM_READ ) );
     956             : 
     957           0 :             if( xIStm.Is() && !xIStm->GetError() )
     958             :             {
     959           0 :                 xIStm->SetBufferSize( STREAMBUF_SIZE );
     960           0 :                 bRet = GallerySvDrawImport( *xIStm, rModel );
     961           0 :                 xIStm->SetBufferSize( 0L );
     962           0 :             }
     963           0 :         }
     964             :     }
     965             : 
     966           0 :     return bRet;
     967             : }
     968             : 
     969             : // -----------------------------------------------------------------------------
     970             : 
     971           0 : sal_Bool GalleryTheme::InsertModel( const FmFormModel& rModel, sal_uIntPtr nInsertPos )
     972             : {
     973           0 :     INetURLObject   aURL( ImplCreateUniqueURL( SGA_OBJ_SVDRAW ) );
     974           0 :     SvStorageRef    xStor( GetSvDrawStorage() );
     975           0 :     sal_Bool            bRet = sal_False;
     976             : 
     977           0 :     if( xStor.Is() )
     978             :     {
     979           0 :         const String        aStmName( GetSvDrawStreamNameFromURL( aURL ) );
     980           0 :         SvStorageStreamRef  xOStm( xStor->OpenSotStream( aStmName, STREAM_WRITE | STREAM_TRUNC ) );
     981             : 
     982           0 :         if( xOStm.Is() && !xOStm->GetError() )
     983             :         {
     984           0 :             SvMemoryStream  aMemStm( 65535, 65535 );
     985           0 :             FmFormModel*    pFormModel = (FmFormModel*) &rModel;
     986             : 
     987           0 :             pFormModel->BurnInStyleSheetAttributes();
     988             : 
     989             :             {
     990           0 :                 uno::Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( aMemStm ) );
     991             : 
     992           0 :                 if( xDocOut.is() )
     993           0 :                     SvxDrawingLayerExport( pFormModel, xDocOut );
     994             :             }
     995             : 
     996           0 :             aMemStm.Seek( 0 );
     997             : 
     998           0 :             xOStm->SetBufferSize( 16348 );
     999           0 :             GalleryCodec aCodec( *xOStm );
    1000           0 :             aCodec.Write( aMemStm );
    1001             : 
    1002           0 :             if( !xOStm->GetError() )
    1003             :             {
    1004           0 :                 SgaObjectSvDraw aObjSvDraw( rModel, aURL );
    1005           0 :                 bRet = InsertObject( aObjSvDraw, nInsertPos );
    1006             :             }
    1007             : 
    1008           0 :             xOStm->SetBufferSize( 0L );
    1009           0 :             xOStm->Commit();
    1010           0 :         }
    1011             :     }
    1012             : 
    1013           0 :     return bRet;
    1014             : }
    1015             : 
    1016             : // -----------------------------------------------------------------------------
    1017             : 
    1018           0 : sal_Bool GalleryTheme::GetModelStream( sal_uIntPtr nPos, SotStorageStreamRef& rxModelStream, sal_Bool )
    1019             : {
    1020           0 :     const GalleryObject*    pObject = ImplGetGalleryObject( nPos );
    1021           0 :     sal_Bool                    bRet = sal_False;
    1022             : 
    1023           0 :     if( pObject && ( SGA_OBJ_SVDRAW == pObject->eObjKind ) )
    1024             :     {
    1025           0 :         const INetURLObject aURL( ImplGetURL( pObject ) );
    1026           0 :         SvStorageRef        xStor( GetSvDrawStorage() );
    1027             : 
    1028           0 :         if( xStor.Is() )
    1029             :         {
    1030           0 :             const String        aStmName( GetSvDrawStreamNameFromURL( aURL ) );
    1031           0 :             SvStorageStreamRef  xIStm( xStor->OpenSotStream( aStmName, STREAM_READ ) );
    1032             : 
    1033           0 :             if( xIStm.Is() && !xIStm->GetError() )
    1034             :             {
    1035           0 :                 sal_uInt32 nVersion = 0;
    1036             : 
    1037           0 :                 xIStm->SetBufferSize( 16348 );
    1038             : 
    1039           0 :                 if( GalleryCodec::IsCoded( *xIStm, nVersion ) )
    1040             :                 {
    1041           0 :                     SvxGalleryDrawModel aModel;
    1042             : 
    1043           0 :                     if( aModel.GetModel() )
    1044             :                     {
    1045           0 :                         if( GallerySvDrawImport( *xIStm, *aModel.GetModel() ) )
    1046             :                         {
    1047           0 :                             aModel.GetModel()->BurnInStyleSheetAttributes();
    1048             : 
    1049             :                             {
    1050           0 :                                 uno::Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxModelStream ) );
    1051             : 
    1052           0 :                                 if( SvxDrawingLayerExport( aModel.GetModel(), xDocOut ) )
    1053           0 :                                     rxModelStream->Commit();
    1054             :                             }
    1055             :                         }
    1056             : 
    1057           0 :                         bRet = ( rxModelStream->GetError() == ERRCODE_NONE );
    1058           0 :                     }
    1059             :                 }
    1060             : 
    1061           0 :                 xIStm->SetBufferSize( 0 );
    1062           0 :             }
    1063           0 :         }
    1064             :     }
    1065             : 
    1066           0 :     return bRet;
    1067             : }
    1068             : 
    1069             : // -----------------------------------------------------------------------------
    1070             : 
    1071           0 : sal_Bool GalleryTheme::InsertModelStream( const SotStorageStreamRef& rxModelStream, sal_uIntPtr nInsertPos )
    1072             : {
    1073           0 :     INetURLObject   aURL( ImplCreateUniqueURL( SGA_OBJ_SVDRAW ) );
    1074           0 :     SvStorageRef    xStor( GetSvDrawStorage() );
    1075           0 :     sal_Bool            bRet = sal_False;
    1076             : 
    1077           0 :     if( xStor.Is() )
    1078             :     {
    1079           0 :         const String        aStmName( GetSvDrawStreamNameFromURL( aURL ) );
    1080           0 :         SvStorageStreamRef  xOStm( xStor->OpenSotStream( aStmName, STREAM_WRITE | STREAM_TRUNC ) );
    1081             : 
    1082           0 :         if( xOStm.Is() && !xOStm->GetError() )
    1083             :         {
    1084           0 :             GalleryCodec    aCodec( *xOStm );
    1085           0 :             SvMemoryStream  aMemStm( 65535, 65535 );
    1086             : 
    1087           0 :             xOStm->SetBufferSize( 16348 );
    1088           0 :             aCodec.Write( *rxModelStream );
    1089             : 
    1090           0 :             if( !xOStm->GetError() )
    1091             :             {
    1092           0 :                 xOStm->Seek( 0 );
    1093           0 :                 SgaObjectSvDraw aObjSvDraw( *xOStm, aURL );
    1094           0 :                 bRet = InsertObject( aObjSvDraw, nInsertPos );
    1095             :             }
    1096             : 
    1097           0 :             xOStm->SetBufferSize( 0L );
    1098           0 :             xOStm->Commit();
    1099           0 :         }
    1100             :     }
    1101             : 
    1102           0 :     return bRet;
    1103             : }
    1104             : 
    1105             : // -----------------------------------------------------------------------------
    1106             : 
    1107           0 : sal_Bool GalleryTheme::GetURL( sal_uIntPtr nPos, INetURLObject& rURL, sal_Bool )
    1108             : {
    1109           0 :     const GalleryObject*    pObject = ImplGetGalleryObject( nPos );
    1110           0 :     sal_Bool                    bRet = sal_False;
    1111             : 
    1112           0 :     if( pObject )
    1113             :     {
    1114           0 :         rURL = INetURLObject( ImplGetURL( pObject ) );
    1115           0 :         bRet = sal_True;
    1116             :     }
    1117             : 
    1118           0 :     return bRet;
    1119             : }
    1120             : 
    1121             : // -----------------------------------------------------------------------------
    1122             : 
    1123           0 : sal_Bool GalleryTheme::InsertURL( const INetURLObject& rURL, sal_uIntPtr nInsertPos )
    1124             : {
    1125           0 :     Graphic         aGraphic;
    1126           0 :     String          aFormat;
    1127           0 :     SgaObject*      pNewObj = NULL;
    1128           0 :     const sal_uInt16    nImportRet = GalleryGraphicImport( rURL, aGraphic, aFormat );
    1129           0 :     sal_Bool            bRet = sal_False;
    1130             : 
    1131           0 :     if( nImportRet != SGA_IMPORT_NONE )
    1132             :     {
    1133           0 :         if ( SGA_IMPORT_INET == nImportRet )
    1134           0 :             pNewObj = (SgaObject*) new SgaObjectINet( aGraphic, rURL, aFormat );
    1135           0 :         else if ( aGraphic.IsAnimated() )
    1136           0 :             pNewObj = (SgaObject*) new SgaObjectAnim( aGraphic, rURL, aFormat );
    1137             :         else
    1138           0 :             pNewObj = (SgaObject*) new SgaObjectBmp( aGraphic, rURL, aFormat );
    1139             :     }
    1140           0 :     else if( ::avmedia::MediaWindow::isMediaURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
    1141           0 :         pNewObj = (SgaObject*) new SgaObjectSound( rURL );
    1142             : 
    1143           0 :     if( pNewObj && InsertObject( *pNewObj, nInsertPos ) )
    1144           0 :         bRet = sal_True;
    1145             : 
    1146           0 :     delete pNewObj;
    1147             : 
    1148           0 :     return bRet;
    1149             : }
    1150             : 
    1151             : // -----------------------------------------------------------------------------
    1152             : 
    1153           0 : sal_Bool GalleryTheme::InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_uIntPtr nInsertPos )
    1154             : {
    1155           0 :     INetURLObject                   aURL;
    1156           0 :     ::std::vector< INetURLObject >  aURLVector;
    1157           0 :     sal_Bool                            bRet = sal_False;
    1158             : 
    1159             :     try
    1160             :     {
    1161           0 :         ::ucbhelper::Content         aCnt( rFileOrDirURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
    1162           0 :         sal_Bool        bFolder = false;
    1163             : 
    1164           0 :         aCnt.getPropertyValue( OUString("IsFolder") ) >>= bFolder;
    1165             : 
    1166           0 :         if( bFolder )
    1167             :         {
    1168           0 :             uno::Sequence< OUString > aProps( 1 );
    1169           0 :             aProps.getArray()[ 0 ] = OUString("Url");
    1170           0 :             uno::Reference< sdbc::XResultSet > xResultSet( aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
    1171           0 :             uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
    1172           0 :             if( xContentAccess.is() )
    1173             :             {
    1174           0 :                 while( xResultSet->next() )
    1175             :                 {
    1176           0 :                     aURL.SetSmartURL( xContentAccess->queryContentIdentifierString() );
    1177           0 :                     aURLVector.push_back( aURL );
    1178             :                 }
    1179           0 :             }
    1180             :         }
    1181             :         else
    1182           0 :             aURLVector.push_back( rFileOrDirURL );
    1183             :     }
    1184           0 :     catch( const ucb::ContentCreationException& )
    1185             :     {
    1186             :     }
    1187           0 :     catch( const uno::RuntimeException& )
    1188             :     {
    1189             :     }
    1190           0 :     catch( const uno::Exception& )
    1191             :     {
    1192             :     }
    1193             : 
    1194           0 :     ::std::vector< INetURLObject >::const_iterator aIter( aURLVector.begin() ), aEnd( aURLVector.end() );
    1195             : 
    1196           0 :     while( aIter != aEnd )
    1197           0 :         bRet = bRet || InsertURL( *aIter++, nInsertPos );
    1198             : 
    1199           0 :     return bRet;
    1200             : }
    1201             : 
    1202             : // -----------------------------------------------------------------------------
    1203             : 
    1204           0 : sal_Bool GalleryTheme::InsertTransferable( const uno::Reference< datatransfer::XTransferable >& rxTransferable, sal_uIntPtr nInsertPos )
    1205             : {
    1206           0 :     sal_Bool bRet = sal_False;
    1207             : 
    1208           0 :     if( rxTransferable.is() )
    1209             :     {
    1210           0 :         TransferableDataHelper  aDataHelper( rxTransferable );
    1211           0 :         Graphic*                pGraphic = NULL;
    1212             : 
    1213           0 :         if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
    1214             :         {
    1215           0 :             SotStorageStreamRef xModelStm;
    1216             : 
    1217           0 :             if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xModelStm ) )
    1218           0 :                 bRet = InsertModelStream( xModelStm, nInsertPos );
    1219             :         }
    1220           0 :         else if( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) ||
    1221           0 :                  aDataHelper.HasFormat( FORMAT_FILE ) )
    1222             :         {
    1223           0 :             FileList aFileList;
    1224             : 
    1225           0 :             if( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) )
    1226           0 :                 aDataHelper.GetFileList( SOT_FORMAT_FILE_LIST, aFileList );
    1227             :             else
    1228             :             {
    1229           0 :                 String aFile;
    1230             : 
    1231           0 :                 aDataHelper.GetString( FORMAT_FILE, aFile );
    1232             : 
    1233           0 :                 if( aFile.Len() )
    1234           0 :                     aFileList.AppendFile( aFile );
    1235             :             }
    1236             : 
    1237           0 :             for( sal_uInt32 i = 0, nCount = aFileList.Count(); i < nCount; ++i )
    1238             :             {
    1239           0 :                 const String    aFile( aFileList.GetFile( i ) );
    1240           0 :                 INetURLObject   aURL( aFile );
    1241             : 
    1242           0 :                 if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
    1243             :                 {
    1244           0 :                     rtl::OUString aLocalURL;
    1245             : 
    1246           0 :                     if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFile, aLocalURL ) )
    1247           0 :                         aURL = INetURLObject( aLocalURL );
    1248             :                 }
    1249             : 
    1250           0 :                 if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
    1251           0 :                     bRet = InsertFileOrDirURL( aURL, nInsertPos );
    1252           0 :             }
    1253             :         }
    1254             :         else
    1255             :         {
    1256           0 :             Graphic aGraphic;
    1257           0 :             sal_uIntPtr nFormat = 0;
    1258             : 
    1259           0 :             if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) )
    1260           0 :                 nFormat = SOT_FORMATSTR_ID_SVXB;
    1261           0 :             else if( aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
    1262           0 :                 nFormat = FORMAT_GDIMETAFILE;
    1263           0 :             else if( aDataHelper.HasFormat( FORMAT_BITMAP ) )
    1264           0 :                 nFormat = FORMAT_BITMAP;
    1265             : 
    1266           0 :             if( nFormat && aDataHelper.GetGraphic( nFormat, aGraphic ) )
    1267           0 :                 pGraphic = new Graphic( aGraphic );
    1268             :         }
    1269             : 
    1270           0 :         if( pGraphic )
    1271             :         {
    1272           0 :             bRet = sal_False;
    1273             : 
    1274           0 :             if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVIM ) )
    1275             :             {
    1276             : 
    1277           0 :                 ImageMap aImageMap;
    1278             : 
    1279             :                 // according to KA we don't need a BaseURL here
    1280           0 :                 if( aDataHelper.GetImageMap( SOT_FORMATSTR_ID_SVIM, aImageMap ) )
    1281             :                 {
    1282           0 :                     SvxGalleryDrawModel aModel;
    1283             : 
    1284           0 :                     if( aModel.GetModel() )
    1285             :                     {
    1286           0 :                         SgaUserDataFactory  aFactory;
    1287             : 
    1288           0 :                         SdrPage*    pPage = aModel.GetModel()->GetPage(0);
    1289           0 :                         SdrGrafObj* pGrafObj = new SdrGrafObj( *pGraphic );
    1290             : 
    1291           0 :                         pGrafObj->AppendUserData( new SgaIMapInfo( aImageMap ) );
    1292           0 :                         pPage->InsertObject( pGrafObj );
    1293           0 :                         bRet = InsertModel( *aModel.GetModel(), nInsertPos );
    1294           0 :                     }
    1295           0 :                 }
    1296             :             }
    1297             : 
    1298           0 :             if( !bRet )
    1299           0 :                 bRet = InsertGraphic( *pGraphic, nInsertPos );
    1300             : 
    1301           0 :             delete pGraphic;
    1302           0 :         }
    1303             :     }
    1304             : 
    1305           0 :     return bRet;
    1306             : }
    1307             : 
    1308             : // -----------------------------------------------------------------------------
    1309             : 
    1310           0 : void GalleryTheme::CopyToClipboard( Window* pWindow, sal_uIntPtr nPos )
    1311             : {
    1312           0 :     GalleryTransferable* pTransferable = new GalleryTransferable( this, nPos, false );
    1313           0 :     pTransferable->CopyToClipboard( pWindow );
    1314           0 : }
    1315             : 
    1316             : // -----------------------------------------------------------------------------
    1317             : 
    1318           0 : void GalleryTheme::StartDrag( Window* pWindow, sal_uIntPtr nPos )
    1319             : {
    1320           0 :     GalleryTransferable* pTransferable = new GalleryTransferable( this, nPos, true );
    1321           0 :     pTransferable->StartDrag( pWindow, DND_ACTION_COPY | DND_ACTION_LINK );
    1322           0 : }
    1323             : 
    1324             : // -----------------------------------------------------------------------------
    1325             : 
    1326           0 : SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const
    1327             : {
    1328           0 :     const INetURLObject aRelURL1( GetParent()->GetRelativeURL() );
    1329           0 :     const INetURLObject aRelURL2( GetParent()->GetUserURL() );
    1330           0 :     INetURLObject       aNewURL, aTempURL;
    1331           0 :     sal_uInt32          nCount = GetObjectCount();
    1332             :     sal_Bool                bRel;
    1333             : 
    1334           0 :     rOStm << (sal_uInt16) 0x0004;
    1335           0 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, GetRealName(), RTL_TEXTENCODING_UTF8);
    1336           0 :     rOStm << nCount << (sal_uInt16) osl_getThreadTextEncoding();
    1337             : 
    1338           0 :     for( sal_uInt32 i = 0; i < nCount; i++ )
    1339             :     {
    1340           0 :         const GalleryObject* pObj = ImplGetGalleryObject( i );
    1341           0 :         String               aPath;
    1342             : 
    1343           0 :         if( SGA_OBJ_SVDRAW == pObj->eObjKind )
    1344             :         {
    1345           0 :             aPath = GetSvDrawStreamNameFromURL( pObj->aURL );
    1346           0 :             bRel = sal_False;
    1347             :         }
    1348             :         else
    1349             :         {
    1350           0 :             aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
    1351           0 :             bRel = ( ( aPath.Erase( sal::static_int_cast< xub_StrLen >( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) ) ) == String(aRelURL1.GetMainURL( INetURLObject::NO_DECODE ) ));
    1352             : 
    1353           0 :             if( bRel && ( pObj->aURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() > ( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() + 1 ) ) )
    1354             :             {
    1355           0 :                 aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
    1356           0 :                 aPath = aPath.Erase( 0, sal::static_int_cast< xub_StrLen >( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) );
    1357             :             }
    1358             :             else
    1359             :             {
    1360           0 :                 aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
    1361           0 :                 bRel = ( ( aPath.Erase( sal::static_int_cast< xub_StrLen >( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) ) ) == String(aRelURL2.GetMainURL( INetURLObject::NO_DECODE ) ));
    1362             : 
    1363           0 :                 if( bRel && ( pObj->aURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() > ( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() + 1 ) ) )
    1364             :                 {
    1365           0 :                     aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
    1366           0 :                     aPath = aPath.Erase( 0, sal::static_int_cast< xub_StrLen >( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) );
    1367             :                 }
    1368             :                 else
    1369           0 :                     aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
    1370             :             }
    1371             :         }
    1372             : 
    1373           0 :         aPath.SearchAndReplace(m_aDestDir, String());
    1374           0 :         rOStm << bRel;
    1375           0 :         write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, aPath, RTL_TEXTENCODING_UTF8);
    1376           0 :         rOStm << pObj->nOffset << (sal_uInt16) pObj->eObjKind;
    1377           0 :     }
    1378             : 
    1379             :     // neuerdings wird ein 512-Byte-Reservepuffer gechrieben;
    1380             :     // um diesen zu erkennen werden zwei sal_uIntPtr-Ids geschrieben
    1381           0 :     rOStm << COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) << COMPAT_FORMAT( 'E', 'S', 'R', 'V' );
    1382             : 
    1383           0 :     const long      nReservePos = rOStm.Tell();
    1384           0 :     VersionCompat*  pCompat = new VersionCompat( rOStm, STREAM_WRITE, 2 );
    1385             : 
    1386           0 :     rOStm << (sal_uInt32) GetId() << IsThemeNameFromResource(); // ab Version 2
    1387             : 
    1388           0 :     delete pCompat;
    1389             : 
    1390             :     // Rest des Puffers auffuellen
    1391           0 :     const long  nRest = Max( 512L - ( (long) rOStm.Tell() - nReservePos ), 0L );
    1392             : 
    1393           0 :     if( nRest )
    1394             :     {
    1395           0 :         char* pReserve = new char[ nRest ];
    1396           0 :         memset( pReserve, 0, nRest );
    1397           0 :         rOStm.Write( pReserve, nRest );
    1398           0 :         delete[] pReserve;
    1399             :     }
    1400             : 
    1401           0 :     return rOStm;
    1402             : }
    1403             : 
    1404             : // ------------------------------------------------------------------------
    1405             : 
    1406           0 : SvStream& GalleryTheme::ReadData( SvStream& rIStm )
    1407             : {
    1408             :     sal_uInt32          nCount;
    1409             :     sal_uInt16          nVersion;
    1410           0 :     String              aThemeName;
    1411             :     rtl_TextEncoding    nTextEncoding;
    1412             : 
    1413           0 :     rIStm >> nVersion;
    1414           0 :     rtl::OString aTmpStr = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIStm);
    1415           0 :     rIStm >> nCount;
    1416             : 
    1417           0 :     if( nVersion >= 0x0004 )
    1418             :     {
    1419             :         sal_uInt16 nTmp16;
    1420           0 :         rIStm >> nTmp16;
    1421           0 :         nTextEncoding = (rtl_TextEncoding) nTmp16;
    1422             :     }
    1423             :     else
    1424           0 :         nTextEncoding = RTL_TEXTENCODING_UTF8;
    1425             : 
    1426           0 :     aThemeName = rtl::OStringToOUString(aTmpStr, nTextEncoding);
    1427             : 
    1428           0 :     if( nCount <= ( 1L << 14 ) )
    1429             :     {
    1430             :         GalleryObject*  pObj;
    1431           0 :         INetURLObject   aRelURL1( GetParent()->GetRelativeURL() );
    1432           0 :         INetURLObject   aRelURL2( GetParent()->GetUserURL() );
    1433             :         sal_uInt32      nId1, nId2;
    1434             :         sal_Bool            bRel;
    1435             : 
    1436           0 :         for( size_t i = 0, n = aObjectList.size(); i < n; ++i )
    1437             :         {
    1438           0 :             pObj = aObjectList[ i ];
    1439           0 :             Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( pObj ) ) );
    1440           0 :             delete pObj;
    1441           0 :             Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uIntPtr >( pObj ) ) );
    1442             :         }
    1443           0 :         aObjectList.clear();
    1444             : 
    1445           0 :         for( sal_uInt32 i = 0; i < nCount; i++ )
    1446             :         {
    1447           0 :             pObj = new GalleryObject;
    1448             : 
    1449           0 :             String      aFileName;
    1450           0 :             String      aPath;
    1451             :             sal_uInt16  nTemp;
    1452             : 
    1453           0 :             rIStm >> bRel;
    1454           0 :             rtl::OString aTempFileName = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIStm);
    1455           0 :             rIStm >> pObj->nOffset;
    1456           0 :             rIStm >> nTemp; pObj->eObjKind = (SgaObjKind) nTemp;
    1457             : 
    1458           0 :             aFileName = rtl::OStringToOUString(aTempFileName, osl_getThreadTextEncoding());
    1459             : 
    1460           0 :             if( bRel )
    1461             :             {
    1462           0 :                 aFileName.SearchAndReplaceAll( '\\', '/' );
    1463           0 :                 aPath = aRelURL1.GetMainURL( INetURLObject::NO_DECODE );
    1464             : 
    1465           0 :                 if( aFileName.GetChar( 0 ) != '/' )
    1466           0 :                         aPath += '/';
    1467             : 
    1468           0 :                 aPath += aFileName;
    1469             : 
    1470           0 :                 pObj->aURL = INetURLObject( aPath );
    1471             : 
    1472           0 :                 if( !FileExists( pObj->aURL ) )
    1473             :                 {
    1474           0 :                     aPath = aRelURL2.GetMainURL( INetURLObject::NO_DECODE );
    1475             : 
    1476           0 :                     if( aFileName.GetChar( 0 ) != '/' )
    1477           0 :                         aPath += '/';
    1478             : 
    1479           0 :                     aPath += aFileName;
    1480             : 
    1481             :                     // assign this URL, even in the case it is not valid (#94482)
    1482           0 :                     pObj->aURL = INetURLObject( aPath );
    1483             :                 }
    1484             :             }
    1485             :             else
    1486             :             {
    1487           0 :                 if( SGA_OBJ_SVDRAW == pObj->eObjKind )
    1488             :                 {
    1489           0 :                     const static String aBaseURLStr( RTL_CONSTASCII_USTRINGPARAM( "gallery/svdraw/" ) );
    1490             : 
    1491           0 :                     String aDummyURL( aBaseURLStr );
    1492           0 :                     pObj->aURL = INetURLObject( aDummyURL += aFileName, INET_PROT_PRIV_SOFFICE );
    1493             :                 }
    1494             :                 else
    1495             :                 {
    1496           0 :                     rtl::OUString aLocalURL;
    1497             : 
    1498           0 :                     pObj->aURL = INetURLObject( aFileName );
    1499             : 
    1500           0 :                     if( ( pObj->aURL.GetProtocol() == INET_PROT_NOT_VALID ) &&
    1501           0 :                         ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFileName, aLocalURL ) )
    1502             :                     {
    1503           0 :                         pObj->aURL = INetURLObject( aLocalURL );
    1504           0 :                     }
    1505             :                 }
    1506             :             }
    1507             : 
    1508           0 :             aObjectList.push_back( pObj );
    1509           0 :         }
    1510             : 
    1511           0 :         rIStm >> nId1 >> nId2;
    1512             : 
    1513             :         // in neueren Versionen befindet sich am Ende ein 512-Byte-Reservepuffer;
    1514             :         // die Daten befinden sich am Anfang dieses Puffers und
    1515             :         // sind durch eine VersionCompat geklammert
    1516           0 :         if( !rIStm.IsEof() &&
    1517             :             nId1 == COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) &&
    1518             :             nId2 == COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) )
    1519             :         {
    1520           0 :             VersionCompat*  pCompat = new VersionCompat( rIStm, STREAM_READ );
    1521             :             sal_uInt32      nTemp32;
    1522           0 :             sal_Bool            bThemeNameFromResource = sal_False;
    1523             : 
    1524           0 :             rIStm >> nTemp32;
    1525             : 
    1526           0 :             if( pCompat->GetVersion() >= 2 )
    1527             :             {
    1528           0 :                 rIStm >> bThemeNameFromResource;
    1529             :             }
    1530             : 
    1531           0 :             SetId( nTemp32, bThemeNameFromResource );
    1532           0 :             delete pCompat;
    1533           0 :         }
    1534             :     }
    1535             :     else
    1536           0 :         rIStm.SetError( SVSTREAM_READ_ERROR );
    1537             : 
    1538           0 :     ImplSetModified( sal_False );
    1539             : 
    1540           0 :     return rIStm;
    1541             : }
    1542             : 
    1543             : // ------------------------------------------------------------------------
    1544             : 
    1545           0 : SvStream& operator<<( SvStream& rOut, const GalleryTheme& rTheme )
    1546             : {
    1547           0 :     return rTheme.WriteData( rOut );
    1548             : }
    1549             : 
    1550             : // ------------------------------------------------------------------------
    1551             : 
    1552           0 : SvStream& operator>>( SvStream& rIn, GalleryTheme& rTheme )
    1553             : {
    1554           0 :     return rTheme.ReadData( rIn );
    1555             : }
    1556             : 
    1557           0 : void GalleryTheme::ImplSetModified( sal_Bool bModified )
    1558           0 : { pThm->SetModified( bModified ); }
    1559             : 
    1560           0 : const rtl::OUString& GalleryTheme::GetRealName() const { return pThm->GetThemeName(); }
    1561           0 : const INetURLObject& GalleryTheme::GetThmURL() const { return pThm->GetThmURL(); }
    1562           0 : const INetURLObject& GalleryTheme::GetSdgURL() const { return pThm->GetSdgURL(); }
    1563           0 : const INetURLObject& GalleryTheme::GetSdvURL() const { return pThm->GetSdvURL(); }
    1564           0 : sal_uInt32 GalleryTheme::GetId() const { return pThm->GetId(); }
    1565           0 : void GalleryTheme::SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName ) { pThm->SetId( nNewId, bResetThemeName ); }
    1566           0 : sal_Bool GalleryTheme::IsThemeNameFromResource() const { return pThm->IsNameFromResource(); }
    1567           0 : sal_Bool GalleryTheme::IsReadOnly() const { return pThm->IsReadOnly(); }
    1568           0 : sal_Bool GalleryTheme::IsDefault() const { return pThm->IsDefault(); }
    1569           0 : sal_Bool GalleryTheme::IsModified() const { return pThm->IsModified(); }
    1570           0 : const rtl::OUString& GalleryTheme::GetName() const { return pThm->GetThemeName(); }
    1571             : 
    1572           0 : void GalleryTheme::InsertAllThemes( ListBox& rListBox )
    1573             : {
    1574           0 :     for( sal_uInt16 i = RID_GALLERYSTR_THEME_FIRST; i <= RID_GALLERYSTR_THEME_LAST; i++ )
    1575           0 :         rListBox.InsertEntry(GAL_RESSTR(i));
    1576           0 : }
    1577             : 
    1578             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10