diff options
Diffstat (limited to 'cui/source/options/optcolor.cxx')
-rw-r--r-- | cui/source/options/optcolor.cxx | 340 |
1 files changed, 247 insertions, 93 deletions
diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx index 81030a79e9c8..d2c94669fa9f 100644 --- a/cui/source/options/optcolor.cxx +++ b/cui/source/options/optcolor.cxx @@ -21,6 +21,8 @@ #include <bitset> +#include <com/sun/star/configuration/ReadWriteAccess.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <tools/debug.hxx> #include <editeng/editids.hrc> #include <svtools/colorcfg.hxx> @@ -34,7 +36,10 @@ #include <dialmgr.hxx> #include "optcolor.hxx" #include <strings.hrc> - +#include <svtools/miscopt.hxx> +#include <officecfg/Office/Common.hxx> +#include <officecfg/Office/ExtendedColorScheme.hxx> +#include <officecfg/Office/UI.hxx> using namespace ::com::sun::star; using namespace ::svtools; @@ -61,7 +66,7 @@ struct // group Group eGroup; // .ui group name - const char *pGroup; + OUString pGroup; } const vGroupInfo[] = { @@ -81,11 +86,13 @@ struct // group Group eGroup; //checkbox (or simple text) - const char *pText; + OUString pText; //color listbox - const char *pColor; + OUString pColor; // has checkbox? bool bCheckBox; + //prop name + std::u16string_view sPropName; } const vEntryInfo[] = { @@ -97,66 +104,102 @@ const vEntryInfo[] = // The list of these entries (enum ColorConfigEntry) are in colorcfg.hxx. - { Group_General, IDS(doccolor) }, - { Group_General, IDS_CB(docboundaries) }, - { Group_General, IDS(appback) }, - { Group_General, IDS_CB(objboundaries) }, - { Group_General, IDS_CB(tblboundaries) }, - { Group_General, IDS(font) }, - { Group_General, IDS_CB(unvisitedlinks) }, - { Group_General, IDS_CB(visitedlinks) }, - { Group_General, IDS(autospellcheck) }, - { Group_General, IDS(smarttags) }, - { Group_General, IDS_CB(shadows) }, - - { Group_Writer, IDS(writergrid) }, - { Group_Writer, IDS_CB(field) }, - { Group_Writer, IDS_CB(index) }, - { Group_Writer, IDS(direct) }, - { Group_Writer, IDS(script) }, - { Group_Writer, IDS_CB(section) }, - { Group_Writer, IDS(hdft) }, - { Group_Writer, IDS(pagebreak) }, - - { Group_Html, IDS(sgml) }, - { Group_Html, IDS(htmlcomment) }, - { Group_Html, IDS(htmlkeyword) }, - { Group_Html, IDS(unknown) }, - - { Group_Calc, IDS(calcgrid) }, - { Group_Calc, IDS(brk) }, - { Group_Calc, IDS(brkmanual) }, - { Group_Calc, IDS(brkauto) }, - { Group_Calc, IDS(det) }, - { Group_Calc, IDS(deterror) }, - { Group_Calc, IDS(ref) }, - { Group_Calc, IDS(notes) }, - { Group_Calc, IDS(values) }, - { Group_Calc, IDS(formulas) }, - { Group_Calc, IDS(text) }, - { Group_Calc, IDS(protectedcells) }, - - { Group_Draw, IDS(drawgrid) }, - - { Group_Basic, IDS(basicid) }, - { Group_Basic, IDS(basiccomment) }, - { Group_Basic, IDS(basicnumber) }, - { Group_Basic, IDS(basicstring) }, - { Group_Basic, IDS(basicop) }, - { Group_Basic, IDS(basickeyword) }, - { Group_Basic, IDS(error) }, - - { Group_Sql, IDS(sqlid) }, - { Group_Sql, IDS(sqlnumber) }, - { Group_Sql, IDS(sqlstring) }, - { Group_Sql, IDS(sqlop) }, - { Group_Sql, IDS(sqlkeyword) }, - { Group_Sql, IDS(sqlparam) }, - { Group_Sql, IDS(sqlcomment) } + { Group_General, IDS(doccolor), std::u16string_view(u"/DocColor") }, + { Group_General, IDS_CB(docboundaries), std::u16string_view(u"/DocBoundaries") }, + { Group_General, IDS(appback), std::u16string_view(u"/AppBackground") }, + { Group_General, IDS_CB(objboundaries), std::u16string_view(u"/ObjectBoundaries") }, + { Group_General, IDS_CB(tblboundaries), std::u16string_view(u"/TableBoundaries") }, + { Group_General, IDS(font), std::u16string_view(u"/FontColor") }, + { Group_General, IDS_CB(unvisitedlinks), std::u16string_view(u"/Links") }, + { Group_General, IDS_CB(visitedlinks), std::u16string_view(u"/LinksVisited") }, + { Group_General, IDS(autospellcheck), std::u16string_view(u"/Spell") }, + { Group_General, IDS(grammarcheck), std::u16string_view(u"/Grammar") }, + { Group_General, IDS(smarttags), std::u16string_view(u"/SmartTags") }, + { Group_General, IDS_CB(shadows), std::u16string_view(u"/Shadow") }, + + { Group_Writer, IDS(writergrid), std::u16string_view(u"/WriterTextGrid") }, + { Group_Writer, IDS_CB(field), std::u16string_view(u"/WriterFieldShadings") }, + { Group_Writer, IDS_CB(index), std::u16string_view(u"/WriterIdxShadings") }, + { Group_Writer, IDS(direct), std::u16string_view(u"/WriterDirectCursor") }, + { Group_Writer, IDS(script), std::u16string_view(u"/WriterScriptIndicator") }, + { Group_Writer, IDS_CB(section), std::u16string_view(u"/WriterSectionBoundaries") }, + { Group_Writer, IDS(hdft), std::u16string_view(u"/WriterHeaderFooterMark") }, + { Group_Writer, IDS(pagebreak), std::u16string_view(u"/WriterPageBreaks") }, + + { Group_Html, IDS(sgml), std::u16string_view(u"/HTMLSGML") }, + { Group_Html, IDS(htmlcomment), std::u16string_view(u"/HTMLComment") }, + { Group_Html, IDS(htmlkeyword), std::u16string_view(u"/HTMLKeyword") }, + { Group_Html, IDS(unknown), std::u16string_view(u"/HTMLUnknown") }, + + { Group_Calc, IDS(calcgrid), std::u16string_view(u"/CalcGrid") }, + { Group_Calc, IDS(calccellfocus), std::u16string_view(u"/CalcCellFocus") }, + { Group_Calc, IDS(brk), std::u16string_view(u"/CalcPageBreak") }, + { Group_Calc, IDS(brkmanual), std::u16string_view(u"/CalcPageBreakManual") }, + { Group_Calc, IDS(brkauto), std::u16string_view(u"/CalcPageBreakAutomatic") }, + { Group_Calc, IDS_CB(hiddencolrow), std::u16string_view(u"/CalcHiddenColRow") }, + { Group_Calc, IDS_CB(textoverflow), std::u16string_view(u"/CalcTextOverflow") }, + { Group_Calc, IDS(comments), std::u16string_view(u"/CalcComments") }, + { Group_Calc, IDS(det), std::u16string_view(u"/CalcDetective") }, + { Group_Calc, IDS(deterror), std::u16string_view(u"/CalcDetectiveError") }, + { Group_Calc, IDS(ref), std::u16string_view(u"/CalcReference") }, + { Group_Calc, IDS(notes), std::u16string_view(u"/CalcNotesBackground") }, + { Group_Calc, IDS(values), std::u16string_view(u"/CalcValue") }, + { Group_Calc, IDS(formulas), std::u16string_view(u"/CalcFormula") }, + { Group_Calc, IDS(text), std::u16string_view(u"/CalcText") }, + { Group_Calc, IDS(protectedcells), std::u16string_view(u"/CalcProtectedBackground") }, + + { Group_Draw, IDS(drawgrid), std::u16string_view(u"/DrawGrid") }, + + { Group_Basic, IDS(basiceditor), std::u16string_view(u"/BASICEditor") }, + { Group_Basic, IDS(basicid), std::u16string_view(u"/BASICIdentifier") }, + { Group_Basic, IDS(basiccomment), std::u16string_view(u"/BASICComment") }, + { Group_Basic, IDS(basicnumber), std::u16string_view(u"/BASICNumber") }, + { Group_Basic, IDS(basicstring), std::u16string_view(u"/BASICString") }, + { Group_Basic, IDS(basicop), std::u16string_view(u"/BASICOperator") }, + { Group_Basic, IDS(basickeyword), std::u16string_view(u"/BASICKeyword") }, + { Group_Basic, IDS(error), std::u16string_view(u"/BASICError") }, + + { Group_Sql, IDS(sqlid), std::u16string_view(u"/SQLIdentifier") }, + { Group_Sql, IDS(sqlnumber), std::u16string_view(u"/SQLNumber") }, + { Group_Sql, IDS(sqlstring), std::u16string_view(u"/SQLString") }, + { Group_Sql, IDS(sqlop), std::u16string_view(u"/SQLOperator") }, + { Group_Sql, IDS(sqlkeyword), std::u16string_view(u"/SQLKeyword") }, + { Group_Sql, IDS(sqlparam), std::u16string_view(u"/SQLParameter") }, + { Group_Sql, IDS(sqlcomment), std::u16string_view(u"/SQLComment") } #undef IDS }; +// Maps the names of default color schemes to the corresponding TranslateId +const std::map<OUString, OUString> &getColorSchemes() +{ + static std::map<OUString, OUString> const vColorSchemes = { + {"COLOR_SCHEME_LIBREOFFICE_AUTOMATIC", CuiResId(RID_COLOR_SCHEME_LIBREOFFICE_AUTOMATIC)}, + }; + return vColorSchemes; +}; + +// If the color scheme name has a translated string, then return the translation +// Or else simply return the input string +// For non-translatable color schemes, the ID and the name are the same +OUString lcl_SchemeIdToTranslatedName(const OUString& sSchemeId) +{ + auto it = getColorSchemes().find(sSchemeId); + if (it != getColorSchemes().end()) + return it->second; + return sSchemeId; +} + +// Given a translated color scheme name, return the scheme ID used in the UI.xcu file +// For non-translatable color schemes, the ID and the name are the same +OUString lcl_TranslatedNameToSchemeId(const OUString& sName) +{ + for (auto it = getColorSchemes().begin(); it != getColorSchemes().end(); ++it) + if (it->second == sName) + return it->first; + return sName; +} + // ColorConfigWindow_Impl class ColorConfigWindow_Impl @@ -170,6 +213,7 @@ public: Link<weld::Widget&,void> const&, weld::ScrolledWindow& rScroll); void Update(EditableColorConfig const*, EditableExtendedColorConfig const*); + void UpdateEntries(); void ClickHdl(EditableColorConfig*, const weld::Toggleable&); void ColorHdl(EditableColorConfig*, EditableExtendedColorConfig*, const ColorListBox*); @@ -200,37 +244,37 @@ private: // text std::unique_ptr<weld::Label> m_xText; public: - Chapter(weld::Builder& rBuilder, const char* pLabelWidget, bool bShow); + Chapter(weld::Builder& rBuilder, const OUString& pLabelWidget, bool bShow); void SetText(const OUString& rLabel) { m_xText->set_label(rLabel); } }; // Entry -- a color config entry: // text (checkbox) + color list box - class Entry + struct Entry { - public: - Entry(weld::Window* pTopLevel, weld::Builder& rBuilder, const char* pTextWidget, const char* pColorWidget, - const Color& rColor, int nCheckBoxLabelOffset, bool bCheckBox, bool bShow); - public: + Entry(weld::Window* pTopLevel, weld::Builder& rBuilder, const OUString& pTextWidget, const OUString& pColorWidget, + const Color& rColor, int nCheckBoxLabelOffset, const ColorListBox* pCache, bool bCheckBox, bool bShow); void SetText(const OUString& rLabel) { dynamic_cast<weld::Label&>(*m_xText).set_label(rLabel); } int get_height_request() const { return std::max(m_xText->get_preferred_size().Height(), m_xColorList->get_widget().get_preferred_size().Height()); } - void Hide (); - public: + void Hide(); + void SetLinks(Link<weld::Toggleable&,void> const&, Link<ColorListBox&,void> const&, Link<weld::Widget&,void> const&); - void Update (ColorConfigValue const&); - void Update (ExtendedColorConfigValue const&); + void Update (ColorConfigValue const&, const std::u16string_view&, + css::uno::Reference<css::configuration::XReadWriteAccess> const&); + void Update (ExtendedColorConfigValue const&, const std::u16string_view&, + css::uno::Reference<css::configuration::XReadWriteAccess> const&); void ColorChanged (ColorConfigValue&); void ColorChanged (ExtendedColorConfigValue&); - public: + bool Is(const weld::Toggleable* pBox) const { return m_xText.get() == pBox; } bool Is(const ColorListBox* pBox) const { return m_xColorList.get() == pBox; } - private: + // checkbox (CheckBox) or simple text (FixedText) std::unique_ptr<weld::Widget> m_xText; // color list box @@ -239,6 +283,8 @@ private: Color m_aDefaultColor; }; + css::uno::Reference<css::configuration::XReadWriteAccess> m_xReadWriteAccess; + private: weld::Window* m_pTopLevel; int m_nCheckBoxLabelOffset; @@ -272,7 +318,7 @@ private: // ctor for default groups // rParent: parent window (ColorConfigWindow_Impl) // eGroup: which group is this? -ColorConfigWindow_Impl::Chapter::Chapter(weld::Builder& rBuilder, const char* pLabelWidget, bool bShow) +ColorConfigWindow_Impl::Chapter::Chapter(weld::Builder& rBuilder, const OUString& pLabelWidget, bool bShow) : m_xText(rBuilder.weld_label(pLabelWidget)) { if (!bShow) @@ -281,10 +327,11 @@ ColorConfigWindow_Impl::Chapter::Chapter(weld::Builder& rBuilder, const char* pL // ColorConfigWindow_Impl::Entry ColorConfigWindow_Impl::Entry::Entry(weld::Window* pTopLevel, weld::Builder& rBuilder, - const char* pTextWidget, const char* pColorWidget, - const Color& rColor, - int nCheckBoxLabelOffset, bool bCheckBox, bool bShow) - : m_xColorList(new ColorListBox(rBuilder.weld_menu_button(pColorWidget), [pTopLevel]{ return pTopLevel; })) + const OUString& pTextWidget, const OUString& pColorWidget, + const Color& rColor, int nCheckBoxLabelOffset, + const ColorListBox* pCache, bool bCheckBox, bool bShow) + : m_xColorList(new ColorListBox(rBuilder.weld_menu_button(pColorWidget), + [pTopLevel]{ return pTopLevel; }, pCache)) , m_aDefaultColor(rColor) { if (bCheckBox) @@ -327,22 +374,54 @@ void ColorConfigWindow_Impl::Entry::SetLinks(Link<weld::Toggleable&,void> const& } // updates a default color config entry -void ColorConfigWindow_Impl::Entry::Update(ColorConfigValue const& rValue) +void ColorConfigWindow_Impl::Entry::Update(ColorConfigValue const& rValue, const std::u16string_view& rConfigPath, + css::uno::Reference<css::configuration::XReadWriteAccess> const& xReadWriteAccess) { Color aColor(rValue.nColor); m_xColorList->SelectEntry(aColor); + + bool bReadOnly = false; + OUString aConfigPath = OUString::Concat(rConfigPath) + "/Color"; + if (xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + m_xColorList->set_sensitive(!bReadOnly); + if (weld::Toggleable* pCheckBox = dynamic_cast<weld::Toggleable*>(m_xText.get())) + { + bReadOnly = false; pCheckBox->set_active(rValue.bIsVisible); + + aConfigPath = OUString::Concat(rConfigPath) + "/IsVisible"; + if (xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + pCheckBox->set_sensitive(!bReadOnly); + } } // updates an extended color config entry -void ColorConfigWindow_Impl::Entry::Update(ExtendedColorConfigValue const& rValue) +void ColorConfigWindow_Impl::Entry::Update(ExtendedColorConfigValue const& rValue, const std::u16string_view& rConfigPath, + css::uno::Reference<css::configuration::XReadWriteAccess> const& xReadWriteAccess) { Color aColor(rValue.getColor()); if (rValue.getColor() == rValue.getDefaultColor()) m_xColorList->SelectEntry(COL_AUTO); else m_xColorList->SelectEntry(aColor); + + bool bReadOnly = false; + OUString aConfigPath = OUString::Concat(rConfigPath) + rValue.getName() + "/Color"; + if (xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + m_xColorList->set_sensitive(!bReadOnly); } // color of a default entry has changed @@ -371,6 +450,9 @@ ColorConfigWindow_Impl::ColorConfigWindow_Impl(weld::Window* pTopLevel, weld::Co , m_xWidget1(m_xBuilder->weld_widget("docboundaries")) , m_xWidget2(m_xBuilder->weld_widget("docboundaries_lb")) { + css::uno::Reference < css::uno::XComponentContext > xContext(::comphelper::getProcessComponentContext()); + m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*"); + CreateEntries(); } @@ -402,16 +484,20 @@ void ColorConfigWindow_Impl::CreateEntries() m_nCheckBoxLabelOffset = aCheckSize.Width() - aFixedSize.Width(); } + const ColorListBox* pCache = nullptr; + // creating entries vEntries.reserve(ColorConfigEntryCount); - for (size_t i = 0; i < SAL_N_ELEMENTS(vEntryInfo); ++i) + for (size_t i = 0; i < std::size(vEntryInfo); ++i) { vEntries.push_back(std::make_shared<Entry>(m_pTopLevel, *m_xBuilder, vEntryInfo[i].pText, vEntryInfo[i].pColor, ColorConfig::GetDefaultColor(static_cast<ColorConfigEntry>(i)), - m_nCheckBoxLabelOffset, + m_nCheckBoxLabelOffset, pCache, vEntryInfo[i].bCheckBox, aModulesInstalled[vEntryInfo[i].eGroup])); + if (!pCache) + pCache = vEntries.back()->m_xColorList.get(); } // extended entries @@ -443,7 +529,7 @@ void ColorConfigWindow_Impl::CreateEntries() aExtConfig.GetComponentColorConfigValue(sComponentName, i); vEntries.push_back(std::make_shared<Entry>(m_pTopLevel, *vExtBuilders.back(), "label", "button", aColorEntry.getDefaultColor(), - m_nCheckBoxLabelOffset, false, true)); + m_nCheckBoxLabelOffset, pCache, false, true)); vEntries.back()->SetText(aColorEntry.getDisplayName()); } } @@ -469,11 +555,17 @@ void ColorConfigWindow_Impl::Update ( EditableExtendedColorConfig const* pExtConfig) { // updating default entries + std::optional<OUString> aUIColorSchemeName = officecfg::Office::UI::ColorScheme::CurrentColorScheme::get(); + OUString aUIColorSchemePath = officecfg::Office::UI::ColorScheme::ColorSchemes::path() + u"/" + aUIColorSchemeName.value(); + for (unsigned i = 0; i != ColorConfigEntryCount; ++i) { + OUString sPath = aUIColorSchemePath + vEntryInfo[i].sPropName; ColorConfigEntry const aColorEntry = static_cast<ColorConfigEntry>(i); vEntries[i]->Update( - pConfig->GetColorValue(aColorEntry) + pConfig->GetColorValue(aColorEntry), + sPath, + m_xReadWriteAccess ); } @@ -483,14 +575,28 @@ void ColorConfigWindow_Impl::Update ( for (unsigned j = 0; j != nExtCount; ++j) { OUString sComponentName = pExtConfig->GetComponentName(j); + aUIColorSchemePath = officecfg::Office::ExtendedColorScheme::ExtendedColorScheme::ColorSchemes::path() + u"/" + + aUIColorSchemeName.value() + u"/" + sComponentName + u"/Entries/"; unsigned const nColorCount = pExtConfig->GetComponentColorCount(sComponentName); for (unsigned k = 0; i != vEntries.size() && k != nColorCount; ++i, ++k) vEntries[i]->Update( - pExtConfig->GetComponentColorConfigValue(sComponentName, k) + pExtConfig->GetComponentColorConfigValue(sComponentName, k), + aUIColorSchemePath, + m_xReadWriteAccess ); } } +void ColorConfigWindow_Impl::UpdateEntries() +{ + for (unsigned i = 0; i != ColorConfigEntryCount; ++i) + { + ColorConfigEntry const aEntry = static_cast<ColorConfigEntry>(i); + Color aColor = ColorConfig::GetDefaultColor(aEntry); + vEntries[i]->m_xColorList->SetAutoDisplayColor(aColor); + } +} + // ClickHdl() void ColorConfigWindow_Impl::ClickHdl(EditableColorConfig* pConfig, const weld::Toggleable& rBox) { @@ -590,6 +696,7 @@ public: void SetConfig (EditableColorConfig& rConfig) { pColorConfig = &rConfig; } void SetExtendedConfig (EditableExtendedColorConfig& rConfig) { pExtColorConfig = &rConfig; } void Update(); + void UpdateEntries(); tools::Long GetScrollPosition() const { return m_xVScroll->vadjustment_get_value(); @@ -633,6 +740,11 @@ void ColorConfigCtrl_Impl::Update () m_xScrollWindow->Update(pColorConfig, pExtColorConfig); } +void ColorConfigCtrl_Impl::UpdateEntries() +{ + m_xScrollWindow->UpdateEntries(); +} + IMPL_LINK(ColorConfigCtrl_Impl, ClickHdl, weld::Toggleable&, rBox, void) { DBG_ASSERT(pColorConfig, "Configuration not set"); @@ -689,19 +801,22 @@ SvxColorOptionsTabPage::SvxColorOptionsTabPage(weld::Container* pPage, weld::Dia : SfxTabPage(pPage, pController, "cui/ui/optappearancepage.ui", "OptAppearancePage", &rCoreSet) , bFillItemSetCalled(false) , m_nSizeAllocEventId(nullptr) + , m_xAutoColorLB(m_xBuilder->weld_combo_box("autocolorlb")) + , m_xAutoColorImg(m_xBuilder->weld_widget("lockautocolorlb")) , m_xColorSchemeLB(m_xBuilder->weld_combo_box("colorschemelb")) + , m_xColorSchemeImg(m_xBuilder->weld_widget("lockcolorschemelb")) , m_xSaveSchemePB(m_xBuilder->weld_button("save")) , m_xDeleteSchemePB(m_xBuilder->weld_button("delete")) , m_xColorConfigCT(new ColorConfigCtrl_Impl(pController->getDialog(), *m_xBuilder)) , m_xTable(m_xBuilder->weld_widget("table")) , m_xOnFT(m_xBuilder->weld_label("on")) - , m_xElementFT(m_xBuilder->weld_label("uielements")) , m_xColorFT(m_xBuilder->weld_label("colorsetting")) , m_rWidget1(m_xColorConfigCT->GetWidget1()) , m_rWidget2(m_xColorConfigCT->GetWidget2()) { m_xColorSchemeLB->make_sorted(); m_xColorSchemeLB->connect_changed(LINK(this, SvxColorOptionsTabPage, SchemeChangedHdl_Impl)); + m_xAutoColorLB->connect_changed(LINK(this, SvxColorOptionsTabPage, onAutoColorChanged)); Link<weld::Button&,void> aLk = LINK(this, SvxColorOptionsTabPage, SaveDeleteHdl_Impl ); m_xSaveSchemePB->connect_clicked(aLk); m_xDeleteSchemePB->connect_clicked(aLk); @@ -743,6 +858,21 @@ std::unique_ptr<SfxTabPage> SvxColorOptionsTabPage::Create(weld::Container* pPag return std::make_unique<SvxColorOptionsTabPage>(pPage, pController, *rAttrSet); } +OUString SvxColorOptionsTabPage::GetAllStrings() +{ + // buttons are excluded + OUString sAllStrings; + OUString labels[] = { "label2", "label3", "autocolor", "uielements", "colorsetting" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxColorOptionsTabPage::FillItemSet( SfxItemSet* ) { bFillItemSetCalled = true; @@ -776,16 +906,30 @@ void SvxColorOptionsTabPage::Reset( const SfxItemSet* ) pExtColorConfig.reset(new EditableExtendedColorConfig); m_xColorConfigCT->SetExtendedConfig(*pExtColorConfig); + m_xAutoColorLB->set_active( MiscSettings::GetAppColorMode() ); + + bool bReadOnly = officecfg::Office::ExtendedColorScheme::ExtendedColorScheme::CurrentColorScheme::isReadOnly() || + officecfg::Office::UI::ColorScheme::CurrentColorScheme::isReadOnly(); + m_xAutoColorLB->set_sensitive(!bReadOnly); + m_xSaveSchemePB->set_sensitive(!bReadOnly); + m_xDeleteSchemePB->set_sensitive(!bReadOnly); + m_xAutoColorImg->set_visible(bReadOnly); + OUString sUser = GetUserData(); //has to be called always to speed up accessibility tools m_xColorConfigCT->SetScrollPosition(sUser.toInt32()); m_xColorSchemeLB->clear(); const uno::Sequence< OUString > aSchemes = pColorConfig->GetSchemeNames(); for(const OUString& s : aSchemes) - m_xColorSchemeLB->append_text(s); - m_xColorSchemeLB->set_active_text(pColorConfig->GetCurrentSchemeName()); + m_xColorSchemeLB->append_text(lcl_SchemeIdToTranslatedName(s)); + + m_xColorSchemeLB->set_active_text(lcl_SchemeIdToTranslatedName(pColorConfig->GetCurrentSchemeName())); + m_xColorSchemeLB->set_sensitive(!officecfg::Office::Common::Misc::ApplicationAppearance::isReadOnly()); + m_xColorSchemeImg->set_visible(officecfg::Office::Common::Misc::ApplicationAppearance::isReadOnly()); m_xColorSchemeLB->save_value(); - m_xDeleteSchemePB->set_sensitive( aSchemes.getLength() > 1 ); + + m_xDeleteSchemePB->set_sensitive( aSchemes.getLength() > 1 && + !officecfg::Office::ExtendedColorScheme::ExtendedColorScheme::CurrentColorScheme::isReadOnly() ); UpdateColorConfig(); } @@ -802,10 +946,21 @@ void SvxColorOptionsTabPage::UpdateColorConfig() m_xColorConfigCT->Update(); } +IMPL_LINK_NOARG(SvxColorOptionsTabPage, onAutoColorChanged, weld::ComboBox&, void) +{ + MiscSettings::SetAppColorMode( m_xAutoColorLB->get_active() ); + + m_xColorConfigCT->UpdateEntries(); + + pColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(m_xColorSchemeLB->get_active_text())); + pExtColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(m_xColorSchemeLB->get_active_text())); + UpdateColorConfig(); +} + IMPL_LINK(SvxColorOptionsTabPage, SchemeChangedHdl_Impl, weld::ComboBox&, rBox, void) { - pColorConfig->LoadScheme(rBox.get_active_text()); - pExtColorConfig->LoadScheme(rBox.get_active_text()); + pColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(rBox.get_active_text())); + pExtColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(rBox.get_active_text())); UpdateColorConfig(); } @@ -824,7 +979,7 @@ IMPL_LINK(SvxColorOptionsTabPage, SaveDeleteHdl_Impl, weld::Button&, rButton, vo aNameDlg->SetCheckNameHdl( LINK(this, SvxColorOptionsTabPage, CheckNameHdl_Impl)); if(RET_OK == aNameDlg->Execute()) { - aNameDlg->GetName(sName); + sName = aNameDlg->GetName(); pColorConfig->AddScheme(sName); pExtColorConfig->AddScheme(sName); m_xColorSchemeLB->append_text(sName); @@ -855,8 +1010,7 @@ IMPL_LINK(SvxColorOptionsTabPage, SaveDeleteHdl_Impl, weld::Button&, rButton, vo IMPL_LINK(SvxColorOptionsTabPage, CheckNameHdl_Impl, AbstractSvxNameDialog&, rDialog, bool ) { - OUString sName; - rDialog.GetName(sName); + OUString sName = rDialog.GetName(); return !sName.isEmpty() && m_xColorSchemeLB->find_text(sName) == -1; } |