summaryrefslogtreecommitdiff
path: root/svx/source/tbxctrls/PaletteManager.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-06-06 14:24:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-06-07 15:39:22 +0100
commit29202a16d9f1934684c7d0978112849f2a21fe2f (patch)
treef72219d0804dd6ba45e0f1e5b02603be5ef5d5c3 /svx/source/tbxctrls/PaletteManager.cxx
parent2c3bf6bfc244517a0134e320acaa1f720703d8f2 (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/source/tbxctrls/PaletteManager.cxx')
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx67
1 files changed, 45 insertions, 22 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);
+ }
+ }
}
}
}