diff options
author | Jim Raykowski <raykowj@gmail.com> | 2023-04-15 19:53:05 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2023-04-25 19:43:33 +0200 |
commit | 4bc86f6477c3ed5f0e97b0a530acf7e102b613b3 (patch) | |
tree | 7fa32d1191383d0f73456daecf6dbfe275f26b8e /sfx2/source/dialog/templdlg.cxx | |
parent | fb76d7f454522c4e8982b8fe1e75d0eb6f37c12d (diff) |
tdf#38194 tdf#106556 Enhancement to highlight direct formatting,
paragraph style, and character style use in Writer documents
Initial commit to realize direct formatting, paragraph style, and
character style highlighting enhancement requests.
Highlighting of character direct formatting is turned on/off using
.uno:HighlightCharDF. Highlighting of paragraph styles and character
styles is turned on/off using a check box in the Sidebar Styles panel.
Closing the Sidebar also turns paragraph and character style
highlighting off. Paragraph direct formatting is indicated by a hatch
pattern over the paragraph style highlight bar and also by "+ Paragraph
Direct Formatting" appended to the tooltip that appears showing the
name of the paragraph style when the mouse pointer is over the style
highlight bar.
Colors used for styles highlighting are determined by a hash of the
style name. Lightgray is used for character direct formatting.
Known issue:
Tooltip doesn't show for paragraph style highlighting in tables and in
frames where the highlighting bar is drawn outside of the frame.
Change-Id: I6e00ee38c1c169bc7c6542a1782c03b2593e1891
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150451
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'sfx2/source/dialog/templdlg.cxx')
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 9001ee0740e1..6b2c258a6aba 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -134,6 +134,27 @@ namespace SfxTemplate default: return 0xffff; } } + // converts from 1-6 to SFX_STYLE_FAMILY Ids + static SfxStyleFamily NIdToSfxFamilyId(sal_uInt16 nId) + { + switch (nId) + { + case 1: + return SfxStyleFamily::Char; + case 2: + return SfxStyleFamily::Para; + case 3: + return SfxStyleFamily::Frame; + case 4: + return SfxStyleFamily::Page; + case 5: + return SfxStyleFamily::Pseudo; + case 6: + return SfxStyleFamily::Table; + default: + return SfxStyleFamily::All; + } + } } void SfxCommonTemplateDialog_Impl::connect_stylelist_execute_drop( @@ -176,6 +197,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl(SfxBindings* pB, weld , m_pDeletionWatcher(nullptr) , m_aStyleList(pBuilder, pB, this, pC, "treeview", "flatview") , mxPreviewCheckbox(pBuilder->weld_check_button("showpreview")) + , mxHighlightCheckbox(pBuilder->weld_check_button("highlightstyles")) , mxFilterLb(pBuilder->weld_combo_box("filter")) , nActFamily(0xffff) , nActFilter(0) @@ -262,7 +284,13 @@ void SfxCommonTemplateDialog_Impl::Initialize() mxFilterLb->connect_changed(LINK(this, SfxCommonTemplateDialog_Impl, FilterSelectHdl)); mxPreviewCheckbox->connect_toggled(LINK(this, SfxCommonTemplateDialog_Impl, PreviewHdl)); + mxHighlightCheckbox->connect_toggled(LINK(this, SfxCommonTemplateDialog_Impl, HighlightHdl)); + m_aStyleList.Initialize(); + + SfxStyleFamily eFam = SfxTemplate::NIdToSfxFamilyId(nActFamily); + mxHighlightCheckbox->set_visible(m_aStyleList.HasStylesHighlighterFeature() + && (eFam == SfxStyleFamily::Para || eFam == SfxStyleFamily::Char)); } IMPL_LINK(SfxCommonTemplateDialog_Impl, UpdateStyles_Hdl, StyleFlags, nFlags, void) @@ -460,6 +488,7 @@ bool SfxCommonTemplateDialog_Impl::Execute_Impl( // Handler Listbox of Filter void SfxCommonTemplateDialog_Impl::EnableHierarchical(bool const bEnable, StyleList& rStyleList) { + OUString aSelectedEntry = rStyleList.GetSelectedEntry(); if (bEnable) { if (!rStyleList.IsHierarchical()) @@ -476,8 +505,9 @@ void SfxCommonTemplateDialog_Impl::EnableHierarchical(bool const bEnable, StyleL // If bHierarchical, then the family can have changed // minus one since hierarchical is inserted at the start m_bWantHierarchical = false; // before FilterSelect - FilterSelect(mxFilterLb->get_active() - 1, rStyleList.IsHierarchical() ); + FilterSelect(mxFilterLb->get_active() - 1, true); } + SelectStyle(aSelectedEntry, false, rStyleList); } // Other filters; can be switched by the users or as a result of new or @@ -517,14 +547,27 @@ IMPL_LINK(SfxCommonTemplateDialog_Impl, FilterSelectHdl, weld::ComboBox&, rBox, } // Select-Handler for the Toolbox -void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry, StyleList&, bool bPreviewRefresh) +void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry, StyleList&, bool bRefresh) { assert((0 < nEntry && nEntry <= MAX_FAMILIES) || 0xffff == nEntry); - if( nEntry != nActFamily || bPreviewRefresh ) + if( nEntry != nActFamily || bRefresh ) { CheckItem(OUString::number(nActFamily), false); nActFamily = nEntry; - m_aStyleList.FamilySelect(nEntry); + m_aStyleList.FamilySelect(nEntry, bRefresh); + + SfxStyleFamily eFam = SfxTemplate::NIdToSfxFamilyId(nActFamily); + mxHighlightCheckbox->set_visible(m_aStyleList.HasStylesHighlighterFeature() + && (eFam == SfxStyleFamily::Para || eFam == SfxStyleFamily::Char)); + if (mxHighlightCheckbox->is_visible()) + { + bool bActive = false; + if (eFam == SfxStyleFamily::Para) + bActive = m_aStyleList.IsHighlightParaStyles(); + else if (eFam == SfxStyleFamily::Char) + bActive = m_aStyleList.IsHighlightCharStyles(); + mxHighlightCheckbox->set_active(bActive); + } } } @@ -632,8 +675,17 @@ IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, PreviewHdl, weld::Toggleable&, voi officecfg::Office::Common::StylesAndFormatting::Preview::set(bCustomPreview, batch ); batch->commit(); - m_aStyleList.EnablePreview(bCustomPreview); + FamilySelect(nActFamily, m_aStyleList, true); +} +IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, HighlightHdl, weld::Toggleable&, void) +{ + bool bActive = mxHighlightCheckbox->get_active(); + SfxStyleFamily eFam = SfxTemplate::NIdToSfxFamilyId(nActFamily); + if (eFam == SfxStyleFamily::Para) + m_aStyleList.SetHighlightParaStyles(bActive); + else if (eFam == SfxStyleFamily::Char) + m_aStyleList.SetHighlightCharStyles(bActive); FamilySelect(nActFamily, m_aStyleList, true); } |