sc/source/ui/inc/tabbgcolordlg.hxx | 13 +++- sc/source/ui/miscdlgs/tabbgcolordlg.cxx | 87 ++++++++++++++++---------------- sc/uiconfig/scalc/ui/tabcolordialog.ui | 45 +++++++++++++++- 3 files changed, 98 insertions(+), 47 deletions(-)
New commits: commit 45b030a3e219bc2876472e1ada12cff602ec6549 Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Fri Nov 30 00:43:22 2018 -0900 Commit: Heiko Tietze <tietze.he...@gmail.com> CommitDate: Fri Dec 7 12:48:44 2018 +0100 tdf#105225 Add palette choice to calc tab background color dialog Change-Id: I9891a20d3bc3de51fec84fb54c7aae42f7142662 Reviewed-on: https://gerrit.libreoffice.org/64329 Tested-by: Jenkins Reviewed-by: Heiko Tietze <tietze.he...@gmail.com> Tested-by: Heiko Tietze <tietze.he...@gmail.com> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 0a139d98477c116f14041b3c4ebb7bb6204808d3) Reviewed-on: https://gerrit.libreoffice.org/64747 diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx index 4b27a4fe73e6..f5c2d330f344 100644 --- a/sc/source/ui/inc/tabbgcolordlg.hxx +++ b/sc/source/ui/inc/tabbgcolordlg.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SC_SOURCE_UI_INC_TABBGCOLORDLG_HXX #include <svx/SvxColorValueSet.hxx> +#include <svx/PaletteManager.hxx> class ScTabBgColorDlg : public weld::GenericDialogController { @@ -36,7 +37,7 @@ public: class ScTabBgColorValueSet : public ColorValueSet { public: - ScTabBgColorValueSet(); + ScTabBgColorValueSet(std::unique_ptr<weld::ScrolledWindow> pWindow); virtual ~ScTabBgColorValueSet() override; void SetDialog(ScTabBgColorDlg* pTabBgColorDlg) @@ -50,14 +51,18 @@ public: }; private: + PaletteManager m_aPaletteManager; Color m_aTabBgColor; const OUString m_aTabBgColorNoColorText; - ScTabBgColorValueSet m_aTabBgColorSet; - std::unique_ptr<weld::CustomWeld> m_xTabBgColorSet; + + std::unique_ptr<weld::ComboBox> m_xSelectPalette; + std::unique_ptr<ScTabBgColorValueSet> m_xTabBgColorSet; + std::unique_ptr<weld::CustomWeld> m_xTabBgColorSetWin; std::unique_ptr<weld::Button> m_xBtnOk; - void FillColorValueSets_Impl(); + void FillPaletteLB(); + DECL_LINK(SelectPaletteLBHdl, weld::ComboBox&, void); DECL_LINK(TabBgColorDblClickHdl_Impl, SvtValueSet*, void); DECL_LINK(TabBgColorOKHdl_Impl, weld::Button&, void); }; diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx index 7ea90d530b4d..f9c0eb0ce502 100644 --- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -30,6 +30,8 @@ #include <vcl/builderfactory.hxx> #include <osl/diagnose.h> +#include <officecfg/Office/Common.hxx> + #define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl) ScTabBgColorDlg::ScTabBgColorDlg(weld::Window* pParent, const OUString& rTitle, @@ -37,16 +39,30 @@ ScTabBgColorDlg::ScTabBgColorDlg(weld::Window* pParent, const OUString& rTitle, : GenericDialogController(pParent, "modules/scalc/ui/tabcolordialog.ui", "TabColorDialog") , m_aTabBgColor(rDefaultColor) , m_aTabBgColorNoColorText(rTabBgColorNoColorText) - , m_xTabBgColorSet(new weld::CustomWeld(*m_xBuilder, "colorset", m_aTabBgColorSet)) + , m_xSelectPalette(m_xBuilder->weld_combo_box("paletteselector")) + , m_xTabBgColorSet(new ScTabBgColorValueSet(m_xBuilder->weld_scrolled_window("colorsetwin"))) + , m_xTabBgColorSetWin(new weld::CustomWeld(*m_xBuilder, "colorset", *m_xTabBgColorSet)) , m_xBtnOk(m_xBuilder->weld_button("ok")) { - m_aTabBgColorSet.SetDialog(this); - m_aTabBgColorSet.SetColCount(SvxColorValueSet::getColumnCount()); + m_xTabBgColorSet->SetDialog(this); + m_xTabBgColorSet->SetColCount(SvxColorValueSet::getColumnCount()); m_xDialog->set_title(rTitle); - FillColorValueSets_Impl(); - m_aTabBgColorSet.SetDoubleClickHdl(HDL(TabBgColorDblClickHdl_Impl)); + const WinBits nBits(m_xTabBgColorSet->GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS); + m_xTabBgColorSet->SetStyle(nBits); + m_xTabBgColorSet->SetText(m_aTabBgColorNoColorText); + + const sal_uInt32 nColCount = SvxColorValueSet::getColumnCount(); + const sal_uInt32 nRowCount(10); + const sal_uInt32 nLength = SvxColorValueSet::getEntryEdgeLength(); + Size aSize(m_xTabBgColorSet->CalcWindowSizePixel(Size(nLength, nLength), nColCount, nRowCount)); + m_xTabBgColorSetWin->set_size_request(aSize.Width() + 8, aSize.Height() + 8); + + FillPaletteLB(); + + m_xSelectPalette->connect_changed(LINK(this, ScTabBgColorDlg, SelectPaletteLBHdl)); + m_xTabBgColorSet->SetDoubleClickHdl(HDL(TabBgColorDblClickHdl_Impl)); m_xBtnOk->connect_clicked(HDL(TabBgColorOKHdl_Impl)); } @@ -59,48 +75,37 @@ void ScTabBgColorDlg::GetSelectedColor( Color& rColor ) const rColor = m_aTabBgColor; } -void ScTabBgColorDlg::FillColorValueSets_Impl() +void ScTabBgColorDlg::FillPaletteLB() { - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - const SfxPoolItem* pItem = nullptr; - XColorListRef pColorList; - - OSL_ENSURE( pDocSh, "DocShell not found!" ); - - if ( pDocSh && ( nullptr != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) ) - pColorList = static_cast<const SvxColorListItem*>(pItem)->GetColorList(); - if ( !pColorList.is() ) - pColorList = XColorList::CreateStdColorList(); - - long nColorCount(0); - - if ( pColorList.is() ) + m_xSelectPalette->clear(); + std::vector<OUString> aPaletteList = m_aPaletteManager.GetPaletteList(); + for (auto const& palette : aPaletteList) { - nColorCount = pColorList->Count(); - m_aTabBgColorSet.addEntriesForXColorList(*pColorList); + m_xSelectPalette->append_text(palette); } - - if (nColorCount) + OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() ); + m_xSelectPalette->set_active_text(aPaletteName); + if (m_xSelectPalette->get_active() != -1) { - const WinBits nBits(m_aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS); - m_aTabBgColorSet.SetText(m_aTabBgColorNoColorText); - m_aTabBgColorSet.SetStyle(nBits); + SelectPaletteLBHdl(*m_xSelectPalette); } +} - //lock down a preferred size - const sal_uInt32 nColCount = SvxColorValueSet::getColumnCount(); - const sal_uInt32 nRowCount(ceil(double(nColorCount)/nColCount)); - const sal_uInt32 nLength = SvxColorValueSet::getEntryEdgeLength(); - Size aSize(m_aTabBgColorSet.CalcWindowSizePixel(Size(nLength, nLength), nColCount, nRowCount)); - m_xTabBgColorSet->set_size_request(aSize.Width() + 8, aSize.Height() + 8); - m_aTabBgColorSet.SelectItem(0); +IMPL_LINK_NOARG(ScTabBgColorDlg, SelectPaletteLBHdl, weld::ComboBox&, void) +{ + m_xTabBgColorSet->Clear(); + sal_Int32 nPos = m_xSelectPalette->get_active(); + m_aPaletteManager.SetPalette( nPos ); + m_aPaletteManager.ReloadColorSet(*m_xTabBgColorSet); + m_xTabBgColorSet->Resize(); + m_xTabBgColorSet->SelectItem(0); } -/// Handler, called when color selection is changed +// Handler, called when color selection is changed IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorDblClickHdl_Impl, SvtValueSet*, void) { - sal_uInt16 nItemId = m_aTabBgColorSet.GetSelectedItemId(); - Color aColor = nItemId ? ( m_aTabBgColorSet.GetItemColor( nItemId ) ) : COL_AUTO; + sal_uInt16 nItemId = m_xTabBgColorSet->GetSelectedItemId(); + Color aColor = nItemId ? ( m_xTabBgColorSet->GetItemColor( nItemId ) ) : COL_AUTO; m_aTabBgColor = aColor; m_xDialog->response(RET_OK); } @@ -108,14 +113,14 @@ IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorDblClickHdl_Impl, SvtValueSet*, void) // Handler, called when the OK button is pushed IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorOKHdl_Impl, weld::Button&, void) { - sal_uInt16 nItemId = m_aTabBgColorSet.GetSelectedItemId(); - Color aColor = nItemId ? ( m_aTabBgColorSet.GetItemColor( nItemId ) ) : COL_AUTO; + sal_uInt16 nItemId = m_xTabBgColorSet->GetSelectedItemId(); + Color aColor = nItemId ? ( m_xTabBgColorSet->GetItemColor( nItemId ) ) : COL_AUTO; m_aTabBgColor = aColor; m_xDialog->response(RET_OK); } -ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet() - : ColorValueSet(nullptr) +ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet(std::unique_ptr<weld::ScrolledWindow> pWindow) + : ColorValueSet(std::move(pWindow)) , m_pTabBgColorDlg(nullptr) { } diff --git a/sc/uiconfig/scalc/ui/tabcolordialog.ui b/sc/uiconfig/scalc/ui/tabcolordialog.ui index a71c77d4c27f..6ee8debc8c82 100644 --- a/sc/uiconfig/scalc/ui/tabcolordialog.ui +++ b/sc/uiconfig/scalc/ui/tabcolordialog.ui @@ -60,12 +60,53 @@ </packing> </child> <child> - <object class="GtkScrolledWindow" id="scroll"> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">3</property> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="label" translatable="yes" context="tabcolordialog |label1">Palette:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">paletteselector</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="paletteselector"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="colorsetwin"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> <property name="shadow_type">in</property> <child> <object class="GtkViewport"> @@ -86,7 +127,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> </object> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits