diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-06-06 14:24:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-06-07 15:39:22 +0100 |
commit | 29202a16d9f1934684c7d0978112849f2a21fe2f (patch) | |
tree | f72219d0804dd6ba45e0f1e5b02603be5ef5d5c3 /svx | |
parent | 2c3bf6bfc244517a0134e320acaa1f720703d8f2 (diff) |
Resolves: tdf#89905 don't copy palettes from shared to user
make this a multi-path element with a shared read-only location
and a user read/write location and don't copy the presets, instead
just keep them in the shared location
Now an admin can copy extra palettes into the shared location
and they magically appear in the user deployments
Change-Id: I7585789c0c59941094f6128368df94b834d3c2a2
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 67 | ||||
-rw-r--r-- | svx/source/xoutdev/xtable.cxx | 54 |
2 files changed, 86 insertions, 35 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 109f934f1b3b..3334afc3e6bc 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -27,6 +27,8 @@ #include <svtools/colrdlg.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <stack> +#include <set> PaletteManager::PaletteManager() : mnMaxRecentColors(Application::GetSettings().GetStyleSettings().GetColorValueSetColumnCount()), @@ -47,31 +49,52 @@ PaletteManager::~PaletteManager() void PaletteManager::LoadPalettes() { maPalettes.clear(); - OUString aPalPath = SvtPathOptions().GetPalettePath(); - - osl::Directory aDir(aPalPath); - osl::DirectoryItem aDirItem; - osl::FileStatus aFileStat( osl_FileStatus_Mask_FileName | - osl_FileStatus_Mask_FileURL | - osl_FileStatus_Mask_Type ); - if( aDir.open() == osl::FileBase::E_None ) + OUString aPalPaths = SvtPathOptions().GetPalettePath(); + + std::stack<OUString> aDirs; + sal_Int32 nIndex = 0; + do + { + aDirs.push(aPalPaths.getToken(0, ';', nIndex)); + } + while (nIndex >= 0); + + std::set<OUString> aNames; + //try all entries palette path list user first, then + //system, ignoring duplicate file names + while (!aDirs.empty()) { - while( aDir.getNextItem(aDirItem) == osl::FileBase::E_None ) + OUString aPalPath = aDirs.top(); + aDirs.pop(); + + osl::Directory aDir(aPalPath); + osl::DirectoryItem aDirItem; + osl::FileStatus aFileStat( osl_FileStatus_Mask_FileName | + osl_FileStatus_Mask_FileURL | + osl_FileStatus_Mask_Type ); + if( aDir.open() == osl::FileBase::E_None ) { - aDirItem.getFileStatus(aFileStat); - if(aFileStat.isRegular() || aFileStat.isLink()) + while( aDir.getNextItem(aDirItem) == osl::FileBase::E_None ) { - OUString aFName = aFileStat.getFileName(); - Palette* pPalette = 0; - if( aFName.endsWithIgnoreAsciiCase(".gpl") ) - pPalette = new PaletteGPL( aFileStat.getFileURL(), aFName ); - else if( aFName.endsWithIgnoreAsciiCase(".soc") ) - pPalette = new PaletteSOC( aFileStat.getFileURL(), aFName ); - else if ( aFName.endsWithIgnoreAsciiCase(".ase") ) - pPalette = new PaletteASE( aFileStat.getFileURL(), aFName ); - - if( pPalette && pPalette->IsValid() ) - maPalettes.push_back( pPalette ); + aDirItem.getFileStatus(aFileStat); + if(aFileStat.isRegular() || aFileStat.isLink()) + { + OUString aFName = aFileStat.getFileName(); + if (aNames.find(aFName) == aNames.end()) + { + Palette* pPalette = 0; + if( aFName.endsWithIgnoreAsciiCase(".gpl") ) + pPalette = new PaletteGPL( aFileStat.getFileURL(), aFName ); + else if( aFName.endsWithIgnoreAsciiCase(".soc") ) + pPalette = new PaletteSOC( aFileStat.getFileURL(), aFName ); + else if ( aFName.endsWithIgnoreAsciiCase(".ase") ) + pPalette = new PaletteASE( aFileStat.getFileURL(), aFName ); + + if( pPalette && pPalette->IsValid() ) + maPalettes.push_back( pPalette ); + aNames.insert(aFName); + } + } } } } diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx index 5e35be97a2c7..b3f1416d8ceb 100644 --- a/svx/source/xoutdev/xtable.cxx +++ b/svx/source/xoutdev/xtable.cxx @@ -25,6 +25,7 @@ #include <svx/xpool.hxx> #include <svx/svdobj.hxx> #include <svx/svdpool.hxx> +#include <stack> using namespace com::sun::star; @@ -224,23 +225,41 @@ bool XPropertyList::Load() if( mbListDirty ) { mbListDirty = false; + std::stack<OUString> aDirs; - INetURLObject aURL( maPath ); - - if( INetProtocol::NotValid == aURL.GetProtocol() ) + sal_Int32 nIndex = 0; + do { - DBG_ASSERT( maPath.isEmpty(), "invalid URL" ); - return false; + aDirs.push(maPath.getToken(0, ';', nIndex)); } + while (nIndex >= 0); + + //try all entries palette path list working back to front until one + //succeeds + while (!aDirs.empty()) + { + OUString aPath(aDirs.top()); + aDirs.pop(); + + INetURLObject aURL(aPath); + + if( INetProtocol::NotValid == aURL.GetProtocol() ) + { + DBG_ASSERT( aPath.isEmpty(), "invalid URL" ); + return false; + } - aURL.Append( maName ); + aURL.Append( maName ); - if( aURL.getExtension().isEmpty() ) - aURL.setExtension( GetDefaultExt() ); + if( aURL.getExtension().isEmpty() ) + aURL.setExtension( GetDefaultExt() ); - return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), maReferer, - uno::Reference < embed::XStorage >(), - createInstance(), NULL ); + bool bRet = SvxXMLXTableImport::load(aURL.GetMainURL(INetURLObject::NO_DECODE), + maReferer, uno::Reference < embed::XStorage >(), + createInstance(), NULL ); + if (bRet) + return bRet; + } } return false; } @@ -256,11 +275,20 @@ bool XPropertyList::LoadFrom( const uno::Reference < embed::XStorage > &xStorage bool XPropertyList::Save() { - INetURLObject aURL( maPath ); + //save to the last path in the palette path list + OUString aLastDir; + sal_Int32 nIndex = 0; + do + { + aLastDir = maPath.getToken(0, ';', nIndex); + } + while (nIndex >= 0); + + INetURLObject aURL(aLastDir); if( INetProtocol::NotValid == aURL.GetProtocol() ) { - DBG_ASSERT( maPath.isEmpty(), "invalid URL" ); + DBG_ASSERT( aLastDir.isEmpty(), "invalid URL" ); return false; } |