diff options
-rw-r--r-- | cui/source/options/optchart.cxx | 83 | ||||
-rw-r--r-- | cui/source/options/optchart.hxx | 13 | ||||
-rw-r--r-- | cui/uiconfig/ui/optchartcolorspage.ui | 61 | ||||
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 2 |
4 files changed, 62 insertions, 97 deletions
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index 8846661ddbb7..2bb82ded9621 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -24,15 +24,7 @@ #include <vcl/svapp.hxx> #include <svx/svxids.hrc> #include <osl/diagnose.h> - -Color SvxDefaultColorOptPage::GetSelectEntryColor() const -{ - sal_Int32 nPos = m_pLbChartColors->GetSelectedEntryPos(); - Color aColor; - if (nPos != LISTBOX_ENTRY_NOTFOUND) - aColor = GetEntryColor(nPos); - return aColor; -} +#include <officecfg/Office/Common.hxx> void SvxDefaultColorOptPage::InsertColorEntry(const XColorEntry& rEntry, sal_Int32 nPos) { @@ -82,14 +74,6 @@ void SvxDefaultColorOptPage::ClearColorEntries() m_pLbChartColors->Clear(); } -Color SvxDefaultColorOptPage::GetEntryColor(sal_Int32 nPos) const -{ - Color aColor; - if (0 <= nPos && static_cast<size_t>(nPos) < aColorList.size()) - aColor = aColorList[nPos]; - return aColor; -} - void SvxDefaultColorOptPage::ModifyColorEntry(const XColorEntry& rEntry, sal_Int32 nPos) { RemoveColorEntry(nPos); @@ -116,6 +100,7 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage(vcl::Window* pParent, const SfxIt get(m_pPBRemove, "delete"); get(m_pPBAdd, "add"); get(m_pPBDefault, "default"); + get(m_pLbPaletteSelector, "paletteselector"); get(m_pValSetColorBox, "table"); get(m_pLbChartColors, "colors"); m_pLbChartColors->set_height_request(m_pLbChartColors->GetTextHeight()*16); @@ -123,18 +108,13 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage(vcl::Window* pParent, const SfxIt m_pPBDefault->SetClickHdl( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) ); m_pPBAdd->SetClickHdl( LINK( this, SvxDefaultColorOptPage, AddChartColor ) ); m_pPBRemove->SetClickHdl( LINK( this, SvxDefaultColorOptPage, RemoveChartColor ) ); - m_pLbChartColors->SetSelectHdl( LINK( this, SvxDefaultColorOptPage, ListClickedHdl ) ); m_pValSetColorBox->SetSelectHdl( LINK( this, SvxDefaultColorOptPage, BoxClickedHdl ) ); + m_pLbPaletteSelector->SetSelectHdl( LINK( this, SvxDefaultColorOptPage, SelectPaletteLbHdl ) ); m_pValSetColorBox->SetStyle( m_pValSetColorBox->GetStyle() - | WB_ITEMBORDER | WB_NAMEFIELD ); - m_pValSetColorBox->SetColCount( 8 ); - m_pValSetColorBox->SetLineCount( 14 ); - m_pValSetColorBox->SetExtraSpacing( 0 ); - m_pValSetColorBox->Show(); + | WB_ITEMBORDER | WB_NAMEFIELD | WB_VSCROLL ); pChartOptions.reset(new SvxChartOptions); - pColorList = XColorList::CreateStdColorList(); const SfxPoolItem* pItem = nullptr; if ( rInAttrs.GetItemState( SID_SCH_EDITOPTIONS, false, &pItem ) == SfxItemState::SET ) @@ -171,6 +151,7 @@ void SvxDefaultColorOptPage::dispose() m_pLbChartColors.clear(); m_pValSetColorBox.clear(); m_pPBDefault.clear(); + m_pLbPaletteSelector.clear(); m_pPBAdd.clear(); m_pPBRemove.clear(); SfxTabPage::dispose(); @@ -179,10 +160,9 @@ void SvxDefaultColorOptPage::dispose() void SvxDefaultColorOptPage::Construct() { FillBoxChartColorLB(); - FillColorBox(); + FillPaletteLB(); m_pLbChartColors->SelectEntryPos( 0 ); - ListClickedHdl(*m_pLbChartColors); } @@ -202,43 +182,24 @@ bool SvxDefaultColorOptPage::FillItemSet( SfxItemSet* rOutAttrs ) void SvxDefaultColorOptPage::Reset( const SfxItemSet* ) { m_pLbChartColors->SelectEntryPos( 0 ); - ListClickedHdl(*m_pLbChartColors); } -void SvxDefaultColorOptPage::FillColorBox() +void SvxDefaultColorOptPage::FillPaletteLB() { - if( !pColorList.is() ) return; - - long nCount = pColorList->Count(); - - if( nCount > 104 ) - m_pValSetColorBox->SetStyle( m_pValSetColorBox->GetStyle() | WB_VSCROLL ); - - for( long i = 0; i < nCount; i++ ) + m_pLbPaletteSelector->Clear(); + std::vector<OUString> aPaletteList = aPaletteManager.GetPaletteList(); + for (auto const& palette : aPaletteList) { - const XColorEntry* pColorEntry = pColorList->GetColor(i); - m_pValSetColorBox->InsertItem( i + 1, pColorEntry->GetColor(), pColorEntry->GetName() ); + m_pLbPaletteSelector->InsertEntry(palette); } -} - - -long SvxDefaultColorOptPage::GetColorIndex( const Color& rCol ) -{ - if( pColorList.is() ) + OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() ); + m_pLbPaletteSelector->SelectEntry(aPaletteName); + if (m_pLbPaletteSelector->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND) { - long nCount = pColorList->Count(); - - for( long i = nCount - 1; i >= 0; i-- ) // default chart colors are at the end of the table - { - const XColorEntry* pColorEntry = pColorList->GetColor(i); - if( pColorEntry && pColorEntry->GetColor() == rCol ) - return pColorList->GetIndex( pColorEntry->GetName() ); - } + SelectPaletteLbHdl( *m_pLbPaletteSelector ); } - return -1; } - // event handlers @@ -313,16 +274,12 @@ IMPL_LINK_NOARG( SvxDefaultColorOptPage, RemoveChartColor, Button*, void ) } } -IMPL_LINK_NOARG( SvxDefaultColorOptPage, ListClickedHdl, ListBox&, void ) +IMPL_LINK_NOARG( SvxDefaultColorOptPage, SelectPaletteLbHdl, ListBox&, void) { - Color aCol = GetSelectEntryColor(); - - long nIndex = GetColorIndex( aCol ); - - if( nIndex == -1 ) // not found - m_pValSetColorBox->SetNoSelection(); - else - m_pValSetColorBox->SelectItem( nIndex + 1 ); // ValueSet is 1-based + sal_Int32 nPos = m_pLbPaletteSelector->GetSelectedEntryPos(); + aPaletteManager.SetPalette( nPos ); + aPaletteManager.ReloadColorSet( *m_pValSetColorBox ); + m_pValSetColorBox->Resize(); } IMPL_LINK_NOARG(SvxDefaultColorOptPage, BoxClickedHdl, ValueSet*, void) diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx index fc7d01091871..19db288db8e1 100644 --- a/cui/source/options/optchart.hxx +++ b/cui/source/options/optchart.hxx @@ -26,6 +26,7 @@ #include <svx/dlgctrl.hxx> #include <vcl/button.hxx> #include <svx/xtable.hxx> +#include <svx/PaletteManager.hxx> #include "cfgchart.hxx" @@ -35,24 +36,24 @@ class SvxDefaultColorOptPage : public SfxTabPage { private: VclPtr<ListBox> m_pLbChartColors; - VclPtr<ValueSet> m_pValSetColorBox; + VclPtr<ListBox> m_pLbPaletteSelector; + VclPtr<SvxColorValueSet> m_pValSetColorBox; VclPtr<PushButton> m_pPBDefault; VclPtr<PushButton> m_pPBAdd; VclPtr<PushButton> m_pPBRemove; std::unique_ptr<SvxChartOptions> pChartOptions; std::unique_ptr<SvxChartColorTableItem> pColorConfig; - XColorListRef pColorList; ImpColorList aColorList; + PaletteManager aPaletteManager; DECL_LINK( ResetToDefaults, Button *, void ); DECL_LINK( AddChartColor, Button *, void ); DECL_LINK( RemoveChartColor, Button *, void ); - DECL_LINK( ListClickedHdl, ListBox&, void ); DECL_LINK(BoxClickedHdl, ValueSet*, void); + DECL_LINK( SelectPaletteLbHdl, ListBox&, void ); - void FillColorBox(); - long GetColorIndex( const Color& rCol ); + void FillPaletteLB(); private: void InsertColorEntry(const XColorEntry& rEntry, sal_Int32 nPos = LISTBOX_APPEND); @@ -60,8 +61,6 @@ private: void ModifyColorEntry(const XColorEntry& rEntry, sal_Int32 nPos); void ClearColorEntries(); void FillBoxChartColorLB(); - Color GetEntryColor(sal_Int32 nPos) const; - Color GetSelectEntryColor() const; public: SvxDefaultColorOptPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); diff --git a/cui/uiconfig/ui/optchartcolorspage.ui b/cui/uiconfig/ui/optchartcolorspage.ui index 331eaffad025..5e8debc83454 100644 --- a/cui/uiconfig/ui/optchartcolorspage.ui +++ b/cui/uiconfig/ui/optchartcolorspage.ui @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.3 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> <requires lib="LibreOffice" version="1.0"/> @@ -32,6 +33,9 @@ <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection1"/> + </child> </object> </child> </object> @@ -70,25 +74,11 @@ <property name="top_padding">6</property> <property name="left_padding">12</property> <child> - <object class="GtkBox" id="box2"> + <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="spacing">12</property> - <child> - <object class="svtlo-ValueSet" id="table:border"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> + <property name="orientation">vertical</property> + <property name="column_spacing">12</property> <child> <object class="GtkButtonBox" id="buttonbox1"> <property name="visible">True</property> @@ -141,11 +131,35 @@ </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> + <property name="left_attach">1</property> + <property name="top_attach">1</property> </packing> </child> + <child> + <object class="GtkComboBoxText" id="paletteselector"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="svxlo-SvxColorValueSet" id="table:border"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> </object> </child> </object> @@ -168,10 +182,5 @@ </packing> </child> </object> - <object class="GtkSizeGroup" id="sizegroup1"> - <widgets> - <widget name="colors:border"/> - <widget name="table:border"/> - </widgets> - </object> + <object class="GtkSizeGroup" id="sizegroup1"/> </interface> diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index f7e5a4b1910c..17afd89e120e 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -140,13 +140,13 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet) } else if( mnCurrentPalette == mnNumOfPalettes - 1 ) { + rColorSet.Clear(); // Add doc colors to palette SfxObjectShell* pDocSh = SfxObjectShell::Current(); if (pDocSh) { std::set<Color> aColors = pDocSh->GetDocColors(); mnColorCount = aColors.size(); - rColorSet.Clear(); rColorSet.addEntriesForColorSet(aColors, SvxResId( RID_SVXSTR_DOC_COLOR_PREFIX ) + " " ); } } |