summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2013-10-23 19:49:06 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-10-29 12:05:59 +0000
commit41102212d49fd18643bba375d65963bd41008bc7 (patch)
treeb5f7e24613768bf710fee2006cd6a168738ae969
parentc24493db0d4b4d2685ef5b8fcca51f163531394d (diff)
fdo#69079 - fix multiple user gallery creations.
Conflicts: include/svx/gallery1.hxx svx/source/gallery2/gallery1.cxx Change-Id: I0539e2708b973b8bea7bd63488277f00201c6c46 Reviewed-on: https://gerrit.libreoffice.org/6417 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/svx/gallery1.hxx4
-rw-r--r--svx/source/gallery2/gallery1.cxx29
-rw-r--r--svx/source/gallery2/galtheme.cxx2
3 files changed, 30 insertions, 5 deletions
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx
index 4a7a9d3ad6c4..5610c0f043b0 100644
--- a/include/svx/gallery1.hxx
+++ b/include/svx/gallery1.hxx
@@ -53,7 +53,9 @@ private:
public:
- GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
+ GalleryThemeEntry( bool bCreateUniqueURL,
+ const INetURLObject& rBaseURL,
+ const String& rName,
sal_Bool bReadOnly, sal_Bool bNewFile,
sal_uInt32 nId, sal_Bool bThemeNameFromResource );
~GalleryThemeEntry() {};
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 3d2f9dce3919..b6ec5e99d604 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -45,7 +45,16 @@ using namespace ::com::sun::star;
// - GalleryThemeEntry -
// ---------------------
-GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
+static bool FileExists( const INetURLObject &rURL, const rtl::OUString &rExt )
+{
+ INetURLObject aURL( rURL );
+ aURL.setExtension( rExt );
+ return FileExists( aURL );
+}
+
+GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL,
+ const INetURLObject& rBaseURL,
+ const String& rName,
sal_Bool _bReadOnly, sal_Bool _bNewFile,
sal_uInt32 _nId, sal_Bool _bThemeNameFromResource ) :
nId ( _nId ),
@@ -55,6 +64,19 @@ GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const Strin
INetURLObject aURL( rBaseURL );
DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+ if (bCreateUniqueURL)
+ {
+ INetURLObject aBaseNoCase( ImplGetURLIgnoreCase( rBaseURL ) );
+ aURL = aBaseNoCase;
+ static sal_Int32 nIdx = 0;
+ while( FileExists( aURL, "thm" ) )
+ { // create new URLs
+ nIdx++;
+ aURL = aBaseNoCase;
+ aURL.setName( aURL.getName() + OUString::number(nIdx));
+ }
+ }
+
aURL.setExtension( "thm" );
aThmURL = ImplGetURLIgnoreCase( aURL );
@@ -520,8 +542,9 @@ sal_Bool Gallery::CreateTheme( const String& rThemeName )
{
INetURLObject aURL( GetUserURL() );
aURL.Append( rThemeName );
- GalleryThemeEntry* pNewEntry = new GalleryThemeEntry( aURL, rThemeName,
- sal_False, sal_True, 0, sal_False );
+ GalleryThemeEntry* pNewEntry = new GalleryThemeEntry(
+ true, aURL, rThemeName,
+ sal_False, sal_True, 0, sal_False );
aThemeList.push_back( pNewEntry );
delete( new GalleryTheme( this, pNewEntry ) );
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 54c706782bfd..cc7754108cb0 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -751,7 +751,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sa
}
INetURLObject aPathURL( rURL );
- pRet = new GalleryThemeEntry( aPathURL, aThemeName,
+ pRet = new GalleryThemeEntry( false, aPathURL, aThemeName,
bReadOnly, sal_False, nThemeId,
bThemeNameFromResource );
}