[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/qa sw/source writerfilter/inc writerfilter/source

2023-04-12 Thread Justin Luth (via logerrit)
 dev/null  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|   34 ++--
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|   12 ---
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   49 
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx |   22 ++---
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |2 
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |   11 +-
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx |   22 ++---
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |   14 +--
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |   13 ++-
 sw/source/core/doc/textboxhelper.cxx  |   15 +--
 sw/source/core/draw/dcontact.cxx  |8 --
 writerfilter/inc/dmapper/resourcemodel.hxx|7 -
 writerfilter/source/dmapper/DomainMapper.cxx  |   11 --
 writerfilter/source/dmapper/DomainMapper.hxx  |3 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   69 --
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |   10 --
 writerfilter/source/dmapper/FontTable.hxx |2 
 writerfilter/source/dmapper/GraphicImport.hxx |2 
 writerfilter/source/dmapper/LoggedResources.cxx   |4 -
 writerfilter/source/dmapper/LoggedResources.hxx   |4 -
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   23 --
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |1 
 23 files changed, 63 insertions(+), 275 deletions(-)

New commits:
commit 6593d375d5504e079730f1b448d1d2648c401ebd
Author: Justin Luth 
AuthorDate: Wed Apr 12 08:19:50 2023 -0400
Commit: Andras Timar 
CommitDate: Wed Apr 12 21:32:27 2023 +0200

Revert "Related tdf#66039 DOCX import: fix Z-order of group shapes"

This reverts commit 0cb370d02bebf6a9d65b5852815e2c617b33a89a.

It was added for T38690 and removed for T41585

Change-Id: I2a019d739f91d9aef2765ee5142825da7ca09a32
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150290
Reviewed-by: Justin Luth 
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx 
b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx
deleted file mode 100644
index 664f47a0b623..
Binary files a/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx and /dev/null 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 5d2d4c8fe252..42a4b0a234da 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -116,9 +116,9 @@ protected:
 
 DECLARE_OOXMLEXPORT_TEST(testWPGtextboxes, "testWPGtextboxes.docx")
 {
-CPPUNIT_ASSERT_EQUAL(2, getShapes());
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
 
-auto MyShape = getShape(2);
+auto MyShape = getShape(1);
 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), 
MyShape->getShapeType());
 
 uno::Reference xGroup(MyShape, uno::UNO_QUERY_THROW);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index e889b07009ea..39efb4b0b8fc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 
 
 #include 
@@ -30,7 +29,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
@@ -393,53 +391,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf126287, "tdf126287.docx")
 CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
-DECLARE_OOXMLEXPORT_TEST(TestWPGZOrder, "testWPGZOrder.docx")
-{
-// Check if the load failed.
-CPPUNIT_ASSERT(mxComponent);
-
-// Get the WPG
-uno::Reference xGroup(getShape(1), uno::UNO_QUERY_THROW);
-uno::Reference xGroupProperties(xGroup, 
uno::UNO_QUERY_THROW);
-
-// Initialize a queue for subgroups
-std::queue> xGroupList;
-xGroupList.push(xGroup);
-
-// Every textbox shall be visible.
-while (xGroupList.size())
-{
-// Get the first group
-xGroup = xGroupList.front();
-xGroupList.pop();
-for (sal_Int32 i = 0; i < xGroup->getCount(); ++i)
-{
-// Get the child shape
-uno::Reference 
xChildShapeProperties(xGroup->getByIndex(i),
-uno::UNO_QUERY_THROW);
-// Check for textbox
-if 
(!xChildShapeProperties->getPropertyValue("TextBox").get())
-{
-// Is this a Group Shape? Put it into the queue.
-uno::Reference 
xInnerGroup(xGroup->getByIndex(i), uno::UNO_QUERY);
-if (xInnerGroup)
-xGroupList.push(xInnerGroup);
-continue;
-}
-
-// Get the textbox properties
-uno::Reference xTextBoxFrameProperties(
-xChildShapeProperties->getPropertyValue("TextBoxContent"), 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/qa sw/source

2023-01-13 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf152425.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx   |8 -
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx   |2 
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |   19 ++
 sw/source/filter/inc/wwstyles.hxx|1 
 sw/source/filter/ww8/docxattributeoutput.cxx |   16 +-
 sw/source/filter/ww8/styles.cxx  |  185 +--
 sw/source/filter/ww8/wrtw8sty.cxx|  142 +++-
 sw/source/filter/ww8/wrtww8.hxx  |   10 +
 9 files changed, 209 insertions(+), 174 deletions(-)

New commits:
commit 673f59684f8bd2aac29c703f07fdb91165a38775
Author: Mike Kaganski 
AuthorDate: Sat Dec 10 08:58:10 2022 +0300
Commit: Mike Kaganski 
CommitDate: Sat Jan 14 07:17:31 2023 +

tdf#152425 Make Word names unique, and use them for style ids generation

Before, a style id was generated from LibreOffice name, and then the
name was replaced with Word name. Given that Writer's List N maps to
Word's List Bullet N, and Word's List N doesn't map to anything in
Writer, this led to styles.xml having after roundtrip:



...



So the idea is to do the following steps:

1. Collect all the exported styles (unchanged);
2. Build unique Word names for collected styles (new):
   a. Process all the styles that map to special Word styles first,
  so that their Word names don't get changed when made unique;
   b. Process the rest of the styles, making sure to append a sequential
  number after the Writer name, if a clash happens.
3. Build Style Ids from the Word names (previously Writer name could be
   used), also making sure they are unique.

Change-Id: I9f8f254aa6ae713671234f0109b94cc72a588150
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143905
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145376
Tested-by: Jenkins CollaboraOffice 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 671d9c9958db..cd194b5c68f1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -1238,8 +1238,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf123628)
 
 xmlDocUniquePtr pXmlStyles = parseExport("word/styles.xml");
 
-assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:hyperlink/w:r/w:rPr/w:rStyle", "val", 
"InternetLink");
-assertXPath(pXmlStyles, 
"/w:styles/w:style[@w:styleId='InternetLink']/w:name", "val", "Hyperlink");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:hyperlink/w:r/w:rPr/w:rStyle", "val", "Hyperlink");
+assertXPath(pXmlStyles, 
"/w:styles/w:style[@w:styleId='Hyperlink']/w:name", "val", "Hyperlink");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf127741, "tdf127741.docx")
@@ -1265,7 +1265,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf127925)
 loadAndSave("tdf127925.odt");
 CPPUNIT_ASSERT_EQUAL(1, getPages());
 xmlDocUniquePtr pXmlStyles = parseExport("word/styles.xml");
-assertXPath(pXmlStyles, 
"/w:styles/w:style[@w:styleId='VisitedInternetLink']/w:name", "val", 
"FollowedHyperlink");
+assertXPath(pXmlStyles, 
"/w:styles/w:style[@w:styleId='FollowedHyperlink']/w:name", "val", 
"FollowedHyperlink");
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf127579)
@@ -1273,7 +1273,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf127579)
 loadAndSave("tdf127579.odt");
 CPPUNIT_ASSERT_EQUAL(1, getPages());
 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
-assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:hyperlink/w:r/w:rPr/w:rStyle", "val", "InternetLink");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:hyperlink/w:r/w:rPr/w:rStyle", "val", "Hyperlink");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf128304, "tdf128304.odt")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index ae8b96c99f66..22c3b75c5e87 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -984,7 +984,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf143726, "Simple-TOC.odt")
 CPPUNIT_ASSERT(pXmlStyles);
 // Without the fix this was "TOA Heading" which belongs to the "Table of 
Authorities" index in Word
 // TOC's heading style should be exported as "TOC Heading" as that's the 
