summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorRishabh Kumar <kris.kr296@gmail.com>2016-08-02 23:53:38 +0530
committerTomaž Vajngerl <quikee@gmail.com>2016-08-03 14:19:51 +0000
commit571866eaba914742a48938abb6c8495e97868bf1 (patch)
treee2b80dbb49f0f011dea676d1a60cd2b24943b61b /svx
parent569825ea2b64f3682932cd07dae2b244854f4157 (diff)
[GSoC] Rework of color tab
New Features - 1. Multiple Palettes in color tab. 2. Remember the selected palette. 3. Recent colors. 4. Custom colors. Change-Id: I36a438a0c282059ddcbda35f934fcd90337fd451 Reviewed-on: https://gerrit.libreoffice.org/26868 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Yousuf Philips <philipz85@hotmail.com> Tested-by: Yousuf Philips <philipz85@hotmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx54
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx5
-rw-r--r--svx/source/tbxctrls/tbcontrl.src4
3 files changed, 51 insertions, 12 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index e1da1d71bff2..e2dbe421c885 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -35,7 +35,7 @@
PaletteManager::PaletteManager() :
mnMaxRecentColors(Application::GetSettings().GetStyleSettings().GetColorValueSetColumnCount()),
- mnNumOfPalettes(1),
+ mnNumOfPalettes(2),
mnCurrentPalette(0),
mnColorCount(0),
mpBtnUpdater(nullptr),
@@ -120,7 +120,21 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
{
SfxObjectShell* pDocSh = SfxObjectShell::Current();
- if( mnCurrentPalette == mnNumOfPalettes - 1 )
+ if( mnCurrentPalette == 0)
+ {
+ rColorSet.Clear();
+ css::uno::Sequence< sal_Int32 > CustomColorList( officecfg::Office::Common::UserColors::CustomColor::get() );
+ css::uno::Sequence< OUString > CustomColorNameList( officecfg::Office::Common::UserColors::CustomColorName::get() );
+ int nIx = 1;
+ for( int i = 0;i < CustomColorList.getLength();i++ )
+ {
+ Color aColor( CustomColorList[i] );
+ OUString aColorName( CustomColorNameList[i] );
+ rColorSet.InsertItem( nIx, aColor, aColorName );
+ ++nIx;
+ }
+ }
+ else if( mnCurrentPalette == mnNumOfPalettes - 1 )
{
// Add doc colors to palette
std::set<Color> aColors = pDocSh->GetDocColors();
@@ -130,7 +144,7 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
}
else
{
- m_Palettes[mnCurrentPalette]->LoadColorSet( rColorSet );
+ m_Palettes[mnCurrentPalette - 1]->LoadColorSet( rColorSet );
mnColorCount = rColorSet.GetItemCount();
}
}
@@ -158,11 +172,11 @@ std::vector<OUString> PaletteManager::GetPaletteList()
{
std::vector<OUString> aPaletteNames;
+ aPaletteNames.push_back( SVX_RESSTR( RID_SVXSTR_CUSTOM_PAL ) );
for (auto const& it : m_Palettes)
{
aPaletteNames.push_back( (*it).GetName() );
}
-
aPaletteNames.push_back( SVX_RESSTR ( RID_SVXSTR_DOC_COLORS ) );
return aPaletteNames;
@@ -170,12 +184,13 @@ std::vector<OUString> PaletteManager::GetPaletteList()
void PaletteManager::SetPalette( sal_Int32 nPos )
{
- if( nPos != mnNumOfPalettes - 1 )
+ mnCurrentPalette = nPos;
+ if( nPos != mnNumOfPalettes - 1 && nPos != 0)
{
pColorList = XPropertyList::AsColorList(
XPropertyList::CreatePropertyListFromURL(
- XCOLOR_LIST, m_Palettes[nPos]->GetPath()));
- pColorList->SetName(m_Palettes[nPos]->GetName());
+ XCOLOR_LIST, GetSelectedPalettePath()));
+ pColorList->SetName(GetPaletteName());
if(pColorList->Load())
{
SfxObjectShell* pShell = SfxObjectShell::Current();
@@ -183,7 +198,9 @@ void PaletteManager::SetPalette( sal_Int32 nPos )
pShell->PutItem( aColorItem );
}
}
- mnCurrentPalette = nPos;
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context));
+ officecfg::Office::Common::UserColors::PaletteName::set(GetPaletteName(), batch);
+ batch->commit();
}
sal_Int32 PaletteManager::GetPalette()
@@ -193,7 +210,26 @@ sal_Int32 PaletteManager::GetPalette()
OUString PaletteManager::GetPaletteName()
{
- return pColorList->GetName();
+ std::vector<OUString> aNames(GetPaletteList());
+ if(mnCurrentPalette != mnNumOfPalettes - 1 && mnCurrentPalette != 0)
+ {
+ 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();
+ }
+ }
+ return aNames[mnCurrentPalette];
+}
+
+OUString PaletteManager::GetSelectedPalettePath()
+{
+ if(mnCurrentPalette != mnNumOfPalettes - 1 && mnCurrentPalette != 0)
+ return m_Palettes[mnCurrentPalette - 1]->GetPath();
+ else
+ return OUString();
}
long PaletteManager::GetColorCount()
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 2851dfa1f2b4..2dceb15814f4 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -96,6 +96,8 @@
#include <svx/xflclit.hxx>
#include <svl/currencytable.hxx>
#include <svtools/langtab.hxx>
+#include <cppu/unotype.hxx>
+#include <officecfg/Office/Common.hxx>
#define MAX_MRU_FONTNAME_ENTRIES 5
@@ -1331,7 +1333,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
{
mpPaletteListBox->InsertEntry( *it );
}
- mpPaletteListBox->SelectEntry(mrPaletteManager.GetPaletteName());
+ OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() );
+ mpPaletteListBox->SelectEntry( aPaletteName );
SelectPaletteHdl( *mpPaletteListBox );
mpButtonAutoColor->SetClickHdl( LINK( this, SvxColorWindow_Impl, AutoColorClickHdl ) );
diff --git a/svx/source/tbxctrls/tbcontrl.src b/svx/source/tbxctrls/tbcontrl.src
index 8e7a44267f6c..48777fc9d70a 100644
--- a/svx/source/tbxctrls/tbcontrl.src
+++ b/svx/source/tbxctrls/tbcontrl.src
@@ -224,9 +224,9 @@ String RID_SVXSTR_CHARFONTNAME_NOTAVAILABLE
Text [ en-US ] = "Font Name. The current font is not available and will be substituted.";
};
-String RID_SVXSTR_DEFAULT_PAL
+String RID_SVXSTR_CUSTOM_PAL
{
- Text [ en-US ] = "Default palette";
+ Text [ en-US ] = "custom";
};
String RID_SVXSTR_DOC_COLORS