1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "sal/config.h"
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>
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>
50 #include <svx/gallery1.hxx>
51 #include "galtheme.hrc"
52 #include <vcl/lstbox.hxx>
53 #include "gallerydrawmodel.hxx"
59 using namespace ::rtl
;
60 using namespace ::com::sun::star
;
65 DBG_NAME(GalleryTheme
)
67 GalleryTheme::GalleryTheme( Gallery
* pGallery
, GalleryThemeEntry
* pThemeEntry
) :
70 mnThemeLockCount ( 0 ),
71 mnBroadcasterLockCount( 0 ),
73 bDragging ( sal_False
)
75 DBG_CTOR(GalleryTheme
,NULL
);
77 ImplCreateSvDrawStorage();
80 // ------------------------------------------------------------------------
82 GalleryTheme::~GalleryTheme()
86 for ( size_t i
= 0, n
= aObjectList
.size(); i
< n
; ++i
)
88 GalleryObject
* pEntry
= aObjectList
[ i
];
89 Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT
, GetName(), reinterpret_cast< sal_uIntPtr
>( pEntry
) ) );
90 Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED
, GetName(), reinterpret_cast< sal_uIntPtr
>( pEntry
) ) );
95 DBG_DTOR(GalleryTheme
,NULL
);
98 // ------------------------------------------------------------------------
100 void GalleryTheme::ImplCreateSvDrawStorage()
102 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 if ( ( aSvDrawStorageRef
->GetError() != ERRCODE_NONE
) && !pThm
->IsReadOnly() )
105 aSvDrawStorageRef
= new SvStorage( sal_False
, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
108 // ------------------------------------------------------------------------
110 sal_Bool
GalleryTheme::ImplWriteSgaObject( const SgaObject
& rObj
, size_t nPos
, GalleryObject
* pExistentEntry
)
112 SvStream
* pOStm
= ::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::NO_DECODE
), STREAM_WRITE
);
113 sal_Bool bRet
= sal_False
;
117 const sal_uInt32 nOffset
= pOStm
->Seek( STREAM_SEEK_TO_END
);
119 rObj
.WriteData( *pOStm
, m_aDestDir
);
121 if( !pOStm
->GetError() )
123 GalleryObject
* pEntry
;
125 if( !pExistentEntry
)
127 pEntry
= new GalleryObject
;
128 if ( nPos
< aObjectList
.size() )
130 GalleryObjectList::iterator it
= aObjectList
.begin();
131 ::std::advance( it
, nPos
);
132 aObjectList
.insert( it
, pEntry
);
135 aObjectList
.push_back( pEntry
);
138 pEntry
= pExistentEntry
;
140 pEntry
->aURL
= rObj
.GetURL();
141 pEntry
->nOffset
= nOffset
;
142 pEntry
->eObjKind
= rObj
.GetObjKind();
152 // ------------------------------------------------------------------------
154 SgaObject
* GalleryTheme::ImplReadSgaObject( GalleryObject
* pEntry
)
156 SgaObject
* pSgaObj
= NULL
;
160 SvStream
* pIStm
= ::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
164 sal_uInt32 nInventor
;
166 // Ueberpruefen, ob das File ein gueltiges SGA-File ist
167 pIStm
->Seek( pEntry
->nOffset
);
170 if( nInventor
== COMPAT_FORMAT( 'S', 'G', 'A', '3' ) )
172 pIStm
->Seek( pEntry
->nOffset
);
174 switch( pEntry
->eObjKind
)
176 case( SGA_OBJ_BMP
): pSgaObj
= new SgaObjectBmp(); break;
177 case( SGA_OBJ_ANIM
): pSgaObj
= new SgaObjectAnim(); break;
178 case( SGA_OBJ_INET
): pSgaObj
= new SgaObjectINet(); break;
179 case( SGA_OBJ_SVDRAW
): pSgaObj
= new SgaObjectSvDraw(); break;
180 case( SGA_OBJ_SOUND
): pSgaObj
= new SgaObjectSound(); break;
189 pSgaObj
->ImplUpdateURL( pEntry
->aURL
);
200 // ------------------------------------------------------------------------
202 void GalleryTheme::ImplWrite()
206 INetURLObject
aPathURL( GetThmURL() );
208 aPathURL
.removeSegment();
209 aPathURL
.removeFinalSlash();
211 DBG_ASSERT( aPathURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
213 if( FileExists( aPathURL
) || CreateDir( aPathURL
) )
216 SvStream
* pOStm
= ::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::NO_DECODE
), STREAM_WRITE
| STREAM_COPY_ON_SYMLINK
| STREAM_TRUNC
);
218 SvStream
* pOStm
= ::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::NO_DECODE
), STREAM_WRITE
| STREAM_TRUNC
);
227 ImplSetModified( sal_False
);
232 // ------------------------------------------------------------------------
234 const GalleryObject
* GalleryTheme::ImplGetGalleryObject( const INetURLObject
& rURL
)
236 for ( size_t i
= 0, n
= aObjectList
.size(); i
< n
; ++i
)
237 if ( aObjectList
[ i
]->aURL
== rURL
)
238 return aObjectList
[ i
];
242 // ------------------------------------------------------------------------
244 INetURLObject
GalleryTheme::ImplGetURL( const GalleryObject
* pObject
) const
249 aURL
= pObject
->aURL
;
254 // ------------------------------------------------------------------------
256 INetURLObject
GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind
, sal_uIntPtr nFormat
)
258 INetURLObject
aDir( GetParent()->GetUserURL() );
259 INetURLObject
aInfoFileURL( GetParent()->GetUserURL() );
260 INetURLObject aNewURL
;
261 sal_uInt32 nNextNumber
= 1999;
262 sal_Char
const* pExt
= NULL
;
265 aDir
.Append( String( RTL_CONSTASCII_USTRINGPARAM( "dragdrop" ) ) );
268 aInfoFileURL
.Append( String( RTL_CONSTASCII_USTRINGPARAM( "sdddndx1" ) ) );
270 // read next possible number
271 if( FileExists( aInfoFileURL
) )
273 SvStream
* pIStm
= ::utl::UcbStreamHelper::CreateStream( aInfoFileURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
277 *pIStm
>> nNextNumber
;
287 case( CVT_BMP
): pExt
= ".bmp"; break;
288 case( CVT_GIF
): pExt
= ".gif"; break;
289 case( CVT_JPG
): pExt
= ".jpg"; break;
290 case( CVT_MET
): pExt
= ".met"; break;
291 case( CVT_PCT
): pExt
= ".pct"; break;
292 case( CVT_PNG
): pExt
= ".png"; break;
293 case( CVT_SVM
): pExt
= ".svm"; break;
294 case( CVT_TIF
): pExt
= ".tif"; break;
295 case( CVT_WMF
): pExt
= ".wmf"; break;
296 case( CVT_EMF
): pExt
= ".emf"; break;
307 if( SGA_OBJ_SVDRAW
== eObjKind
)
309 String
aFileName( RTL_CONSTASCII_USTRINGPARAM( "gallery/svdraw/dd" ) );
310 aNewURL
= INetURLObject( aFileName
+= OUString::number( ++nNextNumber
% 99999999 ), INET_PROT_PRIV_SOFFICE
);
314 for ( size_t i
= 0, n
= aObjectList
.size(); i
< n
; ++i
)
315 if ( aObjectList
[ i
]->aURL
== aNewURL
)
323 String
aFileName( RTL_CONSTASCII_USTRINGPARAM( "dd" ) );
325 aFileName
+= OUString::number( ++nNextNumber
% 999999 );
326 aFileName
+= String( pExt
, RTL_TEXTENCODING_ASCII_US
);
329 aNewURL
.Append( aFileName
);
331 bExists
= FileExists( aNewURL
);
336 // write updated number
337 SvStream
* pOStm
= ::utl::UcbStreamHelper::CreateStream( aInfoFileURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_WRITE
);
341 *pOStm
<< nNextNumber
;
348 // ------------------------------------------------------------------------
350 void GalleryTheme::ImplBroadcast( sal_uIntPtr nUpdatePos
)
352 if( !IsBroadcasterLocked() )
354 if( GetObjectCount() && ( nUpdatePos
>= GetObjectCount() ) )
355 nUpdatePos
= GetObjectCount() - 1;
357 Broadcast( GalleryHint( GALLERY_HINT_THEME_UPDATEVIEW
, GetName(), nUpdatePos
) );
361 // ------------------------------------------------------------------------
363 sal_Bool
GalleryTheme::UnlockTheme()
365 DBG_ASSERT( mnThemeLockCount
, "Theme is not locked" );
367 sal_Bool bRet
= sal_False
;
369 if( mnThemeLockCount
)
378 // ------------------------------------------------------------------------
380 void GalleryTheme::UnlockBroadcaster( sal_uIntPtr nUpdatePos
)
382 DBG_ASSERT( mnBroadcasterLockCount
, "Broadcaster is not locked" );
384 if( mnBroadcasterLockCount
&& !--mnBroadcasterLockCount
)
385 ImplBroadcast( nUpdatePos
);
388 // ------------------------------------------------------------------------
390 bool GalleryTheme::InsertObject( const SgaObject
& rObj
, sal_uIntPtr nInsertPos
)
392 sal_Bool bRet
= sal_False
;
396 GalleryObject
* pFoundEntry
= NULL
;
397 size_t iFoundPos
= 0;
398 for ( size_t n
= aObjectList
.size(); iFoundPos
< n
; ++iFoundPos
)
400 if ( aObjectList
[ iFoundPos
]->aURL
== rObj
.GetURL() )
402 pFoundEntry
= aObjectList
[ iFoundPos
];
409 GalleryObject aNewEntry
;
411 // update title of new object if necessary
412 if( !rObj
.GetTitle().Len() )
414 SgaObject
* pOldObj
= ImplReadSgaObject( pFoundEntry
);
418 ( (SgaObject
&) rObj
).SetTitle( pOldObj
->GetTitle() );
422 else if( rObj
.GetTitle() == String( RTL_CONSTASCII_USTRINGPARAM( "__<empty>__" ) ) )
423 ( (SgaObject
&) rObj
).SetTitle( String() );
425 ImplWriteSgaObject( rObj
, nInsertPos
, &aNewEntry
);
426 pFoundEntry
->nOffset
= aNewEntry
.nOffset
;
429 ImplWriteSgaObject( rObj
, nInsertPos
, NULL
);
431 ImplSetModified( bRet
= sal_True
);
432 ImplBroadcast( pFoundEntry
? iFoundPos
: nInsertPos
);
438 // ------------------------------------------------------------------------
440 SgaObject
* GalleryTheme::AcquireObject( size_t nPos
)
442 return ImplReadSgaObject( aObjectList
[ nPos
] );
445 // ------------------------------------------------------------------------
447 void GalleryTheme::ReleaseObject( SgaObject
* pObject
)
452 // ------------------------------------------------------------------------
454 bool GalleryTheme::RemoveObject( size_t nPos
)
456 GalleryObject
* pEntry
= NULL
;
457 if ( nPos
< aObjectList
.size() )
459 GalleryObjectList::iterator it
= aObjectList
.begin();
460 ::std::advance( it
, nPos
);
462 aObjectList
.erase( it
);
465 if( aObjectList
.empty() )
466 KillFile( GetSdgURL() );
470 if( SGA_OBJ_SVDRAW
== pEntry
->eObjKind
)
471 aSvDrawStorageRef
->Remove( pEntry
->aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
473 Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT
, GetName(), reinterpret_cast< sal_uIntPtr
>( pEntry
) ) );
475 Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED
, GetName(), reinterpret_cast< sal_uIntPtr
>( pEntry
) ) );
477 ImplSetModified( sal_True
);
478 ImplBroadcast( nPos
);
481 return( pEntry
!= NULL
);
484 // ------------------------------------------------------------------------
486 bool GalleryTheme::ChangeObjectPos( size_t nOldPos
, size_t nNewPos
)
488 sal_Bool bRet
= sal_False
;
490 if( nOldPos
!= nNewPos
491 && nOldPos
< aObjectList
.size()
494 GalleryObject
* pEntry
= aObjectList
[ nOldPos
];
496 GalleryObjectList::iterator it
= aObjectList
.begin();
497 ::std::advance( it
, nNewPos
);
498 aObjectList
.insert( it
, pEntry
);
500 if( nNewPos
< nOldPos
) nOldPos
++;
502 it
= aObjectList
.begin();
503 ::std::advance( it
, nOldPos
);
504 aObjectList
.erase( it
);
506 ImplSetModified( bRet
= sal_True
);
507 ImplBroadcast( ( nNewPos
< nOldPos
) ? nNewPos
: ( nNewPos
- 1 ) );
513 // ------------------------------------------------------------------------
515 void GalleryTheme::Actualize( const Link
& rActualizeLink
, GalleryProgress
* pProgress
)
521 GalleryObject
* pEntry
;
522 const size_t nCount
= aObjectList
.size();
525 bAbortActualize
= sal_False
;
527 // LoeschFlag zuruecksetzen
528 for (size_t i
= 0; i
< nCount
; i
++)
529 aObjectList
[ i
]->bDummy
= sal_False
;
531 for(size_t i
= 0; ( i
< nCount
) && !bAbortActualize
; i
++)
534 pProgress
->Update( i
, nCount
- 1 );
536 pEntry
= aObjectList
[ i
];
538 const INetURLObject
aURL( pEntry
->aURL
);
540 rActualizeLink
.Call( (void*) &aURL
);
542 // SvDraw-Objekte werden spaeter aktualisiert
543 if( pEntry
->eObjKind
!= SGA_OBJ_SVDRAW
)
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 if( pEntry
->eObjKind
== SGA_OBJ_SOUND
)
550 SgaObjectSound
aObjSound( aURL
);
551 if( !InsertObject( aObjSound
) )
552 pEntry
->bDummy
= sal_True
;
558 if ( GalleryGraphicImport( aURL
, aGraphic
, aFormat
) )
562 if ( SGA_OBJ_INET
== pEntry
->eObjKind
)
563 pNewObj
= (SgaObject
*) new SgaObjectINet( aGraphic
, aURL
, aFormat
);
564 else if ( aGraphic
.IsAnimated() )
565 pNewObj
= (SgaObject
*) new SgaObjectAnim( aGraphic
, aURL
, aFormat
);
567 pNewObj
= (SgaObject
*) new SgaObjectBmp( aGraphic
, aURL
, aFormat
);
569 if( !InsertObject( *pNewObj
) )
570 pEntry
->bDummy
= sal_True
;
575 pEntry
->bDummy
= sal_True
; // Loesch-Flag setzen
580 if ( aSvDrawStorageRef
.Is() )
582 const String
aStmName( GetSvDrawStreamNameFromURL( pEntry
->aURL
) );
583 SvStorageStreamRef pIStm
= aSvDrawStorageRef
->OpenSotStream( aStmName
, STREAM_READ
);
585 if( pIStm
&& !pIStm
->GetError() )
587 pIStm
->SetBufferSize( 16384 );
589 SgaObjectSvDraw
aNewObj( *pIStm
, pEntry
->aURL
);
591 if( !InsertObject( aNewObj
) )
592 pEntry
->bDummy
= sal_True
;
594 pIStm
->SetBufferSize( 0L );
600 // remove all entries with set flag
601 for ( size_t i
= 0; i
< aObjectList
.size(); )
603 pEntry
= aObjectList
[ i
];
606 Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT
, GetName(), reinterpret_cast< sal_uIntPtr
>( pEntry
) ) );
607 Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED
, GetName(), reinterpret_cast< sal_uLong
>( pEntry
) ) );
608 GalleryObjectList::iterator it
= aObjectList
.begin();
609 ::std::advance( it
, i
);
610 aObjectList
.erase( it
);
617 ::utl::TempFile aTmp
;
618 INetURLObject
aInURL( GetSdgURL() );
619 INetURLObject
aTmpURL( aTmp
.GetURL() );
621 DBG_ASSERT( aInURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
622 DBG_ASSERT( aTmpURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
624 SvStream
* pIStm
= ::utl::UcbStreamHelper::CreateStream( aInURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
625 SvStream
* pTmpStm
= ::utl::UcbStreamHelper::CreateStream( aTmpURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_WRITE
| STREAM_TRUNC
);
627 if( pIStm
&& pTmpStm
)
629 for ( size_t i
= 0, n
= aObjectList
.size(); i
< n
; ++i
)
631 pEntry
= aObjectList
[ i
];
634 switch( pEntry
->eObjKind
)
636 case( SGA_OBJ_BMP
): pObj
= new SgaObjectBmp(); break;
637 case( SGA_OBJ_ANIM
): pObj
= new SgaObjectAnim(); break;
638 case( SGA_OBJ_INET
): pObj
= new SgaObjectINet(); break;
639 case( SGA_OBJ_SVDRAW
): pObj
= new SgaObjectSvDraw(); break;
640 case (SGA_OBJ_SOUND
): pObj
= new SgaObjectSound(); break;
649 pIStm
->Seek( pEntry
->nOffset
);
651 pEntry
->nOffset
= pTmpStm
->Tell();
659 OSL_FAIL( "File(s) could not be opened" );
665 CopyFile( aTmpURL
, aInURL
);
668 sal_uIntPtr nStorErr
= 0;
671 SvStorageRef
aTempStorageRef( new SvStorage( sal_False
, aTmpURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_STD_READWRITE
) );
672 aSvDrawStorageRef
->CopyTo( aTempStorageRef
);
673 nStorErr
= aSvDrawStorageRef
->GetError();
678 aSvDrawStorageRef
.Clear();
679 CopyFile( aTmpURL
, GetSdvURL() );
680 ImplCreateSvDrawStorage();
684 ImplSetModified( sal_True
);
690 // ------------------------------------------------------------------------
692 GalleryThemeEntry
* GalleryTheme::CreateThemeEntry( const INetURLObject
& rURL
, sal_Bool bReadOnly
)
694 DBG_ASSERT( rURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
696 GalleryThemeEntry
* pRet
= NULL
;
698 if( FileExists( rURL
) )
700 SvStream
* pIStm
= ::utl::UcbStreamHelper::CreateStream( rURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
706 sal_Bool bThemeNameFromResource
= sal_False
;
710 if( nVersion
<= 0x00ff )
712 sal_uInt32 nThemeId
= 0;
714 OString aTmpStr
= read_lenPrefixed_uInt8s_ToOString
<sal_uInt16
>(*pIStm
);
715 aThemeName
= OStringToOUString(aTmpStr
, RTL_TEXTENCODING_UTF8
);
717 // Charakterkonvertierung durchfuehren
718 if( nVersion
>= 0x0004 )
723 *pIStm
>> nCount
>> nTemp16
;
724 pIStm
->Seek( STREAM_SEEK_TO_END
);
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 if( pIStm
->Tell() >= 520 )
731 sal_uInt32 nId1
, nId2
;
733 pIStm
->SeekRel( -520 );
734 *pIStm
>> nId1
>> nId2
;
736 if( nId1
== COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) &&
737 nId2
== COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) )
739 VersionCompat
* pCompat
= new VersionCompat( *pIStm
, STREAM_READ
);
743 if( pCompat
->GetVersion() >= 2 )
745 *pIStm
>> bThemeNameFromResource
;
753 INetURLObject
aPathURL( rURL
);
754 pRet
= new GalleryThemeEntry( false, aPathURL
, aThemeName
,
755 bReadOnly
, sal_False
, nThemeId
,
756 bThemeNameFromResource
);
766 // -----------------------------------------------------------------------------
768 sal_Bool
GalleryTheme::GetThumb( sal_uIntPtr nPos
, BitmapEx
& rBmp
, sal_Bool
)
770 SgaObject
* pObj
= AcquireObject( nPos
);
771 sal_Bool bRet
= sal_False
;
775 rBmp
= pObj
->GetThumbBmp();
776 ReleaseObject( pObj
);
783 // -----------------------------------------------------------------------------
785 sal_Bool
GalleryTheme::GetGraphic( sal_uIntPtr nPos
, Graphic
& rGraphic
, sal_Bool bProgress
)
787 const GalleryObject
* pObject
= ImplGetGalleryObject( nPos
);
788 sal_Bool bRet
= sal_False
;
792 const INetURLObject
aURL( ImplGetURL( pObject
) );
794 switch( pObject
->eObjKind
)
797 case( SGA_OBJ_ANIM
):
798 case( SGA_OBJ_INET
):
801 bRet
= ( GalleryGraphicImport( aURL
, rGraphic
, aFilterDummy
, bProgress
) != SGA_IMPORT_NONE
);
805 case( SGA_OBJ_SVDRAW
):
807 SvxGalleryDrawModel aModel
;
809 if( aModel
.GetModel() )
811 if( GetModel( nPos
, *aModel
.GetModel(), bProgress
) )
815 if( CreateIMapGraphic( *aModel
.GetModel(), rGraphic
, aIMap
) )
820 aVDev
.SetMapMode( MapMode( MAP_100TH_MM
) );
821 FmFormView
aView( aModel
.GetModel(), &aVDev
);
823 aView
.hideMarkHandles();
824 aView
.ShowSdrPage(aView
.GetModel()->GetPage(0));
826 rGraphic
= aView
.GetAllMarkedGraphic();
834 case( SGA_OBJ_SOUND
):
836 SgaObject
* pObj
= AcquireObject( nPos
);
840 rGraphic
= pObj
->GetThumbBmp();
841 //Bitmap aBmp( pObj->GetThumbBmp() );
842 //aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
844 ReleaseObject( pObj
);
858 // -----------------------------------------------------------------------------
860 sal_Bool
GalleryTheme::InsertGraphic( const Graphic
& rGraphic
, sal_uIntPtr nInsertPos
)
862 sal_Bool bRet
= sal_False
;
864 if( rGraphic
.GetType() != GRAPHIC_NONE
)
866 sal_uIntPtr nExportFormat
= CVT_UNKNOWN
;
867 const GfxLink
aGfxLink( ( (Graphic
&) rGraphic
).GetLink() );
869 if( aGfxLink
.GetDataSize() )
871 switch( aGfxLink
.GetType() )
873 case( GFX_LINK_TYPE_EPS_BUFFER
): nExportFormat
= CVT_SVM
; break;
874 case( GFX_LINK_TYPE_NATIVE_GIF
): nExportFormat
= CVT_GIF
; break;
875 case( GFX_LINK_TYPE_NATIVE_JPG
): nExportFormat
= CVT_JPG
; break;
876 case( GFX_LINK_TYPE_NATIVE_PNG
): nExportFormat
= CVT_PNG
; break;
877 case( GFX_LINK_TYPE_NATIVE_TIF
): nExportFormat
= CVT_TIF
; break;
878 case( GFX_LINK_TYPE_NATIVE_WMF
): nExportFormat
= CVT_WMF
; break;
879 case( GFX_LINK_TYPE_NATIVE_MET
): nExportFormat
= CVT_MET
; break;
880 case( GFX_LINK_TYPE_NATIVE_PCT
): nExportFormat
= CVT_PCT
; break;
881 case( GFX_LINK_TYPE_NATIVE_SVG
): nExportFormat
= CVT_SVG
; break;
888 if( rGraphic
.GetType() == GRAPHIC_BITMAP
)
890 if( rGraphic
.IsAnimated() )
891 nExportFormat
= CVT_GIF
;
893 nExportFormat
= CVT_PNG
;
896 nExportFormat
= CVT_SVM
;
899 const INetURLObject
aURL( ImplCreateUniqueURL( SGA_OBJ_BMP
, nExportFormat
) );
900 SvStream
* pOStm
= ::utl::UcbStreamHelper::CreateStream( aURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_WRITE
| STREAM_TRUNC
);
904 pOStm
->SetVersion( SOFFICE_FILEFORMAT_50
);
906 if( CVT_SVM
== nExportFormat
)
908 GDIMetaFile
aMtf( rGraphic
.GetGDIMetaFile() );
910 aMtf
.Write( *pOStm
);
911 bRet
= ( pOStm
->GetError() == ERRCODE_NONE
);
915 if( aGfxLink
.GetDataSize() && aGfxLink
.GetData() )
917 pOStm
->Write( aGfxLink
.GetData(), aGfxLink
.GetDataSize() );
918 bRet
= ( pOStm
->GetError() == ERRCODE_NONE
);
921 bRet
= ( GraphicConverter::Export( *pOStm
, rGraphic
, nExportFormat
) == ERRCODE_NONE
);
929 const SgaObjectBmp
aObjBmp( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
930 InsertObject( aObjBmp
, nInsertPos
);
937 // -----------------------------------------------------------------------------
939 sal_Bool
GalleryTheme::GetModel( sal_uIntPtr nPos
, SdrModel
& rModel
, sal_Bool
)
941 const GalleryObject
* pObject
= ImplGetGalleryObject( nPos
);
942 sal_Bool bRet
= sal_False
;
944 if( pObject
&& ( SGA_OBJ_SVDRAW
== pObject
->eObjKind
) )
946 const INetURLObject
aURL( ImplGetURL( pObject
) );
947 SvStorageRef
xStor( GetSvDrawStorage() );
951 const String
aStmName( GetSvDrawStreamNameFromURL( aURL
) );
952 SvStorageStreamRef
xIStm( xStor
->OpenSotStream( aStmName
, STREAM_READ
) );
954 if( xIStm
.Is() && !xIStm
->GetError() )
956 xIStm
->SetBufferSize( STREAMBUF_SIZE
);
957 bRet
= GallerySvDrawImport( *xIStm
, rModel
);
958 xIStm
->SetBufferSize( 0L );
966 // -----------------------------------------------------------------------------
968 sal_Bool
GalleryTheme::InsertModel( const FmFormModel
& rModel
, sal_uIntPtr nInsertPos
)
970 INetURLObject
aURL( ImplCreateUniqueURL( SGA_OBJ_SVDRAW
) );
971 SvStorageRef
xStor( GetSvDrawStorage() );
972 sal_Bool bRet
= sal_False
;
976 const String
aStmName( GetSvDrawStreamNameFromURL( aURL
) );
977 SvStorageStreamRef
xOStm( xStor
->OpenSotStream( aStmName
, STREAM_WRITE
| STREAM_TRUNC
) );
979 if( xOStm
.Is() && !xOStm
->GetError() )
981 SvMemoryStream
aMemStm( 65535, 65535 );
982 FmFormModel
* pFormModel
= (FmFormModel
*) &rModel
;
984 pFormModel
->BurnInStyleSheetAttributes();
987 uno::Reference
< io::XOutputStream
> xDocOut( new utl::OOutputStreamWrapper( aMemStm
) );
990 SvxDrawingLayerExport( pFormModel
, xDocOut
);
995 xOStm
->SetBufferSize( 16348 );
996 GalleryCodec
aCodec( *xOStm
);
997 aCodec
.Write( aMemStm
);
999 if( !xOStm
->GetError() )
1001 SgaObjectSvDraw
aObjSvDraw( rModel
, aURL
);
1002 bRet
= InsertObject( aObjSvDraw
, nInsertPos
);
1005 xOStm
->SetBufferSize( 0L );
1013 // -----------------------------------------------------------------------------
1015 sal_Bool
GalleryTheme::GetModelStream( sal_uIntPtr nPos
, SotStorageStreamRef
& rxModelStream
, sal_Bool
)
1017 const GalleryObject
* pObject
= ImplGetGalleryObject( nPos
);
1018 sal_Bool bRet
= sal_False
;
1020 if( pObject
&& ( SGA_OBJ_SVDRAW
== pObject
->eObjKind
) )
1022 const INetURLObject
aURL( ImplGetURL( pObject
) );
1023 SvStorageRef
xStor( GetSvDrawStorage() );
1027 const String
aStmName( GetSvDrawStreamNameFromURL( aURL
) );
1028 SvStorageStreamRef
xIStm( xStor
->OpenSotStream( aStmName
, STREAM_READ
) );
1030 if( xIStm
.Is() && !xIStm
->GetError() )
1032 sal_uInt32 nVersion
= 0;
1034 xIStm
->SetBufferSize( 16348 );
1036 if( GalleryCodec::IsCoded( *xIStm
, nVersion
) )
1038 SvxGalleryDrawModel aModel
;
1040 if( aModel
.GetModel() )
1042 if( GallerySvDrawImport( *xIStm
, *aModel
.GetModel() ) )
1044 aModel
.GetModel()->BurnInStyleSheetAttributes();
1047 uno::Reference
< io::XOutputStream
> xDocOut( new utl::OOutputStreamWrapper( *rxModelStream
) );
1049 if( SvxDrawingLayerExport( aModel
.GetModel(), xDocOut
) )
1050 rxModelStream
->Commit();
1054 bRet
= ( rxModelStream
->GetError() == ERRCODE_NONE
);
1058 xIStm
->SetBufferSize( 0 );
1066 // -----------------------------------------------------------------------------
1068 sal_Bool
GalleryTheme::InsertModelStream( const SotStorageStreamRef
& rxModelStream
, sal_uIntPtr nInsertPos
)
1070 INetURLObject
aURL( ImplCreateUniqueURL( SGA_OBJ_SVDRAW
) );
1071 SvStorageRef
xStor( GetSvDrawStorage() );
1072 sal_Bool bRet
= sal_False
;
1076 const String
aStmName( GetSvDrawStreamNameFromURL( aURL
) );
1077 SvStorageStreamRef
xOStm( xStor
->OpenSotStream( aStmName
, STREAM_WRITE
| STREAM_TRUNC
) );
1079 if( xOStm
.Is() && !xOStm
->GetError() )
1081 GalleryCodec
aCodec( *xOStm
);
1082 SvMemoryStream
aMemStm( 65535, 65535 );
1084 xOStm
->SetBufferSize( 16348 );
1085 aCodec
.Write( *rxModelStream
);
1087 if( !xOStm
->GetError() )
1090 SgaObjectSvDraw
aObjSvDraw( *xOStm
, aURL
);
1091 bRet
= InsertObject( aObjSvDraw
, nInsertPos
);
1094 xOStm
->SetBufferSize( 0L );
1102 // -----------------------------------------------------------------------------
1104 sal_Bool
GalleryTheme::GetURL( sal_uIntPtr nPos
, INetURLObject
& rURL
, sal_Bool
)
1106 const GalleryObject
* pObject
= ImplGetGalleryObject( nPos
);
1107 sal_Bool bRet
= sal_False
;
1111 rURL
= INetURLObject( ImplGetURL( pObject
) );
1118 // -----------------------------------------------------------------------------
1120 sal_Bool
GalleryTheme::InsertURL( const INetURLObject
& rURL
, sal_uIntPtr nInsertPos
)
1124 SgaObject
* pNewObj
= NULL
;
1125 const sal_uInt16 nImportRet
= GalleryGraphicImport( rURL
, aGraphic
, aFormat
);
1126 sal_Bool bRet
= sal_False
;
1128 if( nImportRet
!= SGA_IMPORT_NONE
)
1130 if ( SGA_IMPORT_INET
== nImportRet
)
1131 pNewObj
= (SgaObject
*) new SgaObjectINet( aGraphic
, rURL
, aFormat
);
1132 else if ( aGraphic
.IsAnimated() )
1133 pNewObj
= (SgaObject
*) new SgaObjectAnim( aGraphic
, rURL
, aFormat
);
1135 pNewObj
= (SgaObject
*) new SgaObjectBmp( aGraphic
, rURL
, aFormat
);
1137 else if( ::avmedia::MediaWindow::isMediaURL( rURL
.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS
) ) )
1138 pNewObj
= (SgaObject
*) new SgaObjectSound( rURL
);
1140 if( pNewObj
&& InsertObject( *pNewObj
, nInsertPos
) )
1148 // -----------------------------------------------------------------------------
1150 sal_Bool
GalleryTheme::InsertFileOrDirURL( const INetURLObject
& rFileOrDirURL
, sal_uIntPtr nInsertPos
)
1153 ::std::vector
< INetURLObject
> aURLVector
;
1154 sal_Bool bRet
= sal_False
;
1158 ::ucbhelper::Content
aCnt( rFileOrDirURL
.GetMainURL( INetURLObject::NO_DECODE
), uno::Reference
< ucb::XCommandEnvironment
>(), comphelper::getProcessComponentContext() );
1159 sal_Bool bFolder
= false;
1161 aCnt
.getPropertyValue( OUString("IsFolder") ) >>= bFolder
;
1165 uno::Sequence
< OUString
> aProps( 1 );
1166 aProps
.getArray()[ 0 ] = OUString("Url");
1167 uno::Reference
< sdbc::XResultSet
> xResultSet( aCnt
.createCursor( aProps
, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY
) );
1168 uno::Reference
< ucb::XContentAccess
> xContentAccess( xResultSet
, uno::UNO_QUERY
);
1169 if( xContentAccess
.is() )
1171 while( xResultSet
->next() )
1173 aURL
.SetSmartURL( xContentAccess
->queryContentIdentifierString() );
1174 aURLVector
.push_back( aURL
);
1179 aURLVector
.push_back( rFileOrDirURL
);
1181 catch( const ucb::ContentCreationException
& )
1184 catch( const uno::RuntimeException
& )
1187 catch( const uno::Exception
& )
1191 ::std::vector
< INetURLObject
>::const_iterator
aIter( aURLVector
.begin() ), aEnd( aURLVector
.end() );
1193 while( aIter
!= aEnd
)
1194 bRet
= bRet
|| InsertURL( *aIter
++, nInsertPos
);
1199 // -----------------------------------------------------------------------------
1201 sal_Bool
GalleryTheme::InsertTransferable( const uno::Reference
< datatransfer::XTransferable
>& rxTransferable
, sal_uIntPtr nInsertPos
)
1203 sal_Bool bRet
= sal_False
;
1205 if( rxTransferable
.is() )
1207 TransferableDataHelper
aDataHelper( rxTransferable
);
1208 Graphic
* pGraphic
= NULL
;
1210 if( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_DRAWING
) )
1212 SotStorageStreamRef xModelStm
;
1214 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING
, xModelStm
) )
1215 bRet
= InsertModelStream( xModelStm
, nInsertPos
);
1217 else if( aDataHelper
.HasFormat( SOT_FORMAT_FILE_LIST
) ||
1218 aDataHelper
.HasFormat( FORMAT_FILE
) )
1222 if( aDataHelper
.HasFormat( SOT_FORMAT_FILE_LIST
) )
1223 aDataHelper
.GetFileList( SOT_FORMAT_FILE_LIST
, aFileList
);
1228 aDataHelper
.GetString( FORMAT_FILE
, aFile
);
1231 aFileList
.AppendFile( aFile
);
1234 for( sal_uInt32 i
= 0, nCount
= aFileList
.Count(); i
< nCount
; ++i
)
1236 const String
aFile( aFileList
.GetFile( i
) );
1237 INetURLObject
aURL( aFile
);
1239 if( aURL
.GetProtocol() == INET_PROT_NOT_VALID
)
1243 if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFile
, aLocalURL
) )
1244 aURL
= INetURLObject( aLocalURL
);
1247 if( aURL
.GetProtocol() != INET_PROT_NOT_VALID
)
1248 bRet
= InsertFileOrDirURL( aURL
, nInsertPos
);
1254 sal_uIntPtr nFormat
= 0;
1256 if( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_SVXB
) )
1257 nFormat
= SOT_FORMATSTR_ID_SVXB
;
1258 else if( aDataHelper
.HasFormat( FORMAT_GDIMETAFILE
) )
1259 nFormat
= FORMAT_GDIMETAFILE
;
1260 else if( aDataHelper
.HasFormat( FORMAT_BITMAP
) )
1261 nFormat
= FORMAT_BITMAP
;
1263 if( nFormat
&& aDataHelper
.GetGraphic( nFormat
, aGraphic
) )
1264 pGraphic
= new Graphic( aGraphic
);
1271 if( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_SVIM
) )
1276 // according to KA we don't need a BaseURL here
1277 if( aDataHelper
.GetImageMap( SOT_FORMATSTR_ID_SVIM
, aImageMap
) )
1279 SvxGalleryDrawModel aModel
;
1281 if( aModel
.GetModel() )
1283 SgaUserDataFactory aFactory
;
1285 SdrPage
* pPage
= aModel
.GetModel()->GetPage(0);
1286 SdrGrafObj
* pGrafObj
= new SdrGrafObj( *pGraphic
);
1288 pGrafObj
->AppendUserData( new SgaIMapInfo( aImageMap
) );
1289 pPage
->InsertObject( pGrafObj
);
1290 bRet
= InsertModel( *aModel
.GetModel(), nInsertPos
);
1296 bRet
= InsertGraphic( *pGraphic
, nInsertPos
);
1305 // -----------------------------------------------------------------------------
1307 void GalleryTheme::CopyToClipboard( Window
* pWindow
, sal_uIntPtr nPos
)
1309 GalleryTransferable
* pTransferable
= new GalleryTransferable( this, nPos
, false );
1310 pTransferable
->CopyToClipboard( pWindow
);
1313 // -----------------------------------------------------------------------------
1315 void GalleryTheme::StartDrag( Window
* pWindow
, sal_uIntPtr nPos
)
1317 GalleryTransferable
* pTransferable
= new GalleryTransferable( this, nPos
, true );
1318 pTransferable
->StartDrag( pWindow
, DND_ACTION_COPY
| DND_ACTION_LINK
);
1321 // -----------------------------------------------------------------------------
1323 SvStream
& GalleryTheme::WriteData( SvStream
& rOStm
) const
1325 const INetURLObject
aRelURL1( GetParent()->GetRelativeURL() );
1326 const INetURLObject
aRelURL2( GetParent()->GetUserURL() );
1327 INetURLObject aNewURL
, aTempURL
;
1328 sal_uInt32 nCount
= GetObjectCount();
1331 rOStm
<< (sal_uInt16
) 0x0004;
1332 write_lenPrefixed_uInt8s_FromOUString
<sal_uInt16
>(rOStm
, GetRealName(), RTL_TEXTENCODING_UTF8
);
1333 rOStm
<< nCount
<< (sal_uInt16
) osl_getThreadTextEncoding();
1335 for( sal_uInt32 i
= 0; i
< nCount
; i
++ )
1337 const GalleryObject
* pObj
= ImplGetGalleryObject( i
);
1340 if( SGA_OBJ_SVDRAW
== pObj
->eObjKind
)
1342 aPath
= GetSvDrawStreamNameFromURL( pObj
->aURL
);
1347 aPath
= pObj
->aURL
.GetMainURL( INetURLObject::NO_DECODE
);
1348 bRel
= ( ( aPath
.Erase( sal::static_int_cast
< xub_StrLen
>( aRelURL1
.GetMainURL( INetURLObject::NO_DECODE
).getLength() ) ) ) == String(aRelURL1
.GetMainURL( INetURLObject::NO_DECODE
) ));
1350 if( bRel
&& ( pObj
->aURL
.GetMainURL( INetURLObject::NO_DECODE
).getLength() > ( aRelURL1
.GetMainURL( INetURLObject::NO_DECODE
).getLength() + 1 ) ) )
1352 aPath
= pObj
->aURL
.GetMainURL( INetURLObject::NO_DECODE
);
1353 aPath
= aPath
.Erase( 0, sal::static_int_cast
< xub_StrLen
>( aRelURL1
.GetMainURL( INetURLObject::NO_DECODE
).getLength() ) );
1357 aPath
= pObj
->aURL
.GetMainURL( INetURLObject::NO_DECODE
);
1358 bRel
= ( ( aPath
.Erase( sal::static_int_cast
< xub_StrLen
>( aRelURL2
.GetMainURL( INetURLObject::NO_DECODE
).getLength() ) ) ) == String(aRelURL2
.GetMainURL( INetURLObject::NO_DECODE
) ));
1360 if( bRel
&& ( pObj
->aURL
.GetMainURL( INetURLObject::NO_DECODE
).getLength() > ( aRelURL2
.GetMainURL( INetURLObject::NO_DECODE
).getLength() + 1 ) ) )
1362 aPath
= pObj
->aURL
.GetMainURL( INetURLObject::NO_DECODE
);
1363 aPath
= aPath
.Erase( 0, sal::static_int_cast
< xub_StrLen
>( aRelURL2
.GetMainURL( INetURLObject::NO_DECODE
).getLength() ) );
1366 aPath
= pObj
->aURL
.GetMainURL( INetURLObject::NO_DECODE
);
1370 if ( m_aDestDir
.Len() > 0 )
1372 if ( aPath
.SearchAndReplace(m_aDestDir
, String()) != STRING_NOTFOUND
)
1373 bRel
= m_bDestDirRelative
;
1375 SAL_WARN( "svx", "failed to replace destdir of '"
1376 << m_aDestDir
<< "' in '" << aPath
<< "'");
1380 write_lenPrefixed_uInt8s_FromOUString
<sal_uInt16
>(rOStm
, aPath
, RTL_TEXTENCODING_UTF8
);
1381 rOStm
<< pObj
->nOffset
<< (sal_uInt16
) pObj
->eObjKind
;
1384 // neuerdings wird ein 512-Byte-Reservepuffer gechrieben;
1385 // um diesen zu erkennen werden zwei sal_uIntPtr-Ids geschrieben
1386 rOStm
<< COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) << COMPAT_FORMAT( 'E', 'S', 'R', 'V' );
1388 const long nReservePos
= rOStm
.Tell();
1389 VersionCompat
* pCompat
= new VersionCompat( rOStm
, STREAM_WRITE
, 2 );
1391 rOStm
<< (sal_uInt32
) GetId() << IsThemeNameFromResource(); // ab Version 2
1395 // Rest des Puffers auffuellen
1396 const long nRest
= std::max( 512L - ( (long) rOStm
.Tell() - nReservePos
), 0L );
1400 char* pReserve
= new char[ nRest
];
1401 memset( pReserve
, 0, nRest
);
1402 rOStm
.Write( pReserve
, nRest
);
1409 // ------------------------------------------------------------------------
1411 SvStream
& GalleryTheme::ReadData( SvStream
& rIStm
)
1414 sal_uInt16 nVersion
;
1416 rtl_TextEncoding nTextEncoding
;
1419 OString aTmpStr
= read_lenPrefixed_uInt8s_ToOString
<sal_uInt16
>(rIStm
);
1422 if( nVersion
>= 0x0004 )
1426 nTextEncoding
= (rtl_TextEncoding
) nTmp16
;
1429 nTextEncoding
= RTL_TEXTENCODING_UTF8
;
1431 aThemeName
= OStringToOUString(aTmpStr
, nTextEncoding
);
1433 if( nCount
<= ( 1L << 14 ) )
1435 GalleryObject
* pObj
;
1436 INetURLObject
aRelURL1( GetParent()->GetRelativeURL() );
1437 INetURLObject
aRelURL2( GetParent()->GetUserURL() );
1438 sal_uInt32 nId1
, nId2
;
1441 for( size_t i
= 0, n
= aObjectList
.size(); i
< n
; ++i
)
1443 pObj
= aObjectList
[ i
];
1444 Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT
, GetName(), reinterpret_cast< sal_uIntPtr
>( pObj
) ) );
1446 Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED
, GetName(), reinterpret_cast< sal_uIntPtr
>( pObj
) ) );
1448 aObjectList
.clear();
1450 for( sal_uInt32 i
= 0; i
< nCount
; i
++ )
1452 pObj
= new GalleryObject
;
1459 OString aTempFileName
= read_lenPrefixed_uInt8s_ToOString
<sal_uInt16
>(rIStm
);
1460 rIStm
>> pObj
->nOffset
;
1461 rIStm
>> nTemp
; pObj
->eObjKind
= (SgaObjKind
) nTemp
;
1463 aFileName
= OStringToOUString(aTempFileName
, osl_getThreadTextEncoding());
1467 aFileName
.SearchAndReplaceAll( '\\', '/' );
1468 aPath
= aRelURL1
.GetMainURL( INetURLObject::NO_DECODE
);
1470 if( aFileName
.GetChar( 0 ) != '/' )
1475 pObj
->aURL
= INetURLObject( aPath
);
1477 if( !FileExists( pObj
->aURL
) )
1479 aPath
= aRelURL2
.GetMainURL( INetURLObject::NO_DECODE
);
1481 if( aFileName
.GetChar( 0 ) != '/' )
1486 // assign this URL, even in the case it is not valid (#94482)
1487 pObj
->aURL
= INetURLObject( aPath
);
1492 if( SGA_OBJ_SVDRAW
== pObj
->eObjKind
)
1494 const static String
aBaseURLStr( RTL_CONSTASCII_USTRINGPARAM( "gallery/svdraw/" ) );
1496 String
aDummyURL( aBaseURLStr
);
1497 pObj
->aURL
= INetURLObject( aDummyURL
+= aFileName
, INET_PROT_PRIV_SOFFICE
);
1503 pObj
->aURL
= INetURLObject( aFileName
);
1505 if( ( pObj
->aURL
.GetProtocol() == INET_PROT_NOT_VALID
) &&
1506 ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFileName
, aLocalURL
) )
1508 pObj
->aURL
= INetURLObject( aLocalURL
);
1512 aObjectList
.push_back( pObj
);
1515 rIStm
>> nId1
>> nId2
;
1517 // in neueren Versionen befindet sich am Ende ein 512-Byte-Reservepuffer;
1518 // die Daten befinden sich am Anfang dieses Puffers und
1519 // sind durch eine VersionCompat geklammert
1520 if( !rIStm
.IsEof() &&
1521 nId1
== COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) &&
1522 nId2
== COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) )
1524 VersionCompat
* pCompat
= new VersionCompat( rIStm
, STREAM_READ
);
1526 sal_Bool bThemeNameFromResource
= sal_False
;
1530 if( pCompat
->GetVersion() >= 2 )
1532 rIStm
>> bThemeNameFromResource
;
1535 SetId( nTemp32
, bThemeNameFromResource
);
1540 rIStm
.SetError( SVSTREAM_READ_ERROR
);
1542 ImplSetModified( sal_False
);
1547 // ------------------------------------------------------------------------
1549 SvStream
& operator<<( SvStream
& rOut
, const GalleryTheme
& rTheme
)
1551 return rTheme
.WriteData( rOut
);
1554 // ------------------------------------------------------------------------
1556 SvStream
& operator>>( SvStream
& rIn
, GalleryTheme
& rTheme
)
1558 return rTheme
.ReadData( rIn
);
1561 void GalleryTheme::ImplSetModified( sal_Bool bModified
)
1562 { pThm
->SetModified( bModified
); }
1564 const OUString
& GalleryTheme::GetRealName() const { return pThm
->GetThemeName(); }
1565 const INetURLObject
& GalleryTheme::GetThmURL() const { return pThm
->GetThmURL(); }
1566 const INetURLObject
& GalleryTheme::GetSdgURL() const { return pThm
->GetSdgURL(); }
1567 const INetURLObject
& GalleryTheme::GetStrURL() const { return pThm
->GetStrURL(); }
1568 const INetURLObject
& GalleryTheme::GetSdvURL() const { return pThm
->GetSdvURL(); }
1569 sal_uInt32
GalleryTheme::GetId() const { return pThm
->GetId(); }
1570 void GalleryTheme::SetId( sal_uInt32 nNewId
, sal_Bool bResetThemeName
) { pThm
->SetId( nNewId
, bResetThemeName
); }
1571 sal_Bool
GalleryTheme::IsThemeNameFromResource() const { return pThm
->IsNameFromResource(); }
1572 sal_Bool
GalleryTheme::IsReadOnly() const { return pThm
->IsReadOnly(); }
1573 sal_Bool
GalleryTheme::IsDefault() const { return pThm
->IsDefault(); }
1574 sal_Bool
GalleryTheme::IsModified() const { return pThm
->IsModified(); }
1575 const OUString
& GalleryTheme::GetName() const { return pThm
->GetThemeName(); }
1577 void GalleryTheme::InsertAllThemes( ListBox
& rListBox
)
1579 for( sal_uInt16 i
= RID_GALLERYSTR_THEME_FIRST
; i
<= RID_GALLERYSTR_THEME_LAST
; i
++ )
1580 rListBox
.InsertEntry(GAL_RESSTR(i
));
1583 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */