sw/qa/extras/layout/data/tdf117923.docx |binary sw/qa/extras/layout/layout.cxx | 31 ++++++++++++++++ sw/source/core/doc/DocumentContentOperationsManager.cxx | 22 +++++++++++ sw/source/core/text/txtfld.cxx | 3 + 4 files changed, 55 insertions(+), 1 deletion(-)
New commits: commit 11768f901b4c9e34e598187a31adf5028377c65c Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Apr 16 11:47:57 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Apr 27 11:30:42 2020 +0200 tdf#127606 DOCX lists: fix unchangeable formatting of numbering symbols. It was not possible to modify the character format of numbering symbols, if it is different from the format of the list item, handled by ListAutoFormat compatibility paragraph attribute and APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING compatibility setting. Now changing character attributes removes ListAutoFormat, if it is applied on wholly list item(s) during editing. See 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)). (cherry picked from commit 6287845eab339a8eb3c660d648d012e9f1dcce30) Change-Id: I60dae1b9c084d0804e453f54df5c6bbafe479869 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92534 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> 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 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf117923.docx differ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index e7e79213ec91..e33eaf66e108 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2773,6 +2773,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) + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_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 81fcb49151d6..caec3a3e9fe7 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> @@ -1293,6 +1294,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 c5d1816200df..1930bfa99b30 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -430,7 +430,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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits