summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-04-16 11:47:57 +0200
committerLászló Németh <nemeth@numbertext.org>2020-04-17 09:51:37 +0200
commit6287845eab339a8eb3c660d648d012e9f1dcce30 (patch)
treec5a45368f2c1f4fb2be14b6ed90dcd6e73168adf
parent6520999570cee4e94075617537e23bb8911f162b (diff)
tdf#127606 DOCX lists: fix unchangeable formatting
of numbering. It was not possible to modify character formatting of numbering symbols, if it is different from the format of the list item, handled by compatibility setting APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING and paragraph attribute "ListAutoFormat". Now changing character attributes removes ListAutoFormat, if it is applied on wholly list item(s) during editing (like in the case of ODT documents). See also commit 5ba30f588d6e41a13d68b1461345fca7a7ca61ac (tdf#64222 sw: better DOCX import/export of paragraph marker formatting) and commit df07d6cb9f62c0a2c4b29bd850d4efb4fcd4790b (handle direct formatting for numbering in .docx (bnc#875717)). Change-Id: I60dae1b9c084d0804e453f54df5c6bbafe479869 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92343 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/layout/data/tdf117923.docxbin0 -> 21227 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx31
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx22
-rw-r--r--sw/source/core/text/txtfld.cxx3
4 files changed, 55 insertions, 1 deletions
diff --git a/sw/qa/extras/layout/data/tdf117923.docx b/sw/qa/extras/layout/data/tdf117923.docx
new file mode 100644
index 000000000000..c10ac24050b2
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf117923.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 70cf21c1ef8a..be9b4e2d0f09 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2859,6 +2859,37 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117923)
assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "220");
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf127606)
+{
+ createDoc("tdf117923.docx");
+ // Ensure that all text portions are calculated before testing.
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwViewShell* pViewShell
+ = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+ pViewShell->Reformat();
+
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+
+ // Check that we actually test the line we need
+ assertXPathContent(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]", "GHI GHI GHI GHI");
+ assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nType",
+ "PortionType::Number");
+ assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "rText", "2.");
+ // The numbering height was 960 in DOC format.
+ assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "220");
+
+ // tdf#127606: now it's possible to change formatting of numbering
+ // increase font size (220 -> 260)
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:Grow", {});
+ pViewShell->Reformat();
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "260");
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109077)
{
createDoc("tdf109077.docx");
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 98c39021af17..1020a40cecea 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -23,6 +23,7 @@
#include <IDocumentState.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <IDocumentStylePoolAccess.hxx>
+#include <IDocumentSettingAccess.hxx>
#include <UndoManager.hxx>
#include <docary.hxx>
#include <textboxhelper.hxx>
@@ -1295,6 +1296,27 @@ namespace //local functions originally from docfmt.cxx
if( pNode && pNode->IsTextNode() )
{
+ // tdf#127606 at editing, remove different formatting of DOCX-like numbering symbol
+ if (pLayout && pNode->GetTextNode()->getIDocumentSettingAccess()->
+ get(DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ))
+ {
+ SwContentNode* pEndNode = pEnd->nNode.GetNode().GetContentNode();
+ SwContentNode* pCurrentNode = pEndNode;
+ auto nStartIndex = pNode->GetIndex();
+ auto nEndIndex = pEndNode->GetIndex();
+ SwNodeIndex aIdx( pEnd->nNode.GetNode() );
+ while ( pCurrentNode != nullptr && nStartIndex <= pCurrentNode->GetIndex() )
+ {
+ if (pCurrentNode->GetSwAttrSet().HasItem(RES_PARATR_LIST_AUTOFMT) &&
+ // remove character formatting only on wholly selected paragraphs
+ (nStartIndex < pCurrentNode->GetIndex() || pStt->nContent.GetIndex() == 0) &&
+ (pCurrentNode->GetIndex() < nEndIndex || pEnd->nContent.GetIndex() == pEndNode->Len()))
+ {
+ pCurrentNode->ResetAttr(RES_PARATR_LIST_AUTOFMT);
+ }
+ pCurrentNode = SwNodes::GoPrevious( &aIdx );
+ }
+ }
// #i27615#
if (rRg.IsInFrontOfLabel())
{
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index eb95ed9453e1..a1c27cbb3597 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -426,7 +426,8 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
std::shared_ptr<SfxItemSet> pSet(rListAutoFormat.GetStyleHandle());
// TODO remove this fallback (for WW8/RTF)
- if (!pSet)
+ bool isDOCX = pIDSA->get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS);
+ if (!isDOCX && !pSet)
{
TextFrameIndex const nTextLen(rInf.GetTextFrame()->GetText().getLength());
SwTextNode const* pNode(nullptr);