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>
diff --git a/sw/qa/extras/layout/data/tdf117923.docx b/sw/qa/extras/layout/data/tdf117923.docx
new file mode 100644
index 0000000..c10ac24
--- /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 70cf21c..be9b4e2 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2859,6 +2859,37 @@
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 98c3902..1020a40 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 @@
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 eb95ed9..a1c27cb 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -426,7 +426,8 @@
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);