diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2014-07-25 16:45:13 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2014-09-17 10:19:41 +0200 |
commit | cfdefe488fedbd12f7a3daf578c889ef82e962fc (patch) | |
tree | 49b10153c14dac54448d89e39f585e10e2596585 /svx/source/tbxctrls/PaletteManager.cxx | |
parent | d1d5c9185f9d5231bdaa332d965b31b946411ac3 (diff) |
Add loading .soc palettes
Change-Id: Ie0d084a70d9b135658840bb7529f2099a702d280
Diffstat (limited to 'svx/source/tbxctrls/PaletteManager.cxx')
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 95c351dd24e6..95485ced1a03 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -39,6 +39,16 @@ PaletteManager::PaletteManager() : mnNumOfPalettes += maPalettes.size(); } +PaletteManager::~PaletteManager() +{ + for( std::vector<Palette*>::iterator it = maPalettes.begin(); + it != maPalettes.end(); + ++it) + { + delete *it; + } +} + void PaletteManager::LoadPalettes() { OUString aPalPath = SvtPathOptions().GetPalettePath(); @@ -57,12 +67,14 @@ void PaletteManager::LoadPalettes() if(aFileStat.isRegular() || aFileStat.isLink()) { OUString aFName = aFileStat.getFileName(); + Palette* pPalette = 0; if( aFName.endsWithIgnoreAsciiCase(".gpl") ) - { - Palette aPalette( aFileStat.getFileURL(), aFName ); - if( aPalette.IsValid() ) - maPalettes.push_back( aPalette ); - } + pPalette = new PaletteGPL( aFileStat.getFileURL(), aFName ); + else if( aFName.endsWithIgnoreAsciiCase(".soc") ) + pPalette = new PaletteSOC( aFileStat.getFileURL(), aFName ); + + if( pPalette && pPalette->IsValid() ) + maPalettes.push_back( pPalette ); } } } @@ -104,10 +116,8 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet) } else { - Palette& rPal = maPalettes[mnCurrentPalette-1]; - mnColorCount = rPal.GetPaletteColors().size(); - rColorSet.Clear(); - rColorSet.loadPalette(rPal); + maPalettes[mnCurrentPalette-1]->LoadColorSet( rColorSet ); + mnColorCount = rColorSet.GetItemCount(); } } @@ -117,11 +127,11 @@ std::vector<OUString> PaletteManager::GetPaletteList() aPaletteNames.push_back( STR_DEFAULT_PAL ); - for( std::vector<Palette>::iterator it = maPalettes.begin(); + for( std::vector<Palette*>::iterator it = maPalettes.begin(); it != maPalettes.end(); ++it) { - aPaletteNames.push_back( it->GetName() ); + aPaletteNames.push_back( (*it)->GetName() ); } aPaletteNames.push_back( STR_DOC_COLORS ); @@ -151,7 +161,7 @@ OUString PaletteManager::GetPaletteName() else if( mnCurrentPalette == mnNumOfPalettes - 1 ) return OUString( STR_DOC_COLORS ); else - return maPalettes[mnCurrentPalette - 1].GetName(); + return maPalettes[mnCurrentPalette - 1]->GetName(); } const Color& PaletteManager::GetLastColor() |