summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-07-19 15:32:59 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-07-19 17:46:26 +0200
commit340eaa6aa15c18cc2696a4a304350810cb36565c (patch)
treedc29c9dc98a7e5e7b112f83eef2209da066bdd8d
parent049d436eaad05a3fbd2e64a558dfef3c03ce7448 (diff)
tdf#101534 sw: fix lost indent attributes when copying into numbered paragraph
Commit aa91dc0ccbe53ffcec9dbfec2265de057775d4e3 (CWS-TOOLING: integrate CWS sw32numbf01, 2009-09-08) replaced the SwDoc::ReplaceNumRule() call with SwDoc::SetNumRule(), as the later handles list ids. This required a decision if resetting of the indent attributes is needed or not, but it did not document why resetting was chosen. On the other hand, the current bugdoc shows why resetting is a bad idea: this way if you paste into a numbered paragraph which has a non-zero paragraph indent inherited from the numbering + zero indent as direct formatting, then this later is lost during paste. Change-Id: Ie5dcf6ed86c240fd61c4d5bfed886910aea3648f Reviewed-on: https://gerrit.libreoffice.org/57727 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins
-rw-r--r--sw/CppunitTest_sw_uiwriter.mk1
-rw-r--r--sw/qa/extras/uiwriter/data2/tdf101534.fodt28
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx60
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx4
4 files changed, 92 insertions, 1 deletions
diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk
index bb3271ec9fa3..d11d1754892b 100644
--- a/sw/CppunitTest_sw_uiwriter.mk
+++ b/sw/CppunitTest_sw_uiwriter.mk
@@ -13,6 +13,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sw_uiwriter))
$(eval $(call gb_CppunitTest_add_exception_objects,sw_uiwriter, \
sw/qa/extras/uiwriter/uiwriter \
+ sw/qa/extras/uiwriter/uiwriter2 \
))
# note: this links msword only for the reason to have a order dependency,
diff --git a/sw/qa/extras/uiwriter/data2/tdf101534.fodt b/sw/qa/extras/uiwriter/data2/tdf101534.fodt
new file mode 100644
index 000000000000..e1db2f08ee08
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/tdf101534.fodt
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+ <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+ <text:list-style style:name="MyList">
+ <text:list-level-style-number text:level="1" style:num-format="1" text:display-levels="1">
+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.635cm" fo:text-indent="1.27cm" fo:margin-left="-1.27cm"/>
+ </style:list-level-properties>
+ </text:list-level-style-number>
+ </text:list-style>
+ </office:styles>
+ <office:automatic-styles>
+ <style:style style:name="P1" style:family="paragraph">
+ <style:paragraph-properties fo:margin-left="0cm"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:p>Lorem ipsum dolor sit amet.</text:p>
+ <text:list text:style-name="MyList">
+ <text:list-item>
+ <text:p text:style-name="P1">Quo dolor dolore ea, vis te dicunt evertitur. Quo idque nostrud referrentur at, saperet volumus sententiae ut pro.</text:p>
+ </text:list-item>
+ </text:list>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
new file mode 100644
index 000000000000..239700294b71
--- /dev/null
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -0,0 +1,60 @@
+/* -*- 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 <com/sun/star/awt/FontSlant.hpp>
+#include <swdtflvr.hxx>
+#include <wrtsh.hxx>
+
+namespace
+{
+char const DATA_DIRECTORY[] = "/sw/qa/extras/uiwriter/data2/";
+}
+
+/// Second set of tests asserting the behavior of Writer user interface shells.
+class SwUiWriterTest2 : public SwModelTestBase
+{
+public:
+ void testTdf101534();
+
+ CPPUNIT_TEST_SUITE(SwUiWriterTest2);
+ CPPUNIT_TEST(testTdf101534);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void SwUiWriterTest2::testTdf101534()
+{
+ // Copy the first paragraph of the document.
+ load(DATA_DIRECTORY, "tdf101534.fodt");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->EndPara(/*bSelect=*/true);
+ rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+ pTransfer->Copy();
+
+ // Go to the second paragraph, assert that we have margins as direct
+ // formatting.
+ pWrtShell->Down(/*bSelect=*/false);
+ SfxItemSet aSet(pWrtShell->GetAttrPool(), svl::Items<RES_LR_SPACE, RES_LR_SPACE>{});
+ pWrtShell->GetCurAttr(aSet);
+ CPPUNIT_ASSERT(aSet.HasItem(RES_LR_SPACE));
+
+ // Make sure that direct formatting is preserved during paste.
+ pWrtShell->EndPara(/*bSelect=*/false);
+ TransferableDataHelper aHelper(pTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
+ pWrtShell->GetCurAttr(aSet);
+ // This failed, direct formatting was lost.
+ CPPUNIT_ASSERT(aSet.HasItem(RES_LR_SPACE));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 6cee3d7973e3..256fce7bbe4d 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4580,8 +4580,10 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
if ( pNumRuleToPropagate != nullptr )
{
// #i86492# - use <SwDoc::SetNumRule(..)>, because it also handles the <ListId>
+ // Don't reset indent attributes, that would mean loss of direct
+ // formatting.
pDoc->SetNumRule( *pCopyPam, *pNumRuleToPropagate, false,
- aListIdToPropagate, true, true );
+ aListIdToPropagate, true, /*bResetIndentAttrs=*/false );
}
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );