summaryrefslogtreecommitdiff
path: root/sw/qa
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/qa
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/qa')
-rw-r--r--sw/qa/uibase/wrtsh/wrtsh.cxx58
1 files changed, 58 insertions, 0 deletions
diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx
new file mode 100644
index 000000000000..9f63ed2fc7e6
--- /dev/null
+++ b/sw/qa/uibase/wrtsh/wrtsh.cxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <optional>
+
+#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <formatlinebreak.hxx>
+#include <wrtsh.hxx>
+
+namespace
+{
+/// Covers sw/source/uibase/wrtsh/ fixes.
+class Test : public SwModelTestBase
+{
+};
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertLineBreak)
+{
+ // Given an empty document:
+ SwDoc* pDoc = createSwDoc();
+
+ // When inserting a clearing break:
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ std::optional<SwLineBreakClear> oClear = SwLineBreakClear::ALL;
+ pWrtShell->InsertLineBreak(oClear);
+
+ // Then make sure it's not just a plain linebreak:
+ uno::Reference<css::text::XTextRange> xTextPortion = getRun(getParagraph(1), 1);
+ auto aPortionType = getProperty<OUString>(xTextPortion, "TextPortionType");
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: LineBreak
+ // - Actual : Text
+ // i.e. the line break lost its "clear" property.
+ CPPUNIT_ASSERT_EQUAL(OUString("LineBreak"), aPortionType);
+ auto xLineBreak = getProperty<uno::Reference<text::XTextContent>>(xTextPortion, "LineBreak");
+ auto eClear = getProperty<sal_Int16>(xLineBreak, "Clear");
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(SwLineBreakClear::ALL), eClear);
+}
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */