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

Generated by: LCOV version 1.10