default Word style name
-assertXPath(pXmlStyles, 
"/w:styles/w:style[@w:styleId='ContentsHeading']/w:name", "val", "TOC Heading");
+assertXPath(pXmlStyles, 
"/w:styles/w:style[@w:styleId='TOCHeading']/w:name", "val", "TOC Heading");
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 37b1bad5d10e..97d1d117e3ea 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -153,6 +153,11 @@ 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/qa sw/source

2023-01-08 Thread Pranam Lashkari (via logerrit)
 sw/qa/uibase/uno/uno.cxx   |   45 +
 sw/source/uibase/shells/basesh.cxx |   23 +-
 sw/source/uibase/uno/loktxdoc.cxx  |   21 -
 3 files changed, 77 insertions(+), 12 deletions(-)

New commits:
commit 8eae44879532f6448b5cce93d4d060197604eed5
Author: Pranam Lashkari 
AuthorDate: Sat Jan 7 02:39:38 2023 +0530
Commit: Andras Timar 
CommitDate: Sun Jan 8 12:16:03 2023 +

sw, UpdateFields: update in sorted order

This was using the order used by GetItemSurrogates() which can be hard to 
predict

So it used to update field in uncertain ways

Now it updates field in order of the fields in file

Change-Id: I7fc39b476cae6ed6a7fb7186803d4205832d7a73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145167
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/sw/source/uibase/shells/basesh.cxx 
b/sw/source/uibase/shells/basesh.cxx
index 0e2f6769167c..b5f3eab9e60a 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -799,10 +799,29 @@ bool UpdateFieldContents(SfxRequest& rReq, SwWrtShell& 
rWrtSh)
 SwDoc* pDoc = rWrtSh.GetDoc();
 pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSBOOKMARK, nullptr);
 rWrtSh.StartAction();
+
+std::vector aRefMarks;
+
+for (sal_uInt16 i = 0; i < pDoc->GetRefMarks(); ++i)
+{
+aRefMarks.push_back(pDoc->GetRefMark(i));
+}
+
+std::sort(aRefMarks.begin(), aRefMarks.end(),
+  [](const SwFormatRefMark* pMark1, const SwFormatRefMark* pMark2) 
-> bool {
+  const SwTextRefMark* pTextRefMark1 = 
pMark1->GetTextRefMark();
+  const SwTextRefMark* pTextRefMark2 = 
pMark2->GetTextRefMark();
+  SwPosition 
aPos1(const_cast(pTextRefMark1->GetTextNode()),
+   pTextRefMark1->GetStart());
+  SwPosition 
aPos2(const_cast(pTextRefMark2->GetTextNode()),
+   pTextRefMark2->GetStart());
+  return aPos1 < aPos2;
+  });
+
 sal_uInt16 nFieldIndex = 0;
