summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2013-10-23 19:49:06 +0100
committerMichael Meeks <michael.meeks@collabora.com>2013-10-24 13:22:18 +0100
commit398519cb61b3aa2df61b9b18724ced4a36eb39d6 (patch)
tree6f01cb40708be310462c50e13e0d3de86b39cafc /svx
parent470b4a03bf6d5f6340c201066a10d72ad7b01107 (diff)
fdo#69079 - fix multiple user gallery creations.
Change-Id: I0539e2708b973b8bea7bd63488277f00201c6c46
Diffstat (limited to 'svx')
-rw-r--r--svx/source/gallery2/gallery1.cxx28
-rw-r--r--svx/source/gallery2/galtheme.cxx2
2 files changed, 26 insertions, 4 deletions
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 939fb1f4f7fd..e7cea796a683 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -42,7 +42,15 @@ using namespace ::com::sun::star;
// - GalleryThemeEntry -
-GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const OUString& 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 OUString& rName,
sal_Bool _bReadOnly, sal_Bool _bNewFile,
sal_uInt32 _nId, sal_Bool _bThemeNameFromResource ) :
nId ( _nId ),
@@ -52,6 +60,19 @@ GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const OUStr
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 );
@@ -491,8 +512,9 @@ sal_Bool Gallery::CreateTheme( const OUString& 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 bab0d02ea403..dc2f48ad336c 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -746,7 +746,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 );
}