sw/source/ui/index/cnttab.cxx | 76 ++++++++++++++++++++++++++++++++- sw/source/uibase/inc/swuicnttab.hxx | 4 + sw/source/uibase/index/toxmgr.cxx | 6 ++ sw/uiconfig/swriter/ui/tocindexpage.ui | 75 ++++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 2 deletions(-)
New commits: commit 43744a9004e0fa59a525855c7e97ca153a839c42 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Jan 25 13:24:01 2023 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Jan 25 19:46:06 2023 +0000 tdf#153090 sw: add UI to SwTOXSelectTabPage Add a checkbox, label and a combobox, for Table of Figures/Table of Tables/Table of Objects - annoyingly the latter is sort of disjoint in the .ui file. Another annoyance is that the tab page sometimes reads its own state while initialising itself, overwriting its source. This is perhaps not ideal, but it appears to work if you don't look at it too closely. Change-Id: I3d3d79f37a75bf6570149d794a2363a53de2f59f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146143 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 6879d4700c27..e821d7ca9c07 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -781,6 +781,10 @@ SwTOXSelectTabPage::SwTOXSelectTabPage(weld::Container* pPage, weld::DialogContr , m_xCaptionSequenceLB(m_xBuilder->weld_combo_box("category")) , m_xDisplayTypeFT(m_xBuilder->weld_label("displayft")) , m_xDisplayTypeLB(m_xBuilder->weld_combo_box("display")) + , m_xParaStyleCB(m_xBuilder->weld_check_button("useparastyle")) + , m_xParaStyleFT(m_xBuilder->weld_label("parastyleft")) + , m_xParaStyleLB(m_xBuilder->weld_combo_box("parastyle")) + , m_xParaStyleFrame(m_xBuilder->weld_widget("parastyleframe")) , m_xTOXMarksCB(m_xBuilder->weld_check_button("indexmarks")) , m_xIdxOptionsFrame(m_xBuilder->weld_widget("optionsframe")) , m_xCollectSameCB(m_xBuilder->weld_check_button("combinesame")) @@ -845,10 +849,12 @@ SwTOXSelectTabPage::SwTOXSelectTabPage(weld::Container* pPage, weld::DialogContr m_xUseDashCB->connect_toggled(aLk); m_xInitialCapsCB->connect_toggled(aLk); m_xKeyAsEntryCB->connect_toggled(aLk); + m_xParaStyleCB->connect_toggled(aLk); m_xTitleED->connect_changed(LINK(this, SwTOXSelectTabPage, ModifyEntryHdl)); m_xLevelNF->connect_value_changed(LINK(this, SwTOXSelectTabPage, ModifySpinHdl)); m_xSortAlgorithmLB->connect_changed(LINK(this, SwTOXSelectTabPage, ModifyListBoxHdl)); + m_xParaStyleLB->connect_changed(LINK(this, SwTOXSelectTabPage, ModifyListBoxHdl)); aLk = LINK(this, SwTOXSelectTabPage, RadioButtonHdl); m_xFromCaptionsRB->connect_toggled(aLk); @@ -953,6 +959,7 @@ void SwTOXSelectTabPage::ApplyTOXDescription() SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType(); SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType); + m_xReadOnlyCB->set_active(rDesc.IsReadonly()); if (!m_xTitleED->get_value_changed_from_saved()) { @@ -991,6 +998,42 @@ void SwTOXSelectTabPage::ApplyTOXDescription() //all but illustration and table m_xTOXMarksCB->set_active( bool(nCreateType & SwTOXElement::Mark) ); + if (TOX_ILLUSTRATIONS == aCurType.eType || TOX_TABLES == aCurType.eType + || TOX_OBJECTS== aCurType.eType) + { + // load all para styles... + m_xParaStyleLB->clear(); + SwWrtShell const& rWrtSh(static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell()); + const sal_uInt16 nSz = rWrtSh.GetTextFormatCollCount(); + for (sal_uInt16 j = 0; j < nSz; ++j) + { + SwTextFormatColl const& rColl = rWrtSh.GetTextFormatColl(j); + if (rColl.IsDefault()) + continue; + + OUString const name(rColl.GetName()); + if (!name.isEmpty()) + { + m_xParaStyleLB->append_text(name); + } + } + // first, init ParaStyle - because any later init (e.g. m_xFromCaptionsRB) + // ends up calling FillTOXDescription() resetting rDesc! + OUString const& rStyle(rDesc.GetStyleNames(0)); + assert(rStyle.indexOf(TOX_STYLE_DELIMITER) == -1); + if (rStyle.isEmpty()) + { + m_xParaStyleCB->set_active(false); + m_xParaStyleLB->set_sensitive(false); + } + else + { + m_xParaStyleCB->set_active(true); + m_xParaStyleLB->set_sensitive(true); + m_xParaStyleLB->set_active_text(rStyle); + } + } + //content if(TOX_CONTENT == aCurType.eType) { @@ -1026,7 +1069,6 @@ void SwTOXSelectTabPage::ApplyTOXDescription() if (m_xDisplayTypeLB->get_active() == -1) m_xDisplayTypeLB->set_active(0); RadioButtonHdl(*m_xFromCaptionsRB); - } else if(TOX_OBJECTS == aCurType.eType) { @@ -1123,6 +1165,14 @@ void SwTOXSelectTabPage::FillTOXDescription() rDesc.SetCreateFromObjectNames(m_xFromObjectNamesRB->get_active()); rDesc.SetSequenceName(m_xCaptionSequenceLB->get_active_text()); rDesc.SetCaptionDisplay(static_cast<SwCaptionDisplay>(m_xDisplayTypeLB->get_active())); + if (m_xParaStyleCB->get_active()) + { + m_aStyleArr[0] = m_xParaStyleLB->get_active_text(); + } + else + { + m_aStyleArr[0] = OUString(); + } break; case TOX_OBJECTS: { @@ -1136,6 +1186,14 @@ void SwTOXSelectTabPage::FillTOXDescription() } } rDesc.SetOLEOptions(nOLEData); + if (m_xParaStyleCB->get_active()) + { + m_aStyleArr[0] = m_xParaStyleLB->get_active_text(); + } + else + { + m_aStyleArr[0] = OUString(); + } } break; case TOX_AUTHORITIES: @@ -1158,8 +1216,11 @@ void SwTOXSelectTabPage::FillTOXDescription() nContentOptions |= SwTOXElement::Mark; if (m_xFromHeadingsCB->get_active() && m_xFromHeadingsCB->get_visible()) nContentOptions |= SwTOXElement::OutlineLevel; - if (m_xAddStylesCB->get_active() && m_xAddStylesCB->get_visible()) + if ((m_xAddStylesCB->get_active() && m_xAddStylesCB->get_visible()) + || (m_xParaStyleCB->get_active() && m_xParaStyleCB->get_visible())) + { nContentOptions |= SwTOXElement::Template; + } rDesc.SetContentOptions(nContentOptions); rDesc.SetIndexOptions(nIndexOptions); @@ -1264,6 +1325,10 @@ IMPL_LINK(SwTOXSelectTabPage, TOXTypeHdl, weld::ComboBox&, rBox, void) m_xCaptionSequenceLB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) ); m_xDisplayTypeFT->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) ); m_xDisplayTypeLB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) ); + m_xParaStyleCB->set_visible(0 != (nType & (TO_ILLUSTRATION|TO_TABLE|TO_OBJECT))); + m_xParaStyleFT->set_visible(0 != (nType & (TO_ILLUSTRATION|TO_TABLE|TO_OBJECT))); + m_xParaStyleLB->set_visible(0 != (nType & (TO_ILLUSTRATION|TO_TABLE|TO_OBJECT))); + m_xParaStyleFrame->set_visible(0 != (nType & (TO_ILLUSTRATION|TO_TABLE|TO_OBJECT))); m_xAuthorityFrame->set_visible( 0 != (nType & TO_AUTHORITIES) ); @@ -1347,6 +1412,13 @@ IMPL_LINK(SwTOXSelectTabPage, CheckBoxHdl, weld::Toggleable&, rButton, void) m_xUseDashCB->set_sensitive(m_xCollectSameCB->get_active() && !m_xUseFFCB->get_active()); m_xCaseSensitiveCB->set_sensitive(m_xCollectSameCB->get_active()); } + else if (TOX_ILLUSTRATIONS == aCurType.eType + || TOX_TABLES == aCurType.eType + || TOX_OBJECTS == aCurType.eType) + { + bool const bEnable(m_xParaStyleCB->get_active()); + m_xParaStyleLB->set_sensitive(bEnable); + } ModifyHdl(); }; diff --git a/sw/source/uibase/inc/swuicnttab.hxx b/sw/source/uibase/inc/swuicnttab.hxx index 12f3888e2980..906d26ceb9bc 100644 --- a/sw/source/uibase/inc/swuicnttab.hxx +++ b/sw/source/uibase/inc/swuicnttab.hxx @@ -161,6 +161,10 @@ class SwTOXSelectTabPage final : public SfxTabPage std::unique_ptr<weld::ComboBox> m_xCaptionSequenceLB; std::unique_ptr<weld::Label> m_xDisplayTypeFT; std::unique_ptr<weld::ComboBox> m_xDisplayTypeLB; + std::unique_ptr<weld::CheckButton> m_xParaStyleCB; + std::unique_ptr<weld::Label> m_xParaStyleFT; + std::unique_ptr<weld::ComboBox> m_xParaStyleLB; + std::unique_ptr<weld::Widget> m_xParaStyleFrame; //all but illustration and table std::unique_ptr<weld::CheckButton> m_xTOXMarksCB; diff --git a/sw/source/uibase/index/toxmgr.cxx b/sw/source/uibase/index/toxmgr.cxx index 7e5bb1ba177b..5fc78fc18053 100644 --- a/sw/source/uibase/index/toxmgr.cxx +++ b/sw/source/uibase/index/toxmgr.cxx @@ -384,6 +384,12 @@ bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc, } pNewTOX->SetFromObjectNames(rDesc.IsCreateFromObjectNames()); pNewTOX->SetOLEOptions(rDesc.GetOLEOptions()); + if (eCurTOXType == TOX_ILLUSTRATIONS + || eCurTOXType == TOX_TABLES + || eCurTOXType == TOX_OBJECTS) + { + pNewTOX->SetCreate(rDesc.GetContentOptions()); + } } break; } diff --git a/sw/uiconfig/swriter/ui/tocindexpage.ui b/sw/uiconfig/swriter/ui/tocindexpage.ui index aa87d26cdfa8..ee381134748f 100644 --- a/sw/uiconfig/swriter/ui/tocindexpage.ui +++ b/sw/uiconfig/swriter/ui/tocindexpage.ui @@ -811,6 +811,81 @@ <property name="top-attach">3</property> </packing> </child> + <child> + <object class="GtkFrame" id="parastyleframe"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="label-xalign">0</property> + <property name="shadow-type">none</property> + <child> + <!-- n-columns=2 n-rows=2 --> + <object class="GtkGrid" id="grid14"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="margin-start">12</property> + <property name="row-spacing">6</property> + <property name="column-spacing">12</property> + <child> + <object class="GtkCheckButton" id="useparastyle"> + <property name="label" translatable="yes" context="tocindexpage|useparastyle">Create from additional paragraph style</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> + <property name="active">True</property> + <property name="draw-indicator">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="useparastyle-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="tocindexpage|extended_tip|useparastyle">Include paragraphs that have the selected style applied in the index.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="parastyleft"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="tocindexpage|parastyleft">Paragraph style:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">display</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="parastyle"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child internal-child="accessible"> + <object class="AtkObject" id="parastyle-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="tocindexpage|extended_tip|parastyle">Select the paragraph style for which you want to create index entries.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">4</property> + </packing> + </child> <child> <object class="GtkFrame" id="authframe"> <property name="can-focus">False</property>