summaryrefslogtreecommitdiffstats
path: root/sw/qa/uibase/shells/textsh.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sw/qa/uibase/shells/textsh.cxx
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/uibase/shells/textsh.cxx')
-rw-r--r--sw/qa/uibase/shells/textsh.cxx110
1 files changed, 110 insertions, 0 deletions
diff --git a/sw/qa/uibase/shells/textsh.cxx b/sw/qa/uibase/shells/textsh.cxx
new file mode 100644
index 0000000000..ca72a710df
--- /dev/null
+++ b/sw/qa/uibase/shells/textsh.cxx
@@ -0,0 +1,110 @@
+/* -*- 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 <comphelper/propertyvalue.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/sequence.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+
+#include <docary.hxx>
+#include <docsh.hxx>
+#include <frmmgr.hxx>
+#include <wrtsh.hxx>
+#include <formatflysplit.hxx>
+#include <view.hxx>
+#include <cmdid.h>
+
+namespace
+{
+/// Covers sw/source/uibase/shells/textsh.cxx fixes.
+class Test : public SwModelTestBase
+{
+public:
+ Test()
+ : SwModelTestBase("/sw/qa/uibase/shells/data/")
+ {
+ }
+};
+
+CPPUNIT_TEST_FIXTURE(Test, testDeleteSections)
+{
+ // Given a document with a section:
+ createSwDoc();
+ SwDoc* pDoc = getSwDoc();
+ uno::Sequence<css::beans::PropertyValue> aArgs = {
+ comphelper::makePropertyValue("RegionName",
+ uno::Any(OUString("ZOTERO_BIBL {} CSL_BIBLIOGRAPHY RND"))),
+ comphelper::makePropertyValue("Content", uno::Any(OUString("old content"))),
+ };
+ dispatchCommand(mxComponent, ".uno:InsertSection", aArgs);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDoc->GetSections().size());
+
+ // When deleting sections:
+ std::vector<beans::PropertyValue> aArgsVec = comphelper::JsonToPropertyValues(R"json(
+{
+ "SectionNamePrefix": {
+ "type": "string",
+ "value": "ZOTERO_BIBL"
+ }
+}
+)json"_ostr);
+ aArgs = comphelper::containerToSequence(aArgsVec);
+ dispatchCommand(mxComponent, ".uno:DeleteSections", aArgs);
+
+ // Then make sure that the section is deleted:
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 0
+ // - Actual : 1
+ // i.e. the section was not deleted.
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pDoc->GetSections().size());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFootnoteUI)
+{
+ // Given a document with a split fly (to host a table):
+ createSwDoc();
+ SwDoc* pDoc = getSwDoc();
+ SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+ SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr);
+ RndStdIds eAnchor = RndStdIds::FLY_AT_PARA;
+ pWrtShell->StartAllAction();
+ aMgr.InsertFlyFrame(eAnchor, aMgr.GetPos(), aMgr.GetSize());
+ pWrtShell->EndAllAction();
+ pWrtShell->StartAllAction();
+ sw::FrameFormats<sw::SpzFrameFormat*>& rFlys = *pDoc->GetSpzFrameFormats();
+ sw::SpzFrameFormat* pFly = rFlys[0];
+ {
+ SwAttrSet aSet(pFly->GetAttrSet());
+ aSet.Put(SwFormatFlySplit(true));
+ pDoc->SetAttr(aSet, *pFly);
+ }
+ pWrtShell->EndAllAction();
+ pWrtShell->UnSelectFrame();
+ pWrtShell->LeaveSelFrameMode();
+ pWrtShell->GetView().AttrChangedNotify(nullptr);
+ pWrtShell->MoveSection(GoCurrSection, fnSectionEnd);
+
+ // When checking if we can insert a footnote inside the split fly:
+ SwView& rView = pWrtShell->GetView();
+ std::unique_ptr<SfxPoolItem> pItem;
+ SfxItemState eState = rView.GetViewFrame().GetBindings().QueryState(FN_INSERT_FOOTNOTE, pItem);
+
+ // Then make sure that the insertion is allowed:
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 32 (DEFAULT)
+ // - Actual : 1 (DISABLED)
+ // i.e. the insertion was denied.
+ CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, eState);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */