summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-03-24 08:44:52 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-03-24 12:52:42 +0100
commit8a7d0e8a811da83265c383630cc48af57f96dc49 (patch)
tree8043977b399dfd69d0983081f84063d4ff4ae64f /sw/source/uibase
parent312cf9580c4b7846d217ce241c36f327a81f6cea (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/uibase')
-rw-r--r--sw/source/uibase/inc/break.hxx5
-rw-r--r--sw/source/uibase/inc/wrtsh.hxx3
-rw-r--r--sw/source/uibase/shells/textsh1.cxx11
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx22
4 files changed, 33 insertions, 8 deletions
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);
+ }
+ }
}
}