summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorRishabh Kumar <kris.kr296@gmail.com>2016-07-24 17:23:40 +0530
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-12-17 02:35:53 +0100
commit34664ccceb4798356ef08b18535318e27c61e990 (patch)
tree2ac930b1217d604e605c7b62dffb5555ccd498a4 /svx
parente516879cc5a17fab70aa421db30dfe7d7beadb88 (diff)
Fix palette selection in sidebar/toolbar color widget
Remember palette selection after the popup is destroyed Change-Id: Iecd7fd4aa89cf9d2d6842c5b544d037df6818aaf Reviewed-on: https://gerrit.libreoffice.org/27474 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit db8ee318293da8967a8294dc558ffae898ba8e6b)
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/Palette.cxx15
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx67
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx3
3 files changed, 53 insertions, 32 deletions
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index d5e2dd9b9505..4dceb783065e 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -53,6 +53,11 @@ const OUString& PaletteASE::GetName()
return maASEPaletteName;
}
+const OUString& PaletteASE::GetPath()
+{
+ return maFPath;
+}
+
bool PaletteASE::IsValid()
{
return mbValidPalette;
@@ -186,6 +191,11 @@ const OUString& PaletteGPL::GetName()
return maGPLPaletteName;
}
+const OUString& PaletteGPL::GetPath()
+{
+ return maFPath;
+}
+
void PaletteGPL::LoadColorSet( SvxColorValueSet& rColorSet )
{
LoadPalette();
@@ -327,6 +337,11 @@ const OUString& PaletteSOC::GetName()
return maSOCPaletteName;
}
+const OUString& PaletteSOC::GetPath()
+{
+ return maFPath;
+}
+
void PaletteSOC::LoadColorSet( SvxColorValueSet& rColorSet )
{
if( !mbLoadedPalette )
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 535134f344de..55123aa002f8 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -33,13 +33,22 @@
PaletteManager::PaletteManager() :
mnMaxRecentColors(Application::GetSettings().GetStyleSettings().GetColorValueSetColumnCount()),
- mnNumOfPalettes(2),
+ mnNumOfPalettes(1),
mnCurrentPalette(0),
mnColorCount(0),
mpBtnUpdater(nullptr),
mLastColor(COL_AUTO),
maColorSelectFunction(PaletteManager::DispatchColorCommand)
{
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ if(pDocSh)
+ {
+ const SfxPoolItem* pItem = nullptr;
+ if( nullptr != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) )
+ pColorList = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
+ }
+ if(!pColorList.is())
+ pColorList = XColorList::CreateStdColorList();
LoadPalettes();
mnNumOfPalettes += m_Palettes.size();
}
@@ -82,19 +91,21 @@ void PaletteManager::LoadPalettes()
if(aFileStat.isRegular() || aFileStat.isLink())
{
OUString aFName = aFileStat.getFileName();
+ INetURLObject aURLObj( aFileStat.getFileURL() );
+ OUString aFNameWithoutExt = aURLObj.GetBase();
if (aNames.find(aFName) == aNames.end())
{
std::unique_ptr<Palette> pPalette;
if( aFName.endsWithIgnoreAsciiCase(".gpl") )
- pPalette.reset(new PaletteGPL(aFileStat.getFileURL(), aFName));
+ pPalette.reset(new PaletteGPL(aFileStat.getFileURL(), aFNameWithoutExt));
else if( aFName.endsWithIgnoreAsciiCase(".soc") )
- pPalette.reset(new PaletteSOC(aFileStat.getFileURL(), aFName));
+ pPalette.reset(new PaletteSOC(aFileStat.getFileURL(), aFNameWithoutExt));
else if ( aFName.endsWithIgnoreAsciiCase(".ase") )
- pPalette.reset(new PaletteASE(aFileStat.getFileURL(), aFName));
+ pPalette.reset(new PaletteASE(aFileStat.getFileURL(), aFNameWithoutExt));
if( pPalette && pPalette->IsValid() )
m_Palettes.push_back( std::move(pPalette) );
- aNames.insert(aFName);
+ aNames.insert(aFNameWithoutExt);
}
}
}
@@ -106,29 +117,7 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
{
SfxObjectShell* pDocSh = SfxObjectShell::Current();
- if( mnCurrentPalette == 0 )
- {
- XColorListRef pColorList;
-
- if ( pDocSh )
- {
- const SfxPoolItem* pItem = nullptr;
- if ( nullptr != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
- pColorList = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
- }
-
- if ( !pColorList.is() )
- pColorList = XColorList::CreateStdColorList();
-
-
- if ( pColorList.is() )
- {
- mnColorCount = pColorList->Count();
- rColorSet.Clear();
- rColorSet.addEntriesForXColorList(*pColorList);
- }
- }
- else if( mnCurrentPalette == mnNumOfPalettes - 1 )
+ if( mnCurrentPalette == mnNumOfPalettes - 1 )
{
// Add doc colors to palette
std::set<Color> aColors = pDocSh->GetDocColors();
@@ -138,7 +127,7 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
}
else
{
- m_Palettes[mnCurrentPalette-1]->LoadColorSet( rColorSet );
+ m_Palettes[mnCurrentPalette]->LoadColorSet( rColorSet );
mnColorCount = rColorSet.GetItemCount();
}
}
@@ -159,8 +148,6 @@ std::vector<OUString> PaletteManager::GetPaletteList()
{
std::vector<OUString> aPaletteNames;
- aPaletteNames.push_back( SVX_RESSTR( RID_SVXSTR_DEFAULT_PAL ) );
-
for (auto const& it : m_Palettes)
{
aPaletteNames.push_back( (*it).GetName() );
@@ -173,6 +160,19 @@ std::vector<OUString> PaletteManager::GetPaletteList()
void PaletteManager::SetPalette( sal_Int32 nPos )
{
+ if( nPos != mnNumOfPalettes - 1 )
+ {
+ pColorList = XPropertyList::AsColorList(
+ XPropertyList::CreatePropertyListFromURL(
+ XCOLOR_LIST, m_Palettes[nPos]->GetPath()));
+ pColorList->SetName(m_Palettes[nPos]->GetName());
+ if(pColorList->Load())
+ {
+ SfxObjectShell* pShell = SfxObjectShell::Current();
+ SvxColorListItem aColorItem(pColorList, SID_COLOR_TABLE);
+ pShell->PutItem( aColorItem );
+ }
+ }
mnCurrentPalette = nPos;
}
@@ -181,6 +181,11 @@ sal_Int32 PaletteManager::GetPalette()
return mnCurrentPalette;
}
+OUString PaletteManager::GetPaletteName()
+{
+ return pColorList->GetName();
+}
+
long PaletteManager::GetColorCount()
{
return mnColorCount;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 28684f4c4c93..fabe35b43cd3 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1332,7 +1332,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
{
mpPaletteListBox->InsertEntry( *it );
}
- mpPaletteListBox->SelectEntryPos(mrPaletteManager.GetPalette());
+ mpPaletteListBox->SelectEntry(mrPaletteManager.GetPaletteName());
+ SelectPaletteHdl( *mpPaletteListBox );
mpButtonAutoColor->SetClickHdl( LINK( this, SvxColorWindow_Impl, AutoColorClickHdl ) );
mpButtonPicker->SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );