25 #include <editeng/editids.hrc>
34 #include <dialmgr.hxx>
36 #include <strings.hrc>
69 { Group_General,
"general" },
70 { Group_Writer,
"writer" },
71 { Group_Html,
"html" },
72 { Group_Calc,
"calc" },
73 { Group_Draw,
"draw" },
74 { Group_Basic,
"basic" },
93 SAL_STRINGIFY(Name), SAL_STRINGIFY(Name##_lb), false
95 #define IDS_CB(Name) \
96 SAL_STRINGIFY(Name), SAL_STRINGIFY(Name##_lb), true
100 { Group_General,
IDS(doccolor) },
101 { Group_General,
IDS_CB(docboundaries) },
102 { Group_General,
IDS(appback) },
103 { Group_General,
IDS_CB(objboundaries) },
104 { Group_General,
IDS_CB(tblboundaries) },
105 { Group_General,
IDS(font) },
106 { Group_General,
IDS_CB(unvisitedlinks) },
107 { Group_General,
IDS_CB(visitedlinks) },
108 { Group_General,
IDS(autospellcheck) },
109 { Group_General,
IDS(smarttags) },
110 { Group_General,
IDS_CB(shadows) },
112 { Group_Writer,
IDS(writergrid) },
113 { Group_Writer,
IDS_CB(field) },
114 { Group_Writer,
IDS_CB(index) },
115 { Group_Writer,
IDS(direct) },
116 { Group_Writer,
IDS(script) },
117 { Group_Writer,
IDS_CB(section) },
118 { Group_Writer,
IDS(hdft) },
119 { Group_Writer,
IDS(pagebreak) },
121 { Group_Html,
IDS(sgml) },
122 { Group_Html,
IDS(htmlcomment) },
123 { Group_Html,
IDS(htmlkeyword) },
124 { Group_Html,
IDS(unknown) },
126 { Group_Calc,
IDS(calcgrid) },
127 { Group_Calc,
IDS(brk) },
128 { Group_Calc,
IDS(brkmanual) },
129 { Group_Calc,
IDS(brkauto) },
130 { Group_Calc,
IDS(det) },
131 { Group_Calc,
IDS(deterror) },
132 { Group_Calc,
IDS(ref) },
133 { Group_Calc,
IDS(notes) },
134 { Group_Calc,
IDS(values) },
135 { Group_Calc,
IDS(formulas) },
136 { Group_Calc,
IDS(text) },
137 { Group_Calc,
IDS(protectedcells) },
139 { Group_Draw,
IDS(drawgrid) },
141 { Group_Basic,
IDS(basicid) },
142 { Group_Basic,
IDS(basiccomment) },
143 { Group_Basic,
IDS(basicnumber) },
144 { Group_Basic,
IDS(basicstring) },
145 { Group_Basic,
IDS(basicop) },
146 { Group_Basic,
IDS(basickeyword) },
147 { Group_Basic,
IDS(error) },
149 { Group_Sql,
IDS(sqlid) },
150 { Group_Sql,
IDS(sqlnumber) },
151 { Group_Sql,
IDS(sqlstring) },
152 { Group_Sql,
IDS(sqlop) },
153 { Group_Sql,
IDS(sqlkeyword) },
154 { Group_Sql,
IDS(sqlparam) },
155 { Group_Sql,
IDS(sqlcomment) }
162 class ColorConfigWindow_Impl
172 void Update(EditableColorConfig
const*, EditableExtendedColorConfig
const*);
174 void ColorHdl(EditableColorConfig*, EditableExtendedColorConfig*,
const ColorListBox*);
191 void AdjustExtraWidths(
int nTextWidth);
198 std::unique_ptr<weld::Label> m_xText;
201 void SetText(
const OUString& rLabel) { m_xText->set_label(rLabel); }
210 const Color& rColor,
tools::Long nCheckBoxLabelOffset,
bool bCheckBox,
bool bShow);
212 void SetText(
const OUString& rLabel) {
dynamic_cast<weld::Label&
>(*m_xText).
set_label(rLabel); }
213 void set_width_request(
int nTextWidth) { m_xText->set_size_request(nTextWidth, -1); }
214 int get_height_request()
const
216 return std::max(m_xText->get_preferred_size().Height(),
217 m_xColorList->get_widget().get_preferred_size().Height());
224 void Update (ColorConfigValue
const&);
225 void Update (ExtendedColorConfigValue
const&);
226 void ColorChanged (ColorConfigValue&);
227 void ColorChanged (ExtendedColorConfigValue&);
230 bool Is(
const ColorListBox* pBox)
const {
return m_xColorList.get() == pBox; }
233 std::unique_ptr<weld::Widget> m_xText;
235 std::unique_ptr<ColorListBox> m_xColorList;
237 Color m_aDefaultColor;
242 std::unique_ptr<weld::Builder> m_xBuilder;
243 std::unique_ptr<weld::Container> m_xGrid;
244 std::unique_ptr<weld::Widget> m_xWidget1;
245 std::unique_ptr<weld::Widget> m_xWidget2;
247 std::vector<std::unique_ptr<weld::Builder>> vExtBuilders;
248 std::vector<std::unique_ptr<weld::Container>> vExtContainers;
250 std::vector<std::shared_ptr<Chapter> > vChapters;
252 std::vector<std::shared_ptr<Entry> > vEntries;
258 void CreateEntries();
262 bool IsGroupVisible (
Group)
const;
272 ColorConfigWindow_Impl::Chapter::Chapter(
weld::Builder& rBuilder,
const char* pLabelWidget,
bool bShow)
273 : m_xText(rBuilder.weld_label(pLabelWidget))
281 const char* pTextWidget,
const char* pColorWidget,
283 tools::Long nCheckBoxLabelOffset,
bool bCheckBox,
bool bShow)
284 : m_xColorList(new
ColorListBox(rBuilder.weld_menu_button(pColorWidget), pTopLevel))
285 , m_aDefaultColor(rColor)
293 m_xColorList->SetSlotId(SID_ATTR_CHAR_COLOR);
294 m_xColorList->SetAutoDisplayColor(m_aDefaultColor);
298 m_xText->set_margin_start(m_xText->get_margin_start() +
299 nCheckBoxLabelOffset);
306 void ColorConfigWindow_Impl::Entry::Hide()
309 m_xColorList->hide();
317 m_xColorList->SetSelectHdl(rColorLink);
318 m_xColorList->connect_focus_in(rGetFocusLink);
321 pCheckBox->connect_toggled(rCheckLink);
322 pCheckBox->connect_focus_in(rGetFocusLink);
327 void ColorConfigWindow_Impl::Entry::Update(ColorConfigValue
const& rValue)
329 Color aColor(rValue.nColor);
330 m_xColorList->SelectEntry(aColor);
332 pCheckBox->set_active(rValue.bIsVisible);
336 void ColorConfigWindow_Impl::Entry::Update(ExtendedColorConfigValue
const& rValue)
338 Color aColor(rValue.getColor());
339 if (rValue.getColor() == rValue.getDefaultColor())
340 m_xColorList->SelectEntry(COL_AUTO);
342 m_xColorList->SelectEntry(aColor);
346 void ColorConfigWindow_Impl::Entry::ColorChanged(ColorConfigValue& rValue)
348 Color aColor = m_xColorList->GetSelectEntryColor();
349 rValue.nColor = aColor;
353 void ColorConfigWindow_Impl::Entry::ColorChanged(ExtendedColorConfigValue& rValue)
355 Color aColor = m_xColorList->GetSelectEntryColor();
356 rValue.setColor(aColor);
357 if (aColor == COL_AUTO)
359 rValue.setColor(rValue.getDefaultColor());
365 : m_pTopLevel(pTopLevel)
366 , m_xBuilder(
Application::CreateBuilder(pParent,
"cui/ui/colorconfigwin.ui"))
367 , m_xGrid(m_xBuilder->weld_container(
"ColorConfigWindow"))
368 , m_xWidget1(m_xBuilder->weld_widget(
"doccolor"))
369 , m_xWidget2(m_xBuilder->weld_widget(
"doccolor_lb"))
374 void ColorConfigWindow_Impl::CreateEntries()
376 std::bitset<nGroupCount> aModulesInstalled;
378 vChapters.reserve(nGroupCount);
379 for (
unsigned i = 0;
i != nGroupCount; ++
i)
381 aModulesInstalled[
i] = IsGroupVisible(vGroupInfo[i].eGroup);
382 vChapters.push_back(std::make_shared<Chapter>(*m_xBuilder, vGroupInfo[i].pGroup, aModulesInstalled[i]));
389 OUString sSampleText(
"X");
390 std::unique_ptr<weld::CheckButton> xCheckBox(m_xBuilder->weld_check_button(
"docboundaries"));
391 std::unique_ptr<weld::Label> xFixedText(m_xBuilder->weld_label(
"doccolor"));
392 OUString sOrigCheck(xCheckBox->get_label());
393 OUString sOrigFixed(xFixedText->get_label());
394 xCheckBox->set_label(sSampleText);
395 xFixedText->set_label(sSampleText);
396 Size aCheckSize(xCheckBox->get_preferred_size());
397 Size aFixedSize(xFixedText->get_preferred_size());
398 xCheckBox->set_label(sOrigCheck);
399 xFixedText->set_label(sOrigFixed);
400 nCheckBoxLabelOffset = aCheckSize.
Width() - aFixedSize.Width();
404 vEntries.reserve(ColorConfigEntryCount);
407 vEntries.push_back(std::make_shared<Entry>(m_pTopLevel, *m_xBuilder,
408 vEntryInfo[i].pText, vEntryInfo[i].pColor,
409 ColorConfig::GetDefaultColor(static_cast<ColorConfigEntry>(i)),
410 nCheckBoxLabelOffset,
411 vEntryInfo[i].bCheckBox,
412 aModulesInstalled[vEntryInfo[i].eGroup]));
416 ExtendedColorConfig aExtConfig;
417 unsigned const nExtGroupCount = aExtConfig.GetComponentCount();
421 size_t nLineNum = vChapters.size() + vEntries.size() + 1;
422 for (
unsigned j = 0; j != nExtGroupCount; ++j)
425 vExtContainers.emplace_back(vExtBuilders.back()->weld_container(
"ChapterFragment"));
427 vExtContainers.back()->set_grid_width(3);
428 vExtContainers.back()->set_grid_left_attach(0);
429 vExtContainers.back()->set_grid_top_attach(nLineNum);
431 OUString
const sComponentName = aExtConfig.GetComponentName(j);
432 vChapters.push_back(std::make_shared<Chapter>(
433 *vExtBuilders.back(),
"chapter",
true));
434 vChapters.back()->SetText(aExtConfig.GetComponentDisplayName(sComponentName));
436 unsigned nColorCount = aExtConfig.GetComponentColorCount(sComponentName);
437 for (
unsigned i = 0;
i != nColorCount; ++
i)
440 vExtContainers.emplace_back(vExtBuilders.back()->weld_container(
"ColorFragment"));
442 vExtContainers.back()->set_grid_width(3);
443 vExtContainers.back()->set_grid_left_attach(0);
444 vExtContainers.back()->set_grid_top_attach(nLineNum);
446 ExtendedColorConfigValue
const aColorEntry =
447 aExtConfig.GetComponentColorConfigValue(sComponentName, i);
448 vEntries.push_back(std::make_shared<Entry>(m_pTopLevel, *vExtBuilders.back(),
449 "label",
"button", aColorEntry.getDefaultColor(),
450 nCheckBoxLabelOffset,
false,
true));
451 vEntries.back()->SetText(aColorEntry.getDisplayName());
457 void ColorConfigWindow_Impl::AdjustExtraWidths(
int nTextWidth)
460 vEntries[i]->set_width_request(nTextWidth);
469 if (vEntries.empty())
471 for (
auto const & i: vEntries)
472 i->SetLinks(aCheckLink, aColorLink, rGetFocusLink);
478 void ColorConfigWindow_Impl::Update (
479 EditableColorConfig
const* pConfig,
480 EditableExtendedColorConfig
const* pExtConfig)
487 pConfig->GetColorValue(aColorEntry)
493 unsigned const nExtCount = pExtConfig->GetComponentCount();
494 for (
unsigned j = 0; j != nExtCount; ++j)
496 OUString sComponentName = pExtConfig->GetComponentName(j);
497 unsigned const nColorCount = pExtConfig->GetComponentColorCount(sComponentName);
498 for (
unsigned k = 0;
i != vEntries.size() && k != nColorCount; ++
i, ++k)
500 pExtConfig->GetComponentColorConfigValue(sComponentName, k)
506 void ColorConfigWindow_Impl::ClickHdl(EditableColorConfig* pConfig,
weld::ToggleButton& rBox)
510 if (vEntries[i]->Is(&rBox))
513 ColorConfigValue aValue = pConfig->GetColorValue(aEntry);
515 pConfig->SetColorValue(aEntry, aValue);
522 void ColorConfigWindow_Impl::ColorHdl(
523 EditableColorConfig* pConfig, EditableExtendedColorConfig* pExtConfig,
531 if (pBox && vEntries[i]->Is(pBox))
534 ColorConfigValue aValue = pConfig->GetColorValue(aColorEntry);
535 vEntries[i]->ColorChanged(aValue);
536 pConfig->SetColorValue(aColorEntry, aValue);
542 unsigned const nExtCount = pExtConfig->GetComponentCount();
544 for (
unsigned j = 0; j != nExtCount; ++j)
546 OUString sComponentName = pExtConfig->GetComponentName(j);
547 unsigned const nColorCount = pExtConfig->GetComponentColorCount(sComponentName);
548 unsigned const nCount = vEntries.size();
549 for (
unsigned k = 0; i != nCount && k != nColorCount; ++i, ++k)
551 if (pBox && vEntries[i]->Is(pBox))
553 ExtendedColorConfigValue aValue =
554 pExtConfig->GetComponentColorConfigValue(sComponentName, k);
555 vEntries[i]->ColorChanged(aValue);
556 pExtConfig->SetColorValue(sComponentName, aValue);
565 bool ColorConfigWindow_Impl::IsGroupVisible (
Group eGroup)
const
602 void SetConfig (EditableColorConfig& rConfig) { pColorConfig = &rConfig; }
607 return m_xVScroll->vadjustment_get_value();
611 m_xVScroll->vadjustment_set_value(nSet);
615 return m_xScrollWindow->GetWidget1();
619 return m_xScrollWindow->GetWidget2();
624 : m_xVScroll(rBuilder.weld_scrolled_window(
"scroll"))
625 , m_xBody(rBuilder.weld_container(
"colorconfig"))
626 , m_xScrollWindow(
std::make_unique<ColorConfigWindow_Impl>(pTopLevel, m_xBody.
get()))
627 , pColorConfig(nullptr)
628 , pExtColorConfig(nullptr)
630 m_xBody->set_stack_background();
646 DBG_ASSERT(pColorConfig,
"Configuration not set");
647 m_xScrollWindow->ClickHdl(pColorConfig, rBox);
653 DBG_ASSERT(pColorConfig,
"Configuration not set" );
654 m_xScrollWindow->ColorHdl(pColorConfig, pExtColorConfig, &rBox);
661 unsigned const nWinHeight = m_xVScroll->vadjustment_get_page_size();
664 auto nThumbPos = m_xVScroll->vadjustment_get_value();
665 int const nWinTop = nThumbPos;
666 int const nWinBottom = nWinTop + nWinHeight;
668 int x, nCtrlPosY, width, nHeight;
669 rCtrl.get_extents_relative_to(m_xScrollWindow->GetBody(), x, nCtrlPosY, width, nHeight);
671 int const nSelectedItemTop = nCtrlPosY;
672 int const nSelectedItemBottom = nCtrlPosY + nHeight;
673 bool const shouldScrollDown = nSelectedItemBottom >= nWinBottom;
674 bool const shouldScrollUp = nSelectedItemTop <= nWinTop;
675 bool const isNeedToScroll = shouldScrollDown || shouldScrollUp || nCtrlPosY < 0;
680 if (shouldScrollDown)
682 int nOffset = nSelectedItemBottom - nWinBottom;
683 nThumbPos += nOffset + 2;
687 int nOffset = nWinTop - nSelectedItemTop;
688 nThumbPos -= nOffset + 2;
692 m_xVScroll->vadjustment_set_value(nThumbPos);
697 :
SfxTabPage(pPage, pController,
"cui/ui/optappearancepage.ui",
"OptAppearancePage", &rCoreSet)
698 , bFillItemSetCalled(false)
699 , m_xColorSchemeLB(m_xBuilder->weld_combo_box(
"colorschemelb"))
700 , m_xSaveSchemePB(m_xBuilder->weld_button(
"save"))
701 , m_xDeleteSchemePB(m_xBuilder->weld_button(
"delete"))
703 , m_xTable(m_xBuilder->weld_widget(
"table"))
704 , m_xOnFT(m_xBuilder->weld_label(
"on"))
705 , m_xElementFT(m_xBuilder->weld_label(
"uielements"))
706 , m_xColorFT(m_xBuilder->weld_label(
"colorsetting"))
707 , m_rWidget1(m_xColorConfigCT->GetWidget1())
708 , m_rWidget2(m_xColorConfigCT->GetWidget2())
729 if(!sOldScheme.isEmpty())
748 return std::make_unique<SvxColorOptionsTabPage>(pPage, pController, *rAttrSet);
788 const uno::Sequence< OUString > aSchemes =
pColorConfig->GetSchemeNames();
789 for(
const OUString& s : aSchemes)
801 return DeactivateRC::LeavePage;
812 pColorConfig->LoadScheme(rBox.get_active_text());
813 pExtColorConfig->LoadScheme(rBox.get_active_text());
819 if (m_xSaveSchemePB.get() == &rButton)
825 sName,
CuiResId(RID_SVXSTR_COLOR_CONFIG_SAVE2) ));
827 aNameDlg->SetText(
CuiResId(RID_SVXSTR_COLOR_CONFIG_SAVE1));
830 if(
RET_OK == aNameDlg->Execute())
832 aNameDlg->GetName(sName);
833 pColorConfig->AddScheme(sName);
834 pExtColorConfig->AddScheme(sName);
835 m_xColorSchemeLB->append_text(sName);
836 m_xColorSchemeLB->set_active_text(sName);
837 SchemeChangedHdl_Impl(*m_xColorSchemeLB);
842 DBG_ASSERT(m_xColorSchemeLB->get_count() > 1,
"don't delete the last scheme");
844 VclMessageType::Question, VclButtonsType::YesNo,
845 CuiResId(RID_SVXSTR_COLOR_CONFIG_DELETE)));
846 xQuery->set_title(
CuiResId(RID_SVXSTR_COLOR_CONFIG_DELETE_TITLE));
849 OUString sDeleteScheme(m_xColorSchemeLB->get_active_text());
850 m_xColorSchemeLB->remove(m_xColorSchemeLB->get_active());
851 m_xColorSchemeLB->set_active(0);
852 SchemeChangedHdl_Impl(*m_xColorSchemeLB);
854 pColorConfig->DeleteScheme(sDeleteScheme);
855 pExtColorConfig->DeleteScheme(sDeleteScheme);
858 m_xDeleteSchemePB->set_sensitive(m_xColorSchemeLB->get_count() > 1);
864 rDialog.GetName(sName);
865 return !sName.isEmpty() && m_xColorSchemeLB->find_text(sName) == -1;
876 int nX0 = 0, nX1, nX2,
y, width, height;
877 if (!m_rWidget1.get_extents_relative_to(*m_xTable, nX1, y, width, height))
879 if (!m_rWidget2.get_extents_relative_to(*m_xTable, nX2, y, width, height))
881 auto nTextWidth1 = nX1 - nX0;
882 auto nTextWidth2 = nX2 - nX1;
883 m_xOnFT->set_size_request(nTextWidth1, -1);
884 m_xElementFT->set_size_request(nTextWidth2, -1);
885 m_xColorConfigCT->AdjustExtraWidths(nTextWidth2 - 12);
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define LINK(Instance, Class, Member)
void SetUserData(const OUString &rString)
SvxColorOptionsTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
EditableExtendedColorConfig * pExtColorConfig
static SvxAbstractDialogFactory * Create()
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
std::unique_ptr< weld::Button > m_xSaveSchemePB
virtual void FillUserData() override
std::unique_ptr< svtools::EditableExtendedColorConfig > pExtColorConfig
std::unique_ptr< svtools::EditableColorConfig > pColorConfig
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
std::unique_ptr< ColorConfigWindow_Impl > m_xScrollWindow
IMPL_LINK(ColorConfigCtrl_Impl, ClickHdl, weld::ToggleButton &, rBox, void)
#define HID_OPTIONS_COLORCONFIG_SAVE_SCHEME
const OUString & GetUserData() const
weld::Widget & GetWidget1()
weld::Widget & GetWidget2()
DECL_LINK(ClickHdl, weld::ToggleButton &, void)
#define SAL_N_ELEMENTS(arr)
virtual ~SvxColorOptionsTabPage() override
void SetConfig(EditableColorConfig &rConfig)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
#define DBG_ASSERT(sCon, aError)
std::unique_ptr< weld::ScrolledWindow > m_xVScroll
weld::Widget & m_rWidget2
std::unique_ptr< weld::Button > m_xDeleteSchemePB
tools::Long Width() const
std::unique_ptr< weld::Container > m_xBody
std::unique_ptr< weld::ComboBox > m_xColorSchemeLB
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
void SetExtendedConfig(EditableExtendedColorConfig &rConfig)
weld::Widget & m_rWidget1
OUString CuiResId(const char *pKey)
virtual void set_label(const OUString &rText)=0
virtual bool FillItemSet(SfxItemSet *rSet) override
EditableColorConfig * pColorConfig
IMPL_LINK_NOARG(SvxColorOptionsTabPage, AdjustHeaderBar, const Size &, void)
virtual std::unique_ptr< CheckButton > weld_check_button(const OString &id)=0
ColorConfigCtrl_Impl(weld::Window *pTopLevel, weld::Builder &rbuilder)
void SetScrollPosition(tools::Long nSet)
void AdjustExtraWidths(int nTextWidth)
virtual std::unique_ptr< Label > weld_label(const OString &id)=0
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
tools::Long GetScrollPosition() const
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
std::unique_ptr< ColorConfigCtrl_Impl > m_xColorConfigCT
virtual void Reset(const SfxItemSet *rSet) override