-for (sal_uInt16 nRefMark = 0; nRefMark < pDoc->GetRefMarks(); ++nRefMark)
+for (auto& pIntermediateRefMark : aRefMarks)
 {
-auto pRefMark = 
const_cast(pDoc->GetRefMark(nRefMark));
+auto pRefMark = const_cast(pIntermediateRefMark);
 if (!pRefMark->GetRefName().startsWith(rNamePrefix))
 {
 continue;
commit 2eb4e5852db9a756809fe2dda9849a9423b66d1b
Author: Miklos Vajna 
AuthorDate: Fri Jan 6 13:35:21 2023 +0100
Commit: Andras Timar 
CommitDate: Sun Jan 8 12:15:48 2023 +

sw lok: get all refmarks: sort the refmarks array

This was using the order used by GetItemSurrogates(), which is mostly by
pointer address.

We know that these pool items have a text attribute, which have a node
and a content index, sort by that.

In theory two refmark may start at the same doc model position, but
that's never the case when using Zotero, so don't worry about that for
now.

For a document with 5 refmarks, the original order I got was 2-3-5-4-1,
now it's properly 1-2-3-4-5.

(cherry picked from commit 5a2ee5ba893b6b8f4e7fd6623b7f10faf0bda509)

Change-Id: I2768845414bd36afca91ec02a0f3364c246ddfd9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145149
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx
index 41866636a969..02bacf5b02f1 100644
--- a/sw/qa/uibase/uno/uno.cxx
+++ b/sw/qa/uibase/uno/uno.cxx
@@ -217,14 +217,21 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testGetBookmarks)
 CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testGetFields)
 {
 // Given a document with a refmark:
-createSwDoc();
-uno::Sequence aArgs = {
-comphelper::makePropertyValue("TypeName", 
uno::Any(OUString("SetRef"))),
-comphelper::makePropertyValue(
-"Name", uno::Any(OUString("ZOTERO_ITEM CSL_CITATION {} 
RNDpyJknp173F"))),
-comphelper::makePropertyValue("Content", 
uno::Any(OUString("mycontent"))),
-};
-dispatchCommand(mxComponent, ".uno:InsertField", aArgs);
+SwDoc* pDoc = createSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+OUString aName("ZOTERO_ITEM CSL_CITATION {} ");
+for (int i = 0; i < 5; ++i)
+{
+uno::Sequence aArgs = {
+comphelper::makePropertyValue("TypeName", 
uno::Any(OUString("SetRef"))),
+comphelper::makePropertyValue("Name", uno::Any(aName + 
OUString::number(i + 1))),
+comphelper::makePropertyValue("Content", 
uno::Any(OUString("mycontent"))),
+};
+dispatchCommand(mxComponent, ".uno:InsertField", aArgs);
+pWrtShell->SttEndDoc(/*bStt=*/false);
+pWrtShell->SplitNode();
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/qa sw/source

2023-01-02 Thread Miklos Vajna (via logerrit)
 sw/qa/core/text/data/number-portion-format.odt  |binary
 sw/qa/core/text/text.cxx|   18 +
 sw/qa/extras/ooxmlexport/data/number-portion-format.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx  |   20 ++
 sw/source/core/text/txtfld.cxx  |   22 
 sw/source/filter/ww8/docxattributeoutput.cxx|2 -
 sw/source/filter/ww8/wrtw8nds.cxx   |   15 +-
 7 files changed, 74 insertions(+), 3 deletions(-)

New commits:
commit 6f4836ae8b72a4f4a5f7a8cb7d32a435a4b96be6
Author: Miklos Vajna 
AuthorDate: Fri Oct 28 16:39:31 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue Jan 3 07:01:35 2023 +

DOCX export, numbering portion format: consider full-para char formats as 
well

The bugdoc had a single paragraph with direct formatting (24pt font
size), numbering enabled and a bookmark covering half of the paragraph.
The numbering had default font size in the DOCX export result, not
inheriting from the paragraph.

In case the bookmark is removed, then the custom font size is not an
autoformat set on the whole text of the paragraph but rather a format on
the paragraph level, which does influence the formatting of the
numbering portion via the paragraph marker formatting, as expected.

Fix the problem in a way similar to what was done in commit
cb0e1b52d68aa6d5b505f91cb4ce577f7f3b2a8f (sw, numbering portion format:
consider full-para char formats as well, 2022-10-20), except that was
for the rendering and this is for the DOCX export.

This also required filtering out grab-bags in
lcl_writeParagraphMarkerProperties(), otherwise citation SDTs show up in
the export result at unexpected places, as shown by
CppunitTest_sw_ooxmlexport14's testTdf129353.

(cherry picked from commit f546f7573158e52359bbeae6194a83a1ff8ac52c)

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport18.cxx

Change-Id: I7bb88e290f2a370d78ecc894f306bcb0a403545f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142103
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144958
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlexport/data/number-portion-format.odt 
b/sw/qa/extras/ooxmlexport/data/number-portion-format.odt
new file mode 100644
index ..3047153b63af
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/number-portion-format.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index c0d3e7c6d161..a77e2ec98ca4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -115,6 +115,26 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152200)
 assertXPath(pXmlDoc, "//w:fldChar", 3); // no field characters elsewhere
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testNumberPortionFormatFromODT)
+{
+// Given a document with a single paragraph, direct formatting asks 24pt 
font size for the
+// numbering and the text portion:
+load(DATA_DIRECTORY, "number-portion-format.odt");
+
+// When saving to DOCX:
+save("Office Open XML Text", maTempFile);
+mbExported = true;
+
+// Then make sure that the paragraph marker's char format has that custom 
font size:
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 0
+// - XPath '//w:pPr/w:rPr/w:sz' number of nodes is incorrect
+// i.e.  was missing under 's .
+assertXPath(pXmlDoc, "//w:pPr/w:rPr/w:sz", "val", "48");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index b190bf38e581..0bff96233ce4 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1407,7 +1407,7 @@ void 
lcl_writeParagraphMarkerProperties(DocxAttributeOutput& rAttributeOutput, c
 bool bFontSizeWritten = false;
 while (nWhichId)
 {
-if (rParagraphMarkerProperties.GetItemState(nWhichId, true, ) == 
SfxItemState::SET)
+if (rParagraphMarkerProperties.GetItemState(nWhichId, true, ) == 
SfxItemState::SET && nWhichId != RES_CHRATR_GRABBAG)
 {
 if (isCHRATR(nWhichId) || nWhichId == RES_TXTATR_CHARFMT)
 {
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index 89fe95801f85..42036c163eca 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -3211,6 +3211,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
 }
 else if (const 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/qa sw/source

2022-09-28 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/data/inline-sdt-header.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |6 +++
 sw/qa/filter/ww8/ww8.cxx |   31 +++
 sw/source/filter/ww8/docxattributeoutput.cxx |7 
 sw/source/filter/ww8/docxattributeoutput.hxx |2 +
 5 files changed, 46 insertions(+)

New commits:
commit e77b511b699feaffd14c0053c258cdfdf3042ccc
Author: Miklos Vajna 
AuthorDate: Tue Sep 27 14:05:10 2022 +0200
Commit: Miklos Vajna 
CommitDate: Wed Sep 28 08:16:18 2022 +0200

DOCX export: fix not-well-formed XML when hyperlink end is a textbox anchor

We failed to save a document which contained anchored text and the
anchor position was inside a hyperlink.

The problem was that the hyperlink covered content which has anchored
text, so when the text inside the shape ended its paragraph, it wanted
to finish the hyperlink that was started outside the shape, which is not
well-formed XML. This was a problem since
7246e57216bb20c15af0ecf6a0183f5ffa81e780 (tdf#143591 DOCX import: handle
anchored objects as at-char, 2021-09-20), previously we lost the
character position of such anchor positions, so in practice this problem
was not visible.

Fix this similarly how we stash away the current state when entering a
table cell: just save / restore the number of hyperlinks we have to
close, that'll close the hyperlink outside the shape.

Note that the source document has the hyperlink outside the shape's
anchor, while we include the shape inside the hyperlink, but that
doesn't cause problems in practice.

(cherry picked from commit a825e23a2980fcb3d970834c4ce1f8403fb93054)

Change-Id: I711fad2336fd78e2ba709c3fc0a4f75de32aae8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140656
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx
index d537cee04188..44ef994bf412 100644
--- a/sw/qa/filter/ww8/ww8.cxx
+++ b/sw/qa/filter/ww8/ww8.cxx
@@ -83,6 +83,37 @@ CPPUNIT_TEST_FIXTURE(Test, 
testDocxComboBoxContentControlExport)
 // i.e. the combo box content control was turned into a drop-down one on 
export.
 assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:comboBox", 1);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testDocxHyperlinkShape)
+{
+// Given a document with a hyperlink at char positions 0 -> 6 and a shape 
with text anchored at
+// char position 6:
+mxComponent = loadFromDesktop("private:factory/swriter");
+uno::Reference xMSF(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+xText->insertString(xCursor, "beforeafter", /*bAbsorb=*/false);
+xCursor->gotoStart(/*bExpand=*/false);
+xCursor->goRight(/*nCount=*/6, /*bExpand=*/true);
+uno::Reference xCursorProps(xCursor, uno::UNO_QUERY);
+xCursorProps->setPropertyValue("HyperLinkURL", 
uno::Any(OUString("http://www.example.com/;)));
+xCursor->gotoStart(/*bExpand=*/false);
+xCursor->goRight(/*nCount=*/6, /*bExpand=*/false);
+uno::Reference xFactory(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xShape(
+xFactory->createInstance("com.sun.star.drawing.RectangleShape"), 
uno::UNO_QUERY);
+xShape->setSize(awt::Size(5000, 5000));
+uno::Reference xShapeProps(xShape, uno::UNO_QUERY);
+xShapeProps->setPropertyValue("AnchorType", 
uno::Any(text::TextContentAnchorType_AT_CHARACTER));
+uno::Reference xShapeContent(xShape, uno::UNO_QUERY);
+xText->insertTextContent(xCursor, xShapeContent, /*bAbsorb=*/false);
+xShapeProps->setPropertyValue("TextBox", uno::Any(true));
+
+// When saving this document to DOCX, then make sure we don't crash on 
export (due to an
+// assertion failure for not-well-formed XML output):
+save("Office Open XML Text", maTempFile);
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index ac1882e8d20c..7862a57b8394 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6918,6 +6918,9 @@ void 
DocxAttributeOutput::pushToTableExportContext(DocxTableExportContext& rCont
 m_aParagraphSdt.m_bStartedSdt = false;
 rContext.m_bStartedRunSdt = m_aRunSdt.m_bStartedSdt;
 m_aRunSdt.m_bStartedSdt = false;
+
+rContext.m_nHyperLinkCount = m_nHyperLinkCount;
+m_nHyperLinkCount = 0;
 }
 
 void DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext 
const & rContext)
@@ -6927,6 +6930,7 @@ void 
DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext const
 m_tableReference->m_nTableDepth = rContext.m_nTableDepth;
 m_aParagraphSdt.m_bStartedSdt = 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/qa sw/source

2022-04-22 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   34 ++
 sw/source/filter/ww8/attributeoutputbase.hxx |6 +++
 sw/source/filter/ww8/docxattributeoutput.cxx |   41 +++
 sw/source/filter/ww8/docxattributeoutput.hxx |   11 +++
 sw/source/filter/ww8/wrtw8nds.cxx|   19 
 5 files changed, 111 insertions(+)

New commits:
commit 7c146a4dfaaf4c8e295803d1deb4d8d0be9cc9d5
Author: Miklos Vajna 
AuthorDate: Wed Apr 13 08:34:33 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri Apr 22 14:59:12 2022 +0200

sw content controls, DOCX export: handle SDT end at para end

Once the DOCX import maps Run SDTs to SwContentControl,

make -C sw -sr CppunitTest_sw_ooxmlexport17 
CPPUNIT_TEST_NAME=testTdf148361

starts to fail without this fix. Previously we only tested
SwContentControl end in the middle of a paragraph. Fix the paragraph end
case similar to how hyperlinks are handled to be consistent.

(cherry picked from commit ada2d449175afd9a6aa1db9281739e5ad6ac6fef)

Change-Id: I0633ca8d7d909a2cb3c70e7edce3a85df5fac3f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133318
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1caa49ed4036..038a5bd86520 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -368,7 +368,10 @@ void DocxAttributeOutput::StartContentControl(const 
SwFormatContentControl& rFor
 m_pContentControl = rFormatContentControl.GetContentControl();
 }
 
-void DocxAttributeOutput::EndContentControl() { ++m_nCloseContentControl; }
+void DocxAttributeOutput::EndContentControl()
+{
+++m_nCloseContentControlInThisRun;
+}
 
 static void checkAndWriteFloatingTables(DocxAttributeOutput& 
rDocxAttributeOutput)
 {
@@ -1629,8 +1632,9 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, 
sal_Int32 nPos, bool /
 m_bEndCharSdt = false;
 }
 
-for (; m_nCloseContentControl > 0; --m_nCloseContentControl)
+for (; m_nCloseContentControlInPreviousRun > 0; 
--m_nCloseContentControlInPreviousRun)
 {
+// Not the last run of this paragraph.
 m_pSerializer->endElementNS(XML_w, XML_sdtContent);
 m_pSerializer->endElementNS(XML_w, XML_sdt);
 }
@@ -1855,6 +1859,13 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, bool /
 m_pRedlineData = nullptr;
 }
 
+for (; m_nCloseContentControlInThisRun > 0; 
--m_nCloseContentControlInThisRun)
+{
+// Last run of this paragraph.
+m_pSerializer->endElementNS(XML_w, XML_sdtContent);
+m_pSerializer->endElementNS(XML_w, XML_sdt);
+}
+
 if ( m_closeHyperlinkInThisRun )
 {
 if ( m_startedHyperlink )
@@ -3267,6 +3278,10 @@ void DocxAttributeOutput::RunText( const OUString& 
rText, rtl_TextEncoding /*eCh
 {
 m_closeHyperlinkInPreviousRun = true;
 }
+if (m_nCloseContentControlInThisRun > 0)
+{
+++m_nCloseContentControlInPreviousRun;
+}
 m_bRunTextIsOn = true;
 // one text can be split into more blah's by line breaks etc.
 const sal_Unicode *pBegin = rText.getStr();
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 6a486dc76f6a..88ed18db6a6b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -911,7 +911,8 @@ private:
 o3tl::sorted_vector m_aFloatingTablesOfParagraph;
 sal_Int32 m_nTextFrameLevel;
 
-sal_Int32 m_nCloseContentControl = 0;
+sal_Int32 m_nCloseContentControlInThisRun = 0;
+sal_Int32 m_nCloseContentControlInPreviousRun = 0;
 
 // close of hyperlink needed
 bool m_closeHyperlinkInThisRun;
commit 856667fa9b36701ba1ff4a45b3a5e505c37a2f26
Author: Miklos Vajna 
AuthorDate: Tue Apr 12 08:25:16 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri Apr 22 14:58:57 2022 +0200

sw content controls: add initial DOCX export

Wrap the text portions inside the content control inside 
and . Also map the (so far) single property of it to
.

This is just initial export for inline text content controls, more
properties are to be added in follow-up commits.

(cherry picked from commit b40f9c536c1cefae8404a3f1c0080473151913d2)

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport17.cxx

Change-Id: I21e085496b4c79114b158656c5611aff8ffdd08a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133317
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 9a31041d6465..a3bd1a18094f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/qa sw/source

2022-03-31 Thread Miklos Vajna (via logerrit)
 sw/qa/core/text/text.cxx   |   52 +
 sw/qa/unit/swmodeltestbase.cxx |6 ++--
 sw/source/core/inc/txtfly.hxx  |   11 ++--
 sw/source/core/text/inftxt.cxx |   27 -
 sw/source/core/text/porrst.cxx |2 -
 sw/source/core/text/txtfly.cxx |   37 +++--
 6 files changed, 115 insertions(+), 20 deletions(-)

New commits:
commit 6c6d9a5457af20f14a0e6344efa19b93e0f7c026
Author: Miklos Vajna 
AuthorDate: Mon Mar 28 08:45:53 2022 +0200
Commit: Miklos Vajna 
CommitDate: Thu Mar 31 13:10:25 2022 +0200

sw clearing breaks: add layout support for the left and right cases

This means that the vertical position calculated in SwTextFly now depend
son the horizontal position of the break portion, so it doesn't make
sense to cache it.

(cherry picked from commit e799ebfd7a2deab13b47092807335670abb7b485)

Change-Id: I4e30bb12d9ba117d3af065881a65a1c2001e1164
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132353
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 9987fac58a3f..0923758694b8 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -293,6 +293,58 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testClearingLineBreakAtStart)
 assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", "1024");
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testClearingLineBreakLeft)
+{
+// Given a document with two anchored objects (left height is 5cm, right 
height is 7.5cm) and a
+// clearing break (type=left):
+loadURL("private:factory/swriter", nullptr);
+uno::Reference xFactory(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xDocument(mxComponent, uno::UNO_QUERY);
+uno::Reference xText = xDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+{
+uno::Reference xShape(
+xFactory->createInstance("com.sun.star.drawing.RectangleShape"), 
uno::UNO_QUERY);
+xShape->setSize(awt::Size(5000, 5000));
+uno::Reference xShapeProps(xShape, 
uno::UNO_QUERY);
+xShapeProps->setPropertyValue("AnchorType",
+  
uno::makeAny(text::TextContentAnchorType_AT_CHARACTER));
+uno::Reference xShapeContent(xShape, 
uno::UNO_QUERY);
+xText->insertTextContent(xCursor, xShapeContent, /*bAbsorb=*/false);
+}
+{
+uno::Reference xShape(
+xFactory->createInstance("com.sun.star.drawing.RectangleShape"), 
uno::UNO_QUERY);
+xShape->setSize(awt::Size(5000, 7500));
+uno::Reference xShapeProps(xShape, 
uno::UNO_QUERY);
+xShapeProps->setPropertyValue("AnchorType",
+  
uno::makeAny(text::TextContentAnchorType_AT_CHARACTER));
+xShapeProps->setPropertyValue("HoriOrientPosition", 
uno::makeAny(sal_Int32(1)));
+uno::Reference xShapeContent2(xShape, 
uno::UNO_QUERY);
+xText->insertTextContent(xCursor, xShapeContent2, /*bAbsorb=*/false);
+}
+uno::Reference xLineBreak(
+xFactory->createInstance("com.sun.star.text.LineBreak"), 
uno::UNO_QUERY);
+uno::Reference xLineBreakProps(xLineBreak, 
uno::UNO_QUERY);
+auto eClear = static_cast(SwLineBreakClear::LEFT);
+xLineBreakProps->setPropertyValue("Clear", uno::makeAny(eClear));
+xText->insertString(xCursor, "foo", /*bAbsorb=*/false);
+xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
+xText->insertString(xCursor, "bar", /*bAbsorb=*/false);
+
+// When laying out that document:
+calcLayout();
+
+// Then make sure the "bar" jumps down below the left shape, but not below 
the right shape (due
+// to type=left):
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 2837
+// - Actual  : 4254
+// i.e. any non-none type was handled as type=all, and this was jumping 
below both shapes.
+assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", "2837");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx
index ee35a1cc7259..28ee075120fa 100644
--- a/sw/qa/unit/swmodeltestbase.cxx
+++ b/sw/qa/unit/swmodeltestbase.cxx
@@ -218,9 +218,9 @@ xmlDocUniquePtr SwModelTestBase::parseLayoutDump()
 if (!mpXmlBuffer)
 dumpLayout(mxComponent);
 
-return xmlDocUniquePtr(
-xmlParseMemory(reinterpret_cast(xmlBufferContent(mpXmlBuffer)),
-   xmlBufferLength(mpXmlBuffer)));
+auto pBuffer = reinterpret_cast(xmlBufferContent(mpXmlBuffer));
+SAL_INFO("sw", "SwModelTestBase::parseLayoutDump: pBuffer is '" << pBuffer 
<< "'");
+return xmlDocUniquePtr(xmlParseMemory(pBuffer, 
xmlBufferLength(mpXmlBuffer)));
 }