diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-03-24 08:44:52 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-24 12:52:42 +0100 |
commit | 8a7d0e8a811da83265c383630cc48af57f96dc49 (patch) | |
tree | 8043977b399dfd69d0983081f84063d4ff4ae64f /sw/source | |
parent | 312cf9580c4b7846d217ce241c36f327a81f6cea (diff) |
sw clearing breaks: add insert UI
Expose SwLineBreakClear in SwBreakDlg and extend
SwWrtShell::InsertLineBreak() to be able to insert clearing breaks as
well.
Change-Id: I17a4c34cb74f1c72d8e208bace25597de0367e17
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132024
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/chrdlg/break.cxx | 8 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 11 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/inc/break.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/inc/wrtsh.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 11 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh1.cxx | 22 |
7 files changed, 52 insertions, 9 deletions
diff --git a/sw/source/ui/chrdlg/break.cxx b/sw/source/ui/chrdlg/break.cxx index 7bc1210ef34d..8c1c6a0ccbfc 100644 --- a/sw/source/ui/chrdlg/break.cxx +++ b/sw/source/ui/chrdlg/break.cxx @@ -36,7 +36,10 @@ void SwBreakDlg::rememberResult() { nKind = 0; if (m_xLineBtn->get_active()) + { nKind = 1; + m_eClear = static_cast<SwLineBreakClear>(m_xLineClearBox->get_active()); + } else if(m_xColumnBtn->get_active()) nKind = 2; else if(m_xPageBtn->get_active()) @@ -125,6 +128,8 @@ IMPL_LINK_NOARG(SwBreakDlg, OkHdl, weld::Button&, void) SwBreakDlg::SwBreakDlg(weld::Window *pParent, SwWrtShell &rS) : GenericDialogController(pParent, "modules/swriter/ui/insertbreak.ui", "BreakDialog") , m_xLineBtn(m_xBuilder->weld_radio_button("linerb")) + , m_xLineClearText(m_xBuilder->weld_label("clearft")) + , m_xLineClearBox(m_xBuilder->weld_combo_box("clearlb")) , m_xColumnBtn(m_xBuilder->weld_radio_button("columnrb")) , m_xPageBtn(m_xBuilder->weld_radio_button("pagerb")) , m_xPageCollText(m_xBuilder->weld_label("styleft")) @@ -189,6 +194,9 @@ void SwBreakDlg::CheckEnable() const bool bPage = m_xPageBtn->get_active(); m_xPageCollText->set_sensitive(bPage); m_xPageCollBox->set_sensitive(bPage); + bool bLine = m_xLineBtn->get_active(); + m_xLineClearText->set_sensitive(bLine); + m_xLineClearBox->set_sensitive(bLine); bEnable &= bPage; if ( bEnable ) diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 2f28ef1b385d..dd5211277832 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -87,7 +87,7 @@ #include <mailconfigpage.hxx> #include <uiborder.hxx> #include <mmresultdialogs.hxx> - +#include <formatlinebreak.hxx> using namespace ::com::sun::star; using namespace css::frame; @@ -386,6 +386,15 @@ sal_uInt16 AbstractSwBreakDlg_Impl:: GetKind() return 0; } +std::optional<SwLineBreakClear> AbstractSwBreakDlg_Impl::GetClear() +{ + SwBreakDlg* pDlg = dynamic_cast<SwBreakDlg*>(m_xDlg.get()); + if (pDlg) + return pDlg->GetClear(); + + return SwLineBreakClear::NONE; +} + void AbstractSwConvertTableDlg_Impl::GetValues( sal_Unicode& rDelim,SwInsertTableOptions& rInsTableFlags, SwTableAutoFormat const*& prTAFormat) { diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index bd0f8ab392c5..867b37a467f6 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -181,6 +181,7 @@ public: virtual OUString GetTemplateName() override; virtual sal_uInt16 GetKind() override; virtual ::std::optional<sal_uInt16> GetPageNumber() override; + std::optional<SwLineBreakClear> GetClear() override; virtual std::shared_ptr<weld::DialogController> getDialogController() override { return m_xDlg; } }; diff --git a/sw/source/uibase/inc/break.hxx b/sw/source/uibase/inc/break.hxx index 928761305027..3dbb4c681039 100644 --- a/sw/source/uibase/inc/break.hxx +++ b/sw/source/uibase/inc/break.hxx @@ -24,10 +24,13 @@ #include <optional> class SwWrtShell; +enum class SwLineBreakClear; class SwBreakDlg final : public weld::GenericDialogController { std::unique_ptr<weld::RadioButton> m_xLineBtn; + std::unique_ptr<weld::Label> m_xLineClearText; + std::unique_ptr<weld::ComboBox> m_xLineClearBox; std::unique_ptr<weld::RadioButton> m_xColumnBtn; std::unique_ptr<weld::RadioButton> m_xPageBtn; std::unique_ptr<weld::Label> m_xPageCollText; @@ -40,6 +43,7 @@ class SwBreakDlg final : public weld::GenericDialogController OUString m_aTemplate; sal_uInt16 nKind; ::std::optional<sal_uInt16> oPgNum; + std::optional<SwLineBreakClear> m_eClear; bool bHtmlMode; @@ -57,6 +61,7 @@ public: const OUString& GetTemplateName() const { return m_aTemplate; } sal_uInt16 GetKind() const { return nKind; } const ::std::optional<sal_uInt16>& GetPageNumber() const { return oPgNum; } + std::optional<SwLineBreakClear> GetClear() const { return m_eClear; } }; #endif diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx index 41ef84d1d00f..1c85873bc249 100644 --- a/sw/source/uibase/inc/wrtsh.hxx +++ b/sw/source/uibase/inc/wrtsh.hxx @@ -53,6 +53,7 @@ class SfxStringListItem; enum class SvMacroItemId : sal_uInt16; class SwFieldMgr; class SfxRequest; +enum class SwLineBreakClear; namespace i18nutil { struct SearchOptions2; @@ -312,7 +313,7 @@ typedef bool (SwWrtShell::*FNSimpleMove)(); void InsertByWord( const OUString & ); void InsertPageBreak(const OUString *pPageDesc = nullptr, const ::std::optional<sal_uInt16>& rPgNum = std::nullopt); - void InsertLineBreak(); + void InsertLineBreak(std::optional<SwLineBreakClear> oClear = std::nullopt); void InsertColumnBreak(); void InsertFootnote(const OUString &, bool bEndNote = false, bool bEdit = true ); void SplitNode( bool bAutoFormat = false ); diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index c7b05a53b4c6..e0f4459f31e9 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -331,12 +331,13 @@ namespace { void InsertBreak(SwWrtShell& rWrtSh, sal_uInt16 nKind, ::std::optional<sal_uInt16> oPageNumber, - const OUString& rTemplateName) + const OUString& rTemplateName, std::optional<SwLineBreakClear> oClear) { switch ( nKind ) { case 1 : - rWrtSh.InsertLineBreak(); break; + rWrtSh.InsertLineBreak(oClear); + break; case 2 : rWrtSh.InsertColumnBreak(); break; case 3 : @@ -652,6 +653,7 @@ void SwTextShell::Execute(SfxRequest &rReq) if ( pItem ) { ::std::optional<sal_uInt16> oPageNumber; + std::optional<SwLineBreakClear> oClear; OUString aTemplateName; sal_uInt16 nKind = static_cast<const SfxInt16Item*>(pItem)->GetValue(); const SfxStringItem* pTemplate = rReq.GetArg<SfxStringItem>(FN_PARAM_1); @@ -662,7 +664,7 @@ void SwTextShell::Execute(SfxRequest &rReq) if ( pNumber && pIsNumberFilled && pIsNumberFilled->GetValue() ) oPageNumber = pNumber->GetValue(); - InsertBreak(rWrtSh, nKind, oPageNumber, aTemplateName); + InsertBreak(rWrtSh, nKind, oPageNumber, aTemplateName, oClear); } else { @@ -678,8 +680,9 @@ void SwTextShell::Execute(SfxRequest &rReq) sal_uInt16 nKind = pAbstractDialog->GetKind(); OUString aTemplateName = pAbstractDialog->GetTemplateName(); ::std::optional<sal_uInt16> oPageNumber = pAbstractDialog->GetPageNumber(); + std::optional<SwLineBreakClear> oClear = pAbstractDialog->GetClear(); - InsertBreak(rWrtSh, nKind, oPageNumber, aTemplateName); + InsertBreak(rWrtSh, nKind, oPageNumber, aTemplateName, oClear); } }); } diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index e4e4efb76d2d..a55b5ed7513a 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -111,6 +111,7 @@ #include <IDocumentUndoRedo.hxx> #include <UndoInsert.hxx> #include <UndoCore.hxx> +#include <formatlinebreak.hxx> using namespace sw::mark; using namespace com::sun::star; @@ -949,7 +950,7 @@ void SwWrtShell::InsertPageBreak(const OUString *pPageDesc, const ::std::optiona // Insert hard page break; // Selections will be overwritten -void SwWrtShell::InsertLineBreak() +void SwWrtShell::InsertLineBreak(std::optional<SwLineBreakClear> oClear) { if (!lcl_IsAllowed(this)) return; @@ -961,11 +962,26 @@ void SwWrtShell::InsertLineBreak() DelRight(); const sal_Unicode cIns = 0x0A; + SwLineBreakClear eClear = SwLineBreakClear::NONE; + if (oClear.has_value()) + { + eClear = *oClear; + } SvxAutoCorrect* pACorr = lcl_IsAutoCorr(); - if( pACorr ) + if (pACorr && eClear == SwLineBreakClear::NONE) AutoCorrect( *pACorr, cIns ); else - SwWrtShell::Insert( OUString( cIns ) ); + { + if (eClear == SwLineBreakClear::NONE) + { + SwWrtShell::Insert(OUString(cIns)); + } + else + { + SwFormatLineBreak aLineBreak(eClear); + SetAttrItem(aLineBreak); + } + } } } |