diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-07-16 13:57:43 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-07-16 14:16:47 +0100 |
commit | 6d6198393e0677710191248d6f7c9ec15d0f0e0f (patch) | |
tree | 4b1c10c38a6613323799857fb432a881be936f3a /svx/source/gallery2 | |
parent | make gtk-print stuff build on gtk+2 2.12.0 (diff) | |
download | core-6d6198393e0677710191248d6f7c9ec15d0f0e0f.tar.gz core-6d6198393e0677710191248d6f7c9ec15d0f0e0f.zip |
Resolves: fdo#42454 'imported' gallery format doesn't appear to exist
AFAICS an "imported" gallery can only be written if you already have an
imported gallery in the first place, i.e. its something coming from an earlier
version. All the way back to 2000, so I suspect its an earlier pre-OOo feature,
which can't arise in practice with no migration from staroffice configs to
OpenOffice.org or LibreOffice.
Change-Id: I9f248baadb20633da129d3bcacce3d7f92ef7510
Diffstat (limited to 'svx/source/gallery2')
-rw-r--r-- | svx/source/gallery2/galbrws1.cxx | 16 | ||||
-rw-r--r-- | svx/source/gallery2/galbrws2.cxx | 13 | ||||
-rw-r--r-- | svx/source/gallery2/galctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/gallery2/gallery.src | 5 | ||||
-rw-r--r-- | svx/source/gallery2/gallery1.cxx | 160 | ||||
-rw-r--r-- | svx/source/gallery2/galtheme.cxx | 38 |
6 files changed, 35 insertions, 199 deletions
diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx index 143dde6d8d9c..df80ccf72bc9 100644 --- a/svx/source/gallery2/galbrws1.cxx +++ b/svx/source/gallery2/galbrws1.cxx @@ -147,8 +147,7 @@ GalleryBrowser1::GalleryBrowser1( GalleryBrowser* pParent, const ResId& rResId, mpThemePropsDlgItemSet( NULL ), aImgNormal ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_NORMAL ) ), aImgDefault ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_DEFAULT ) ), - aImgReadOnly ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_READONLY ) ), - aImgImported ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_IMPORTED ) ) + aImgReadOnly ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_READONLY ) ) { StartListening( *mpGallery ); @@ -195,9 +194,7 @@ sal_uIntPtr GalleryBrowser1::ImplInsertThemeEntry( const GalleryThemeEntry* pEnt { const Image* pImage; - if( pEntry->IsImported() ) - pImage = &aImgImported; - else if( pEntry->IsReadOnly() ) + if( pEntry->IsReadOnly() ) pImage = &aImgReadOnly; else if( pEntry->IsDefault() ) pImage = &aImgDefault; @@ -267,11 +264,6 @@ void GalleryBrowser1::ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec) if( pTheme->IsReadOnly() ) bUpdateAllowed = bRenameAllowed = bRemoveAllowed = sal_False; - else if( pTheme->IsImported() ) - { - bUpdateAllowed = sal_False; - bRenameAllowed = bRemoveAllowed = sal_True; - } else if( pTheme->IsDefault() ) { bUpdateAllowed = bRenameAllowed = sal_True; @@ -289,7 +281,7 @@ void GalleryBrowser1::ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec) if( bRemoveAllowed ) o_aExec.push_back( MN_DELETE ); - if( bIdDialog && !pTheme->IsReadOnly() && !pTheme->IsImported() ) + if( bIdDialog && !pTheme->IsReadOnly() ) o_aExec.push_back( MN_ASSIGN_ID ); o_aExec.push_back( MN_PROPERTIES ); @@ -465,7 +457,7 @@ void GalleryBrowser1::ImplExecute( sal_uInt16 nId ) { GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this ); - if( pTheme && !pTheme->IsReadOnly() && !pTheme->IsImported() ) + if (pTheme && !pTheme->IsReadOnly()) { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index 6a673f5bc777..287a1885dcef 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -460,7 +460,7 @@ sal_Int8 GalleryBrowser2::AcceptDrop( DropTargetHelper& rTarget, const AcceptDro { sal_Int8 nRet = DND_ACTION_NONE; - if( mpCurTheme && !mpCurTheme->IsReadOnly() && !mpCurTheme ->IsImported() ) + if( mpCurTheme && !mpCurTheme->IsReadOnly() ) { if( !mpCurTheme->IsDragging() ) { @@ -1092,18 +1092,9 @@ void GalleryBrowser2::ImplExecute( sal_uInt16 nId ) String GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags ) { - INetURLObject aURL; String aRet; - if( rTheme.IsImported() ) - { - aURL = rTheme.GetParent()->GetImportURL( rTheme.GetName() ); - - aURL.removeSegment(); - aURL.Append( rObj.GetURL().GetName() ); - } - else - aURL = rObj.GetURL(); + INetURLObject aURL(rObj.GetURL()); if( nItemTextFlags & GALLERY_ITEM_THEMENAME ) { diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx index 2a00e5cdd2b7..c803c5802c5b 100644 --- a/svx/source/gallery2/galctrl.cxx +++ b/svx/source/gallery2/galctrl.cxx @@ -692,7 +692,7 @@ sal_Int8 GalleryListView::AcceptDrop( const BrowserAcceptDropEvent& ) { sal_Int8 nRet = DND_ACTION_NONE; - if( mpTheme && !mpTheme->IsReadOnly() && !mpTheme ->IsImported() ) + if( mpTheme && !mpTheme->IsReadOnly() ) nRet = DND_ACTION_COPY; return nRet; diff --git a/svx/source/gallery2/gallery.src b/svx/source/gallery2/gallery.src index b801b1d3fa50..6bb583a053d2 100644 --- a/svx/source/gallery2/gallery.src +++ b/svx/source/gallery2/gallery.src @@ -190,11 +190,6 @@ Bitmap RID_SVXBMP_THEME_NORMAL File = "galnors.bmp" ; }; -Bitmap RID_SVXBMP_THEME_IMPORTED -{ - File = "galimps.bmp" ; -}; - Bitmap RID_SVXBMP_THEME_READONLY { File = "galrdos.bmp" ; diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index b00d02ab6f97..f50b3c6ff2da 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -53,12 +53,11 @@ using namespace ::com::sun::star; // --------------------- GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName, - sal_uInt32 _nFileNumber, sal_Bool _bReadOnly, sal_Bool _bImported, + sal_uInt32 _nFileNumber, sal_Bool _bReadOnly, sal_Bool _bNewFile, sal_uInt32 _nId, sal_Bool _bThemeNameFromResource ) : nFileNumber ( _nFileNumber ), nId ( _nId ), - bReadOnly ( _bReadOnly || _bImported ), - bImported ( _bImported ), + bReadOnly ( _bReadOnly ), bThemeNameFromResource ( _bThemeNameFromResource ) { INetURLObject aURL( rBaseURL ); @@ -136,7 +135,7 @@ SvStream& operator<<( SvStream& rOut, const GalleryImportThemeEntry& rEntry ) write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, rEntry.aThemeName, RTL_TEXTENCODING_UTF8); write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, rEntry.aUIName, RTL_TEXTENCODING_UTF8); write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, (rEntry.aURL.GetMainURL( INetURLObject::NO_DECODE )), RTL_TEXTENCODING_UTF8); - write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, rEntry.aImportName, RTL_TEXTENCODING_UTF8); + write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, rtl::OUString(), RTL_TEXTENCODING_UTF8); //aImportName write_lenPrefixed_uInt8s_FromOString<sal_uInt16>(rOut, rtl::OString()); return rOut; @@ -149,7 +148,7 @@ SvStream& operator>>( SvStream& rIn, GalleryImportThemeEntry& rEntry ) rEntry.aThemeName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8); rEntry.aUIName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8); rEntry.aURL = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8); - rEntry.aImportName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8); + read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8); //aImportName read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIn); return rIn; } @@ -254,8 +253,6 @@ void Gallery::ImplLoad( const rtl::OUString& rMultiPath ) DBG_ASSERT( aUserURL.GetProtocol() != INET_PROT_NOT_VALID, "no writable Gallery user directory available" ); DBG_ASSERT( aRelURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" ); - - ImplLoadImports(); } // ------------------------------------------------------------------------ @@ -454,85 +451,6 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR // ------------------------------------------------------------------------ -void Gallery::ImplLoadImports() -{ - INetURLObject aURL( GetUserURL() ); - - aURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( "gallery.sdi" ) ) ); - - if( FileExists( aURL ) ) - { - SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ ); - - if( pIStm ) - { - GalleryThemeEntry* pThemeEntry; - GalleryImportThemeEntry* pImportEntry; - INetURLObject aFile; - sal_uInt32 nInventor; - sal_uInt32 nCount; - sal_uInt16 nId; - sal_uInt16 i; - sal_uInt16 nTempCharSet; - - for ( size_t j = 0, n = aImportList.size(); j < n; ++j ) - delete aImportList[ j ]; - aImportList.clear(); - - *pIStm >> nInventor; - - if( nInventor == COMPAT_FORMAT( 'S', 'G', 'A', '3' ) ) - { - *pIStm >> nId >> nCount >> nTempCharSet; - - for( i = 0; i < nCount; i++ ) - { - pImportEntry = new GalleryImportThemeEntry; - - *pIStm >> *pImportEntry; - aImportList.push_back( pImportEntry ); - aFile = INetURLObject( pImportEntry->aURL ); - pThemeEntry = new GalleryThemeEntry( aFile, - pImportEntry->aUIName, - String(aFile.GetBase()).Erase( 0, 2 ).Erase( 6 ).ToInt32(), - sal_True, sal_True, sal_False, 0, sal_False ); - - aThemeList.push_back( pThemeEntry ); - } - } - - delete pIStm; - } - } -} - -// ------------------------------------------------------------------------ - -void Gallery::ImplWriteImportList() -{ - INetURLObject aURL( GetUserURL() ); - aURL.Append( ( String( "gallery.sdi", RTL_TEXTENCODING_UTF8 ) ) ); - SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC ); - - if( pOStm ) - { - const sal_uInt32 nInventor = (sal_uInt32) COMPAT_FORMAT( 'S', 'G', 'A', '3' ); - const sal_uInt16 nId = 0x0004; - - *pOStm << nInventor << nId << (sal_uInt32) aImportList.size() << (sal_uInt16) osl_getThreadTextEncoding(); - - for ( size_t i = 0, n = aImportList.size(); i < n; ++i ) - *pOStm << *aImportList[ i ]; - - if( pOStm->GetError() ) - ErrorHandler::HandleError( ERRCODE_IO_GENERAL ); - - delete pOStm; - } -} - -// ------------------------------------------------------------------------ - GalleryThemeEntry* Gallery::ImplGetThemeEntry( const rtl::OUString& rThemeName ) { GalleryThemeEntry* pFound = NULL; @@ -632,7 +550,7 @@ sal_Bool Gallery::CreateTheme( const String& rThemeName, sal_uInt32 nNumFrom ) nLastFileNumber = nNumFrom > nLastFileNumber ? nNumFrom : nLastFileNumber + 1; GalleryThemeEntry* pNewEntry = new GalleryThemeEntry( GetUserURL(), rThemeName, nLastFileNumber, - sal_False, sal_False, sal_True, 0, sal_False ); + sal_False, sal_True, 0, sal_False ); aThemeList.push_back( pNewEntry ); delete( new GalleryTheme( this, pNewEntry ) ); @@ -651,7 +569,7 @@ sal_Bool Gallery::RenameTheme( const String& rOldName, const String& rNewName ) sal_Bool bRet = sal_False; // Ueberpruefen, ob neuer Themenname schon vorhanden ist - if( pThemeEntry && !HasTheme( rNewName ) && ( !pThemeEntry->IsReadOnly() || pThemeEntry->IsImported() ) ) + if( pThemeEntry && !HasTheme( rNewName ) && !pThemeEntry->IsReadOnly() ) { SfxListener aListener; GalleryTheme* pThm = AcquireTheme( rOldName, aListener ); @@ -663,19 +581,6 @@ sal_Bool Gallery::RenameTheme( const String& rOldName, const String& rNewName ) pThemeEntry->SetName( rNewName ); pThm->ImplWrite(); - if( pThemeEntry->IsImported() ) - { - pThm->SetImportName( rNewName ); - - GalleryImportThemeEntry* pImportEntry = ImplGetImportThemeEntry( rOldName ); - - if( pImportEntry ) - { - pImportEntry->aUIName = rNewName; - ImplWriteImportList(); - } - } - Broadcast( GalleryHint( GALLERY_HINT_THEME_RENAMED, aOldName, pThm->GetName() ) ); ReleaseTheme( pThm, aListener ); bRet = sal_True; @@ -692,44 +597,24 @@ sal_Bool Gallery::RemoveTheme( const String& rThemeName ) GalleryThemeEntry* pThemeEntry = ImplGetThemeEntry( rThemeName ); sal_Bool bRet = sal_False; - if( pThemeEntry && ( !pThemeEntry->IsReadOnly() || pThemeEntry->IsImported() ) ) + if( pThemeEntry && !pThemeEntry->IsReadOnly() ) { Broadcast( GalleryHint( GALLERY_HINT_CLOSE_THEME, rThemeName ) ); - if( pThemeEntry->IsImported() ) - { - GalleryImportThemeEntry* pImportEntry = ImplGetImportThemeEntry( rThemeName ); + SfxListener aListener; + GalleryTheme* pThm = AcquireTheme( rThemeName, aListener ); - if( pImportEntry ) - { - for ( GalleryImportThemeList::iterator it = aImportList.begin(); it != aImportList.end(); ++it ) - { - if ( *it == pImportEntry ) - { - delete pImportEntry; - aImportList.erase( it ); - break; - } - } - } - } - else + if( pThm ) { - SfxListener aListener; - GalleryTheme* pThm = AcquireTheme( rThemeName, aListener ); - - if( pThm ) - { - INetURLObject aThmURL( pThm->GetThmURL() ); - INetURLObject aSdgURL( pThm->GetSdgURL() ); - INetURLObject aSdvURL( pThm->GetSdvURL() ); + INetURLObject aThmURL( pThm->GetThmURL() ); + INetURLObject aSdgURL( pThm->GetSdgURL() ); + INetURLObject aSdvURL( pThm->GetSdvURL() ); - ReleaseTheme( pThm, aListener ); + ReleaseTheme( pThm, aListener ); - KillFile( aThmURL ); - KillFile( aSdgURL ); - KillFile( aSdvURL ); - } + KillFile( aThmURL ); + KillFile( aSdgURL ); + KillFile( aSdvURL ); } for ( GalleryThemeList::iterator it = aThemeList.begin(); it != aThemeList.end(); ++it ) @@ -784,12 +669,7 @@ GalleryTheme* Gallery::ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry if( !pTheme ) { - INetURLObject aURL; - - if( !pThemeEntry->IsImported() ) - aURL = pThemeEntry->GetThmURL(); - else - aURL = GetImportURL( pThemeEntry->GetThemeName() ); + INetURLObject aURL = pThemeEntry->GetThmURL(); DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" ); @@ -803,9 +683,9 @@ GalleryTheme* Gallery::ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry *pIStm >> *pTheme; if( pIStm->GetError() ) + { delete pTheme, pTheme = NULL; - else if( pThemeEntry->IsImported() ) - pTheme->SetImportName( pThemeEntry->GetThemeName() ); + } delete pIStm; } diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index 27caa5f5ef1d..e82289d5f970 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -79,9 +79,6 @@ GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry ) bDragging ( sal_False ) { ImplCreateSvDrawStorage(); - - if( pThm->IsImported() ) - aImportName = pThm->GetThemeName(); } // ------------------------------------------------------------------------ @@ -104,15 +101,10 @@ GalleryTheme::~GalleryTheme() void GalleryTheme::ImplCreateSvDrawStorage() { - if( !pThm->IsImported() ) - { - aSvDrawStorageRef = new SvStorage( sal_False, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), pThm->IsReadOnly() ? STREAM_READ : STREAM_STD_READWRITE ); - // #i50423# ReadOnly may not been set though the file can't be written (because of security reasons) - if ( ( aSvDrawStorageRef->GetError() != ERRCODE_NONE ) && !pThm->IsReadOnly() ) - aSvDrawStorageRef = new SvStorage( sal_False, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ ); - } - else - aSvDrawStorageRef.Clear(); + aSvDrawStorageRef = new SvStorage( sal_False, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), pThm->IsReadOnly() ? STREAM_READ : STREAM_STD_READWRITE ); + // #i50423# ReadOnly may not been set though the file can't be written (because of security reasons) + if ( ( aSvDrawStorageRef->GetError() != ERRCODE_NONE ) && !pThm->IsReadOnly() ) + aSvDrawStorageRef = new SvStorage( sal_False, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ ); } // ------------------------------------------------------------------------ @@ -256,19 +248,7 @@ INetURLObject GalleryTheme::ImplGetURL( const GalleryObject* pObject ) const INetURLObject aURL; if( pObject ) - { - if( IsImported() ) - { - INetURLObject aPathURL( GetParent()->GetImportURL( GetName() ) ); - - aPathURL.removeSegment(); - aPathURL.removeFinalSlash(); - aPathURL.Append( pObject->aURL.GetName() ); - aURL = aPathURL; - } - else - aURL = pObject->aURL; - } + aURL = pObject->aURL; return aURL; } @@ -536,7 +516,7 @@ bool GalleryTheme::ChangeObjectPos( size_t nOldPos, size_t nNewPos ) void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProgress ) { - if( !IsReadOnly() && !IsImported() ) + if( !IsReadOnly() ) { Graphic aGraphic; String aFormat; @@ -778,7 +758,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sa aPathURL.removeFinalSlash(); pRet = new GalleryThemeEntry( aPathURL, aThemeName, String(rURL.GetBase()).Copy( 2, 6 ).ToInt32(), - bReadOnly, sal_False, sal_False, nThemeId, + bReadOnly, sal_False, nThemeId, bThemeNameFromResource ); } @@ -1432,7 +1412,6 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm ) String aThemeName; rtl_TextEncoding nTextEncoding; - aImportName = rtl::OUString(); rIStm >> nVersion; rtl::OString aTmpStr = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIStm); rIStm >> nCount; @@ -1587,11 +1566,10 @@ const INetURLObject& GalleryTheme::GetSdvURL() const { return pThm->GetSdvURL(); sal_uInt32 GalleryTheme::GetId() const { return pThm->GetId(); } void GalleryTheme::SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName ) { pThm->SetId( nNewId, bResetThemeName ); } sal_Bool GalleryTheme::IsThemeNameFromResource() const { return pThm->IsNameFromResource(); } -sal_Bool GalleryTheme::IsImported() const { return pThm->IsImported(); } sal_Bool GalleryTheme::IsReadOnly() const { return pThm->IsReadOnly(); } sal_Bool GalleryTheme::IsDefault() const { return pThm->IsDefault(); } sal_Bool GalleryTheme::IsModified() const { return pThm->IsModified(); } -const rtl::OUString& GalleryTheme::GetName() const { return IsImported() ? aImportName : pThm->GetThemeName(); } +const rtl::OUString& GalleryTheme::GetName() const { return pThm->GetThemeName(); } void GalleryTheme::InsertAllThemes( ListBox& rListBox ) { |