[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/qa writerfilter/source

2023-04-18 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf154481.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|5 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |9 +
 3 files changed, 14 insertions(+)

New commits:
commit 4304ac507781a258c8e72390a90a9672b840546a
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Apr 6 13:34:42 2023 +0200
Commit: László Németh 
CommitDate: Tue Apr 18 19:30:46 2023 +0200

tdf#154481 sw DOCX import: fix page loss and freezing at ODT export

Disable TOC creation in case when field context stack
is empty but TOC creation is in progress in textboxes.
Before if TOC creation failed because it is already
existed, the TOC creation member (mbStartTOC) kept
true resulting in broken textbox handling.

Textbox and TOC import use the same text append
stack but the TOC was not removed from the stack
so content have been written into the TOC instead
of the textbox, resulting page loss, and because
of the broken structure, freezing at further ODT export.

Change-Id: If27aa477c49f276d4e538b6e125798d89f0ac423
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150099
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 94de79e7d3c980b576192d2f264bee658716163a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150319
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf154481.docx 
b/sw/qa/extras/ooxmlexport/data/tdf154481.docx
new file mode 100644
index ..bfbfeda7687a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf154481.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 0ff6256fc3b8..11bbfa86541b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -988,6 +988,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148132, "tdf148132.docx")
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf154481, "tdf154481.docx")
+{
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing pages!", 7, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149200)
 {
 loadAndSave("tdf149200.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d422240348d5..ae0a8a27da12 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4906,6 +4906,15 @@ void DomainMapper_Impl::PushTextBoxContent()
 if (m_bIsInTextBox)
 return;
 
+// tdf#154481: check for TOC creation with empty field stack,
+// and close TOC, unless pages will lost. FIXME.
+if (IsInTOC() && m_aFieldStack.size() == 0)
+{
+m_bStartTOC = false;
+SAL_WARN("writerfilter.dmapper",
+ "broken TOC creation in textbox, but field stack is empty, so 
closing TOC!");
+}
+
 try
 {
 uno::Reference xTBoxFrame(


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sw/qa writerfilter/source

2023-04-13 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf154481.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|6 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |9 +
 3 files changed, 15 insertions(+)

New commits:
commit 9d4cb8c356c0f83c81dc8e96b3e96e3c009a19f6
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Apr 6 13:34:42 2023 +0200
Commit: László Németh 
CommitDate: Thu Apr 13 22:54:54 2023 +0200

tdf#154481 sw DOCX import: fix page loss and freezing at ODT export

Disable TOC creation in case when field context stack
is empty but TOC creation is in progress in textboxes.
Before if TOC creation failed because it is already
existed, the TOC creation member (mbStartTOC) kept
true resulting in broken textbox handling.

Textbox and TOC import use the same text append
stack but the TOC was not removed from the stack
so content have been written into the TOC instead
of the textbox, resulting page loss, and because
of the broken structure, freezing at further ODT export.

Change-Id: If27aa477c49f276d4e538b6e125798d89f0ac423
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150099
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 94d6e1d9b30aee7ec78de3b4a4a208701b2a4976)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150318
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf154481.docx 
b/sw/qa/extras/ooxmlexport/data/tdf154481.docx
new file mode 100644
index ..bfbfeda7687a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf154481.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 7b31df3395cf..ebb5ae15a87e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -1077,6 +1077,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148132, "tdf148132.docx")
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf154481)
+{
+createSwDoc("tdf154481.docx");
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing pages!", 7, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149200)
 {
 loadAndSave("tdf149200.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3b774608756a..ac080656a98a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5046,6 +5046,15 @@ void DomainMapper_Impl::PushTextBoxContent()
 if (m_bIsInTextBox)
 return;
 
+// tdf#154481: check for TOC creation with empty field stack,
+// and close TOC, unless pages will lost. FIXME.
+if (IsInTOC() && m_aFieldStack.size() == 0)
+{
+m_bStartTOC = false;
+SAL_WARN("writerfilter.dmapper",
+ "broken TOC creation in textbox, but field stack is empty, so 
closing TOC!");
+}
+
 try
 {
 uno::Reference xTBoxFrame(


[Libreoffice-commits] core.git: sw/qa writerfilter/source

2023-04-13 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf154481.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|6 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |9 +
 3 files changed, 15 insertions(+)

New commits:
commit 94de79e7d3c980b576192d2f264bee658716163a
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Apr 6 13:34:42 2023 +0200
Commit: László Németh 
CommitDate: Thu Apr 13 17:18:58 2023 +0200

tdf#154481 sw DOCX import: fix page loss and freezing at ODT export

Disable TOC creation in case when field context stack
is empty but TOC creation is in progress in textboxes.
Before if TOC creation failed because it is already
existed, the TOC creation member (mbStartTOC) kept
true resulting in broken textbox handling.

Textbox and TOC import use the same text append
stack but the TOC was not removed from the stack
so content have been written into the TOC instead
of the textbox, resulting page loss, and because
of the broken structure, freezing at further ODT export.

Change-Id: If27aa477c49f276d4e538b6e125798d89f0ac423
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150099
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf154481.docx 
b/sw/qa/extras/ooxmlexport/data/tdf154481.docx
new file mode 100644
index ..bfbfeda7687a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf154481.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 890f1104ee9b..fed8066f87f8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -1083,6 +1083,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148132, "tdf148132.docx")
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf154481)
+{
+createSwDoc("tdf154481.docx");
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing pages!", 7, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149200)
 {
 loadAndSave("tdf149200.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6a7e9a405ee1..f76ca11b01a1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5189,6 +5189,15 @@ void DomainMapper_Impl::PushTextBoxContent()
 if (m_bIsInTextBox)
 return;
 
+// tdf#154481: check for TOC creation with empty field stack,
+// and close TOC, unless pages will lost. FIXME.
+if (IsInTOC() && m_aFieldStack.size() == 0)
+{
+m_bStartTOC = false;
+SAL_WARN("writerfilter.dmapper",
+ "broken TOC creation in textbox, but field stack is empty, so 
closing TOC!");
+}
+
 try
 {
 uno::Reference xTBoxFrame(


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

2023-01-17 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf66039.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|   30 +--
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|   12 +++
 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 +--
 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 
 20 files changed, 207 insertions(+), 55 deletions(-)

New commits:
commit c4f3aa127ad33fe691b00336cdc9d6c88a9ebfb9
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Nov 11 14:02:12 2021 +0100
Commit: Mike Kaganski 
CommitDate: Tue Jan 17 09:29:15 2023 +

tdf#66039 DOCX: import textboxes (with tables, images etc.) in group shapes

Text boxes in group shapes were imported as shapes, losing
complex text content: tables (tdf#66039), colors (tdf#73022),
images (tdf#81958), lists, paragraph styles, hyperlinks
(tdf#122960) and track changes.

Note: a few unit tests have been deactivated temporarily.
Test document "groupshape-trackedchanges.docx" of
testGroupshapeTrackedchanges is imported correctly now:
with track changes, and the test was modified accordingly.

Follow-up to commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

Change-Id: I6eb918dbf64393fd723fe43f798f93b5b9a12575
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125051
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143371
Tested-by: Miklos Vajna 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf66039.docx 
b/sw/qa/extras/ooxmlexport/data/tdf66039.docx
new file mode 100644
index ..f17032b3f90b
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf66039.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 3dafae143432..cfeafa71170b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -439,13 +439,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf59274)
 // This was 3674: too wide last cell in first row
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[4]/w:tcPr/w:tcW", "w", "1695");
 }
-
-DECLARE_OOXMLEXPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
-{
-uno::Reference xGroupShape(getShape(1), uno::UNO_QUERY);
-// The text in the groupshape was missing due to the w:sdt and 
w:sdtContent wrapper around it.
-CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), 
uno::Reference(xGroupShape->getByIndex(1), 
uno::UNO_QUERY_THROW)->getString());
-}
+//FIXME:
+//DECLARE_OOXMLEXPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
+//{
+//uno::Reference xGroupShape(getShape(1), 
uno::UNO_QUERY);
+//// The text in the groupshape was missing due to the w:sdt and 
w:sdtContent wrapper around it.
+//CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), 
uno::Reference(xGroupShape->getByIndex(1), 
uno::UNO_QUERY_THROW)->getString());
+//}
 
 DECLARE_OOXMLEXPORT_TEST(testDmlCharheightDefault, 
"dml-charheight-default.docx")
 {
@@ -745,9 +745,21 @@ DECLARE_OOXMLEXPORT_TEST(testCaption, "caption.docx")
 DECLARE_OOXMLEXPORT_TEST(testGroupshapeTrackedchanges, 
"groupshape-trackedchanges.docx")
 {
 uno::Reference xGroup(getShape(1), uno::UNO_QUERY);
-uno::Reference xShape(xGroup->getByIndex(0), 
uno::UNO_QUERY);
+uno::Reference xShape(xGroup->getByIndex(0), 
uno::UNO_QUERY);
 // Shape text was completely missing, ensure inserted text is available.
-CPPUNIT_ASSERT_EQUAL(OUString(" Inserted"), xShape->getString());
+uno::Reference xText
+= uno::Reference(xShape, 
uno::UNO_QUERY_THROW)->getText();
+auto xParagraph = getParagraphOfText(1, xText);
+
+CPPUNIT_ASSERT(hasProperty(getRun(xParagraph, 1), "RedlineType"));
+CPPUNIT_ASSERT_EQUAL(OUString("Delete"),
+  

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

2023-01-17 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx   |4 -
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   49 +++
 sw/source/core/doc/textboxhelper.cxx |   15 ---
 sw/source/core/draw/dcontact.cxx |8 +++
 5 files changed, 68 insertions(+), 8 deletions(-)

New commits:
commit 0cb370d02bebf6a9d65b5852815e2c617b33a89a
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jan 11 12:09:46 2022 +0100
Commit: Miklos Vajna 
CommitDate: Tue Jan 17 09:26:33 2023 +

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

A missing function resulted covered textboxes which weren't
visible in group shapes.

Follow-up to 121cbc250b36290f0f8c7265fea57256dad69553
"tdf#66039 DOCX: import textboxes (with tables, images etc.)
in group shapes".

Change-Id: I08eb1c1cf4a4f4769af8812500b9cf9778b01e9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128279
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143372
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx 
b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx
new file mode 100644
index ..664f47a0b623
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index e23a42bf4983..3dafae143432 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(1, getShapes());
+CPPUNIT_ASSERT_EQUAL(2, getShapes());
 
-auto MyShape = getShape(1);
+auto MyShape = getShape(2);
 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 395f0dbf03fc..42b7a0891877 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 
 #include 
@@ -28,6 +29,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -390,6 +392,53 @@ 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"), 
uno::UNO_QUERY_THROW);
+
+// Assert that the textbox ZOrder greater than the groupshape
+
CPPUNIT_ASSERT_GREATER(xGroupProperties->getPropertyValue("ZOrder").get(),
+
xTextBoxFrameProperties->getPropertyValue("ZOrder").get());
+// Before the fix, this failed because that was less, and the 
textboxes were covered.
+}
+
+}
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, "tdf123642.docx")
 {
 // get bookmark interface
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index bcdf25002305..bb1d6f331dbc 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1432,15 +1432,20 @@ bool 
SwTextBoxHelper::DoTextBoxZOrderCorrection(SwFrameFormat* pShape, const Sdr
 {
 // TODO: do this with group shape textboxes.
 SdrObject* pShpObj = nullptr;
-//if (pObj)
-//pShpObj = pObj;
-//else
+
 

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

2023-01-17 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |   11 +++
 sw/qa/extras/uiwriter/data/tdf149550.docx|binary
 sw/qa/extras/uiwriter/uiwriter4.cxx  |   25 
 sw/source/core/doc/DocumentLayoutManager.cxx |   65 +
 sw/source/core/doc/textboxhelper.cxx |   81 ++-
 5 files changed, 120 insertions(+), 62 deletions(-)

New commits:
commit d981737bcebf825949cd8b13c2c609a109abc984
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jun 14 10:38:46 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue Jan 17 09:25:29 2023 +

tdf#149550 sw: fix crash by implementing nested textbox copy

Grouped shapes with a nested textbox were copied without
the textbox with frequent crashing.

Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

Change-Id: Ie2cc24f10706d8999026dc92ebad21f2c5673003
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135815
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143370
Tested-by: Miklos Vajna 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index a389634c60eb..b0ab5618b466 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -27,6 +27,7 @@ class SdrObject;
 class SfxItemSet;
 class SwFrameFormat;
 class SwFrameFormats;
+class SwFormatAnchor;
 class SwFormatContent;
 class SwDoc;
 namespace tools
@@ -204,6 +205,8 @@ class SwTextBoxNode
 // (and the textboxes)
 SwFrameFormat* m_pOwnerShapeFormat;
 
+mutable bool m_bIsCloningInProgress;
+
 public:
 // Not needed.
 SwTextBoxNode() = delete;
@@ -251,6 +254,14 @@ public:
 size_t GetTextBoxCount() const { return m_pTextBoxes.size(); };
 // Returns with a const collection of textboxes owned by this node.
 std::map GetAllTextBoxes() const;
+
+void Clone(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* 
o_pTarget, bool bSetAttr,
+   bool bMakeFrame) const;
+
+private:
+void Clone_Impl(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* 
o_pTarget,
+const SdrObject* pSrcObj, SdrObject* pDestObj, bool 
bSetAttr,
+bool bMakeFrame) const;
 };
 
 #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX
diff --git a/sw/qa/extras/uiwriter/data/tdf149550.docx 
b/sw/qa/extras/uiwriter/data/tdf149550.docx
new file mode 100644
index ..3434fc1fff93
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf149550.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index fc7bd27e3124..76f0506d52fa 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -292,6 +292,7 @@ public:
 void testInsertPdf();
 void testTdf143760WrapContourToOff();
 void testHatchFill();
+void testNestedGroupTextBoxCopyCrash();
 
 CPPUNIT_TEST_SUITE(SwUiWriterTest4);
 CPPUNIT_TEST(testTdf96515);
@@ -417,6 +418,7 @@ public:
 CPPUNIT_TEST(testInsertPdf);
 CPPUNIT_TEST(testTdf143760WrapContourToOff);
 CPPUNIT_TEST(testHatchFill);
+CPPUNIT_TEST(testNestedGroupTextBoxCopyCrash);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -4140,6 +4142,29 @@ void SwUiWriterTest4::testHatchFill()
 CPPUNIT_ASSERT_EQUAL(sal_Int32(30), getProperty(getShape(1), 
"FillTransparence"));
 }
 
+void SwUiWriterTest4::testNestedGroupTextBoxCopyCrash()
+{
+createSwDoc(DATA_DIRECTORY, "tdf149550.docx");
+
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+Scheduler::ProcessEventsToIdle();
+dispatchCommand(mxComponent, ".uno:Copy", {});
+Scheduler::ProcessEventsToIdle();
+// This crashed here before the fix.
+SwXTextDocument* pXTextDocument = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pXTextDocument);
+pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE);
+Scheduler::ProcessEventsToIdle();
+dispatchCommand(mxComponent, ".uno:Paste", {});
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_MESSAGE("Where is the doc, it crashed, isn't it?!", 
mxComponent);
+
+auto pLayout = parseLayoutDump();
+// There must be 2 textboxes!
+assertXPath(pLayout, "/root/page/body/txt/anchored/fly[2]");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest4);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx 
b/sw/source/core/doc/DocumentLayoutManager.cxx
index 006501b3aa36..a03d5dc1d60d 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -463,67 +463,6 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
 if( bMakeFrames )
 pDest->MakeFrames();
 
-// If the draw format has a TextBox, then copy its fly format as well.
-if (rSource.Which() == RES_DRAWFRMFMT && 

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

2023-01-17 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/frmfmt.hxx |6 
 sw/inc/textboxhelper.hxx  |   26 -
 sw/qa/extras/ooxmlexport/data/Tdf147485.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|6 
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |   18 -
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |4 
 sw/qa/extras/uiwriter/data/tdf147126.docx |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx   |  132 +
 sw/source/core/doc/DocumentLayoutManager.cxx  |8 
 sw/source/core/doc/docdraw.cxx|   29 +-
 sw/source/core/doc/textboxhelper.cxx  |  373 --
 sw/source/core/draw/dcontact.cxx  |2 
 sw/source/core/frmedt/feshview.cxx|8 
 sw/source/core/layout/atrfrm.cxx  |   31 --
 sw/source/core/text/porfly.cxx|   56 ---
 sw/source/core/undo/undobj1.cxx   |   22 -
 sw/source/core/undo/undraw.cxx|   32 +-
 xmloff/qa/unit/draw.cxx   |2 
 18 files changed, 417 insertions(+), 338 deletions(-)

New commits:
commit 044c63c631f0af832aa8452bc4a8b0b38dc91c23
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Mar 30 13:05:37 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue Jan 17 09:24:56 2023 +

tdf#147485 sw: fix group shape crash using std::shared_ptr

for SwFrameFormat::m_pOtherTextBoxeFormats.
Before there was broken manual handling of this
member, resulting random crashes.

Details: Writer textboxes are textframe + shape
pairs. Accordingly the shape has a draw format,
the frame has a fly format. In case of group
shapes the paired structure doesn't work, because
there is one shape format and many fly formats.
To handle this there is a class (SwTextBoxNode)
which has a small frame format table inside.
This cache gives the possibility to handle
each frame shape pairs inside the group depending
on what SdrObject owns that textbox.

However there is another place where these formats
stored, namely the SpzFrameFormatTable in SwDoc.
The only problem is that, when a flyframe removed,
it has to be deleted from both tables, but if the
DelLayoutFormat() is called, that will call the
~FrameFormat(), and if the format already deleted
from the SwTextBoxNode, there will be double deleting
for the same address, which caused the crash.

To avoid this the following is present:

When fly deletion occurs, first the format is
deleted from the doc, then via the ~SwFrameFomat()
will be deleted from the TextBoxNode. If the deleted
format is a drawing, the whole node will be destructed
via the shared_ptr. Hopefully that will be fine,
without any leak.

Change-Id: I007724695bc035998cb35efeefecd308aae36e85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132308
Reviewed-by: László Németh 
Tested-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143369
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 59aee54a2f4a..808bbb482e5d 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -74,7 +74,7 @@ class SW_DLLPUBLIC SwFrameFormat
 // The assigned SwFrmFmt list.
 SwFrameFormats *m_ffList;
 
-SwTextBoxNode* m_pOtherTextBoxFormat;
+std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats;
 
 struct change_name
 {
@@ -102,8 +102,8 @@ protected:
 
 public:
 
-SwTextBoxNode* GetOtherTextBoxFormat() const { return 
m_pOtherTextBoxFormat; };
-void SetOtherTextBoxFormat(SwTextBoxNode* pNew) { m_pOtherTextBoxFormat = 
pNew; };
+const std::shared_ptr< SwTextBoxNode >& GetOtherTextBoxFormats() const { 
return m_pOtherTextBoxFormats; };
+void SetOtherTextBoxFormats(const std::shared_ptr& rNew) { 
m_pOtherTextBoxFormats = rNew; };
 
 virtual ~SwFrameFormat() override;
 
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index fd194a639bcc..a389634c60eb 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -214,7 +214,7 @@ public:
 ~SwTextBoxNode();
 
 // default copy ctor is enough
-SwTextBoxNode(SwTextBoxNode&) = default;
+SwTextBoxNode(const SwTextBoxNode&) = default;
 
 // This method adds a textbox entry to the shape
 // Parameters:
@@ -225,7 +225,12 @@ public:
 // This will remove the textbox entry.
 // Parameters:
 // pDrawObject: The shape which have the textbox to be deleted.
-void DelTextBox(const SdrObject* pDrawObject);
+void DelTextBox(const SdrObject* pDrawObject, bool bDelFromDoc = false);
+
+// This will remove the textbox entry.
+// Parameters:
+// pTextBox: The textbox what have to be deleted.
+void DelTextBox(const SwFrameFormat* pTextBox, bool bDelFromDoc = false);
 
 // This will return with the frame format of the textbox what 

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

2023-01-17 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/shape/ShapeContextHandler.hxx |5 +-
 oox/source/drawingml/shape.cxx|2 
 oox/source/shape/ShapeContextHandler.cxx  |8 ++-
 oox/source/shape/WpgContext.cxx   |   45 +-
 oox/source/shape/WpgContext.hxx   |8 ++-
 sw/qa/extras/ooxmlexport/data/testWPGtextboxes.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|   21 
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx |7 +-
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |2 
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |4 -
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx |7 +-
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |7 ++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |4 +
 13 files changed, 92 insertions(+), 28 deletions(-)

New commits:
commit b5034017e566cd4e5a236bf59555196598fd01cf
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Nov 10 14:10:11 2021 +0100
Commit: Miklos Vajna 
CommitDate: Tue Jan 17 09:24:12 2023 +

tdf#143574 OOXML export/import of textboxes in group shapes

In this part, oox module has been modified in order to prepare
for WPG handling during OOXML import. Note: Wpg is the drawingML
equivalent of v:group, supporting text boxes in the group.

1) Added new parameter for WpgContext to support nested
Wpg shapes, and WPS enabled for the WPG member shapes.

2) A bug has fixed, where group member line shape and
connector shapes have wrong positions before in the group.

3) Unit tests had to be modified, and 3 of them disabled
temporarily due to missing Writerfilter implementation (what
will be the next commit)

Now group shapes can have textboxes and the text is imported
for that, but complex content is still missing (this will be
fixed in writerfilter by the next commit).

Known issue: WPG shapes with textboxes in floating table
have issues during import at floating table conversion, so until
this is not fixed this function is disabled for shapes in tables
(will be fixed a follow-up commit later).

Follow-up to commit 19394a924fdc486202ca27e318385287eb0df26f
"tdf#143574 sw: textboxes in group shapes -- part 4".

Change-Id: I71032187697807087bd8f27f7c3a7b052e174bd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124964
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143367
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/include/oox/shape/ShapeContextHandler.hxx 
b/include/oox/shape/ShapeContextHandler.hxx
index dadaf7f64cb3..fcd713e4c5a6 100644
--- a/include/oox/shape/ShapeContextHandler.hxx
+++ b/include/oox/shape/ShapeContextHandler.hxx
@@ -96,6 +96,9 @@ public:
 
 void setPosition(const css::awt::Point& rPosition);
 
+const bool& getFullWPGSupport() { return m_bFullWPGSUpport; };
+void setFullWPGSupport(const bool& rbUse) { m_bFullWPGSUpport = rbUse; };
+
 void setDocumentProperties(const 
css::uno::Reference& xDocProps);
 void setMediaDescriptor(const 
css::uno::Sequence& rMediaDescriptor);
 
@@ -110,7 +113,7 @@ private:
 
 ::sal_uInt32 mnStartToken;
 css::awt::Point maPosition;
-
+bool m_bFullWPGSUpport;
 drawingml::ShapePtr mpShape;
 std::shared_ptr< vml::Drawing > mpDrawing;
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 7740c2e153be..2343f8b3b027 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1567,7 +1567,7 @@ Reference< XShape > const & Shape::createAndInsert(
 // These can have a custom geometry, so position should be set here,
 // after creation but before custom shape handling, using the position
 // we got from the caller.
-if (mbWps && aServiceName == "com.sun.star.drawing.LineShape")
+if (mbWps && aServiceName == "com.sun.star.drawing.LineShape" && 
!pParentGroupShape)
 mxShape->setPosition(maPosition);
 
 if( bIsCustomShape )
diff --git a/oox/source/shape/ShapeContextHandler.cxx 
b/oox/source/shape/ShapeContextHandler.cxx
index 09b7d8613ce9..8aa5aad6d869 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -47,7 +47,9 @@ using namespace drawingml;
 
 ShapeContextHandler::ShapeContextHandler(const 
rtl::Reference& xFilterBase) :
   mnStartToken(0),
+  m_bFullWPGSUpport(false),
   mxShapeFilterBase(xFilterBase)
+
 {
 }
 
@@ -139,8 +141,12 @@ uno::Reference const & 
ShapeContextHandler::getWp
 switch (getBaseToken(nElement))
 {
 case XML_wgp:
-mxWpgContext.set(static_cast(new 
WpgContext(*rFragmentHandler)));
+{
+rtl::Reference rContext = new 

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

2023-01-17 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx|   19 +
 sw/inc/unomid.h |3 
 sw/inc/unoprnms.hxx |1 
 sw/qa/extras/layout/data/TextBoxFrame.odt   |binary
 sw/qa/extras/layout/layout2.cxx |   41 
 sw/qa/uitest/data/ComplexGroupShapeTest.odt |binary
 sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py |  127 
 sw/source/core/doc/docdraw.cxx  |   56 -
 sw/source/core/doc/textboxhelper.cxx|  203 +++-
 sw/source/core/draw/dcontact.cxx|6 
 sw/source/core/draw/dview.cxx   |9 
 sw/source/core/unocore/unodraw.cxx  |   77 +--
 sw/source/core/unocore/unomap.cxx   |3 
 13 files changed, 495 insertions(+), 50 deletions(-)

New commits:
commit d4b87c11b451cb08aa950e09efed3cc6fa1422f3
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Nov 30 15:38:26 2021 +0100
Commit: Miklos Vajna 
CommitDate: Tue Jan 17 09:24:00 2023 +

tdf#143574 sw: textboxes in group shapes -- part 4

A new UNO property has been added and implemented
for the filters. This provides the possibility of
assigning textboxes in the filter at import time via UNO.

Follow-up to commit e5650de86072b9db586a4532b5239acda77598c4
"tdf#143574 sw: textboxes in group shapes - part 3 take 2".

Change-Id: I58c445cb7f6d865c1d82dbe68f985e4c11ff832e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126162
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143366
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 924b3e6b5c91..1a0cadabc0e9 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -60,6 +60,9 @@ public:
 /// the original text in the shape will be copied to the frame
 /// The textbox is created for the shape given by the pObject parameter.
 static void create(SwFrameFormat* pShape, SdrObject* pObject, bool 
bCopyText = false);
+/// Sets the given textframe as textbox for the given (group member) shape.
+static void set(SwFrameFormat* pShape, SdrObject* pObject,
+css::uno::Reference xNew);
 /// Destroy a TextBox for a shape. If the format has more textboxes
 /// like group shapes, it will destroy only that textbox what belongs
 /// to the given pObject shape.
diff --git a/sw/inc/unomid.h b/sw/inc/unomid.h
index d249b32fc25a..9f413509ae1c 100644
--- a/sw/inc/unomid.h
+++ b/sw/inc/unomid.h
@@ -151,6 +151,9 @@
 // SwFormatFollowTextFlow
 #define MID_FOLLOW_TEXT_FLOW0
 
+#define MID_TEXT_BOX0
+#define MID_TEXT_BOX_CONTENT1
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 3a8df7c69182..bb3ee1f47b3c 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -74,6 +74,7 @@
 #define UNO_NAME_FOOTER_RIGHT_MARGIN "FooterRightMargin"
 #define UNO_NAME_TEXT_RANGE "TextRange"
 #define UNO_NAME_TEXT_BOX "TextBox"
+#define UNO_NAME_TEXT_BOX_CONTENT "TextBoxContent"
 #define UNO_NAME_NAME "Name"
 #define UNO_NAME_CHAR_STYLE_NAME "CharStyleName"
 #define UNO_NAME_ANCHOR_CHAR_STYLE_NAME "AnchorCharStyleName"
diff --git a/sw/qa/extras/layout/data/TextBoxFrame.odt 
b/sw/qa/extras/layout/data/TextBoxFrame.odt
new file mode 100644
index ..a6155e34fdfb
Binary files /dev/null and b/sw/qa/extras/layout/data/TextBoxFrame.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 466f640b..9fd595eafefc 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -1647,6 +1647,47 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf141220)
 CPPUNIT_ASSERT_LESS(static_cast(15), nTextBoxTop - nShapeTop);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, TestTextBoxChangeViaUNO)
+{
+CPPUNIT_ASSERT(createSwDoc(DATA_DIRECTORY, "TextBoxFrame.odt"));
+// this file has a shape and a frame inside. Try to set up
+// the frame for the shape as textbox. Before this was not
+// implemented. This will be necesary for proper WPG import.
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("There must be a shape and a frame!", 2, 
getShapes());
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("This must be a custom shape!",
+ OUString("com.sun.star.drawing.CustomShape"),
+ getShape(1)->getShapeType());
+CPPUNIT_ASSERT_EQUAL_MESSAGE("This must be a frame shape!", 
OUString("FrameShape"),
+ getShape(2)->getShapeType());
+
+CPPUNIT_ASSERT_MESSAGE("This is not supposed to be a textbox!",
+   !uno::Reference(getShape(1), 
uno::UNO_QUERY_THROW)
+

[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - sw/qa sw/source

2022-07-19 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data/tdf142715.odt |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx  |   34 +++
 sw/source/core/doc/textboxhelper.cxx |   13 +--
 3 files changed, 36 insertions(+), 11 deletions(-)

New commits:
commit 8e75da583db160b15ca55d74b3a2c64b1d034e33
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jun 30 15:48:07 2022 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jul 19 09:45:44 2022 +0200

tdf#142715 sw: fix crash on exit when textbox inserted to table

This reverts commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653
"tdf#130805 SwTextBoxHelper::create: fix frame position in shape"
which caused this regression. That fix is not necessary any more: 
synchronization does the same without crashing.

Note: according to this, unit test of commit 
06e2cbb31d0ea703df872b91eb8eacdcaced7653 wasn't removed.

Change-Id: I45bc15d3cf6a5d93b8c54cb4e68018702e58efff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136674
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 9188d7389c06496905c351a936b85974c1ae516f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136982
Tested-by: Jenkins
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137047

diff --git a/sw/qa/extras/uiwriter/data/tdf142715.odt 
b/sw/qa/extras/uiwriter/data/tdf142715.odt
new file mode 100644
index ..70682a54056c
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf142715.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 068a14113a0b..d4175ccc93a5 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3920,6 +3921,39 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf103612)
 "Text after section");
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testCrashOnExit)
+{
+// Load the bugdoc with a table and a textbox shape inside.
+CPPUNIT_ASSERT(createSwDoc(DATA_DIRECTORY, "tdf142715.odt"));
+// Get the textbox selected
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+auto xShape = getShape(1);
+CPPUNIT_ASSERT(xShape);
+uno::Reference xModel(mxComponent, uno::UNO_QUERY);
+CPPUNIT_ASSERT(xModel);
+uno::Reference xController = 
xModel->getCurrentController();
+CPPUNIT_ASSERT(xController);
+uno::Reference xSelection(xController, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xSelection);
+CPPUNIT_ASSERT(xSelection->select(uno::Any(xShape)));
+CPPUNIT_ASSERT(xSelection->getSelection().hasValue());
+uno::Reference xProperties(xShape, uno::UNO_QUERY);
+// Check if the textbox is selected
+CPPUNIT_ASSERT_EQUAL(true, 
xProperties->getPropertyValue("TextBox").get());
+// Remove the textbox
+dispatchCommand(mxComponent, ".uno:RemoveTextBox", {});
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT_EQUAL(false, 
xProperties->getPropertyValue("TextBox").get());
+// Readd the textbox (to run the textboxhelper::create() method)
+dispatchCommand(mxComponent, ".uno:AddTextBox", {});
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT_EQUAL(true, 
xProperties->getPropertyValue("TextBox").get());
+// save and reload
+reload("writer8", "tdf142715_.odt");
+// Before the fix this crashed here and could not reopen.
+CPPUNIT_ASSERT_MESSAGE("Crash on exit, isn't it?", mxComponent);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf97899)
 {
 SwDoc* pDoc = createSwDoc();
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 418c69927228..413424cb93b0 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -93,17 +93,8 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, 
SdrObject* pObject, bool bCo
 pShape->GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
 uno::Reference 
xTextContentAppend(xTextDocument->getText(),
 
uno::UNO_QUERY);
-try
-{
-uno::Reference XSourceShape(pObject->getUnoShape(),
-uno::UNO_QUERY_THROW);
-xTextContentAppend->insertTextContentWithProperties(
-xTextFrame, uno::Sequence(), 
XSourceShape->getAnchor());
-}
-catch (uno::Exception&)
-{
-xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence());
-}
+xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence());
+
 // Link FLY and DRAW formats, so it becomes a text box (needed for 
syncProperty calls).
 uno::Reference xRealTextFrame(xTextFrame, 
uno::UNO_QUERY);
 auto pTextFrame = dynamic_cast(xRealTextFrame.get());


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/qa sw/source

2022-07-13 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data/tdf142715.odt |binary
 sw/qa/extras/uiwriter/uiwriter6.cxx  |   42 +++
 sw/source/core/doc/textboxhelper.cxx |   13 +
 3 files changed, 44 insertions(+), 11 deletions(-)

New commits:
commit 66fa07371f9db8c1f0d492ccbc493317fae7b3cc
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jun 30 15:48:07 2022 +0200
Commit: László Németh 
CommitDate: Wed Jul 13 09:25:30 2022 +0200

tdf#142715 sw: fix crash on exit when textbox inserted to table

This reverts commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653
"tdf#130805 SwTextBoxHelper::create: fix frame position in shape"
which caused this regression. That fix is not necessary any more: 
synchronization does the same without crashing.

Note: according to this, unit test of commit 
06e2cbb31d0ea703df872b91eb8eacdcaced7653 wasn't removed.

Change-Id: I45bc15d3cf6a5d93b8c54cb4e68018702e58efff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136674
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 9188d7389c06496905c351a936b85974c1ae516f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136982
Tested-by: Jenkins

diff --git a/sw/qa/extras/uiwriter/data/tdf142715.odt 
b/sw/qa/extras/uiwriter/data/tdf142715.odt
new file mode 100644
index ..70682a54056c
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf142715.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index e52e16abba71..6a341088d8e6 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -31,6 +31,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2055,6 +2056,47 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, 
testNestedGroupTextBoxCopyCrash)
 assertXPath(pLayout, "/root/page/body/txt/anchored/fly[2]");
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testCrashOnExit)
+{
+// Load the bugdoc with a table and a textbox shape inside.
+CPPUNIT_ASSERT(createSwDoc(DATA_DIRECTORY, "tdf142715.odt"));
+
+// Get the textbox selected
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+auto xShape = getShape(1);
+CPPUNIT_ASSERT(xShape);
+uno::Reference xModel(mxComponent, uno::UNO_QUERY);
+CPPUNIT_ASSERT(xModel);
+uno::Reference xController = 
xModel->getCurrentController();
+CPPUNIT_ASSERT(xController);
+uno::Reference xSelection(xController, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xSelection);
+CPPUNIT_ASSERT(xSelection->select(uno::Any(xShape)));
+CPPUNIT_ASSERT(xSelection->getSelection().hasValue());
+uno::Reference xProperties(xShape, uno::UNO_QUERY);
+
+// Check if the textbox is selected
+CPPUNIT_ASSERT_EQUAL(true, 
xProperties->getPropertyValue("TextBox").get());
+
+// Remove the textbox
+dispatchCommand(mxComponent, ".uno:RemoveTextBox", {});
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(false, 
xProperties->getPropertyValue("TextBox").get());
+
+// Readd the textbox (to run the textboxhelper::create() method)
+dispatchCommand(mxComponent, ".uno:AddTextBox", {});
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(true, 
xProperties->getPropertyValue("TextBox").get());
+
+// save and reload
+reload("writer8", "tdf142715_.odt");
+
+// Before the fix this crashed here and could not reopen.
+CPPUNIT_ASSERT_MESSAGE("Crash on exit, isn't it?", mxComponent);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testCaptionShape)
 {
 createSwDoc();
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index dffe2d8acb62..131bbaa164b3 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -93,17 +93,8 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, 
SdrObject* pObject, bool bCo
 pShape->GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
 uno::Reference 
xTextContentAppend(xTextDocument->getText(),
 
uno::UNO_QUERY);
-try
-{
-uno::Reference XSourceShape(pObject->getUnoShape(),
-uno::UNO_QUERY_THROW);
-xTextContentAppend->insertTextContentWithProperties(
-xTextFrame, uno::Sequence(), 
XSourceShape->getAnchor());
-}
-catch (uno::Exception&)
-{
-xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence());
-}
+xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence());
+
 // Link FLY and DRAW formats, so it becomes a text box (needed for 
syncProperty calls).
 uno::Reference xRealTextFrame(xTextFrame, 
uno::UNO_QUERY);
 auto pTextFrame = dynamic_cast(xRealTextFrame.get());


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/inc sw/qa sw/source writerfilter/source

2022-07-13 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx  |   40 ++
 sw/qa/extras/layout/layout.cxx|5 
 sw/qa/extras/ooxmlexport/data/tdf149546.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|6 
 sw/source/core/doc/docfly.cxx |7 
 sw/source/core/doc/textboxhelper.cxx  |  309 ++
 sw/source/core/edit/edundo.cxx|9 
 sw/source/core/layout/atrfrm.cxx  |9 
 sw/source/core/text/porfly.cxx|7 
 sw/source/core/undo/undobj1.cxx   |   12 
 sw/source/core/unocore/unodraw.cxx|   22 +
 sw/source/core/unocore/unotext.cxx|   23 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   27 +
 13 files changed, 348 insertions(+), 128 deletions(-)

New commits:
commit 44eef5f494825a26594ba3d50ef1f3211ae73b9b
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Jun 20 17:27:53 2022 +0200
Commit: László Németh 
CommitDate: Wed Jul 13 09:25:10 2022 +0200

tdf#148687 tdf#149173 tdf#149546 sw: fix crash with textboxes

Regression from 2110597ac730fa07dbbdd603fda82b182ed27c9e
"tdf#147485 sw: fix group shape crash using std::shared_ptr".

Details:

1) Using reference instead of copy assignment in SwTextBoxHelper.

2) Cleanup: Unused parts of SwTextBoxHelper were removed.

3) Fixing destruction of textboxes, in case when first the shape
is removed, with clearing all textboxes from the doc and the shape
before the pointer is released. All of this only have to be done if
the call is not coming from the swdoc dtor, unless there will be
double freeing.

4) Missing style conversion was fixed in writerfilter.

5) Don't import sections in textboxes, unless the hack of dummy
paragraph before tables in sections will be applied and the paragraph
with anchored objects inside will be removed with the objects;

6) ConvertTextRangeToTextFrame also fixed, so embed frames in
frames are imported from now. (Also textboxes in frames, this
can be useful when there is a floating table having group
textbox with nested complex content inside, or floating table
in floating table, etc...) Note: Follow up commit will enable
group textbox import in frames and tables.

7) Import of group textboxes with complex content in header/footer
was impossible, from now this is also supported both from DOCX and
ODT (test included).

8) Guard class for blocking unwanted recursive textbox sync
has been introduced, and maybe some speedup with group
textbox import has been achieved.

9) The anchor sync method got a new function which avoids
unnecessary sync when the anchor is the same.

10) Sync of As_char textboxes during layout calculation caused
crash so that has a workaround from now, for DOCX import anchor
change and Undo. That syncs starts before the layout calculation
so sync not needed later.

11) A memory leak was found in Undo, which has been fixed.

Note: layout test "testTdf147485Forcepoint" has to be limited
to Windows and Mac builds, because font substitution
causes crash on the Unix based systems.

Change-Id: I69d5d79cc120e3a70ba9285be32ec36a434b2a04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136192
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 1d3d2a995239c3c71432006cb795324c56a0412a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136929
Tested-by: Jenkins

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 112b312a0dab..ebf329342d8e 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -179,6 +179,9 @@ public:
 /// vector filled with the textboxes.
 static std::vector CollectTextBoxes(const SdrObject* 
pGroupObject,
 SwFrameFormat* 
pFormat);
+
+// Compares the anchor of the first and second given formats, and decides 
whether sync needed.
+static bool isAnchorSyncNeeded(const SwFrameFormat* pFirst, const 
SwFrameFormat* pSecond);
 };
 
 /// Textboxes are basically textframe + shape pairs. This means one shape has 
one frame.
@@ -187,6 +190,8 @@ public:
 /// it can have multiple textboxes.
 class SwTextBoxNode
 {
+friend class SwTextBoxLockGuard;
+
 // One TextBox-entry
 struct SwTextBoxElement
 {
@@ -194,8 +199,6 @@ class SwTextBoxNode
 SwFrameFormat* m_pTextBoxFormat;
 // The Draw object where the textbox belongs to
 SdrObject* m_pDrawObject;
-// This is for indicating if the textbox is in special case: for 
example during undo.
-bool m_bIsActive;
 };
 
 // This vector stores the textboxes what belongs to this node
@@ -204,8 +207,12 @@ class SwTextBoxNode
 // (and the textboxes)
 

[Libreoffice-commits] core.git: sw/qa sw/source

2022-07-12 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data/tdf142715.odt |binary
 sw/qa/extras/uiwriter/uiwriter6.cxx  |   42 +++
 sw/source/core/doc/textboxhelper.cxx |   13 +
 3 files changed, 44 insertions(+), 11 deletions(-)

New commits:
commit 2f93eb49db71c8cbaffbd022cb2b654d56920bda
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jun 30 15:48:07 2022 +0200
Commit: László Németh 
CommitDate: Tue Jul 12 15:14:36 2022 +0200

tdf#142715 sw: fix crash on exit when textbox inserted to table

This reverts commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653
"tdf#130805 SwTextBoxHelper::create: fix frame position in shape"
which caused this regression. That fix is not necessary any more: 
synchronization does the same without crashing.

Note: according to this, unit test of commit 
06e2cbb31d0ea703df872b91eb8eacdcaced7653 wasn't removed.

Change-Id: I45bc15d3cf6a5d93b8c54cb4e68018702e58efff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136674
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/data/tdf142715.odt 
b/sw/qa/extras/uiwriter/data/tdf142715.odt
new file mode 100644
index ..70682a54056c
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf142715.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index e52e16abba71..6a341088d8e6 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -31,6 +31,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2055,6 +2056,47 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, 
testNestedGroupTextBoxCopyCrash)
 assertXPath(pLayout, "/root/page/body/txt/anchored/fly[2]");
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testCrashOnExit)
+{
+// Load the bugdoc with a table and a textbox shape inside.
+CPPUNIT_ASSERT(createSwDoc(DATA_DIRECTORY, "tdf142715.odt"));
+
+// Get the textbox selected
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+auto xShape = getShape(1);
+CPPUNIT_ASSERT(xShape);
+uno::Reference xModel(mxComponent, uno::UNO_QUERY);
+CPPUNIT_ASSERT(xModel);
+uno::Reference xController = 
xModel->getCurrentController();
+CPPUNIT_ASSERT(xController);
+uno::Reference xSelection(xController, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xSelection);
+CPPUNIT_ASSERT(xSelection->select(uno::Any(xShape)));
+CPPUNIT_ASSERT(xSelection->getSelection().hasValue());
+uno::Reference xProperties(xShape, uno::UNO_QUERY);
+
+// Check if the textbox is selected
+CPPUNIT_ASSERT_EQUAL(true, 
xProperties->getPropertyValue("TextBox").get());
+
+// Remove the textbox
+dispatchCommand(mxComponent, ".uno:RemoveTextBox", {});
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(false, 
xProperties->getPropertyValue("TextBox").get());
+
+// Readd the textbox (to run the textboxhelper::create() method)
+dispatchCommand(mxComponent, ".uno:AddTextBox", {});
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(true, 
xProperties->getPropertyValue("TextBox").get());
+
+// save and reload
+reload("writer8", "tdf142715_.odt");
+
+// Before the fix this crashed here and could not reopen.
+CPPUNIT_ASSERT_MESSAGE("Crash on exit, isn't it?", mxComponent);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testCaptionShape)
 {
 createSwDoc();
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index db081a466b37..674b22b3f4d4 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -93,17 +93,8 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, 
SdrObject* pObject, bool bCo
 pShape->GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
 uno::Reference 
xTextContentAppend(xTextDocument->getText(),
 
uno::UNO_QUERY);
-try
-{
-uno::Reference XSourceShape(pObject->getUnoShape(),
-uno::UNO_QUERY_THROW);
-xTextContentAppend->insertTextContentWithProperties(
-xTextFrame, uno::Sequence(), 
XSourceShape->getAnchor());
-}
-catch (uno::Exception&)
-{
-xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence());
-}
+xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence());
+
 // Link FLY and DRAW formats, so it becomes a text box (needed for 
syncProperty calls).
 uno::Reference xRealTextFrame(xTextFrame, 
uno::UNO_QUERY);
 auto pTextFrame = dynamic_cast(xRealTextFrame.get());


[Libreoffice-commits] core.git: sw/inc sw/qa sw/source writerfilter/source

2022-07-11 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx  |   40 ++
 sw/qa/extras/layout/layout.cxx|5 
 sw/qa/extras/ooxmlexport/data/tdf149546.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|6 
 sw/source/core/doc/docfly.cxx |7 
 sw/source/core/doc/textboxhelper.cxx  |  309 ++
 sw/source/core/edit/edundo.cxx|9 
 sw/source/core/layout/atrfrm.cxx  |9 
 sw/source/core/text/porfly.cxx|7 
 sw/source/core/undo/undobj1.cxx   |   12 
 sw/source/core/unocore/unodraw.cxx|   22 +
 sw/source/core/unocore/unotext.cxx|   23 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   27 +
 13 files changed, 348 insertions(+), 128 deletions(-)

New commits:
commit 1d3d2a995239c3c71432006cb795324c56a0412a
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Jun 20 17:27:53 2022 +0200
Commit: László Németh 
CommitDate: Mon Jul 11 14:09:09 2022 +0200

tdf#148687 tdf#149173 tdf#149546 sw: fix crash with textboxes

Regression from 2110597ac730fa07dbbdd603fda82b182ed27c9e
"tdf#147485 sw: fix group shape crash using std::shared_ptr".

Details:

1) Using reference instead of copy assignment in SwTextBoxHelper.

2) Cleanup: Unused parts of SwTextBoxHelper were removed.

3) Fixing destruction of textboxes, in case when first the shape
is removed, with clearing all textboxes from the doc and the shape
before the pointer is released. All of this only have to be done if
the call is not coming from the swdoc dtor, unless there will be
double freeing.

4) Missing style conversion was fixed in writerfilter.

5) Don't import sections in textboxes, unless the hack of dummy
paragraph before tables in sections will be applied and the paragraph
with anchored objects inside will be removed with the objects;

6) ConvertTextRangeToTextFrame also fixed, so embed frames in
frames are imported from now. (Also textboxes in frames, this
can be useful when there is a floating table having group
textbox with nested complex content inside, or floating table
in floating table, etc...) Note: Follow up commit will enable
group textbox import in frames and tables.

7) Import of group textboxes with complex content in header/footer
was impossible, from now this is also supported both from DOCX and
ODT (test included).

8) Guard class for blocking unwanted recursive textbox sync
has been introduced, and maybe some speedup with group
textbox import has been achieved.

9) The anchor sync method got a new function which avoids
unnecessary sync when the anchor is the same.

10) Sync of As_char textboxes during layout calculation caused
crash so that has a workaround from now, for DOCX import anchor
change and Undo. That syncs starts before the layout calculation
so sync not needed later.

11) A memory leak was found in Undo, which has been fixed.

Note: layout test "testTdf147485Forcepoint" has to be limited
to Windows and Mac builds, because font substitution
causes crash on the Unix based systems.

Change-Id: I69d5d79cc120e3a70ba9285be32ec36a434b2a04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136192
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 112b312a0dab..ebf329342d8e 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -179,6 +179,9 @@ public:
 /// vector filled with the textboxes.
 static std::vector CollectTextBoxes(const SdrObject* 
pGroupObject,
 SwFrameFormat* 
pFormat);
+
+// Compares the anchor of the first and second given formats, and decides 
whether sync needed.
+static bool isAnchorSyncNeeded(const SwFrameFormat* pFirst, const 
SwFrameFormat* pSecond);
 };
 
 /// Textboxes are basically textframe + shape pairs. This means one shape has 
one frame.
@@ -187,6 +190,8 @@ public:
 /// it can have multiple textboxes.
 class SwTextBoxNode
 {
+friend class SwTextBoxLockGuard;
+
 // One TextBox-entry
 struct SwTextBoxElement
 {
@@ -194,8 +199,6 @@ class SwTextBoxNode
 SwFrameFormat* m_pTextBoxFormat;
 // The Draw object where the textbox belongs to
 SdrObject* m_pDrawObject;
-// This is for indicating if the textbox is in special case: for 
example during undo.
-bool m_bIsActive;
 };
 
 // This vector stores the textboxes what belongs to this node
@@ -204,8 +207,12 @@ class SwTextBoxNode
 // (and the textboxes)
 SwFrameFormat* m_pOwnerShapeFormat;
 
+// Prevents oscillating during recursive clone calling.
 mutable bool m_bIsCloningInProgress;
 
+// Protection 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/inc sw/qa sw/source

2022-06-29 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |   11 +++
 sw/qa/extras/uiwriter/data/tdf149550.docx|binary
 sw/qa/extras/uiwriter/uiwriter6.cxx  |   23 +++
 sw/source/core/doc/DocumentLayoutManager.cxx |   65 +
 sw/source/core/doc/textboxhelper.cxx |   81 ++-
 5 files changed, 118 insertions(+), 62 deletions(-)

New commits:
commit 56b3fb0cc14af8dd2a1ddaee4566cbf53fe05c4c
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jun 14 10:38:46 2022 +0200
Commit: László Németh 
CommitDate: Wed Jun 29 13:06:06 2022 +0200

tdf#149550 sw: fix crash by implementing nested textbox copy

Grouped shapes with a nested textbox were copied without
the textbox with frequent crashing.

Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

Change-Id: Ie2cc24f10706d8999026dc92ebad21f2c5673003
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135815
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit a94edb7f9b8987518a1757a873d2c1fc94efa327)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136550
Tested-by: Jenkins

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index d851a0fda7d2..112b312a0dab 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -26,6 +26,7 @@ class SdrObject;
 class SfxItemSet;
 class SwFrameFormat;
 class SwFrameFormats;
+class SwFormatAnchor;
 class SwFormatContent;
 class SwDoc;
 namespace tools
@@ -203,6 +204,8 @@ class SwTextBoxNode
 // (and the textboxes)
 SwFrameFormat* m_pOwnerShapeFormat;
 
+mutable bool m_bIsCloningInProgress;
+
 public:
 // Not needed.
 SwTextBoxNode() = delete;
@@ -250,6 +253,14 @@ public:
 size_t GetTextBoxCount() const { return m_pTextBoxes.size(); };
 // Returns with a const collection of textboxes owned by this node.
 std::map GetAllTextBoxes() const;
+
+void Clone(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* 
o_pTarget, bool bSetAttr,
+   bool bMakeFrame) const;
+
+private:
+void Clone_Impl(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* 
o_pTarget,
+const SdrObject* pSrcObj, SdrObject* pDestObj, bool 
bSetAttr,
+bool bMakeFrame) const;
 };
 
 #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX
diff --git a/sw/qa/extras/uiwriter/data/tdf149550.docx 
b/sw/qa/extras/uiwriter/data/tdf149550.docx
new file mode 100644
index ..3434fc1fff93
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf149550.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index cf37fe5f28ee..b7187568cff4 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -2014,6 +2014,29 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testHatchFill)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(30), getProperty(getShape(1), 
"FillTransparence"));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testNestedGroupTextBoxCopyCrash)
+{
+createSwDoc(DATA_DIRECTORY, "tdf149550.docx");
+
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+Scheduler::ProcessEventsToIdle();
+dispatchCommand(mxComponent, ".uno:Copy", {});
+Scheduler::ProcessEventsToIdle();
+// This crashed here before the fix.
+SwXTextDocument* pXTextDocument = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pXTextDocument);
+pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE);
+Scheduler::ProcessEventsToIdle();
+dispatchCommand(mxComponent, ".uno:Paste", {});
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_MESSAGE("Where is the doc, it crashed, isn't it?!", 
mxComponent);
+
+auto pLayout = parseLayoutDump();
+// There must be 2 textboxes!
+assertXPath(pLayout, "/root/page/body/txt/anchored/fly[2]");
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testCaptionShape)
 {
 createSwDoc();
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx 
b/sw/source/core/doc/DocumentLayoutManager.cxx
index 006501b3aa36..a03d5dc1d60d 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -463,67 +463,6 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
 if( bMakeFrames )
 pDest->MakeFrames();
 
-// If the draw format has a TextBox, then copy its fly format as well.
-if (rSource.Which() == RES_DRAWFRMFMT && rSource.GetOtherTextBoxFormats())
-{
-auto pObj = rSource.FindRealSdrObject();
-auto pTextBoxNd = 
std::make_shared(SwTextBoxNode(pDest));
-pDest->SetOtherTextBoxFormats(pTextBoxNd);
-
-if (pObj)
-{
-const bool bIsGroupObj = pObj->getChildrenOfSdrObject();
-for (size_t it = 0;
- it < (bIsGroupObj ? 
pObj->getChildrenOfSdrObject()->GetObjCount() : 1); it++)
-

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2022-06-29 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |   11 +++
 sw/qa/extras/uiwriter/data/tdf149550.docx|binary
 sw/qa/extras/uiwriter/uiwriter6.cxx  |   23 +++
 sw/source/core/doc/DocumentLayoutManager.cxx |   65 +
 sw/source/core/doc/textboxhelper.cxx |   81 ++-
 5 files changed, 118 insertions(+), 62 deletions(-)

New commits:
commit cd67e988f27de819a39e75e5243b9b20ba56faab
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jun 14 10:38:46 2022 +0200
Commit: László Németh 
CommitDate: Wed Jun 29 10:35:53 2022 +0200

tdf#149550 sw: fix crash by implementing nested textbox copy

Grouped shapes with a nested textbox were copied without
the textbox with frequent crashing.

Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

Change-Id: Ie2cc24f10706d8999026dc92ebad21f2c5673003
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135815
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index d851a0fda7d2..112b312a0dab 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -26,6 +26,7 @@ class SdrObject;
 class SfxItemSet;
 class SwFrameFormat;
 class SwFrameFormats;
+class SwFormatAnchor;
 class SwFormatContent;
 class SwDoc;
 namespace tools
@@ -203,6 +204,8 @@ class SwTextBoxNode
 // (and the textboxes)
 SwFrameFormat* m_pOwnerShapeFormat;
 
+mutable bool m_bIsCloningInProgress;
+
 public:
 // Not needed.
 SwTextBoxNode() = delete;
@@ -250,6 +253,14 @@ public:
 size_t GetTextBoxCount() const { return m_pTextBoxes.size(); };
 // Returns with a const collection of textboxes owned by this node.
 std::map GetAllTextBoxes() const;
+
+void Clone(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* 
o_pTarget, bool bSetAttr,
+   bool bMakeFrame) const;
+
+private:
+void Clone_Impl(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* 
o_pTarget,
+const SdrObject* pSrcObj, SdrObject* pDestObj, bool 
bSetAttr,
+bool bMakeFrame) const;
 };
 
 #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX
diff --git a/sw/qa/extras/uiwriter/data/tdf149550.docx 
b/sw/qa/extras/uiwriter/data/tdf149550.docx
new file mode 100644
index ..3434fc1fff93
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf149550.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index cf37fe5f28ee..b7187568cff4 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -2014,6 +2014,29 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testHatchFill)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(30), getProperty(getShape(1), 
"FillTransparence"));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testNestedGroupTextBoxCopyCrash)
+{
+createSwDoc(DATA_DIRECTORY, "tdf149550.docx");
+
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+Scheduler::ProcessEventsToIdle();
+dispatchCommand(mxComponent, ".uno:Copy", {});
+Scheduler::ProcessEventsToIdle();
+// This crashed here before the fix.
+SwXTextDocument* pXTextDocument = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pXTextDocument);
+pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE);
+Scheduler::ProcessEventsToIdle();
+dispatchCommand(mxComponent, ".uno:Paste", {});
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_MESSAGE("Where is the doc, it crashed, isn't it?!", 
mxComponent);
+
+auto pLayout = parseLayoutDump();
+// There must be 2 textboxes!
+assertXPath(pLayout, "/root/page/body/txt/anchored/fly[2]");
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testCaptionShape)
 {
 createSwDoc();
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx 
b/sw/source/core/doc/DocumentLayoutManager.cxx
index 006501b3aa36..a03d5dc1d60d 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -463,67 +463,6 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
 if( bMakeFrames )
 pDest->MakeFrames();
 
-// If the draw format has a TextBox, then copy its fly format as well.
-if (rSource.Which() == RES_DRAWFRMFMT && rSource.GetOtherTextBoxFormats())
-{
-auto pObj = rSource.FindRealSdrObject();
-auto pTextBoxNd = 
std::make_shared(SwTextBoxNode(pDest));
-pDest->SetOtherTextBoxFormats(pTextBoxNd);
-
-if (pObj)
-{
-const bool bIsGroupObj = pObj->getChildrenOfSdrObject();
-for (size_t it = 0;
- it < (bIsGroupObj ? 
pObj->getChildrenOfSdrObject()->GetObjCount() : 1); it++)
-{
-auto pChild = bIsGroupObj ? 
pObj->getChildrenOfSdrObject()->GetObj(it)
-  : 

[Libreoffice-commits] core.git: include/oox oox/source sd/qa

2022-05-31 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/export/drawingml.hxx   |5 ++-
 oox/source/export/drawingml.cxx|   53 -
 oox/source/export/shapes.cxx   |   13 
 sd/qa/unit/data/odp/testZeroIndent.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx |   38 +++
 5 files changed, 95 insertions(+), 14 deletions(-)

New commits:
commit 445d4ce232b8e8efaeb2605533fede1b71f52f30
Author: Attila Bakos (NISZ) 
AuthorDate: Thu May 26 17:04:54 2022 +0200
Commit: László Németh 
CommitDate: Tue May 31 13:00:38 2022 +0200

tdf#147991 PPTX export: fix bullet indent regression

Instead of exporting the inherited master slide indent
values of the placeholders, export 0 indent value for
removed/disabled bullets to fix interoperability.

Regression from commit f57cfddb51b7d7409b7b425dc200aa73406a13bd
"tdf#145162 PPTX export: fix extra bullet regression".

Change-Id: Icbf823adc07f19fd10d1a60da9cff17616a2aef6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135025
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 294319cf43af..455676e9c262 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -163,6 +163,9 @@ protected:
 css::uno::Reference m_xParent;
 bool  mbIsBackgroundDark;
 
+/// True when exporting presentation placeholder shape.
+bool mbPlaceholder;
+
 bool GetProperty( const css::uno::Reference< css::beans::XPropertySet >& 
rXPropSet, const OUString& aName );
 bool GetPropertyAndState( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet,
   const css::uno::Reference< css::beans::XPropertyState >& 
rXPropState,
@@ -210,7 +213,7 @@ protected:
 
 public:
 DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* 
pFB, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 
nullptr )
-: meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( 
pFS ), mpFB( pFB ), mbIsBackgroundDark( false ) {}
+: meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( 
pFS ), mpFB( pFB ), mbIsBackgroundDark( false ), mbPlaceholder(false) {}
 void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
 const ::sax_fastparser::FSHelperPtr& GetFS() const { return mpFS; }
 ::oox::core::XmlFilterBase* GetFB() { return mpFB; }
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 18e6e2723e89..eea8394aef36 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -122,6 +122,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2705,13 +2706,7 @@ static OUString GetAutoNumType(SvxNumType 
nNumberingType, bool bSDot, bool bPBeh
 void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& 
rXPropSet, float fFirstCharHeight, sal_Int16 nLevel )
 {
 if (nLevel < 0 || !GetProperty(rXPropSet, "NumberingRules"))
-{
-if (GetDocumentType() == DOCUMENT_PPTX)
-{
-mpFS->singleElementNS(XML_a, XML_buNone);
-}
 return;
-}
 
 Reference< XIndexAccess > rXIndexAccess;
 
@@ -3015,6 +3010,32 @@ bool DrawingML::WriteParagraphProperties( const 
Reference< XTextContent >& rPara
 if (GetProperty(rXPropSet, "NumberingLevel"))
 mAny >>= nLevel;
 
+bool bWriteNumbering = true;
+bool bForceZeroIndent = false;
+if (mbPlaceholder)
+{
+Reference< text::XTextRange > xParaText(rParagraph, UNO_QUERY);
+if (xParaText)
+{
+bool bNumberingOnThisLevel = false;
+if (nLevel > -1)
+{
+Reference< XIndexAccess > 
xNumberingRules(rXPropSet->getPropertyValue("NumberingRules"), UNO_QUERY);
+const PropertyValues& rNumRuleOfLevel = 
xNumberingRules->getByIndex(nLevel).get();
+for (const PropertyValue& rRule : rNumRuleOfLevel)
+if (rRule.Name == "NumberingType" && 
rRule.Value.hasValue())
+bNumberingOnThisLevel = rRule.Value.get() 
!= style::NumberingType::NUMBER_NONE;
+}
+
+const bool bIsNumberingVisible = 
rXPropSet->getPropertyValue("NumberingIsNumber").get();
+const bool bIsLineEmpty = !xParaText->getString().getLength();
+
+bWriteNumbering = !bIsLineEmpty && bIsNumberingVisible && (nLevel 
!= -1);
+bForceZeroIndent = (!bIsNumberingVisible || bIsLineEmpty || 
!bNumberingOnThisLevel);
+}
+
+}
+
 sal_Int16 nTmp = sal_Int16(style::ParagraphAdjust_LEFT);
 if (GetProperty(rXPropSet, "ParaAdjust"))
 mAny >>= nTmp;
@@ -3058,23 +3079,26 @@ bool DrawingML::WriteParagraphProperties( const 
Reference< XTextContent >& rPara
 sal_Int32 nLeftMargin =  

[Libreoffice-commits] core.git: sw/qa sw/source

2022-05-30 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/tdf146272.odt |binary
 sw/qa/extras/layout/layout2.cxx|   21 +
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |2 +-
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |2 +-
 sw/source/core/layout/flylay.cxx   |   17 +++--
 5 files changed, 38 insertions(+), 4 deletions(-)

New commits:
commit e1f6b136fd125c5d3648c51b202a698d418afc18
Author: Attila Bakos (NISZ) 
AuthorDate: Wed May 25 15:40:57 2022 +0200
Commit: László Németh 
CommitDate: Mon May 30 13:21:10 2022 +0200

tdf#146272 sw: fix fly in fly hid by incomplete z-ordering

Fixing z-order was incomplete for textboxes
(shape + frame pair), because only the frame
moved to back, but not the shape, covering the
textbox.

Regression from commit 504d78acb866495fd954fcd6db22ea68f174a5ab
"tdf#143574 sw: textboxes in group shapes - part 1".

See also commit 0e6d963fbca16f98a3dbb6ef2fee3736a89d055b
"tdf#138141 sw: fix textbox z-order".

Change-Id: I03e3b55302c984e5968e579e77ccd5ed0a336dd9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134942
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/layout/data/tdf146272.odt 
b/sw/qa/extras/layout/data/tdf146272.odt
new file mode 100644
index ..3652cf06f110
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf146272.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index f88fbdc94f71..a47642acfb8d 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -1072,6 +1072,27 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194)
 assertXPath(pXmlDoc, "//textarray", 8);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf146272)
+{
+createSwDoc(DATA_DIRECTORY, "tdf146272.odt");
+
+uno::Reference xPicture(getShape(2), uno::UNO_QUERY);
+uno::Reference xDrawing(getShape(1), uno::UNO_QUERY);
+uno::Reference 
xFrame(xDrawing->getPropertyValue("TextBoxContent"),
+   uno::UNO_QUERY);
+
+CPPUNIT_ASSERT(xPicture);
+CPPUNIT_ASSERT(xDrawing);
+CPPUNIT_ASSERT(xFrame);
+
+const sal_uInt64 nPitureZorder = 
xPicture->getPropertyValue("ZOrder").get();
+const sal_uInt64 nDrawingZorder = 
xDrawing->getPropertyValue("ZOrder").get();
+const sal_uInt64 nFrameZorder = 
xFrame->getPropertyValue("ZOrder").get();
+
+CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nDrawingZorder < nFrameZorder);
+CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nFrameZorder < nPitureZorder);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138773)
 {
 SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf138773.docx");
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 0fc4462e32b7..cf5877ea873d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -89,7 +89,7 @@ DECLARE_OOXMLEXPORT_TEST(testWPGtextboxes, 
"testWPGtextboxes.docx")
 {
 CPPUNIT_ASSERT_EQUAL(2, 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 67f3c838e759..d85a8da12f18 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -645,7 +645,7 @@ DECLARE_OOXMLEXPORT_TEST(testWPGBodyPr, "WPGbodyPr.docx")
 CPPUNIT_ASSERT_EQUAL(2, getShapes());
 
 // Get the WPG shape
-uno::Reference xGroup(getShape(2), uno::UNO_QUERY);
+uno::Reference xGroup(getShape(1), uno::UNO_QUERY);
 // And the embed WPG
 uno::Reference xEmbedGroup(xGroup->getByIndex(1), 
uno::UNO_QUERY);
 
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 8ffa9ff3d860..38d8f2887c48 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -810,10 +810,23 @@ void SwPageFrame::AppendFlyToPage( SwFlyFrame *pNew )
 {
 //#i119945# set pFly's OrdNum to _rNewObj's. So when pFly is removed 
by Undo, the original OrdNum will not be changed.
 sal_uInt32 nNewNum = pObj->GetOrdNumDirect();
+SdrObject* pDrawObj = nullptr;
+if (auto pFormat = pFly->GetFormat())
+if (auto pShapeFormat = 
SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_FLYFRMFMT))
+pDrawObj = pShapeFormat->FindRealSdrObject();
+
+if (pDrawObj)
+{
+if (auto pPage = pDrawObj->getSdrPageFromSdrObject())
+pPage->SetObjectOrdNum(pDrawObj->GetOrdNumDirect(), nNewNum);
+else
+pDrawObj->SetOrdNum(nNewNum);
+}
+
 if ( pObj->getSdrPageFromSdrObject() )
-

[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - sw/source

2022-05-30 Thread Attila Bakos (NISZ) (via logerrit)
 sw/source/core/layout/flycnt.cxx |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 906151f18771418ee899f59fc98c774b07dadf16
Author: Attila Bakos (NISZ) 
AuthorDate: Tue May 17 15:28:59 2022 +0200
Commit: László Németh 
CommitDate: Mon May 30 11:17:15 2022 +0200

tdf#148365 sw: fix freezing with FrameIsAutomaticHeight

Lock layout update temporarily during setting horizontal
and after that, vertical orientations of textboxes
with FrameIsAutomaticHeight to avoid freezing
SwObjectFormatter, and depending on the platform,
freezing Writer completely.

Regression from commit 3b0a0e70cb67fc2e1fd2e8cbb9cfcd8c670e
"Related tdf#66039 DOCX import: fix Z-order of group shapes".

Change-Id: Ib106182b9f0d3d74ebdc3e746345380c8b685fdf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134480
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 182d2a47a2b4ed0affdc828a534c1659cc2e926d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135007
Tested-by: Jenkins
Reviewed-by: Attila Bakos 

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 5e9bdfe92ef0..5bcdad916e13 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -549,8 +549,14 @@ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 aHOri.SetPos(aHOri.GetPos() + aTextRectangle.Left());
 aVOri.SetPos(aVOri.GetPos() + aTextRectangle.Top());
 // save the new position for the shape
-GetFormat()->SetFormatAttr(aHOri);
-GetFormat()->SetFormatAttr(aVOri);
+auto pFormat = GetFormat();
+const bool bLocked = pFormat->IsModifyLocked();
+if (!bLocked)
+pFormat->LockModify();
+pFormat->SetFormatAttr(aHOri);
+pFormat->SetFormatAttr(aVOri);
+if (!bLocked)
+pFormat->UnlockModify();
 }
 if ( bOsz || bConsiderWrapInfluenceDueToOverlapPrevCol ||
  // #i40444#


[Libreoffice-commits] core.git: sw/source

2022-05-27 Thread Attila Bakos (NISZ) (via logerrit)
 sw/source/core/layout/flycnt.cxx |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 182d2a47a2b4ed0affdc828a534c1659cc2e926d
Author: Attila Bakos (NISZ) 
AuthorDate: Tue May 17 15:28:59 2022 +0200
Commit: László Németh 
CommitDate: Fri May 27 09:38:03 2022 +0200

tdf#148365 sw: fix freezing with FrameIsAutomaticHeight

Lock layout update temporarily during setting horizontal
and after that, vertical orientations of textboxes
with FrameIsAutomaticHeight to avoid freezing
SwObjectFormatter, and depending on the platform,
freezing Writer completely.

Regression from commit 3b0a0e70cb67fc2e1fd2e8cbb9cfcd8c670e
"Related tdf#66039 DOCX import: fix Z-order of group shapes".

Change-Id: Ib106182b9f0d3d74ebdc3e746345380c8b685fdf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134480
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index cf6aa1f41029..f7611392d345 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -548,8 +548,14 @@ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 aHOri.SetPos(aHOri.GetPos() + aTextRectangle.Left());
 aVOri.SetPos(aVOri.GetPos() + aTextRectangle.Top());
 // save the new position for the shape
-GetFormat()->SetFormatAttr(aHOri);
-GetFormat()->SetFormatAttr(aVOri);
+auto pFormat = GetFormat();
+const bool bLocked = pFormat->IsModifyLocked();
+if (!bLocked)
+pFormat->LockModify();
+pFormat->SetFormatAttr(aHOri);
+pFormat->SetFormatAttr(aVOri);
+if (!bLocked)
+pFormat->UnlockModify();
 }
 if ( bOsz || bConsiderWrapInfluenceDueToOverlapPrevCol ||
  // #i40444#


[Libreoffice-commits] core.git: sw/qa sw/source

2022-05-19 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf148720.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx  |   59 
 sw/source/core/doc/textboxhelper.cxx|5 ++
 3 files changed, 64 insertions(+)

New commits:
commit 5648363e8f70cd95b00db62f91effb7eb1385ac9
Author: Attila Bakos (NISZ) 
AuthorDate: Wed May 11 09:12:12 2022 +0200
Commit: László Németh 
CommitDate: Thu May 19 11:18:33 2022 +0200

tdf#148720 sw DOCX: fix jumbled group textbox regression

Left-aligned group shape was synced to the textbox, resulting
jumbled positions after DOCX export/import. To fix it,
set horizontal orientation of the textbox back to NONE.

Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

Change-Id: I02ee79862344f3495846091e3eef27c24d8ef162
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134149
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148720.odt 
b/sw/qa/extras/ooxmlexport/data/tdf148720.odt
new file mode 100644
index ..771c845053ee
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148720.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 62f8095dabaf..5c25a3b5d369 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -442,6 +442,65 @@ DECLARE_OOXMLEXPORT_TEST(TestWPGZOrder, 
"testWPGZOrder.docx")
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148720, "tdf148720.odt")
+{
+const auto& pLayout = parseLayoutDump();
+
+const OString sShapeXPaths[] =
+{
+
OString("/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[1]"),
+
OString("/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObjGroup/SdrObjList/SdrObjGroup/SdrObjList/SdrObject[1]"),
+
OString("/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObjGroup/SdrObjList/SdrObjGroup/SdrObjList/SdrObject[2]"),
+
OString("/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[2]")
+};
+
+const OString sTextXPaths[] =
+{
+OString("/root/page/body/txt/anchored/fly[1]/infos/bounds"),
+OString("/root/page/body/txt/anchored/fly[2]/infos/bounds"),
+OString("/root/page/body/txt/anchored/fly[3]/infos/bounds"),
+OString("/root/page/body/txt/anchored/fly[4]/infos/bounds")
+};
+
+const OString sAttribs[] =
+{
+OString("left"),
+OString("top"),
+OString("width"),
+OString("height")
+};
+
+for (sal_Int32 i = 0; i < 4; ++i)
+{
+OUString aShapeVals[4];
+int aTextVals[4] = {0, 0, 0, 0};
+
+const auto aOutRect = getXPath(pLayout, sShapeXPaths[i], "aOutRect");
+
+sal_uInt16 nCommaPos[4] = {0, 0, 0, 0};
+nCommaPos[1] = aOutRect.indexOf(",");
+nCommaPos[2] = aOutRect.indexOf(",", nCommaPos[1] + 1);
+nCommaPos[3] = aOutRect.indexOf(",", nCommaPos[2] + 1);
+
+
+aShapeVals[0] = aOutRect.copy(nCommaPos[0], nCommaPos[1] - 
nCommaPos[0]);
+aShapeVals[1] = aOutRect.copy(nCommaPos[1] + 2, nCommaPos[2] - 
nCommaPos[1] - 2);
+aShapeVals[2] = aOutRect.copy(nCommaPos[2] + 2, nCommaPos[3] - 
nCommaPos[2] - 2);
+aShapeVals[3] = aOutRect.copy(nCommaPos[3] + 2, aOutRect.getLength() - 
nCommaPos[3] - 2);
+
+for (int ii = 0; ii < 4; ++ii)
+{
+aTextVals[ii] = getXPath(pLayout, sTextXPaths[i], 
sAttribs[ii]).toInt32();
+}
+
+tools::Rectangle ShapeArea(Point(aShapeVals[0].toInt32(), 
aShapeVals[1].toInt32()), Size(aShapeVals[2].toInt32() + 5, 
aShapeVals[3].toInt32() + 5));
+
+tools::Rectangle TextArea(Point(aTextVals[0], aTextVals[1]), 
Size(aTextVals[2], aTextVals[3]));
+
+CPPUNIT_ASSERT(ShapeArea.Contains(TextArea));
+}
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf126287, "tdf126287.docx")
 {
 CPPUNIT_ASSERT_EQUAL(2, getPages());
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 676f31fd4022..68d42b7e91f7 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1344,6 +1344,8 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* 
pShape, SdrObject* pOb
 
 // Set the textbox position at the X-axis:
 SwFormatHoriOrient aNewHOri(pFormat->GetHoriOrient());
+if (bIsGroupObj && aNewHOri.GetHoriOrient() != 
text::HoriOrientation::NONE)
+aNewHOri.SetHoriOrient(text::HoriOrientation::NONE);
 aNewHOri.SetPos(aRect.Left() + nLeftSpace
 + (bIsGroupObj ? pObj->GetRelativePos().getX() : 
0));
 SwFormatVertOrient aNewVOri(pFormat->GetVertOrient());
@@ -1424,6 +1426,9 @@ bool 

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source writerfilter/source

2022-04-28 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/IDocumentSettingAccess.hxx |3 +++
 sw/qa/extras/layout/data/tdf100680.docx   |binary
 sw/qa/extras/layout/layout2.cxx   |8 
 sw/source/core/doc/DocumentSettingManager.cxx |8 +++-
 sw/source/core/inc/DocumentSettingManager.hxx |2 ++
 sw/source/core/text/portxt.cxx|7 +--
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   16 
 writerfilter/source/filter/WriterFilter.cxx   |1 +
 8 files changed, 42 insertions(+), 3 deletions(-)

New commits:
commit 41b012767feb8552b60a68c7be18d80c403304bf
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Apr 5 13:37:55 2022 +0200
Commit: László Németh 
CommitDate: Thu Apr 28 11:47:42 2022 +0200

tdf#100680 sw DOCX compatibility: fix wrap of as_char flys

New DOCX compatibility flag "WordLikeWrapForAsCharFlys"
has been introduced which true in case of importing DOCX
documents. It modifies the wrapping of long words
with as_char anchored flys anchored into the same line,
resulting e.g. correct import of poor man's header lines
drawn by using underline characters under an image.

Note: this example was imported as a broken header line:
half of it was there after the left aligned image in the
same line, and after the line break, only the other half
under the image.

Change-Id: I9474900ef778bcf5ddc9d95f39d536d67015f3b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132571
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 7de8674c4d0f..4e434f20a3ee 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -119,6 +119,9 @@ enum class DocumentSettingId
 // footnoteContainer default position is the page end instead of the 
column end
 // only if "evenly distributed" is set, and "collected at the end" is not 
set
 FOOTNOTE_IN_COLUMN_TO_PAGEEND,
+// AsChar anchored flys wrapped differently in ooxlm than normally so in 
case of
+// docx enable this flag. For details see ticket tdf#100680.
+WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML
 };
 
 /** Provides access to settings of a document
diff --git a/sw/qa/extras/layout/data/tdf100680.docx 
b/sw/qa/extras/layout/data/tdf100680.docx
new file mode 100644
index ..c949540be388
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf100680.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 02b40c21b5ef..faf978d65f1e 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -93,6 +93,14 @@ void SwLayoutWriter2::CheckRedlineCharAttributesHidden()
 assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "Portion", 
"foobaz");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf100680_as_char_wrap)
+{
+createSwDoc(DATA_DIRECTORY, "tdf100680.docx");
+auto pDump = parseLayoutDump();
+assertXPath(pDump, "/root/page/header/txt/SwParaPortion/SwLineLayout[3]");
+// If the third line missing that assert will fire, as was before the fix.
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineCharAttributes)
 {
 createSwDoc(DATA_DIRECTORY, "redline_charatr.fodt");
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 3e03097fb41f..851aec5b9e10 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -105,7 +105,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
)
 mbGutterAtTop(false),
 mbFootnoteInColumnToPageEnd(false),
 mnImagePreferredDPI(0),
-mbAutoFirstLineIndentDisregardLineSpace(true)
+mbAutoFirstLineIndentDisregardLineSpace(true),
+mbWrapAsCharFlysLikeInOOXML(false)
 
 // COMPATIBILITY FLAGS END
 {
@@ -244,6 +245,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
 case DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND: return 
mbFootnoteInColumnToPageEnd;
 case DocumentSettingId::AUTO_FIRST_LINE_INDENT_DISREGARD_LINE_SPACE:
 return mbAutoFirstLineIndentDisregardLineSpace;
+case DocumentSettingId::WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML: return 
mbWrapAsCharFlysLikeInOOXML;
 default:
 OSL_FAIL("Invalid setting id");
 }
@@ -422,6 +424,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
 mbAutoFirstLineIndentDisregardLineSpace = value;
 break;
 
+case DocumentSettingId::WRAP_AS_CHAR_FLYS_LIKE_IN_OOXML:
+mbWrapAsCharFlysLikeInOOXML = value;
+break;
+
 // COMPATIBILITY FLAGS END
 
 case DocumentSettingId::BROWSE_MODE: //can be used temporary 
(load/save) when no SwViewShell is available
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 

[Libreoffice-commits] core.git: sw/qa sw/source xmloff/qa

2022-04-27 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data/tdf146449.odt |binary
 sw/qa/extras/uiwriter/uiwriter4.cxx  |   30 ++
 sw/source/core/doc/textboxhelper.cxx |   11 +--
 sw/source/core/undo/undraw.cxx   |5 +
 xmloff/qa/unit/draw.cxx  |2 +-
 5 files changed, 41 insertions(+), 7 deletions(-)

New commits:
commit a3e540304269772595439de22b54269011721bb2
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Mar 2 14:08:14 2022 +0100
Commit: László Németh 
CommitDate: Wed Apr 27 16:44:09 2022 +0200

tdf#146449 sw: fix Z-order after undoing

Textbox z-order synchronization was missing in case
of Undo, resulting broken text boxes.

Regression from 504d78acb866495fd954fcd6db22ea68f174a5ab
"tdf#143574 sw: textboxes in group shapes - part 1".

Change-Id: I2632b7fb40e327f083e680e10b19c8f405df1875
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130875
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: Attila Bakos 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/data/tdf146449.odt 
b/sw/qa/extras/uiwriter/data/tdf146449.odt
new file mode 100644
index ..c18d98e8aaec
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf146449.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 6c3d3578ca26..d1aee7f23986 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -119,6 +119,36 @@ static OUString lcl_translitTest(SwDoc& rDoc, const SwPaM& 
rPaM, Transliteration
 return rPaM.GetNode(false).GetTextNode()->GetText();
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf146449)
+{
+load(DATA_DIRECTORY, "tdf146449.odt");
+
+auto pDoc = dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pDoc);
+auto pShell = pDoc->GetDocShell()->GetFEShell();
+CPPUNIT_ASSERT(pShell);
+
+auto xTextBox = getShapeByName(u"Frame1");
+auto pObject = SdrObject::getSdrObjectFromXShape(xTextBox);
+
+CPPUNIT_ASSERT(pShell->SelectObj(Point(), 0, pObject));
+
+dispatchCommand(mxComponent, ".uno:Cut", {});
+Scheduler::ProcessEventsToIdle();
+
+dispatchCommand(mxComponent, ".uno:Undo", {});
+Scheduler::ProcessEventsToIdle();
+
+uno::Reference xShapeProps(xTextBox, uno::UNO_QUERY);
+uno::Reference 
xFrameProps(xShapeProps->getPropertyValue("TextBoxContent"),
+uno::UNO_QUERY);
+
+const auto& nShapeZOrder = pObject->GetOrdNum();
+const auto& nFrameZOrder = xFrameProps->getPropertyValue("ZOrder");
+
+CPPUNIT_ASSERT_MESSAGE("Wrong Zorder!", nShapeZOrder < 
nFrameZOrder.get());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf49033)
 {
 SwDoc* pDoc = createSwDoc();
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 74d29aad270b..3eeed981d74f 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1329,7 +1329,6 @@ bool SwTextBoxHelper::changeAnchor(SwFrameFormat* pShape, 
SdrObject* pObj)
 
 bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* 
pObj)
 {
-bool bSuccess = false;
 // Set the position of the textboxes according to the position of its 
shape-pair
 const bool bIsGroupObj = (pObj != pShape->FindRealSdrObject()) && pObj;
 if (auto pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT, pObj))
@@ -1414,8 +1413,8 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* 
pShape, SdrObject* pOb
 }
 }
 
-bSuccess = pFormat->SetFormatAttr(aNewHOri);
-bSuccess &= pFormat->SetFormatAttr(aNewVOri);
+pFormat->SetFormatAttr(aNewHOri);
+pFormat->SetFormatAttr(aNewVOri);
 }
 // Other cases when the shape has different anchor from AS_CHAR
 else
@@ -1498,10 +1497,10 @@ bool 
SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb
 aNewVOri.SetPos(aNewVOri.GetPos() + nTableOffset.getY());
 }
 
-bSuccess = pFormat->SetFormatAttr(aNewHOri);
-bSuccess &= pFormat->SetFormatAttr(aNewVOri);
+pFormat->SetFormatAttr(aNewHOri);
+pFormat->SetFormatAttr(aNewVOri);
 }
-return bSuccess;
+return true;
 }
 
 return false;
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index f316858c2bfd..9eb5502eceaa 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -601,6 +601,11 @@ void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & 
rContext)
 pContact->MoveObjToVisibleLayer( pObj );
 
 SwDrawFrameFormat* pDrawFrameFormat = rSave.pFormat;
+if (pDrawFrameFormat->GetOtherTextBoxFormats())
+{
+SwTextBoxHelper::synchronizeGroupTextBoxProperty(
+

[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - oox/source sw/qa

2022-04-07 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/shapes.cxx   |3 +-
 sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |   30 +
 3 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit e342185c4650ca2678ccbea92770e1ae147d08bc
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Apr 5 10:13:02 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Apr 7 11:33:04 2022 +0200

tdf#148342 docx export: fix puzzle shape

There is an exporter class for preset shapes,
namely the DMLPresetShapeExporter, which in
its ctor calls the msfilter::GetShapeName()
converter method where the puzzle cause
exception. To avoid this return with false
to export it with custgeom in time.

Change-Id: I8d29bf551638a66abf381c9cb8f6a0eebc881195
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132567
Tested-by: Jenkins
Reviewed-by: Attila Bakos 
Reviewed-by: Regina Henschel 
(cherry picked from commit 9592da0a8e596869a1cd0859619dd28a541d7234)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132606
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 86ca6264129d..138106938ee2 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -928,7 +928,8 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 // as preset ones with parameters. Try that with this converter class.
 if (!sShapeType.startsWith("ooxml") && sShapeType != "non-primitive"
 && GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes
-&& xShape->getShapeType() == "com.sun.star.drawing.CustomShape")
+&& xShape->getShapeType() == "com.sun.star.drawing.CustomShape"
+&& !lcl_IsOnAllowlist(sShapeType))
 {
 DMLPresetShapeExporter aCustomShapeConverter(this, xShape);
 bPresetWriteSuccessful = aCustomShapeConverter.WriteShape();
diff --git a/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt 
b/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt
new file mode 100644
index ..6f7a62deecd2
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 633aa6ddb4eb..c97acffdc038 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -1292,6 +1292,36 @@ DECLARE_OOXMLEXPORT_TEST( testTableCellMargin, 
"table-cell-margin.docx" )
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(TestPuzzleExport, "TestPuzzleExport.odt")
+{
+// See tdf#148342 fo details
+// Get the doc
+uno::Reference< text::XTextDocument > xTextDoc(mxComponent, 
uno::UNO_QUERY_THROW);
+auto pSwDoc = dynamic_cast(xTextDoc.get());
+CPPUNIT_ASSERT(pSwDoc);
+// Create a metafile
+auto pMeta = pSwDoc->GetDocShell()->GetPreviewMetaFile();
+CPPUNIT_ASSERT(pMeta);
+MetafileXmlDump aDumper;
+auto pMetaXml = dumpAndParse(aDumper, *pMeta);
+CPPUNIT_ASSERT(pMetaXml);
+// After parsing check that node...
+auto pXNode = getXPathNode(pMetaXml, 
"/metafile/push/push/push/push[4]/push/push/polypolygon/polygon");
+CPPUNIT_ASSERT(pXNode);
+auto pNode = pXNode->nodesetval->nodeTab[0];
+CPPUNIT_ASSERT(pNode);
+auto it = pNode->children;
+int nCount = 0;
+// .. and count the children
+while (it != nullptr)
+{
+nCount++;
+it = it->next;
+}
+// In case of puzzle thre will be so many... Without the fix there was a 
rectangle with 4 points.
+CPPUNIT_ASSERT_GREATER(300, nCount);
+}
+
 // tdf#106742 for DOCX with compatibility level <= 14 (MS Word up to and incl. 
ver.2010), we should use cell margins when calculating table left border 
position
 DECLARE_OOXMLEXPORT_TEST( testTablePosition14, "table-position-14.docx" )
 {


[Libreoffice-commits] core.git: oox/source sw/qa

2022-04-06 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/shapes.cxx   |3 +-
 sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |   30 +
 3 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit 9592da0a8e596869a1cd0859619dd28a541d7234
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Apr 5 10:13:02 2022 +0200
Commit: Regina Henschel 
CommitDate: Wed Apr 6 19:07:34 2022 +0200

tdf#148327 docx export: fix puzzle shape

There is an exporter class for preset shapes,
namely the DMLPresetShapeExporter, which in
its ctor calls the msfilter::GetShapeName()
converter method where the puzzle cause
exception. To avoid this return with false
to export it with custgeom in time.

Change-Id: I8d29bf551638a66abf381c9cb8f6a0eebc881195
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132567
Tested-by: Jenkins
Reviewed-by: Attila Bakos 
Reviewed-by: Regina Henschel 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 0405c975db0a..e4d378bd6111 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -928,7 +928,8 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 // as preset ones with parameters. Try that with this converter class.
 if (!sShapeType.startsWith("ooxml") && sShapeType != "non-primitive"
 && GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes
-&& xShape->getShapeType() == "com.sun.star.drawing.CustomShape")
+&& xShape->getShapeType() == "com.sun.star.drawing.CustomShape"
+&& !lcl_IsOnAllowlist(sShapeType))
 {
 DMLPresetShapeExporter aCustomShapeConverter(this, xShape);
 bPresetWriteSuccessful = aCustomShapeConverter.WriteShape();
diff --git a/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt 
b/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt
new file mode 100644
index ..6f7a62deecd2
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 21f81b619bda..9765cc62a24c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -1300,6 +1300,36 @@ DECLARE_OOXMLEXPORT_TEST( testTableCellMargin, 
"table-cell-margin.docx" )
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(TestPuzzleExport, "TestPuzzleExport.odt")
+{
+// See tdf#148342 fo details
+// Get the doc
+uno::Reference< text::XTextDocument > xTextDoc(mxComponent, 
uno::UNO_QUERY_THROW);
+auto pSwDoc = dynamic_cast(xTextDoc.get());
+CPPUNIT_ASSERT(pSwDoc);
+// Create a metafile
+auto pMeta = pSwDoc->GetDocShell()->GetPreviewMetaFile();
+CPPUNIT_ASSERT(pMeta);
+MetafileXmlDump aDumper;
+auto pMetaXml = dumpAndParse(aDumper, *pMeta);
+CPPUNIT_ASSERT(pMetaXml);
+// After parsing check that node...
+auto pXNode = getXPathNode(pMetaXml, 
"/metafile/push/push/push/push[4]/push/push/polypolygon/polygon");
+CPPUNIT_ASSERT(pXNode);
+auto pNode = pXNode->nodesetval->nodeTab[0];
+CPPUNIT_ASSERT(pNode);
+auto it = pNode->children;
+int nCount = 0;
+// .. and count the children
+while (it != nullptr)
+{
+nCount++;
+it = it->next;
+}
+// In case of puzzle thre will be so many... Without the fix there was a 
rectangle with 4 points.
+CPPUNIT_ASSERT_GREATER(300, nCount);
+}
+
 // tdf#106742 for DOCX with compatibility level <= 14 (MS Word up to and incl. 
ver.2010), we should use cell margins when calculating table left border 
position
 DECLARE_OOXMLEXPORT_TEST( testTablePosition14, "table-position-14.docx" )
 {


[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2022-04-01 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/frmfmt.hxx|6 -
 sw/inc/textboxhelper.hxx |9 ++
 sw/qa/extras/ooxmlexport/data/Tdf147485.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |6 +
 sw/source/core/doc/DocumentLayoutManager.cxx |8 +-
 sw/source/core/doc/docdraw.cxx   |   29 
 sw/source/core/doc/textboxhelper.cxx |   92 +--
 sw/source/core/draw/dcontact.cxx |2 
 sw/source/core/layout/atrfrm.cxx |   31 ++---
 sw/source/core/text/porfly.cxx   |2 
 sw/source/core/undo/undobj1.cxx  |   22 +++---
 sw/source/core/undo/undraw.cxx   |   32 -
 12 files changed, 135 insertions(+), 104 deletions(-)

New commits:
commit 2110597ac730fa07dbbdd603fda82b182ed27c9e
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Mar 30 13:05:37 2022 +0200
Commit: László Németh 
CommitDate: Fri Apr 1 08:01:57 2022 +0200

tdf#147485 sw: fix group shape crash using std::shared_ptr

for SwFrameFormat::m_pOtherTextBoxeFormats.
Before there was broken manual handling of this
member, resulting random crashes.

Details: Writer textboxes are textframe + shape
pairs. Accordingly the shape has a draw format,
the frame has a fly format. In case of group
shapes the paired structure doesn't work, because
there is one shape format and many fly formats.
To handle this there is a class (SwTextBoxNode)
which has a small frame format table inside.
This cache gives the possibility to handle
each frame shape pairs inside the group depending
on what SdrObject owns that textbox.

However there is another place where these formats
stored, namely the SpzFrameFormatTable in SwDoc.
The only problem is that, when a flyframe removed,
it has to be deleted from both tables, but if the
DelLayoutFormat() is called, that will call the
~FrameFormat(), and if the format already deleted
from the SwTextBoxNode, there will be double deleting
for the same address, which caused the crash.

To avoid this the following is present:

When fly deletion occurs, first the format is
deleted from the doc, then via the ~SwFrameFomat()
will be deleted from the TextBoxNode. If the deleted
format is a drawing, the whole node will be destructed
via the shared_ptr. Hopefully that will be fine,
without any leak.

Change-Id: I007724695bc035998cb35efeefecd308aae36e85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132308
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 12795bf10428..4a5f2f1e8e87 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -74,7 +74,7 @@ class SW_DLLPUBLIC SwFrameFormat
 // The assigned SwFrmFmt list.
 SwFrameFormats *m_ffList;
 
-SwTextBoxNode* m_pOtherTextBoxFormat;
+std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats;
 
 struct change_name
 {
@@ -102,8 +102,8 @@ protected:
 
 public:
 
-SwTextBoxNode* GetOtherTextBoxFormat() const { return 
m_pOtherTextBoxFormat; };
-void SetOtherTextBoxFormat(SwTextBoxNode* pNew) { m_pOtherTextBoxFormat = 
pNew; };
+const std::shared_ptr< SwTextBoxNode >& GetOtherTextBoxFormats() const { 
return m_pOtherTextBoxFormats; };
+void SetOtherTextBoxFormats(const std::shared_ptr& rNew) { 
m_pOtherTextBoxFormats = rNew; };
 
 virtual ~SwFrameFormat() override;
 
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 3881d897c629..d851a0fda7d2 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -213,7 +213,7 @@ public:
 ~SwTextBoxNode();
 
 // default copy ctor is enough
-SwTextBoxNode(SwTextBoxNode&) = default;
+SwTextBoxNode(const SwTextBoxNode&) = default;
 
 // This method adds a textbox entry to the shape
 // Parameters:
@@ -224,7 +224,12 @@ public:
 // This will remove the textbox entry.
 // Parameters:
 // pDrawObject: The shape which have the textbox to be deleted.
-void DelTextBox(const SdrObject* pDrawObject);
+void DelTextBox(const SdrObject* pDrawObject, bool bDelFromDoc = false);
+
+// This will remove the textbox entry.
+// Parameters:
+// pTextBox: The textbox what have to be deleted.
+void DelTextBox(const SwFrameFormat* pTextBox, bool bDelFromDoc = false);
 
 // This will return with the frame format of the textbox what belongs
 // to the given shape (pDrawObject)
diff --git a/sw/qa/extras/ooxmlexport/data/Tdf147485.docx 
b/sw/qa/extras/ooxmlexport/data/Tdf147485.docx
new file mode 100644
index ..cb630efb8717
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/Tdf147485.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 8ee4c8c3650c..fa0199ede9dd 100644
--- 

[Libreoffice-commits] core.git: sw/qa writerfilter/source

2022-03-29 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf73499.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   28 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   91 +-
 3 files changed, 115 insertions(+), 4 deletions(-)

New commits:
commit f81800193a942b3f68c61a5cede634f3eeb47b1f
Author: Attila Bakos (NISZ) 
AuthorDate: Fri Mar 4 08:27:49 2022 +0100
Commit: László Németh 
CommitDate: Tue Mar 29 16:29:39 2022 +0200

tdf#73499 DOCX import: fix grouped linked textbox

Only ungrouped text boxes were imported correctly.
Grouped textboxes lost their linking, resulting
broken layout. Now the linking is fixed for DrawingML.

Note: in old MSO versions, linking needed grouping.
To import these DOC documents correctly, convert them
to DOCX/DrawingML in MSO before opening them in Writer.

Change-Id: Ib5a8744d783a9c95c42447d204e17891b3aea7bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130950
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf73499.docx 
b/sw/qa/extras/ooxmlexport/data/tdf73499.docx
new file mode 100644
index ..605c01e2b3ac
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf73499.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 486dc6c3d1e9..53e80df5a301 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -346,6 +346,34 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148111, "tdf148111.docx")
 CPPUNIT_ASSERT(!xFields->hasMoreElements());
 }
 
+DECLARE_OOXMLEXPORT_TEST(TestTdf73499, "tdf73499.docx")
+{
+// Ensure, the bugdoc is opened
+CPPUNIT_ASSERT(mxComponent);
+// Get the groupshape
+uno::Reference xGroup(getShape(1), uno::UNO_QUERY_THROW);
+
+// Get the textboxes of the groupshape
+uno::Reference xTextBox1(xGroup->getByIndex(0), 
uno::UNO_QUERY_THROW);
+uno::Reference xTextBox2(xGroup->getByIndex(1), 
uno::UNO_QUERY_THROW);
+
+// Get the properties of the textboxes
+uno::Reference xTextBox1Properties(xTextBox1, 
uno::UNO_QUERY_THROW);
+uno::Reference xTextBox2Properties(xTextBox2, 
uno::UNO_QUERY_THROW);
+
+// Get the name of the textboxes
+uno::Reference xTextBox1Name(xTextBox1, 
uno::UNO_QUERY_THROW);
+uno::Reference xTextBox2Name(xTextBox2, 
uno::UNO_QUERY_THROW);
+
+// Check for the links, before the fix that were missing
+CPPUNIT_ASSERT_EQUAL_MESSAGE(
+"Link name missing!", xTextBox2Name->getName(),
+
xTextBox1Properties->getPropertyValue("ChainNextName").get());
+CPPUNIT_ASSERT_EQUAL_MESSAGE(
+"Link name missing!", xTextBox1Name->getName(),
+
xTextBox2Properties->getPropertyValue("ChainPrevName").get());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf81507, "tdf81507.docx")
 {
 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index a3d6a4f69498..f8700faee88c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4634,20 +4634,103 @@ void DomainMapper_Impl::PopTextBoxContent()
 
 void 
DomainMapper_Impl::AttachTextBoxContentToShape(css::uno::Reference
 xShape)
 {
+// Without textbox or shape pointless to continue
 if (m_xPendingTextBoxFrames.empty() || !xShape)
 return;
 
 uno::Reference< drawing::XShapes >xGroup(xShape, uno::UNO_QUERY);
 uno::Reference< beans::XPropertySet >xProps(xShape, uno::UNO_QUERY);
 
+// If this is a group go inside
 if (xGroup)
 for (sal_Int32 i = 0; i < xGroup->getCount(); ++i)
-
AttachTextBoxContentToShape(uno::Reference(xGroup->getByIndex(i),uno::UNO_QUERY_THROW));
+AttachTextBoxContentToShape(
+uno::Reference(xGroup->getByIndex(i), 
uno::UNO_QUERY));
 
-if (xProps->getPropertyValue("TextBox").get())
+// if this shape has to be a textbox, attach the frame
+if (!xProps->getPropertyValue("TextBox").get())
+return;
+
+// if this is a textbox there must be a waiting frame
+auto xTextBox = m_xPendingTextBoxFrames.front();
+if (!xTextBox)
+return;
+
+// Pop the pending frames
+m_xPendingTextBoxFrames.pop();
+
+// Attach the textbox to the shape
+try
+{
+xProps->setPropertyValue("TextBoxContent", uno::Any(xTextBox));
+}
+catch (...)
+{
+SAL_WARN("writerfilter.dmapper", "Exception while trying to attach 
textboxes!");
+return;
+}
+
+// If attaching is successful, then do the linking
+try
+{
+// Get the name of the textbox
+OUString sTextBoxName;
+uno::Reference xName(xTextBox, uno::UNO_QUERY);
+if (xName && !xName->getName().isEmpty())
+sTextBoxName = 

[Libreoffice-commits] core.git: Changes to 'distro/mimo/mimo-7-2'

2022-03-11 Thread Attila Bakos (NISZ) (via logerrit)
New branch 'distro/mimo/mimo-7-2' available with the following commits:


[Libreoffice-commits] core.git: Changes to 'refs/tags/mimo-7-2-branch-point'

2022-03-11 Thread Attila Bakos (NISZ) (via logerrit)
Tag 'mimo-7-2-branch-point' created by Andras Timar 
 at 2022-03-11 09:55 +

mimo-7-2-branch-point

Changes since libreoffice-7-2-branch-point-1013:
---
 0 files changed
---


[Libreoffice-commits] core.git: sw/qa sw/source xmloff/qa

2022-03-10 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/tdf116256.docx |binary
 sw/qa/extras/layout/layout2.cxx |   44 +++
 sw/source/core/doc/textboxhelper.cxx|   90 
 xmloff/qa/unit/draw.cxx |2 
 4 files changed, 125 insertions(+), 11 deletions(-)

New commits:
commit 6e8ae79176be1c34cadc833c8e521be19455fade
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Feb 17 16:00:01 2022 +0100
Commit: László Németh 
CommitDate: Thu Mar 10 19:50:36 2022 +0100

tdf#116256 sw: fix textbox position in floating table

in case of it has to follow the text flow.

Change-Id: Ic4f195c2efcc465276faa9a95362933dafa65bee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130077
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/layout/data/tdf116256.docx 
b/sw/qa/extras/layout/data/tdf116256.docx
new file mode 100644
index ..f067e04f0614
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf116256.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 38451465bab0..7c8914b814d7 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -988,6 +989,49 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf69648)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116256)
+{
+// Open bugdoc
+createSwDoc(DATA_DIRECTORY, "tdf116256.docx");
+CPPUNIT_ASSERT(mxComponent);
+
+// Get the textbox
+uno::Reference xTextBox(getShape(2), 
uno::UNO_QUERY_THROW);
+
+// Ensure that is a real textbox, and follows the text flow
+CPPUNIT_ASSERT(xTextBox->getPropertyValue("TextBox").get());
+
CPPUNIT_ASSERT(xTextBox->getPropertyValue("IsFollowingTextFlow").get());
+
+// Parse the layout
+auto pLayout = parseLayoutDump();
+// Get the position of the shape
+const auto nTextBoxShapeLeft = getXPath(pLayout,
+
"/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/"
+
"anchored/SwAnchoredDrawObject/bounds",
+"left")
+   .toInt64();
+const auto nTextBoxShapeTop = getXPath(pLayout,
+   
"/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/"
+   
"anchored/SwAnchoredDrawObject/bounds",
+   "top")
+  .toInt64();
+// Get the position of the textframe too.
+const auto nTextBoxFrameLeft
+= getXPath(pLayout,
+   
"/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/anchored/fly/infos/bounds",
+   "left")
+  .toInt64();
+const auto nTextBoxFrameTop
+= getXPath(pLayout,
+   
"/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/anchored/fly/infos/bounds",
+   "top")
+  .toInt64();
+
+// Without the fix in place these were less than they supposed to.
+CPPUNIT_ASSERT_GREATEREQUAL(nTextBoxShapeLeft, nTextBoxFrameLeft);
+CPPUNIT_ASSERT_GREATEREQUAL(nTextBoxShapeTop, nTextBoxFrameTop);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194)
 {
 SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "xaxis-labelbreak.docx");
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 6657a5244305..21da16f5f2d8 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -26,9 +26,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1069,6 +1071,9 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
 return;
 
 const bool bInlineAnchored = rShape.GetAnchor().GetAnchorId() == 
RndStdIds::FLY_AS_CHAR;
+const bool bLayoutInCell
+= rShape.GetFollowTextFlow().GetValue() && 
rShape.GetAnchor().GetContentAnchor()
+  && 
rShape.GetAnchor().GetContentAnchor()->nNode.GetNode().FindTableNode();
 SfxItemSet aTextBoxSet(pFormat->GetDoc()->GetAttrPool(), 
aFrameFormatSetRange);
 
 SfxItemIter aIter(rSet);
@@ -1085,7 +1090,7 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
 = mapAnchorType(rShape.GetAnchor().GetAnchorId());
 syncProperty(, RES_ANCHOR, MID_ANCHOR_ANCHORTYPE, 
uno::Any(aNewAnchorType),
  pObj);
-if (bInlineAnchored)
+if (bInlineAnchored || bLayoutInCell)
 return;
 SwFormatVertOrient 
aOrient(pItem->StaticWhichCast(RES_VERT_ORIENT));
 
@@ -1115,7 +1120,7 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa sw/source

2022-03-10 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/odfimport/data/tdf146597.odt |binary
 sw/qa/extras/odfimport/odfimport.cxx  |6 ++
 sw/source/core/draw/dcontact.cxx  |5 -
 3 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit d691e9ef4d77cf5e46aec288d5efcf9291534352
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Feb 24 09:51:15 2022 +0100
Commit: László Németh 
CommitDate: Thu Mar 10 13:34:41 2022 +0100

tdf#146597 sw: fix freezing with GroupShape

in case it is anchored to character and wrap is none.

Regression from 8da3586cff9cc11cf5db985d19851f21f0d42eb8
"tdf#141220 sw: fix textbox popped out of off-page shape".

Note: This is a backport-compatible fix made also for the
7.3 backport. There will be a less urgent 7.4-only fix
for its unresolved group case soon.

Change-Id: I421c85e2dd16ad2649bc299fc4733d462be8d7b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130478
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit e835c2c0d3aff4f1ee5d29c9eaf36400b1aca6a7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130456
Tested-by: Jenkins
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130715
Reviewed-by: Attila Bakos 

diff --git a/sw/qa/extras/odfimport/data/tdf146597.odt 
b/sw/qa/extras/odfimport/data/tdf146597.odt
new file mode 100644
index ..6dcc379cef4d
Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf146597.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index bd936937475d..c1ec472f405d 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1322,5 +1322,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf146257)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf146597)
+{
+load(mpTestDocumentPath, "tdf146597.odt");
+// This was creashed before.
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index ad377073a58e..e4d2450629c8 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1338,7 +1338,10 @@ void SwDrawContact::Changed_( const SdrObject& rObj,
 
 // tdf#135198: keep text box together with its shape
 const SwPageFrame* rPageFrame = pAnchoredDrawObj->GetPageFrame();
-if (rPageFrame && rPageFrame->isFrameAreaPositionValid())
+auto pFormat = GetFormat();
+if (rPageFrame && rPageFrame->isFrameAreaPositionValid() && pFormat
+&& (SwTextBoxHelper::isTextBox(pFormat, RES_FLYFRMFMT) ||
+SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT)))
 {
 SwDoc* const pDoc = GetFormat()->GetDoc();
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - oox/source sd/qa

2022-03-07 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx |   15 ++-
 sd/qa/unit/data/pptx/tdf147121.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   32 
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 2c06fba68d3cd194edfddf49cd2779c761b6bd38
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Feb 16 16:09:00 2022 +0100
Commit: Xisco Fauli 
CommitDate: Mon Mar 7 10:55:42 2022 +0100

tdf#147121 PPTX: fix regression of font size export of empty lines

If the empty line has got direct formatted font size,
don't forget to export it, unless the master setting
is applied.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
"tdf#111903 tdf#137152 PPTX export: fix placeholders".

Change-Id: If686e487bca9c198fd7c96860a21e4efe91381bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130005
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit f29c14e8c36819296d0c66bb995201acf0a2647e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130675
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 69f210cfe325..c457e65ac0c8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2450,6 +2450,10 @@ void DrawingML::WriteRun( const Reference< XTextRange >& 
rRun,
 if (GetProperty(rXPropSet, "NumberingIsNumber"))
 mAny >>= bNumberingIsNumber;
 
+float nFontSize = -1;
+if (GetProperty(rXPropSet, "CharHeight"))
+mAny >>= nFontSize;
+
 bool bIsURLField = false;
 OUString sFieldValue = GetFieldValue( rRun, bIsURLField );
 bool bWriteField  = !( sFieldValue.isEmpty() || bIsURLField );
@@ -2482,7 +2486,16 @@ void DrawingML::WriteRun( const Reference< XTextRange >& 
rRun,
 
 if (sText == "\n")
 {
-mpFS->singleElementNS(XML_a, XML_br);
+// Empty run? Do not forget to write the font size in case of pptx:
+if ((GetDocumentType() == DOCUMENT_PPTX) && (nFontSize != -1))
+{
+mpFS->startElementNS(XML_a, XML_br);
+mpFS->singleElementNS(XML_a, XML_rPr, XML_sz,
+  OString::number(nFontSize * 100).getStr());
+mpFS->endElementNS(XML_a, XML_br);
+}
+else
+mpFS->singleElementNS(XML_a, XML_br);
 }
 else
 {
diff --git a/sd/qa/unit/data/pptx/tdf147121.pptx 
b/sd/qa/unit/data/pptx/tdf147121.pptx
new file mode 100644
index ..5762a4b9216b
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf147121.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 1650680a2c30..db33ac9b88c4 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -123,6 +123,7 @@ public:
 void testTdf143222_embeddedWorksheet();
 void testTdf142235_TestPlaceholderTextAlignment();
 void testTdf143315();
+void testTdf147121();
 void testTdf140912_PicturePlaceholder();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
@@ -197,6 +198,7 @@ public:
 CPPUNIT_TEST(testTdf143222_embeddedWorksheet);
 CPPUNIT_TEST(testTdf142235_TestPlaceholderTextAlignment);
 CPPUNIT_TEST(testTdf143315);
+CPPUNIT_TEST(testTdf147121);
 CPPUNIT_TEST(testTdf140912_PicturePlaceholder);
 CPPUNIT_TEST_SUITE_END();
 
@@ -1847,6 +1849,36 @@ void SdOOXMLExportTest3::testTdf143315()
 assertXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:buChar", 0);
 }
 
+void SdOOXMLExportTest3::testTdf147121()
+{
+// Get the bugdoc
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf147121.pptx"), 
PPTX);
+
+CPPUNIT_ASSERT(xDocShRef);
+// Get the second line props of the placeholder
+uno::Reference xPage(getPage(0, xDocShRef));
+uno::Reference xShape(xPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
+uno::Reference xRun(
+getRunFromParagraph(2, getParagraphFromShape(0, xShape)), 
uno::UNO_QUERY_THROW);
+
+// Save the font size
+const auto nFontSizeBefore = 
xRun->getPropertyValue("CharHeight").get() * 100;
+
+// Save and reload
+utl::TempFile tmpfile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+// Parse the export
+xmlDocUniquePtr pXml = parseExport(tmpfile, "ppt/slides/slide1.xml");
+const auto nFontSizeAfter
+= getXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:br[1]/a:rPr", "sz").toFloat();
+
+// The font size was not saved before now it must be equal with the saved 
one.
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected font size", nFontSizeBefore, 
nFontSizeAfter);
+}
+
 void SdOOXMLExportTest3::testTdf140912_PicturePlaceholder()
 {
 ::sd::DrawDocShellRef xDocShRef = loadURL(


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

2022-03-02 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |   39 ++
 sw/qa/extras/ooxmlexport/data/tdf141550.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx   |   17 +
 sw/qa/extras/uiwriter/data3/tdf140975.docx   |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx  |   30 ++
 sw/qa/uitest/data/tdf141557.docx |binary
 sw/source/core/doc/textboxhelper.cxx |  362 +++
 sw/source/core/text/porfly.cxx   |1 
 8 files changed, 344 insertions(+), 105 deletions(-)

New commits:
commit bea00ffb1b6d65a276b8bc55a6e0135fb9bcf65b
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Apr 1 17:08:58 2021 +0200
Commit: Miklos Vajna 
CommitDate: Thu Mar 3 08:12:52 2022 +0100

tdf#141550 tdf#141557 tdf#140975 sw: fix textbox crash

and regressions by refactoring SwTextBoxHelper.

tdf#141550 was a DOCX import regression from
commit ff321dd36554d25f0817903becf4598065e0a194
(tdf#140828 sw textbox: fix AS_CHAR regression),
resulting bad horizontal position of the frame of
the textbox.

tdf#141557 was a regression resulting crash
by changing text box anchoring "To Paragraph".

tdf#140975 was an implementation error, resulting
broken textbox by changing box anchoring to
"As Character".

In the SwTextBoxHelper class there were many
repeating code parts for textbox positioning.
Now these parts have been replaced with
the calls of several new functions:

1) getShapeFormat() returns with the SwFrameFormat
   of the UNO XShape;

2) setWrapThrough() only sets the surround
   of the textframe (used in the code frequently);

3) changeAnchor() sets the anchor of the textframe
   according to the anchor of the shape;

4) doTextFramePositioning() sets the position of the
   textbox according to the shape (used in the code
   frequently);

5) isAnchorTypeDifferent() shows difference of the
   anchor types of the shape and the textframe. Also it
   handles the situation of anchoring "As Character";

6) isTextBoxHasValidTextFrame() checks if the shape
   is a part of a textbox or not.

Every function returns with true on success, otherwise
gives information to the log. All of them can be called
with ShapeFormat or UNO XShape.

The goal of this to make the possibility to advance this
class for further functions – rotation, grouped
textboxes etc. – without code copying.

Change-Id: I4441cab87931f161d0ace4983646d6d2a68a7321
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113463
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit cb965f2cf6d68c284ccbd8a9635abfdfcc0538ca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130900
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 2043b1ffcfb3..aa1940b5dd60 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -79,9 +79,48 @@ public:
 /// Similar to syncProperty(), but used by the internal API (e.g. for UI 
purposes).
 static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
rSet);
 
+/// Returns the SwFrameFormat* of the given UNO-XShape if exists otherwise 
nullptr.
+static SwFrameFormat* 
getShapeFormat(css::uno::Reference xShape);
+
 /// Copy shape attributes to the text frame
 static void updateTextBoxMargin(SdrObject* pObj);
 
+/// Sets the surround to through for the textframe of the given shape,
+/// not to interfere with the layout. Returns true on success.
+static bool setWrapThrough(SwFrameFormat* pShape);
+
+/// Sets the surround to through for the textframe of the given shape,
+/// not to interfere with the layout. Returns true on success.
+static bool setWrapThrough(css::uno::Reference 
xShape);
+
+/// Sets the anchor of the associated textframe of the given shape, and
+/// returns true on success.
+static bool changeAnchor(SwFrameFormat* pShape);
+
+/// Sets the anchor of the associated textframe of the given shape, and
+/// returns true on success.
+static bool changeAnchor(css::uno::Reference xShape);
+
+/// Does the positioning for the associated textframe of the shape, and
+/// returns true on success.
+static bool doTextBoxPositioning(SwFrameFormat* pShape);
+
+/// Does the positioning for the associated textframe of the shape, and
+/// returns true on success.
+static bool doTextBoxPositioning(css::uno::Reference 
xShape);
+
+/// Returns true if the anchor different for the  given shape, and the
+/// associated textframe of the given shape.
+/// Note: In case of AS_CHAR anchor the anchor type must be different,
+/// because if not, layout breaks, but this situation also handled by
+/// this function, and returns true in that case 

[Libreoffice-commits] core.git: sw/qa sw/source

2022-03-02 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/tdf69648.docx |binary
 sw/qa/extras/layout/layout2.cxx|   42 +
 sw/source/core/doc/textboxhelper.cxx   |   20 +++
 3 files changed, 62 insertions(+)

New commits:
commit 9c0779cfe6a091e222a35b068e9354dce32cc2dc
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Feb 10 18:59:11 2022 +0100
Commit: László Németh 
CommitDate: Wed Mar 2 09:11:23 2022 +0100

tdf#69648 tdf#119234 sw: fix at-char group textbox position

in case of it has at-page relative position. This fixes
missing or invisible text content of shapes.

Note: the remaining problem (original DOCX resaved in
MSO 2016) was fixed at tdf#119234.

Partial regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

Change-Id: I5c9af0d9a50e4251d3017862ad1fc94eca7d40c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129796
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/layout/data/tdf69648.docx 
b/sw/qa/extras/layout/data/tdf69648.docx
new file mode 100644
index ..5bf8fcc70911
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf69648.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 8b457c7f3f9c..38451465bab0 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -946,6 +946,48 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testHorizontal_multilevel)
 CPPUNIT_ASSERT_DOUBLES_EQUAL(8057, nYposition, 20);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf69648)
+{
+createSwDoc(DATA_DIRECTORY, "tdf69648.docx");
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+CPPUNIT_ASSERT(pXmlDoc);
+
+OString sShapeXPath[2] = {
+
"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[1]",
+
"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[2]"
+};
+OString sFrameXPath[2] = { 
"/root/page/body/txt/anchored/fly[1]/infos/bounds",
+   
"/root/page/body/txt/anchored/fly[2]/infos/bounds" };
+
+for (int i = 0; i < 2; ++i)
+{
+const auto sDrawRect = getXPath(pXmlDoc, sShapeXPath[i], "aOutRect");
+const auto nComaPos1 = sDrawRect.indexOf(',', 0);
+const auto nComaPos2 = sDrawRect.indexOf(',', nComaPos1 + 1);
+const auto nComaPos3 = sDrawRect.indexOf(',', nComaPos2 + 1);
+
+const auto nDraw1 = OUString(sDrawRect.subView(0, 
nComaPos1).data()).toInt64();
+const auto nDraw2
+= OUString(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - 
nComaPos1).data()).toInt64();
+const auto nDraw3
+= OUString(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - 
nComaPos2).data()).toInt64();
+const auto nDraw4
+= OUString(
+  sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - 
nComaPos3 - 1).data())
+  .toInt64();
+const auto aChildShape = SwRect(nDraw1, nDraw2, nDraw3, nDraw4);
+
+const auto nFlyLeft = getXPath(pXmlDoc, sFrameXPath[i], 
"left").toInt64();
+const auto nFlyTop = getXPath(pXmlDoc, sFrameXPath[i], 
"top").toInt64();
+const auto nFlyWidth = getXPath(pXmlDoc, sFrameXPath[i], 
"width").toInt64();
+const auto nFlyHeight = getXPath(pXmlDoc, sFrameXPath[i], 
"height").toInt64();
+
+const auto aFrame = SwRect(nFlyLeft, nFlyTop, nFlyWidth, nFlyHeight);
+
+CPPUNIT_ASSERT_MESSAGE("Textbox must be inside the shape!", 
aChildShape.Contains(aFrame));
+}
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194)
 {
 SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "xaxis-labelbreak.docx");
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 206e05dc811e..6657a5244305 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1408,6 +1408,26 @@ bool 
SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb
 (bIsGroupObj && pObj ? pObj->GetRelativePos().getY() : 
aNewVOri.GetPos())
 + aRect.Top());
 
+const auto& nInshapePos
+= pObj ? pObj->GetRelativePos() - 
pShape->FindRealSdrObject()->GetRelativePos()
+   : Point();
+
+if (pShape->GetHoriOrient().GetRelationOrient() == 
text::RelOrientation::PAGE_FRAME
+&& pShape->GetAnchor().GetAnchorId() != RndStdIds::FLY_AT_PAGE)
+{
+aNewHOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
+aNewHOri.SetPos(pShape->GetHoriOrient().GetPos() + 
nInshapePos.getX()
++ aRect.Left());
+}
+
+if (pShape->GetVertOrient().GetRelationOrient() == 
text::RelOrientation::PAGE_FRAME
+&& 

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source xmloff/qa

2022-03-01 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx  |   15 -
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |   19 -
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |4 
 sw/qa/extras/uiwriter/data/tdf147126.docx |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx   |  132 
 sw/source/core/doc/textboxhelper.cxx  |  281 +++---
 sw/source/core/frmedt/feshview.cxx|8 
 sw/source/core/text/porfly.cxx|   56 -
 xmloff/qa/unit/draw.cxx   |2 
 9 files changed, 282 insertions(+), 235 deletions(-)

New commits:
commit 0d29394598db2e336a9982cbb7041ea407b2bf6d
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Feb 7 17:09:42 2022 +0100
Commit: László Németh 
CommitDate: Tue Mar 1 17:53:01 2022 +0100

tdf#147126 sw: fix missing as_char anchoring of group textboxes

which resulted lost (invisible) text content before
implementing its support now.

Cleanup to SwTextBoxHelper by removing its unneeded functions.

testFDO78590 was commented out temporarily because it has a
pure VML groupshape inside and it's converted to WPG during
the test run resulting crash on reopening, because lack of
its support in DocumentContentOperationsManager, trying to
convert the content to a text frame inside a text frame.

Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

Change-Id: Ic6ce3549d390ae763044f54e991f390677704396
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129627
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index a41c6c9eaf87..fd194a639bcc 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -92,10 +92,6 @@ public:
 /// Copy shape attributes to the text frame
 static void updateTextBoxMargin(SdrObject* pObj);
 
-/// Sets the surround to through for the textframe of the given shape,
-/// not to interfere with the layout. Returns true on success.
-static bool setWrapThrough(SwFrameFormat* pShape);
-
 /// Sets the anchor of the associated textframe of the given shape, and
 /// returns true on success.
 static bool changeAnchor(SwFrameFormat* pShape, SdrObject* pObj);
@@ -104,19 +100,9 @@ public:
 /// returns true on success.
 static bool doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pObj);
 
-/// Returns true if the anchor different for the  given shape, and the
-/// associated textframe of the given shape.
-/// Note: In case of AS_CHAR anchor the anchor type must be different,
-/// because if not, layout breaks, but this situation also handled by
-/// this function, and returns true in that case too.
-static std::optional isAnchorTypeDifferent(const SwFrameFormat* 
pShape);
-
 /// Sets the correct size of textframe depending on the given SdrObject.
 static bool syncTextBoxSize(SwFrameFormat* pShape, SdrObject* pObj);
 
-/// Returns true if the given shape has a valid textframe.
-static bool isTextBoxShapeHasValidTextFrame(const SwFrameFormat* pShape);
-
 // Returns true on success. Synchronize z-order of the text frame of the 
given textbox
 // by setting it one level higher than the z-order of the shape of the 
textbox.
 static bool DoTextBoxZOrderCorrection(SwFrameFormat* pShape, const 
SdrObject* pObj);
@@ -188,6 +174,7 @@ public:
 /// Calls the method given by pFunc with every textboxes of the group 
given by pFormat.
 static void synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat*, 
SdrObject*),
 SwFrameFormat* pFormat, 
SdrObject* pObj);
+
 /// Collect all textboxes of the group given by the pGroupObj Parameter. 
Returns with a
 /// vector filled with the textboxes.
 static std::vector CollectTextBoxes(SdrObject* 
pGroupObject,
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index bcfa93e84e72..42b743aabccc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -432,15 +432,16 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo78910)
 assertXPath ( pXmlDoc, "//w:hyperlink[2]/w:r[5]/w:fldChar", "fldCharType", 
"end" );
 }
 
-CPPUNIT_TEST_FIXTURE(Test, testFDO78590)
-{
-loadAndReload("FDO78590.docx");
-xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
-
-// This is to ensure that the fld starts and ends inside a hyperlink...
-assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:framePr", "w", 
"9851" );
-assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:framePr", "h", 
"1669" );
-}
+// FIXME: During this test a pure VML shape get converted to DML and crash at 
verifying.
+// CPPUNIT_TEST_FIXTURE(Test, testFDO78590)
+// {
+// 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-02-28 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx |   15 ++-
 sd/qa/unit/data/pptx/tdf147121.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   32 
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit f29c14e8c36819296d0c66bb995201acf0a2647e
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Feb 16 16:09:00 2022 +0100
Commit: László Németh 
CommitDate: Mon Feb 28 14:53:55 2022 +0100

tdf#147121 PPTX: fix regression of font size export of empty lines

If the empty line has got direct formatted font size,
don't forget to export it, unless the master setting
is applied.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
"tdf#111903 tdf#137152 PPTX export: fix placeholders".

Change-Id: If686e487bca9c198fd7c96860a21e4efe91381bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130005
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 6e4197fa69c3..835654d7f3a2 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2534,6 +2534,10 @@ void DrawingML::WriteRun( const Reference< XTextRange >& 
rRun,
 if (GetProperty(rXPropSet, "NumberingIsNumber"))
 mAny >>= bNumberingIsNumber;
 
+float nFontSize = -1;
+if (GetProperty(rXPropSet, "CharHeight"))
+mAny >>= nFontSize;
+
 bool bIsURLField = false;
 OUString sFieldValue = GetFieldValue( rRun, bIsURLField );
 bool bWriteField  = !( sFieldValue.isEmpty() || bIsURLField );
@@ -2566,7 +2570,16 @@ void DrawingML::WriteRun( const Reference< XTextRange >& 
rRun,
 
 if (sText == "\n")
 {
-mpFS->singleElementNS(XML_a, XML_br);
+// Empty run? Do not forget to write the font size in case of pptx:
+if ((GetDocumentType() == DOCUMENT_PPTX) && (nFontSize != -1))
+{
+mpFS->startElementNS(XML_a, XML_br);
+mpFS->singleElementNS(XML_a, XML_rPr, XML_sz,
+  OString::number(nFontSize * 100).getStr());
+mpFS->endElementNS(XML_a, XML_br);
+}
+else
+mpFS->singleElementNS(XML_a, XML_br);
 }
 else
 {
diff --git a/sd/qa/unit/data/pptx/tdf147121.pptx 
b/sd/qa/unit/data/pptx/tdf147121.pptx
new file mode 100644
index ..5762a4b9216b
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf147121.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index cb1ad50ac2ed..58b4d3680da9 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -103,6 +103,7 @@ public:
 void testTdf143222_embeddedWorksheet();
 void testTdf142235_TestPlaceholderTextAlignment();
 void testTdf143315();
+void testTdf147121();
 void testTdf140912_PicturePlaceholder();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
@@ -177,6 +178,7 @@ public:
 CPPUNIT_TEST(testTdf143222_embeddedWorksheet);
 CPPUNIT_TEST(testTdf142235_TestPlaceholderTextAlignment);
 CPPUNIT_TEST(testTdf143315);
+CPPUNIT_TEST(testTdf147121);
 CPPUNIT_TEST(testTdf140912_PicturePlaceholder);
 CPPUNIT_TEST_SUITE_END();
 
@@ -1828,6 +1830,36 @@ void SdOOXMLExportTest3::testTdf143315()
 assertXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:buChar", 0);
 }
 
+void SdOOXMLExportTest3::testTdf147121()
+{
+// Get the bugdoc
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf147121.pptx"), 
PPTX);
+
+CPPUNIT_ASSERT(xDocShRef);
+// Get the second line props of the placeholder
+uno::Reference xPage(getPage(0, xDocShRef));
+uno::Reference xShape(xPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
+uno::Reference xRun(
+getRunFromParagraph(2, getParagraphFromShape(0, xShape)), 
uno::UNO_QUERY_THROW);
+
+// Save the font size
+const auto nFontSizeBefore = 
xRun->getPropertyValue("CharHeight").get() * 100;
+
+// Save and reload
+utl::TempFile tmpfile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+// Parse the export
+xmlDocUniquePtr pXml = parseExport(tmpfile, "ppt/slides/slide1.xml");
+const auto nFontSizeAfter
+= getXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:br[1]/a:rPr", "sz").toFloat();
+
+// The font size was not saved before now it must be equal with the saved 
one.
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected font size", nFontSizeBefore, 
nFontSizeAfter);
+}
+
 void SdOOXMLExportTest3::testTdf140912_PicturePlaceholder()
 {
 ::sd::DrawDocShellRef xDocShRef = loadURL(


[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - sw/qa sw/source

2022-02-28 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/odfimport/data/tdf146597.odt |binary
 sw/qa/extras/odfimport/odfimport.cxx  |6 ++
 sw/source/core/draw/dcontact.cxx  |3 ++-
 3 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit e38ab299c109766a5a431e5c0fb6b2c59ae3025c
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Feb 24 09:51:15 2022 +0100
Commit: László Németh 
CommitDate: Mon Feb 28 10:00:50 2022 +0100

tdf#146597 sw: fix freezing with GroupShape

in case it is anchored to character and wrap is none.

Regression from 8da3586cff9cc11cf5db985d19851f21f0d42eb8
"tdf#141220 sw: fix textbox popped out of off-page shape".

Note: This is a backport-compatible fix made also for the
7.3 backport. There will be a less urgent 7.4-only fix
for its unresolved group case soon.

Change-Id: I421c85e2dd16ad2649bc299fc4733d462be8d7b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130478
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit e835c2c0d3aff4f1ee5d29c9eaf36400b1aca6a7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130456
Tested-by: Jenkins

diff --git a/sw/qa/extras/odfimport/data/tdf146597.odt 
b/sw/qa/extras/odfimport/data/tdf146597.odt
new file mode 100644
index ..6dcc379cef4d
Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf146597.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index fa79c7197f42..336cca824232 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1328,5 +1328,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf146257)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf146597)
+{
+load(mpTestDocumentPath, "tdf146597.odt");
+// This was creashed before.
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index cb9618c44e8b..668288dac689 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1342,7 +1342,8 @@ void SwDrawContact::Changed_( const SdrObject& rObj,
 
 // tdf#135198: keep text box together with its shape
 const SwPageFrame* rPageFrame = pAnchoredDrawObj->GetPageFrame();
-if (rPageFrame && rPageFrame->isFrameAreaPositionValid() && 
!rObj.getChildrenOfSdrObject())
+if (rPageFrame && rPageFrame->isFrameAreaPositionValid() && 
GetFormat()
+&& GetFormat()->GetOtherTextBoxFormat())
 {
 SwDoc* const pDoc = GetFormat()->GetDoc();
 


[Libreoffice-commits] core.git: sw/qa sw/source

2022-02-25 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/odfimport/data/tdf146597.odt |binary
 sw/qa/extras/odfimport/odfimport.cxx  |6 ++
 sw/source/core/draw/dcontact.cxx  |3 ++-
 3 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit e835c2c0d3aff4f1ee5d29c9eaf36400b1aca6a7
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Feb 24 09:51:15 2022 +0100
Commit: László Németh 
CommitDate: Fri Feb 25 11:22:01 2022 +0100

tdf#146597 sw: fix freezing with GroupShape

in case it is anchored to character and wrap is none.

Regression from 8da3586cff9cc11cf5db985d19851f21f0d42eb8
"tdf#141220 sw: fix textbox popped out of off-page shape".

Note: This is a backport-compatible fix made also for the
7.3 backport. There will be a less urgent 7.4-only fix
for its unresolved group case soon.

Change-Id: I421c85e2dd16ad2649bc299fc4733d462be8d7b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130478
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/odfimport/data/tdf146597.odt 
b/sw/qa/extras/odfimport/data/tdf146597.odt
new file mode 100644
index ..6dcc379cef4d
Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf146597.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index ed715a75f9a2..1130f3cce848 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1328,5 +1328,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf146257)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf146597)
+{
+load(mpTestDocumentPath, "tdf146597.odt");
+// This was creashed before.
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 563bb61737a6..7040a741076c 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1341,7 +1341,8 @@ void SwDrawContact::Changed_( const SdrObject& rObj,
 
 // tdf#135198: keep text box together with its shape
 const SwPageFrame* rPageFrame = pAnchoredDrawObj->GetPageFrame();
-if (rPageFrame && rPageFrame->isFrameAreaPositionValid() && 
!rObj.getChildrenOfSdrObject())
+if (rPageFrame && rPageFrame->isFrameAreaPositionValid() && 
GetFormat()
+&& GetFormat()->GetOtherTextBoxFormat())
 {
 SwDoc* const pDoc = GetFormat()->GetDoc();
 


[Libreoffice-commits] core.git: include/oox oox/source sw/qa

2022-02-03 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/drawingml/shape.hxx  |3 +
 oox/source/drawingml/shape.cxx   |   42 +++
 oox/source/shape/WpgContext.hxx  |2 -
 oox/source/shape/WpsContext.cxx  |   43 +++
 oox/source/shape/WpsContext.hxx  |1 
 sw/qa/extras/ooxmlexport/data/WPGbodyPr.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   49 +++
 7 files changed, 139 insertions(+), 1 deletion(-)

New commits:
commit 65b09ef1c5e24651579eb11900cf2ddbbb7b0971
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Jan 24 10:57:34 2022 +0100
Commit: László Németh 
CommitDate: Thu Feb 3 09:28:52 2022 +0100

tdf#146803 tdf#146805 OOXML import: fix bodyPr at grouped shapes

Grouped text boxes (WPG) lost their alignment and spacing,
because the bodyPr tag what has the information for this,
processed after the textbox content, and applied to the XShape
which in case of group shape is not ready. To solve this, the
mentioned properties read for the shape member after copied
to the XShape when its ready, and than synced to the textbox.

Regression from commit 121cbc250b36290f0f8c7265fea57256dad69553
"tdf#66039 DOCX: import textboxes (with tables, images etc.) in
group shapes".

Change-Id: Ifb5e8bde58613137441bec2e2b51bc67118dab40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128854
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 57a47cbdb4e5..40c8319f67d3 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -205,6 +205,8 @@ public:
 const Color&getFontRefColorForNodes() const { return 
maFontRefColorForNodes; }
 voidsetLockedCanvas(bool bLockedCanvas);
 boolgetLockedCanvas() const { return mbLockedCanvas;}
+voidsetWPGChild(bool bWPG);
+boolisWPGChild() const { return mbWPGChild;}
 voidsetWps(bool bWps);
 boolgetWps() const { return mbWps;}
 voidsetTextBox(bool bTextBox);
@@ -360,6 +362,7 @@ private:
  // we need separate 
flag because we don't want
  // to propagate it 
when applying reference shape
 boolmbLocked;
+bool mbWPGChild; // Is this shape a child of a WPG shape?
 bool mbLockedCanvas; ///< Is this shape part of a locked canvas?
 bool mbWps; ///< Is this a wps shape?
 bool mbTextBox; ///< This shape has a textbox.
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index f7161e01291f..b1335add 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -134,6 +134,7 @@ Shape::Shape( const char* pServiceName, bool bDefaultHeight 
)
 , mbHidden( false )
 , mbHiddenMasterShape( false )
 , mbLocked( false )
+, mbWPGChild(false)
 , mbLockedCanvas( false )
 , mbWps( false )
 , mbTextBox( false )
@@ -176,6 +177,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
 , mbHidden( pSourceShape->mbHidden )
 , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
 , mbLocked( pSourceShape->mbLocked )
+, mbWPGChild( pSourceShape->mbWPGChild )
 , mbLockedCanvas( pSourceShape->mbLockedCanvas )
 , mbWps( pSourceShape->mbWps )
 , mbTextBox( pSourceShape->mbTextBox )
@@ -292,6 +294,41 @@ void Shape::addShape(
 if ( xShapes.is() )
 addChildren( rFilterBase, *this, pTheme, xShapes, pShapeMap, 
aMatrix );
 
+if (isWPGChild() && xShape)
+{
+// This is a wps shape and it is the child of the WPG, now 
copy the
+// the text body properties to the xshape.
+Reference xChildWPSProperties(xShape, 
uno::UNO_QUERY);
+
+if (getTextBody() && xChildWPSProperties)
+{
+xChildWPSProperties->setPropertyValue(
+UNO_NAME_TEXT_VERTADJUST,
+uno::Any(getTextBody()->getTextProperties().meVA));
+
+xChildWPSProperties->setPropertyValue(
+UNO_NAME_TEXT_LEFTDIST,
+
uno::Any(getTextBody()->getTextProperties().moInsets[0].has_value()
+ ? 
*getTextBody()->getTextProperties().moInsets[0]
+ : 0));
+xChildWPSProperties->setPropertyValue(
+UNO_NAME_TEXT_UPPERDIST,
+
uno::Any(getTextBody()->getTextProperties().moInsets[1].has_value()
+ ? 
*getTextBody()->getTextProperties().moInsets[1]
+ : 0));
+

[Libreoffice-commits] core.git: include/oox oox/source sw/qa writerfilter/source

2022-02-03 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/shape/ShapeContextHandler.hxx |   18 +++---
 oox/source/shape/ShapeContextHandler.cxx  |   31 +++---
 sw/qa/extras/ooxmlexport/data/tdf146802.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   13 +++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |5 +-
 5 files changed, 48 insertions(+), 19 deletions(-)

New commits:
commit 4a38ca4035ac03571925e72cb47e0beb8da2003a
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Jan 19 17:43:54 2022 +0100
Commit: László Németh 
CommitDate: Thu Feb 3 09:12:20 2022 +0100

tdf#146802 OOXML import: fix embedded VML in grouped textbox

E.g. OLE formulas inside them broke document load.

Regression from 121cbc250b36290f0f8c7265fea57256dad69553
"tdf#66039 DOCX: import textboxes (with tables, images etc.)
in group shapes".

Note: now embedded VML OLE is loaded in WPG shapes, thanks to
that the ShapeHandler in oox/ has a stack having the start
token inside for each shape.

Change-Id: I973d78ed88c5c83efffd9629061e2a2c6fdd25e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128627
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/include/oox/shape/ShapeContextHandler.hxx 
b/include/oox/shape/ShapeContextHandler.hxx
index 27b70d2cf2c4..a245224730ed 100644
--- a/include/oox/shape/ShapeContextHandler.hxx
+++ b/include/oox/shape/ShapeContextHandler.hxx
@@ -19,6 +19,7 @@
 #pragma once
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -90,12 +91,15 @@ public:
 void setRelationFragmentPath(const OUString & the_value);
 
 sal_Int32 getStartToken() const;
-void setStartToken( sal_Int32 _starttoken );
+void popStartToken();
+void pushStartToken( sal_Int32 _starttoken );
 
 void setPosition(const css::awt::Point& rPosition);
 
-const bool& getFullWPGSupport() { return m_bFullWPGSUpport; };
-void setFullWPGSupport(const bool& rbUse) { m_bFullWPGSUpport = rbUse; };
+const bool& getFullWPGSupport() { return m_bFullWPGSUpport; }
+void setFullWPGSupport(const bool& rbUse) { m_bFullWPGSUpport = rbUse; }
+
+bool isWordProcessingGroupShape() const { return mxWpgContext ? true : 
false; }
 
 void setDocumentProperties(const 
css::uno::Reference& xDocProps);
 void setMediaDescriptor(const 
css::uno::Sequence& rMediaDescriptor);
@@ -109,9 +113,13 @@ private:
 ShapeContextHandler(ShapeContextHandler const &) = delete;
 void operator =(ShapeContextHandler const &) = delete;
 
-::sal_uInt32 mnStartToken;
+// Special stack which always has at least one element.
+// In case of group shapes with embedded content it will have more element 
than one.
+std::stack mnStartTokenStack;
+
 css::awt::Point maPosition;
-bool m_bFullWPGSUpport;
+bool m_bFullWPGSUpport; // Is this DrawingML shape supposed to be 
proccessed as WPG?
+
 drawingml::ShapePtr mpShape;
 std::shared_ptr< vml::Drawing > mpDrawing;
 
diff --git a/oox/source/shape/ShapeContextHandler.cxx 
b/oox/source/shape/ShapeContextHandler.cxx
index 6eb9e5ce9083..cacd46d82d14 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -44,7 +44,6 @@ using namespace core;
 using namespace drawingml;
 
 ShapeContextHandler::ShapeContextHandler(const 
rtl::Reference& xFilterBase) :
-  mnStartToken(0),
   m_bFullWPGSUpport(false),
   mxShapeFilterBase(xFilterBase)
 
@@ -225,8 +224,9 @@ uno::Reference
 ShapeContextHandler::getContextHandler(sal_Int32 nElement)
 {
 uno::Reference xResult;
+const sal_uInt32 nStartToken = getStartToken();
 
-switch (getNamespace( mnStartToken ))
+switch (getNamespace( nStartToken ))
 {
 case NMSP_doc:
 case NMSP_vml:
@@ -236,19 +236,19 @@ ShapeContextHandler::getContextHandler(sal_Int32 nElement)
 xResult.set(getDiagramShapeContext());
 break;
 case NMSP_dmlLockedCanvas:
-xResult.set(getLockedCanvasContext(mnStartToken));
+xResult.set(getLockedCanvasContext(nStartToken));
 break;
 case NMSP_dmlChart:
-xResult.set(getChartShapeContext(mnStartToken));
+xResult.set(getChartShapeContext(nStartToken));
 break;
 case NMSP_wps:
-xResult.set(getWpsContext(mnStartToken, nElement));
+xResult.set(getWpsContext(nStartToken, nElement));
 break;
 case NMSP_wpg:
-xResult.set(getWpgContext(mnStartToken));
+xResult.set(getWpgContext(nStartToken));
 break;
 default:
-xResult.set(getGraphicShapeContext(mnStartToken));
+xResult.set(getGraphicShapeContext(nStartToken));
 break;
 }
 
@@ -456,7 +456,7 @@ ShapeContextHandler::getShape()
 //NMSP_dmlChart == getNamespace( mnStartToken ) check is introduced to 
make sure that
 

[Libreoffice-commits] core.git: sw/qa

2022-02-02 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx |   95 ++
 1 file changed, 59 insertions(+), 36 deletions(-)

New commits:
commit 3ee6e4e7c2046c4124b5c34f053888d3ee0a5a53
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jan 6 16:41:09 2022 +0100
Commit: László Németh 
CommitDate: Wed Feb 2 18:18:16 2022 +0100

Related tdf#66039: restore unit tests disabled temporarily

Follow-up to 121cbc250b36290f0f8c7265fea57256dad69553
"tdf#66039 DOCX: import textboxes (with tables, images etc.)
in group shapes"

Two tests have been restored. One of them had to be modified,
where the test document has a pure VML shape inside, and after
its reload, the shape has got a DML part with textboxes. This
differs from the input, but verification handles it now.

Change-Id: Ic71cd06496da7d07c09530770282c03c7438640e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128055
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index 30c9d81627fc..392831f9387c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -690,17 +690,17 @@ DECLARE_OOXMLEXPORT_TEST(testN792778, "n792778.docx")
 xInnerShape.set(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(11684), xInnerShape->getPosition().Y);
 }
-//FIXME:
-//DECLARE_OOXMLEXPORT_TEST(testGroupshapeSmarttag, "groupshape-smarttag.docx")
-//{
-//uno::Reference xGroupShape(getShape(1), 
uno::UNO_QUERY);
-//uno::Reference xShape(xGroupShape->getByIndex(0), 
uno::UNO_QUERY);
-//// First run of shape text was missing due to the w:smartTag wrapper 
around it.
-//CPPUNIT_ASSERT_EQUAL(OUString("Box 2"), xShape->getString());
-//
-//// Font size of the shape text was 10.
-//CPPUNIT_ASSERT_EQUAL(12.f, getProperty(getParagraphOfText(1, 
xShape->getText()), "CharHeight"));
-//}
+
+DECLARE_OOXMLEXPORT_TEST(testGroupshapeSmarttag, "groupshape-smarttag.docx")
+{
+uno::Reference xGroupShape(getShape(1), uno::UNO_QUERY);
+uno::Reference xShape(xGroupShape->getByIndex(0), 
uno::UNO_QUERY);
+// First run of shape text was missing due to the w:smartTag wrapper 
around it.
+CPPUNIT_ASSERT_EQUAL(OUString("Box 2"), xShape->getString());
+
+// Font size of the shape text was 10.
+CPPUNIT_ASSERT_EQUAL(12.f, getProperty(getParagraphOfText(1, 
xShape->getText()), "CharHeight"));
+}
 
 DECLARE_OOXMLEXPORT_TEST(testN793262, "n793262.docx")
 {
@@ -1038,35 +1038,58 @@ DECLARE_OOXMLEXPORT_TEST(testTableAutoColumnFixedSize2, 
"table-auto-column-fixed
 // This was 17907, i.e. the sum of the width of the 3 cells (10152 twips 
each), which is too wide.
 CPPUNIT_ASSERT_EQUAL(sal_Int32(16891), getProperty(xTextTable, 
"Width"));
 }
-#if 0
-// FIXME:
+
 DECLARE_OOXMLEXPORT_TEST(testFdo46361, "fdo46361.docx")
 {
 uno::Reference xGroupShape(getShape(1), 
uno::UNO_QUERY);
-uno::Reference xShape(xGroupShape->getByIndex(0), 
uno::UNO_QUERY);
-// This was CENTER.
-CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, 
getProperty(xShape, "TextVerticalAdjust"));
-uno::Reference xText = 
uno::Reference(xShape, uno::UNO_QUERY_THROW)->getText();
-uno::Reference xParagraph = getParagraphOfText(1, xText);
-// This was LEFT.
-CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, 
static_cast(getProperty(xParagraph, 
"ParaAdjust")));
-// This was black, not green.
-CPPUNIT_ASSERT_EQUAL(Color(0x008000), Color(ColorTransparency, 
getProperty(getRun(xParagraph, 1), "CharColor")));
-// \n char was missing due to unhandled w:br.
-uno::Reference xShapeText(xGroupShape->getByIndex(1), 
uno::UNO_QUERY_THROW);
-CPPUNIT_ASSERT_EQUAL(OUString("text\ntext"), xShapeText->getString());
-// \n chars were missing, due to unhandled multiple w:p tags.
-xShapeText.set(xGroupShape->getByIndex(2), uno::UNO_QUERY_THROW);
-CPPUNIT_ASSERT_EQUAL(OUString("text\ntext\n"), xShapeText->getString());
-
-// tdf#128153 The first and second lines are directly specified as 
centered. Make sure that doesn't change.
-xParagraph.set(getParagraphOfText(2, xShapeText->getText(), "text"));
-CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, 
static_cast(getProperty(xParagraph, 
"ParaAdjust")));
-// The last paragraph should be left aligned.
-xParagraph.set(getParagraphOfText(3, xShapeText->getText(), ""));
-CPPUNIT_ASSERT_MESSAGE("You FIXED me!", style::ParagraphAdjust_LEFT != 
static_cast(getProperty(xParagraph, 
"ParaAdjust")));
+uno::Reference xTextBox;
+
+// FIXME:
+// uno::Reference xShape(xGroupShape->getByIndex(0), 
uno::UNO_QUERY);
+// CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, 
getProperty(xShape, "TextVerticalAdjust"));
+
+// This was CENTER
+xTextBox.set(xGroupShape->getByIndex(0), uno::UNO_QUERY_THROW);
+

[Libreoffice-commits] core.git: sw/qa sw/source

2022-02-02 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx   |4 -
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   49 +++
 sw/source/core/doc/textboxhelper.cxx |   15 ---
 sw/source/core/draw/dcontact.cxx |8 +++
 5 files changed, 68 insertions(+), 8 deletions(-)

New commits:
commit 3b0a0e70cb67fc2e1fd2e8cbb9cfcd8c670e
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jan 11 12:09:46 2022 +0100
Commit: László Németh 
CommitDate: Wed Feb 2 14:20:55 2022 +0100

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

A missing function resulted covered textboxes which weren't
visible in group shapes.

Follow-up to 121cbc250b36290f0f8c7265fea57256dad69553
"tdf#66039 DOCX: import textboxes (with tables, images etc.)
in group shapes".

Change-Id: I08eb1c1cf4a4f4769af8812500b9cf9778b01e9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128279
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx 
b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx
new file mode 100644
index ..664f47a0b623
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 70d39cdbcde8..29996d119812 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -95,9 +95,9 @@ protected:
 
 DECLARE_OOXMLEXPORT_TEST(testWPGtextboxes, "testWPGtextboxes.docx")
 {
-CPPUNIT_ASSERT_EQUAL(1, getShapes());
+CPPUNIT_ASSERT_EQUAL(2, getShapes());
 
-auto MyShape = getShape(1);
+auto MyShape = getShape(2);
 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 76b768155677..6feb92b15149 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -8,10 +8,12 @@
  */
 
 #include 
+#include 
 
 #include 
 #include 
 
+#include 
 #include 
 
 constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/ooxmlexport/data/";
@@ -103,6 +105,53 @@ CPPUNIT_TEST_FIXTURE(Test, testDontAddNewStyles)
 assertXPath(pXmlDoc, "/w:styles/w:style[@w:styleId='Caption']", 0);
 }
 
+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"), 
uno::UNO_QUERY_THROW);
+
+// Assert that the textbox ZOrder greater than the groupshape
+
CPPUNIT_ASSERT_GREATER(xGroupProperties->getPropertyValue("ZOrder").get(),
+
xTextBoxFrameProperties->getPropertyValue("ZOrder").get());
+// Before the fix, this failed because that was less, and the 
textboxes were covered.
+}
+
+}
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, "tdf123642.docx")
 {
 // get bookmark interface
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 65f6e2e03863..a2ca9175a957 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1473,15 +1473,20 @@ bool 
SwTextBoxHelper::DoTextBoxZOrderCorrection(SwFrameFormat* pShape, const Sdr
 {
 // TODO: do this with group shape textboxes.
 SdrObject* pShpObj = nullptr;
-//if (pObj)
-//pShpObj = pObj;
-//else
+
 pShpObj = pShape->FindRealSdrObject();
 
 if (pShpObj)
 {
-if (SdrObject* pFrmObj

[Libreoffice-commits] core.git: sw/qa writerfilter/source

2022-01-31 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|   14 +++---
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx |   22 +++---
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |2 ++
 3 files changed, 20 insertions(+), 18 deletions(-)

New commits:
commit e1dc4a5815a56eef27d2c83f7971e0eb1ac09b45
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jan 6 14:23:35 2022 +0100
Commit: László Németh 
CommitDate: Mon Jan 31 17:16:25 2022 +0100

Related tdf#66039 DOCX WPG import: Do not put extra paragraph at the end

Regression from 121cbc250b36290f0f8c7265fea57256dad69553
tdf#66039 DOCX: import textboxes (with tables, images etc.) in group shapes

Change-Id: I16195d1d3b0955d5686fe225bbba6def2c28ef93
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128043
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: Attila Bakos 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index d3701ac6e01e..70d39cdbcde8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -419,13 +419,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf59274)
 // This was 3674: too wide last cell in first row
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[4]/w:tcPr/w:tcW", "w", "1695");
 }
-//FIXME:
-//DECLARE_OOXMLEXPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
-//{
-//uno::Reference xGroupShape(getShape(1), 
uno::UNO_QUERY);
-//// The text in the groupshape was missing due to the w:sdt and 
w:sdtContent wrapper around it.
-//CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), 
uno::Reference(xGroupShape->getByIndex(1), 
uno::UNO_QUERY_THROW)->getString());
-//}
+
+DECLARE_OOXMLEXPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
+{
+uno::Reference xGroupShape(getShape(1), uno::UNO_QUERY);
+// The text in the groupshape was missing due to the w:sdt and 
w:sdtContent wrapper around it.
+CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), 
uno::Reference(xGroupShape->getByIndex(1), 
uno::UNO_QUERY_THROW)->getString());
+}
 
 DECLARE_OOXMLEXPORT_TEST(testDmlCharheightDefault, 
"dml-charheight-default.docx")
 {
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 30ac826f23e3..5fc907c4d938 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -91,17 +91,17 @@ DECLARE_OOXMLEXPORT_TEST(testBezier, "bezier.odt")
 // Check that no shape got lost: a bezier, a line and a text shape.
 CPPUNIT_ASSERT_EQUAL(3, getShapes());
 }
-// FIXME:
-//DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox, "groupshape-textbox.docx")
-//{
-//uno::Reference xGroup(getShape(1), uno::UNO_QUERY);
-//uno::Reference xShape(xGroup->getByIndex(0), 
uno::UNO_QUERY);
-//// The VML export lost text on textboxes inside groupshapes.
-//// The DML export does not, make sure it stays that way.
-//CPPUNIT_ASSERT_EQUAL(OUString("first"), xShape->getString());
-//// This was 16, i.e. inheriting doc default char height didn't work.
-//CPPUNIT_ASSERT_EQUAL(11.f, getProperty(getParagraphOfText(1, 
xShape->getText()), "CharHeight"));
-//}
+
+DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox, "groupshape-textbox.docx")
+{
+uno::Reference xGroup(getShape(1), uno::UNO_QUERY);
+uno::Reference xShape(xGroup->getByIndex(0), 
uno::UNO_QUERY);
+// The VML export lost text on textboxes inside groupshapes.
+// The DML export does not, make sure it stays that way.
+CPPUNIT_ASSERT_EQUAL(OUString("first"), xShape->getString());
+// This was 16, i.e. inheriting doc default char height didn't work.
+CPPUNIT_ASSERT_EQUAL(11.f, getProperty(getParagraphOfText(1, 
xShape->getText()), "CharHeight"));
+}
 
 DECLARE_OOXMLEXPORT_TEST(testGroupshapePicture, "groupshape-picture.docx")
 {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 952d225f52f7..548425914616 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4507,6 +4507,8 @@ void DomainMapper_Impl::PopTextBoxContent()
 getTableManager().endLevel();
 popTableManager();
 }
+RemoveLastParagraph();
+
 m_aTextAppendStack.pop();
 m_bIsInTextBox = false;
 }


[Libreoffice-commits] core.git: sw/qa writerfilter/inc writerfilter/source

2022-01-06 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf66039.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|   30 +--
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|   12 +++
 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 +--
 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 
 20 files changed, 207 insertions(+), 55 deletions(-)

New commits:
commit 121cbc250b36290f0f8c7265fea57256dad69553
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Nov 11 14:02:12 2021 +0100
Commit: László Németh 
CommitDate: Thu Jan 6 10:41:32 2022 +0100

tdf#66039 DOCX: import textboxes (with tables, images etc.) in group shapes

Text boxes in group shapes were imported as shapes, losing
complex text content: tables (tdf#66039), colors (tdf#73022),
images (tdf#81958), lists, paragraph styles, hyperlinks
(tdf#122960) and track changes.

Note: a few unit tests have been deactivated temporarily.
Test document "groupshape-trackedchanges.docx" of
testGroupshapeTrackedchanges is imported correctly now:
with track changes, and the test was modified accordingly.

Follow-up to commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
"tdf#143574 OOXML export/import of textboxes in group shapes".

Change-Id: I6eb918dbf64393fd723fe43f798f93b5b9a12575
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125051
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf66039.docx 
b/sw/qa/extras/ooxmlexport/data/tdf66039.docx
new file mode 100644
index ..f17032b3f90b
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf66039.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index af0a2a378c4f..857accd57f7d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -440,13 +440,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf59274)
 // This was 3674: too wide last cell in first row
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[4]/w:tcPr/w:tcW", "w", "1695");
 }
-
-DECLARE_OOXMLEXPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
-{
-uno::Reference xGroupShape(getShape(1), uno::UNO_QUERY);
-// The text in the groupshape was missing due to the w:sdt and 
w:sdtContent wrapper around it.
-CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), 
uno::Reference(xGroupShape->getByIndex(1), 
uno::UNO_QUERY_THROW)->getString());
-}
+//FIXME:
+//DECLARE_OOXMLEXPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
+//{
+//uno::Reference xGroupShape(getShape(1), 
uno::UNO_QUERY);
+//// The text in the groupshape was missing due to the w:sdt and 
w:sdtContent wrapper around it.
+//CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), 
uno::Reference(xGroupShape->getByIndex(1), 
uno::UNO_QUERY_THROW)->getString());
+//}
 
 DECLARE_OOXMLEXPORT_TEST(testDmlCharheightDefault, 
"dml-charheight-default.docx")
 {
@@ -746,9 +746,21 @@ DECLARE_OOXMLEXPORT_TEST(testCaption, "caption.docx")
 DECLARE_OOXMLEXPORT_TEST(testGroupshapeTrackedchanges, 
"groupshape-trackedchanges.docx")
 {
 uno::Reference xGroup(getShape(1), uno::UNO_QUERY);
-uno::Reference xShape(xGroup->getByIndex(0), 
uno::UNO_QUERY);
+uno::Reference xShape(xGroup->getByIndex(0), 
uno::UNO_QUERY);
 // Shape text was completely missing, ensure inserted text is available.
-CPPUNIT_ASSERT_EQUAL(OUString(" Inserted"), xShape->getString());
+uno::Reference xText
+= uno::Reference(xShape, 
uno::UNO_QUERY_THROW)->getText();
+auto xParagraph = getParagraphOfText(1, xText);
+
+CPPUNIT_ASSERT(hasProperty(getRun(xParagraph, 1), "RedlineType"));
+CPPUNIT_ASSERT_EQUAL(OUString("Delete"),
+ getProperty(getRun(xParagraph, 1), 
"RedlineType"));
+CPPUNIT_ASSERT_EQUAL(OUString("Deleted"), 

[Libreoffice-commits] core.git: include/oox oox/source sw/qa writerfilter/source

2022-01-03 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/shape/ShapeContextHandler.hxx |5 +-
 oox/source/drawingml/shape.cxx|2 
 oox/source/shape/ShapeContextHandler.cxx  |8 ++-
 oox/source/shape/WpgContext.cxx   |   45 +-
 oox/source/shape/WpgContext.hxx   |8 ++-
 sw/qa/extras/ooxmlexport/data/testWPGtextboxes.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|   21 
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx |7 +-
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |2 
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |4 -
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx |7 +-
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |7 ++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |4 +
 13 files changed, 92 insertions(+), 28 deletions(-)

New commits:
commit 2951cbdf3a6e2b62461665546b47e1d253fcb834
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Nov 10 14:10:11 2021 +0100
Commit: László Németh 
CommitDate: Mon Jan 3 14:28:15 2022 +0100

tdf#143574 OOXML export/import of textboxes in group shapes

In this part, oox module has been modified in order to prepare
for WPG handling during OOXML import. Note: Wpg is the drawingML
equivalent of v:group, supporting text boxes in the group.

1) Added new parameter for WpgContext to support nested
Wpg shapes, and WPS enabled for the WPG member shapes.

2) A bug has fixed, where group member line shape and
connector shapes have wrong positions before in the group.

3) Unit tests had to be modified, and 3 of them disabled
temporarily due to missing Writerfilter implementation (what
will be the next commit)

Now group shapes can have textboxes and the text is imported
for that, but complex content is still missing (this will be
fixed in writerfilter by the next commit).

Known issue: WPG shapes with textboxes in floating table
have issues during import at floating table conversion, so until
this is not fixed this function is disabled for shapes in tables
(will be fixed a follow-up commit later).

Follow-up to commit 19394a924fdc486202ca27e318385287eb0df26f
"tdf#143574 sw: textboxes in group shapes -- part 4".

Change-Id: I71032187697807087bd8f27f7c3a7b052e174bd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124964
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/include/oox/shape/ShapeContextHandler.hxx 
b/include/oox/shape/ShapeContextHandler.hxx
index 934ea374fd7c..27b70d2cf2c4 100644
--- a/include/oox/shape/ShapeContextHandler.hxx
+++ b/include/oox/shape/ShapeContextHandler.hxx
@@ -94,6 +94,9 @@ public:
 
 void setPosition(const css::awt::Point& rPosition);
 
+const bool& getFullWPGSupport() { return m_bFullWPGSUpport; };
+void setFullWPGSupport(const bool& rbUse) { m_bFullWPGSUpport = rbUse; };
+
 void setDocumentProperties(const 
css::uno::Reference& xDocProps);
 void setMediaDescriptor(const 
css::uno::Sequence& rMediaDescriptor);
 
@@ -108,7 +111,7 @@ private:
 
 ::sal_uInt32 mnStartToken;
 css::awt::Point maPosition;
-
+bool m_bFullWPGSUpport;
 drawingml::ShapePtr mpShape;
 std::shared_ptr< vml::Drawing > mpDrawing;
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 78a27f8a0c9c..fd9eb691b2e8 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1531,7 +1531,7 @@ Reference< XShape > const & Shape::createAndInsert(
 // These can have a custom geometry, so position should be set here,
 // after creation but before custom shape handling, using the position
 // we got from the caller.
-if (mbWps && aServiceName == "com.sun.star.drawing.LineShape")
+if (mbWps && aServiceName == "com.sun.star.drawing.LineShape" && 
!pParentGroupShape)
 mxShape->setPosition(maPosition);
 
 if( bIsCustomShape )
diff --git a/oox/source/shape/ShapeContextHandler.cxx 
b/oox/source/shape/ShapeContextHandler.cxx
index 5404cc82fe81..3454c0e03f87 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -47,7 +47,9 @@ using namespace drawingml;
 
 ShapeContextHandler::ShapeContextHandler(const 
rtl::Reference& xFilterBase) :
   mnStartToken(0),
+  m_bFullWPGSUpport(false),
   mxShapeFilterBase(xFilterBase)
+
 {
 }
 
@@ -139,8 +141,12 @@ uno::Reference const & 
ShapeContextHandler::getWp
 switch (getBaseToken(nElement))
 {
 case XML_wgp:
-mxWpgContext.set(static_cast(new 
WpgContext(*rFragmentHandler)));
+{
+rtl::Reference rContext = new 
WpgContext(*rFragmentHandler, oox::drawingml::ShapePtr());
+rContext->setFullWPGSupport(m_bFullWPGSUpport);
+

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2021-12-14 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx  |3 
 sw/inc/unomid.h   |3 
 sw/inc/unoprnms.hxx   |1 
 sw/qa/extras/layout/data/TextBoxFrame.odt |binary
 sw/qa/extras/layout/layout2.cxx   |   41 ++
 sw/source/core/doc/textboxhelper.cxx  |  121 ++
 sw/source/core/unocore/unodraw.cxx|   62 +++
 sw/source/core/unocore/unomap.cxx |3 
 8 files changed, 216 insertions(+), 18 deletions(-)

New commits:
commit 19394a924fdc486202ca27e318385287eb0df26f
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Nov 30 15:38:26 2021 +0100
Commit: László Németh 
CommitDate: Tue Dec 14 15:31:57 2021 +0100

tdf#143574 sw: textboxes in group shapes -- part 4

A new UNO property has been added and implemented
for the filters. This provides the possibility of
assigning textboxes in the filter at import time via UNO.

Follow-up to commit e5650de86072b9db586a4532b5239acda77598c4
"tdf#143574 sw: textboxes in group shapes - part 3 take 2".

Change-Id: I58c445cb7f6d865c1d82dbe68f985e4c11ff832e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126162
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 924b3e6b5c91..1a0cadabc0e9 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -60,6 +60,9 @@ public:
 /// the original text in the shape will be copied to the frame
 /// The textbox is created for the shape given by the pObject parameter.
 static void create(SwFrameFormat* pShape, SdrObject* pObject, bool 
bCopyText = false);
+/// Sets the given textframe as textbox for the given (group member) shape.
+static void set(SwFrameFormat* pShape, SdrObject* pObject,
+css::uno::Reference xNew);
 /// Destroy a TextBox for a shape. If the format has more textboxes
 /// like group shapes, it will destroy only that textbox what belongs
 /// to the given pObject shape.
diff --git a/sw/inc/unomid.h b/sw/inc/unomid.h
index d249b32fc25a..9f413509ae1c 100644
--- a/sw/inc/unomid.h
+++ b/sw/inc/unomid.h
@@ -151,6 +151,9 @@
 // SwFormatFollowTextFlow
 #define MID_FOLLOW_TEXT_FLOW0
 
+#define MID_TEXT_BOX0
+#define MID_TEXT_BOX_CONTENT1
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 7ef5d0a58cd7..1e16bc413d01 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -74,6 +74,7 @@
 #define UNO_NAME_FOOTER_RIGHT_MARGIN "FooterRightMargin"
 #define UNO_NAME_TEXT_RANGE "TextRange"
 #define UNO_NAME_TEXT_BOX "TextBox"
+#define UNO_NAME_TEXT_BOX_CONTENT "TextBoxContent"
 #define UNO_NAME_NAME "Name"
 #define UNO_NAME_CHAR_STYLE_NAME "CharStyleName"
 #define UNO_NAME_ANCHOR_CHAR_STYLE_NAME "AnchorCharStyleName"
diff --git a/sw/qa/extras/layout/data/TextBoxFrame.odt 
b/sw/qa/extras/layout/data/TextBoxFrame.odt
new file mode 100644
index ..a6155e34fdfb
Binary files /dev/null and b/sw/qa/extras/layout/data/TextBoxFrame.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 10d01fa05e33..47403ea6a1da 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -1557,6 +1557,47 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf141220)
 CPPUNIT_ASSERT_LESS(static_cast(15), nTextBoxTop - nShapeTop);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, TestTextBoxChangeViaUNO)
+{
+CPPUNIT_ASSERT(createSwDoc(DATA_DIRECTORY, "TextBoxFrame.odt"));
+// this file has a shape and a frame inside. Try to set up
+// the frame for the shape as textbox. Before this was not
+// implemented. This will be necesary for proper WPG import.
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("There must be a shape and a frame!", 2, 
getShapes());
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("This must be a custom shape!",
+ OUString("com.sun.star.drawing.CustomShape"),
+ getShape(1)->getShapeType());
+CPPUNIT_ASSERT_EQUAL_MESSAGE("This must be a frame shape!", 
OUString("FrameShape"),
+ getShape(2)->getShapeType());
+
+CPPUNIT_ASSERT_MESSAGE("This is not supposed to be a textbox!",
+   !uno::Reference(getShape(1), 
uno::UNO_QUERY_THROW)
+->getPropertyValue("TextBox")
+.get());
+// Without the fix it will crash at this line:
+CPPUNIT_ASSERT_MESSAGE("This is not supposed to be a textbox!",
+   !uno::Reference(getShape(1), 
uno::UNO_QUERY_THROW)
+->getPropertyValue("TextBoxContent")
+.hasValue());
+
+// So now set the frame as textbox for the shape!
+uno::Reference(getShape(1), uno::UNO_QUERY_THROW)
+

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2021-12-14 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx|   16 ++
 sw/qa/uitest/data/ComplexGroupShapeTest.odt |binary
 sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py |  127 
 sw/source/core/doc/docdraw.cxx  |   56 ++--
 sw/source/core/doc/textboxhelper.cxx|   82 +++-
 sw/source/core/draw/dcontact.cxx|6 
 sw/source/core/draw/dview.cxx   |9 -
 sw/source/core/unocore/unodraw.cxx  |   15 +-
 8 files changed, 279 insertions(+), 32 deletions(-)

New commits:
commit e5650de86072b9db586a4532b5239acda77598c4
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Nov 29 14:37:20 2021 +0100
Commit: László Németh 
CommitDate: Tue Dec 14 15:28:19 2021 +0100

tdf#143574 sw: textboxes in group shapes - part 3 take 2

In this part, missing parameters have been fixed, and
queryInterface method can handle textbox groups now.

A new function, synchronizeGroupTextBoxProperty has been
introduced to do the sync for all group members. Nested
group textbox shape handling also has been introduced.

Note: Copy still has issues.

Change-Id: I3d2090fe6a4066edfd2cb417b30bca9dd9acb011
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126052
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 2e5b27cfccb0..924b3e6b5c91 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -65,7 +65,8 @@ public:
 /// to the given pObject shape.
 static void destroy(const SwFrameFormat* pShape, const SdrObject* pObject);
 /// Get interface of a shape's TextBox, if there is any.
-static css::uno::Any queryInterface(const SwFrameFormat* pShape, const 
css::uno::Type& rType);
+static css::uno::Any queryInterface(const SwFrameFormat* pShape, const 
css::uno::Type& rType,
+SdrObject* pObj);
 
 /// Sync property of TextBox with the one of the shape.
 static void syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 
nMemberID,
@@ -107,6 +108,9 @@ public:
 /// this function, and returns true in that case too.
 static std::optional isAnchorTypeDifferent(const SwFrameFormat* 
pShape);
 
+/// Sets the correct size of textframe depending on the given SdrObject.
+static bool syncTextBoxSize(SwFrameFormat* pShape, SdrObject* pObj);
+
 /// Returns true if the given shape has a valid textframe.
 static bool isTextBoxShapeHasValidTextFrame(const SwFrameFormat* pShape);
 
@@ -177,6 +181,14 @@ public:
 /// Undo the effect of saveLinks() + individual resetLink() calls.
 static void restoreLinks(std::set& rOld, 
std::vector& rNew,
  SavedLink& rSavedLinks);
+
+/// Calls the method given by pFunc with every textboxes of the group 
given by pFormat.
+static void synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat*, 
SdrObject*),
+SwFrameFormat* pFormat, 
SdrObject* pObj);
+/// Collect all textboxes of the group given by the pGoupObj Parameter. 
Returns with a
+/// vector filled with the textboxes.
+static std::vector CollectTextBoxes(SdrObject* 
pGroupObject,
+SwFrameFormat* 
pFormat);
 };
 
 /// Textboxes are basically textframe + shape pairs. This means one shape has 
one frame.
@@ -242,6 +254,8 @@ public:
 SwFrameFormat* GetOwnerShape() { return m_pOwnerShapeFormat; };
 // This will give the current number of textboxes.
 size_t GetTextBoxCount() const { return m_pTextBoxes.size(); };
+// Returns with a const collection of textboxes owned by this node.
+std::map GetAllTextBoxes() const;
 };
 
 #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX
diff --git a/sw/qa/uitest/data/ComplexGroupShapeTest.odt 
b/sw/qa/uitest/data/ComplexGroupShapeTest.odt
new file mode 100644
index ..8fe093203690
Binary files /dev/null and b/sw/qa/uitest/data/ComplexGroupShapeTest.odt differ
diff --git a/sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py 
b/sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py
new file mode 100644
index ..7e219d8d7976
--- /dev/null
+++ b/sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py
@@ -0,0 +1,127 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-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/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.common import get_url_for_data_file
+from libreoffice.uno.propertyvalue import 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - oox/source sd/qa

2021-12-09 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx |6 ++
 sd/qa/unit/data/pptx/tdf145162.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   16 
 3 files changed, 22 insertions(+)

New commits:
commit bfef95dcb38c1d004fc907a14af4eaaf99798b7e
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Dec 8 10:22:37 2021 +0100
Commit: Xisco Fauli 
CommitDate: Thu Dec 9 17:21:04 2021 +0100

tdf#145162 PPTX export: fix extra bullet regression

Placeholders have bullet by default in MSO, so
write  for paragraphs where numbering/bullet
is disabled to avoid extra bullets in Impress.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
(tdf#111903 tdf#137152 PPTX export: fix placeholders).

Change-Id: Ib4c563cba475d61bc475ca05623e7c7b20fded30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126528
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit f57cfddb51b7d7409b7b425dc200aa73406a13bd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126525
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 1040f52fad1c..8ea77ad8b84c 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2479,7 +2479,13 @@ static OUString GetAutoNumType(SvxNumType 
nNumberingType, bool bSDot, bool bPBeh
 void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& 
rXPropSet, float fFirstCharHeight, sal_Int16 nLevel )
 {
 if (nLevel < 0 || !GetProperty(rXPropSet, "NumberingRules"))
+{
+if (GetDocumentType() == DOCUMENT_PPTX)
+{
+mpFS->singleElementNS(XML_a, XML_buNone);
+}
 return;
+}
 
 Reference< XIndexAccess > rXIndexAccess;
 
diff --git a/sd/qa/unit/data/pptx/tdf145162.pptx 
b/sd/qa/unit/data/pptx/tdf145162.pptx
new file mode 100644
index ..3746740f327c
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf145162.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 623761f25786..92c62451549f 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -69,6 +69,7 @@ public:
 void testTdf118806();
 void testTdf130058();
 void testTdf111789();
+void testTdf145162();
 void testTdf100348_convert_Fontwork2TextWarp();
 void testTdf1225573_FontWorkScaleX();
 void testTdf99497_keepAppearanceOfCircleKind();
@@ -141,6 +142,7 @@ public:
 CPPUNIT_TEST(testTdf118806);
 CPPUNIT_TEST(testTdf130058);
 CPPUNIT_TEST(testTdf111789);
+CPPUNIT_TEST(testTdf145162);
 CPPUNIT_TEST(testTdf100348_convert_Fontwork2TextWarp);
 CPPUNIT_TEST(testTdf1225573_FontWorkScaleX);
 CPPUNIT_TEST(testTdf99497_keepAppearanceOfCircleKind);
@@ -609,6 +611,20 @@ void SdOOXMLExportTest3::testTdf111789()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest3::testTdf145162()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf145162.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+
+assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buNone");
+// Before the fix, that tag was missing so PP put bullet to each para.
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest3::testTdf100348_convert_Fontwork2TextWarp()
 {
 ::sd::DrawDocShellRef xDocShRef = loadURL(


[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - oox/source sd/qa

2021-12-09 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx |6 ++
 sd/qa/unit/data/pptx/tdf145162.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   16 
 3 files changed, 22 insertions(+)

New commits:
commit 97ce03ccf1287c1fa79d5741a85fa419e03d9a35
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Dec 8 10:22:37 2021 +0100
Commit: Xisco Fauli 
CommitDate: Thu Dec 9 15:25:48 2021 +0100

tdf#145162 PPTX export: fix extra bullet regression

Placeholders have bullet by default in MSO, so
write  for paragraphs where numbering/bullet
is disabled to avoid extra bullets in Impress.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
(tdf#111903 tdf#137152 PPTX export: fix placeholders).

Change-Id: Ib4c563cba475d61bc475ca05623e7c7b20fded30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126528
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit f57cfddb51b7d7409b7b425dc200aa73406a13bd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126524
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index fbe13359dd9b..008e6ff9cf12 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2549,7 +2549,13 @@ static OUString GetAutoNumType(SvxNumType 
nNumberingType, bool bSDot, bool bPBeh
 void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& 
rXPropSet, float fFirstCharHeight, sal_Int16 nLevel )
 {
 if (nLevel < 0 || !GetProperty(rXPropSet, "NumberingRules"))
+{
+if (GetDocumentType() == DOCUMENT_PPTX)
+{
+mpFS->singleElementNS(XML_a, XML_buNone);
+}
 return;
+}
 
 Reference< XIndexAccess > rXIndexAccess;
 
diff --git a/sd/qa/unit/data/pptx/tdf145162.pptx 
b/sd/qa/unit/data/pptx/tdf145162.pptx
new file mode 100644
index ..3746740f327c
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf145162.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 900716e20093..fbf39e111f71 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -70,6 +70,7 @@ public:
 void testTdf118806();
 void testTdf130058();
 void testTdf111789();
+void testTdf145162();
 void testTdf100348_convert_Fontwork2TextWarp();
 void testTdf1225573_FontWorkScaleX();
 void testTdf99497_keepAppearanceOfCircleKind();
@@ -143,6 +144,7 @@ public:
 CPPUNIT_TEST(testTdf118806);
 CPPUNIT_TEST(testTdf130058);
 CPPUNIT_TEST(testTdf111789);
+CPPUNIT_TEST(testTdf145162);
 CPPUNIT_TEST(testTdf100348_convert_Fontwork2TextWarp);
 CPPUNIT_TEST(testTdf1225573_FontWorkScaleX);
 CPPUNIT_TEST(testTdf99497_keepAppearanceOfCircleKind);
@@ -612,6 +614,20 @@ void SdOOXMLExportTest3::testTdf111789()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest3::testTdf145162()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf145162.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+
+assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buNone");
+// Before the fix, that tag was missing so PP put bullet to each para.
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest3::testTdf100348_convert_Fontwork2TextWarp()
 {
 ::sd::DrawDocShellRef xDocShRef = loadURL(


[Libreoffice-commits] core.git: oox/source sd/qa

2021-12-09 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx |6 ++
 sd/qa/unit/data/pptx/tdf145162.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   16 
 3 files changed, 22 insertions(+)

New commits:
commit f57cfddb51b7d7409b7b425dc200aa73406a13bd
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Dec 8 10:22:37 2021 +0100
Commit: László Németh 
CommitDate: Thu Dec 9 12:14:51 2021 +0100

tdf#145162 PPTX export: fix extra bullet regression

Placeholders have bullet by default in MSO, so
write  for paragraphs where numbering/bullet
is disabled to avoid extra bullets in Impress.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
(tdf#111903 tdf#137152 PPTX export: fix placeholders).

Change-Id: Ib4c563cba475d61bc475ca05623e7c7b20fded30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126528
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 249c897740a9..8581535357a0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2613,7 +2613,13 @@ static OUString GetAutoNumType(SvxNumType 
nNumberingType, bool bSDot, bool bPBeh
 void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& 
rXPropSet, float fFirstCharHeight, sal_Int16 nLevel )
 {
 if (nLevel < 0 || !GetProperty(rXPropSet, "NumberingRules"))
+{
+if (GetDocumentType() == DOCUMENT_PPTX)
+{
+mpFS->singleElementNS(XML_a, XML_buNone);
+}
 return;
+}
 
 Reference< XIndexAccess > rXIndexAccess;
 
diff --git a/sd/qa/unit/data/pptx/tdf145162.pptx 
b/sd/qa/unit/data/pptx/tdf145162.pptx
new file mode 100644
index ..3746740f327c
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf145162.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 375922511661..1650680a2c30 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -71,6 +71,7 @@ public:
 void testTdf118806();
 void testTdf130058();
 void testTdf111789();
+void testTdf145162();
 void testTdf100348_convert_Fontwork2TextWarp();
 void testTdf1225573_FontWorkScaleX();
 void testTdf99497_keepAppearanceOfCircleKind();
@@ -145,6 +146,7 @@ public:
 CPPUNIT_TEST(testTdf118806);
 CPPUNIT_TEST(testTdf130058);
 CPPUNIT_TEST(testTdf111789);
+CPPUNIT_TEST(testTdf145162);
 CPPUNIT_TEST(testTdf100348_convert_Fontwork2TextWarp);
 CPPUNIT_TEST(testTdf1225573_FontWorkScaleX);
 CPPUNIT_TEST(testTdf99497_keepAppearanceOfCircleKind);
@@ -627,6 +629,20 @@ void SdOOXMLExportTest3::testTdf111789()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest3::testTdf145162()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf145162.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+
+assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buNone");
+// Before the fix, that tag was missing so PP put bullet to each para.
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest3::testTdf100348_convert_Fontwork2TextWarp()
 {
 ::sd::DrawDocShellRef xDocShRef = loadURL(


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sc/qa sc/source

2021-11-29 Thread Attila Bakos (NISZ) (via logerrit)
 sc/qa/uitest/calc_tests8/tdf144940.py|   72 +++
 sc/source/filter/xml/XMLTableHeaderFooterContext.cxx |   11 +-
 2 files changed, 78 insertions(+), 5 deletions(-)

New commits:
commit 5ece740b3672b4204231c995a31ae97c108e7c80
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Nov 17 09:15:23 2021 +0100
Commit: Xisco Fauli 
CommitDate: Mon Nov 29 12:35:50 2021 +0100

tdf#144940 sc: fix disabled header/footer regression

Setting "Same content on first page" in the Page Style
dialog on either the Header or Footer tab resulted
disabled header/footer after reload. This was due to
flawed logic when assigning SC_UNO_PAGE_HDRON/FTRON
value: "leftness" was checked for but not "first pageness".

Regression from commit b9993369b4011cd8f367e439f5248096827f1efc
"tdf#121715 XLSX: support custom first page header/footer".

Co-authored-by: Daniel Arato (NISZ)

Change-Id: I8ee4c9f8145913d9dc5f4b66cdbc2352f2e405f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125367
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 5db9b33dadda67c7f97d8c23df17211fae380919)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125841
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/uitest/calc_tests8/tdf144940.py 
b/sc/qa/uitest/calc_tests8/tdf144940.py
new file mode 100644
index ..1f3d34b51219
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf144940.py
@@ -0,0 +1,72 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from tempfile import TemporaryDirectory
+from org.libreoffice.unotest import systemPathToFileUrl
+import os.path
+
+class tdf144940(UITestCase):
+
+def test_tdf144940(self):
+
+with TemporaryDirectory() as tempdir:
+xFilePath = os.path.join(tempdir, "tdf144940-tmp.ods")
+
+calc_doc = self.ui_test.create_doc_in_start_center("calc")
+
+
self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog")
+xDialog = self.xUITest.getTopFocusWindow()
+xTabs = xDialog.getChild("tabcontrol")
+select_pos(xTabs, "4")
+
+xCheckHeaderOn = xDialog.getChild("checkHeaderOn")
+xCheckSameFP = xDialog.getChild("checkSameFP")
+xCheckSameLR = xDialog.getChild("checkSameLR")
+
+self.assertEqual("true", 
get_state_as_dict(xCheckHeaderOn)["Selected"])
+self.assertEqual("true", 
get_state_as_dict(xCheckSameLR)["Selected"])
+self.assertEqual("false", 
get_state_as_dict(xCheckSameFP)["Selected"])
+
+xCheckSameFP.executeAction("CLICK", tuple())
+
+self.assertEqual("true", 
get_state_as_dict(xCheckSameFP)["Selected"])
+
+xOkBtn = xDialog.getChild("ok")
+self.ui_test.close_dialog_through_button(xOkBtn)
+
+self.ui_test.execute_dialog_through_command(".uno:Save")
+xSaveDialog = self.xUITest.getTopFocusWindow()
+xFileName = xSaveDialog.getChild("file_name")
+xFileName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+xFileName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": 
xFilePath}))
+
+xOkBtn = xSaveDialog.getChild("open")
+self.ui_test.close_dialog_through_button(xOkBtn)
+
+self.ui_test.close_doc()
+
+self.ui_test.load_file(systemPathToFileUrl(xFilePath))
+document = self.ui_test.get_component()
+
+xPageStyles = document.StyleFamilies.getByIndex(1)
+xDefaultPageStyle = xPageStyles.getByIndex(0)
+
+# Without the fix in place, this test would have failed with
+# AssertionError: False is not true
+self.assertTrue(xDefaultPageStyle.HeaderOn)
+self.assertTrue(xDefaultPageStyle.FooterOn)
+self.assertTrue(xDefaultPageStyle.FirstPageHeaderIsShared)
+self.assertTrue(xDefaultPageStyle.FirstPageFooterIsShared)
+
+self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx 
b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
index c0b5c6eb6cc1..773eb12da88b 100644
--- a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
+++ b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
@@ -63,19 +63,20 @@ 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - sc/qa sc/source

2021-11-26 Thread Attila Bakos (NISZ) (via logerrit)
 sc/qa/uitest/calc_tests8/tdf144940.py|   59 +++
 sc/source/filter/xml/XMLTableHeaderFooterContext.cxx |   11 +--
 2 files changed, 65 insertions(+), 5 deletions(-)

New commits:
commit 241733d1d91233b2f3bb996fc55302fb55b6c036
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Nov 17 09:15:23 2021 +0100
Commit: Xisco Fauli 
CommitDate: Fri Nov 26 21:35:47 2021 +0100

tdf#144940 sc: fix disabled header/footer regression

Setting "Same content on first page" in the Page Style
dialog on either the Header or Footer tab resulted
disabled header/footer after reload. This was due to
flawed logic when assigning SC_UNO_PAGE_HDRON/FTRON
value: "leftness" was checked for but not "first pageness".

Regression from commit b9993369b4011cd8f367e439f5248096827f1efc
"tdf#121715 XLSX: support custom first page header/footer".

Co-authored-by: Daniel Arato (NISZ)

Change-Id: I8ee4c9f8145913d9dc5f4b66cdbc2352f2e405f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125367
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 5db9b33dadda67c7f97d8c23df17211fae380919)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125840
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/uitest/calc_tests8/tdf144940.py 
b/sc/qa/uitest/calc_tests8/tdf144940.py
new file mode 100644
index ..6b118c7602c2
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf144940.py
@@ -0,0 +1,59 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from tempfile import TemporaryDirectory
+from org.libreoffice.unotest import systemPathToFileUrl
+import os.path
+
+class tdf144940(UITestCase):
+
+def test_tdf144940(self):
+
+with TemporaryDirectory() as tempdir:
+xFilePath = os.path.join(tempdir, "tdf144940-tmp.ods")
+
+with self.ui_test.create_doc_in_start_center("calc"):
+
+with 
self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") as xDialog:
+xTabs = xDialog.getChild("tabcontrol")
+select_pos(xTabs, "4")
+
+xCheckHeaderOn = xDialog.getChild("checkHeaderOn")
+xCheckSameFP = xDialog.getChild("checkSameFP")
+xCheckSameLR = xDialog.getChild("checkSameLR")
+
+self.assertEqual("true", 
get_state_as_dict(xCheckHeaderOn)["Selected"])
+self.assertEqual("true", 
get_state_as_dict(xCheckSameLR)["Selected"])
+self.assertEqual("false", 
get_state_as_dict(xCheckSameFP)["Selected"])
+
+xCheckSameFP.executeAction("CLICK", tuple())
+
+self.assertEqual("true", 
get_state_as_dict(xCheckSameFP)["Selected"])
+
+with self.ui_test.execute_dialog_through_command(".uno:Save", 
close_button="open") as xSaveDialog:
+xFileName = xSaveDialog.getChild("file_name")
+xFileName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+xFileName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": 
xFilePath}))
+
+with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
+
+xPageStyles = document.StyleFamilies.getByIndex(1)
+xDefaultPageStyle = xPageStyles.getByIndex(0)
+
+# Without the fix in place, this test would have failed with
+# AssertionError: False is not true
+self.assertTrue(xDefaultPageStyle.HeaderOn)
+self.assertTrue(xDefaultPageStyle.FooterOn)
+self.assertTrue(xDefaultPageStyle.FirstPageHeaderIsShared)
+self.assertTrue(xDefaultPageStyle.FirstPageFooterIsShared)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx 
b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
index c0b5c6eb6cc1..773eb12da88b 100644
--- a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
+++ b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
@@ -63,19 +63,20 @@ XMLTableHeaderFooterContext::XMLTableHeaderFooterContext( 
SvXMLImport& rImport,
 XMLOFF_WARN_UNKNOWN("sc", aIter);
 }
 bool bOn(::cppu::any2bool(xPropSet->getPropertyValue( sOn )));
-if( bLeft )
+if( bLeft || bFirst )
 {
+const OUString sShare = bLeft ? 

[Libreoffice-commits] core.git: sc/qa sc/source

2021-11-26 Thread Attila Bakos (NISZ) (via logerrit)
 sc/qa/uitest/calc_tests8/tdf144940.py|   59 +++
 sc/source/filter/xml/XMLTableHeaderFooterContext.cxx |   11 +--
 2 files changed, 65 insertions(+), 5 deletions(-)

New commits:
commit 5db9b33dadda67c7f97d8c23df17211fae380919
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Nov 17 09:15:23 2021 +0100
Commit: László Németh 
CommitDate: Fri Nov 26 11:52:13 2021 +0100

tdf#144940 sc: fix disabled header/footer regression

Setting "Same content on first page" in the Page Style
dialog on either the Header or Footer tab resulted
disabled header/footer after reload. This was due to
flawed logic when assigning SC_UNO_PAGE_HDRON/FTRON
value: "leftness" was checked for but not "first pageness".

Regression from commit b9993369b4011cd8f367e439f5248096827f1efc
"tdf#121715 XLSX: support custom first page header/footer".

Co-authored-by: Daniel Arato (NISZ)

Change-Id: I8ee4c9f8145913d9dc5f4b66cdbc2352f2e405f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125367
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/uitest/calc_tests8/tdf144940.py 
b/sc/qa/uitest/calc_tests8/tdf144940.py
new file mode 100644
index ..6b118c7602c2
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf144940.py
@@ -0,0 +1,59 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from tempfile import TemporaryDirectory
+from org.libreoffice.unotest import systemPathToFileUrl
+import os.path
+
+class tdf144940(UITestCase):
+
+def test_tdf144940(self):
+
+with TemporaryDirectory() as tempdir:
+xFilePath = os.path.join(tempdir, "tdf144940-tmp.ods")
+
+with self.ui_test.create_doc_in_start_center("calc"):
+
+with 
self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") as xDialog:
+xTabs = xDialog.getChild("tabcontrol")
+select_pos(xTabs, "4")
+
+xCheckHeaderOn = xDialog.getChild("checkHeaderOn")
+xCheckSameFP = xDialog.getChild("checkSameFP")
+xCheckSameLR = xDialog.getChild("checkSameLR")
+
+self.assertEqual("true", 
get_state_as_dict(xCheckHeaderOn)["Selected"])
+self.assertEqual("true", 
get_state_as_dict(xCheckSameLR)["Selected"])
+self.assertEqual("false", 
get_state_as_dict(xCheckSameFP)["Selected"])
+
+xCheckSameFP.executeAction("CLICK", tuple())
+
+self.assertEqual("true", 
get_state_as_dict(xCheckSameFP)["Selected"])
+
+with self.ui_test.execute_dialog_through_command(".uno:Save", 
close_button="open") as xSaveDialog:
+xFileName = xSaveDialog.getChild("file_name")
+xFileName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+xFileName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": 
xFilePath}))
+
+with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
+
+xPageStyles = document.StyleFamilies.getByIndex(1)
+xDefaultPageStyle = xPageStyles.getByIndex(0)
+
+# Without the fix in place, this test would have failed with
+# AssertionError: False is not true
+self.assertTrue(xDefaultPageStyle.HeaderOn)
+self.assertTrue(xDefaultPageStyle.FooterOn)
+self.assertTrue(xDefaultPageStyle.FirstPageHeaderIsShared)
+self.assertTrue(xDefaultPageStyle.FirstPageFooterIsShared)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx 
b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
index c0b5c6eb6cc1..773eb12da88b 100644
--- a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
+++ b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
@@ -63,19 +63,20 @@ XMLTableHeaderFooterContext::XMLTableHeaderFooterContext( 
SvXMLImport& rImport,
 XMLOFF_WARN_UNKNOWN("sc", aIter);
 }
 bool bOn(::cppu::any2bool(xPropSet->getPropertyValue( sOn )));
-if( bLeft )
+if( bLeft || bFirst )
 {
+const OUString sShare = bLeft ? sShareContent : sShareFirstContent;
 if( bOn && bDisplay )
 {
-if( ::cppu::any2bool(xPropSet->getPropertyValue( sShareContent )) )
+if( 

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2021-11-24 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx|   74 +--
 sw/inc/unomid.h |4 
 sw/inc/unoprnms.hxx |1 
 sw/qa/uitest/data/ComplexGroupShapeTest.odt |binary
 sw/qa/uitest/writer_tests4/ComplexGroupShapeTest.py |  124 +
 sw/source/core/doc/DocumentLayoutManager.cxx|   45 +
 sw/source/core/doc/docdraw.cxx  |   55 +-
 sw/source/core/doc/docfly.cxx   |   11 
 sw/source/core/doc/textboxhelper.cxx|  492 +++-
 sw/source/core/draw/dcontact.cxx|   11 
 sw/source/core/draw/dview.cxx   |8 
 sw/source/core/frmedt/feshview.cxx  |4 
 sw/source/core/layout/atrfrm.cxx|5 
 sw/source/core/unocore/unodraw.cxx  |   66 +-
 sw/source/core/unocore/unomap.cxx   |3 
 sw/source/core/unocore/unomap1.cxx  |1 
 16 files changed, 702 insertions(+), 202 deletions(-)

New commits:
commit eabcfb3f18a6944d9ad89cecd3eb3ca7a2259cf3
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Nov 3 15:39:32 2021 +0100
Commit: László Németh 
CommitDate: Wed Nov 24 11:51:07 2021 +0100

tdf#129183 sw: textboxes in group shapes - part 3

Grouping/ungrouping nested groups works now.

Manual test:

1.  Insert Shape.
2.  Right-click on selected shape, Add Text Box (and some text).
3.  Insert a new shape.
4.  Select and group the two shapes.
3.  Insert a third shape.
4.  Select and group the shape and the previously grouped shapes.

The text box remains in the nested shape group.

Details:

1) tdf#144271 memory leak of SwTextBoxHelper, by replacing the
textbox structure vector with std::unordered map, and rethinking
of the ownership of the objects. If a SwFrameFormat dies, and that
is a FLYFRMFMT, it will be deleted from the textbox node and the
FrameFormat table in the doc too, and the drawing will be stay as
it was before. If the dying format is a drawing, all the textboxes,
and the node will be deleted.

2) Introducing the new UNO property TextBoxContent, which is needed
for writerfilter/xmloff later to set a new textbox for the shape
via UNO.

3) Missing parameters are present now for syncing the textbox
parameters.

4) Introducing a new function namely the handleGroupTextBox() to
do the tasks simply with all textboxes in a group shape.
This can handle nested groups as well (group in a group).

Known issues: now copy of nested group objects is implemented
but not enabled, because it causes an assert.

Change-Id: I931886eda01c7a3db93098de10f5e5f48f2f217b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124657
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 2e5b27cfccb0..10841ed8626c 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -11,6 +11,7 @@
 #define INCLUDED_SW_INC_TEXTBOXHELPER_HXX
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -60,12 +61,16 @@ public:
 /// the original text in the shape will be copied to the frame
 /// The textbox is created for the shape given by the pObject parameter.
 static void create(SwFrameFormat* pShape, SdrObject* pObject, bool 
bCopyText = false);
+/// Sets the given textframe as textbox for the given (group member) shape.
+static void set(SwFrameFormat* pShape, SdrObject* pObject,
+css::uno::Reference xNew);
 /// Destroy a TextBox for a shape. If the format has more textboxes
 /// like group shapes, it will destroy only that textbox what belongs
 /// to the given pObject shape.
 static void destroy(const SwFrameFormat* pShape, const SdrObject* pObject);
 /// Get interface of a shape's TextBox, if there is any.
-static css::uno::Any queryInterface(const SwFrameFormat* pShape, const 
css::uno::Type& rType);
+static css::uno::Any queryInterface(const SwFrameFormat* pShape, const 
css::uno::Type& rType,
+SdrObject* pObj = nullptr);
 
 /// Sync property of TextBox with the one of the shape.
 static void syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 
nMemberID,
@@ -90,7 +95,7 @@ public:
 
 /// Sets the surround to through for the textframe of the given shape,
 /// not to interfere with the layout. Returns true on success.
-static bool setWrapThrough(SwFrameFormat* pShape);
+static bool setWrapThrough(SwFrameFormat* pShape, SdrObject* pObj = 
nullptr);
 
 /// Sets the anchor of the associated textframe of the given shape, and
 /// returns true on success.
@@ -100,15 +105,20 @@ public:
 /// returns true on success.
 static bool doTextBoxPositioning(SwFrameFormat* 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sd/qa sd/source

2021-10-21 Thread Attila Bakos (NISZ) (via logerrit)
 sd/qa/uitest/impress_tests/data/tdf127900.fodp |  778 +
 sd/qa/uitest/impress_tests/tdf127900.py|   39 +
 sd/source/ui/view/drawview.cxx |3 
 3 files changed, 819 insertions(+), 1 deletion(-)

New commits:
commit 90d79c4703e81c3b8b2b9db9cee679fb964f325a
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Aug 24 16:48:07 2021 +0200
Commit: Tünde Tóth 
CommitDate: Thu Oct 21 10:51:55 2021 +0200

tdf#127900 sd: fix regression at applying master properties

Language settings of frames in slide master weren't applied
on the slides based on that master.

Regression since LO 6.3 by "tdf#126067 Fix slide scope
feature." (commit 40bb9ac690d979ef544d5aa759bd734a176912a0).

Co-developed-by: Dániel Arató (NISZ)

Change-Id: I559adbe00870ed8a3d2947fef8dae435a387e34a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120993
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit ca5e344aec6a5848831101bc0d623b2bac754b6e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123862
Tested-by: Tünde Tóth 
Reviewed-by: Tünde Tóth 

diff --git a/sd/qa/uitest/impress_tests/data/tdf127900.fodp 
b/sd/qa/uitest/impress_tests/data/tdf127900.fodp
new file mode 100644
index ..adedafc2757a
--- /dev/null
+++ b/sd/qa/uitest/impress_tests/data/tdf127900.fodp
@@ -0,0 +1,778 @@
+
+
+http://openoffice.org/2004/office; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:rpt="http://openoffice.org/2005/report; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw; 
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: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: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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns
 :css3t="http://www.w3.org/TR/css3-text/; 
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" 
xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" 
xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.presentation">
+ 
2021-08-30T08:55:10.39400LibreOffice/7.1.1.2$Windows_X86_64
 
LibreOffice_project/fe0b08f4af1bacafe4c7ecc87ce55bb4261646762021-08-30T08:56:29.11600PT7S1
+ 
+  
+   0
+   0
+   14099
+   
+   
+
+ view1
+ false
+ false
+ true
+ true
+ true
+ true
+ false
+ false
+ true
+ 1500
+ false
+ Hw==
+ Hw==
+ 
+ false
+ true
+ false
+ 0
+ 1
+ false
+ true
+ true
+ 4
+ 0
+ -974
+ -423
+ 28894
+ 17739
+ 2000
+ 2000
+ 500
+ 500
+ 2000
+ 4
+ 2000
+ 4
+ false
+ 1500
+ true
+ false
+
+   
+  
+  
+   true
+   $(inst)/share/palette%3B$(user)/config/standard.sob
+   0
+   $(inst)/share/palette%3B$(user)/config/standard.soc
+   $(inst)/share/palette%3B$(user)/config/standard.sod
+   1250
+   true
+   true
+   false
+   true
+   false
+   $(inst)/share/palette%3B$(user)/config/standard.sog
+   true
+   $(inst)/share/palette%3B$(user)/config/standard.soh
+   false
+   false
+   true
+   true
+   false
+   true
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   false
+   $(inst)/share/palette%3B$(user)/config/standard.soe
+   false
+   4
+   false
+   0
+   low-resolution
+   Microsoft Print to PDF
+   false
+   

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sw/qa sw/source

2021-10-21 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/uitest/data/tdf142847.fodt|   49 
 sw/qa/uitest/writer_tests5/tdf142847.py |   39 +
 sw/source/core/doc/docfmt.cxx   |   10 ++
 sw/source/core/doc/textboxhelper.cxx|   10 +-
 sw/source/core/text/porfly.cxx  |3 +
 5 files changed, 109 insertions(+), 2 deletions(-)

New commits:
commit 6df1ea43d565035fd2edf71b7ab7103beeaffb55
Author: Attila Bakos (NISZ) 
AuthorDate: Fri Jul 2 11:29:58 2021 +0200
Commit: Tünde Tóth 
CommitDate: Thu Oct 21 10:51:28 2021 +0200

tdf#142847 sw: fix textbox layout at wrap setting

Setting wrap spacing of a textbox via its Wrap->Edit...
dialog window, the textbox had fallen apart, if it
was anchored as character.

Change-Id: I6c48c7a631a93a874129f64e1bdc6b3e2051e64f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118281
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123959
Tested-by: Tünde Tóth 
Reviewed-by: Tünde Tóth 

diff --git a/sw/qa/uitest/data/tdf142847.fodt b/sw/qa/uitest/data/tdf142847.fodt
new file mode 100644
index ..5ceed7151808
--- /dev/null
+++ b/sw/qa/uitest/data/tdf142847.fodt
@@ -0,0 +1,49 @@
+
+
+http://openoffice.org/2004/office; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:rpt="http://openoffice.org/2005/report; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw; 
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: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: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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns
 :css3t="http://www.w3.org/TR/css3-text/; 
xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
2021-08-25T15:50:24.33400PT5M16S4LibreOffice/7.1.1.2$Windows_X86_64
 
LibreOffice_project/fe0b08f4af1bacafe4c7ecc87ce55bb426164676
+ 
+  
+  
+  
+  
+  
+  
+  
+  
+  
+ 
+ 
+  
+   
+  
+  
+   
+  
+  
+   
+
+   
+   
+   
+  
+ 
+ 
+  
+ 
+ 
+  
+   
+
+
+
+
+
+   
+   Xx xx x xx x x xx  x x x xx 
x x xx x x x x xx x x x xx xx x xx x x x x x x x x x x xx 
x x x x  x x x x x xxx  Xx xx x xx x x xx  x x x xx x 
x xx x x x x xx x x x xx xx x xx x x x x x x x x x x xx x 
x x x
+ 
+ 
+  x x x x x xx xXx xx x xx x x xx  x 
x x xx x x xx x x x x xx x x x xx xx x xx x x x 
x x x x x x x xx x x x x  x x x x x xx xXx xx x xx x x xx  x 
x x xx x x xx x x x x xx x x x xx xx x xx x x x 
x x x x x x x xx x x x x  x x x x x x  xxXx xx x xx x x xx  x 
x x xx x x xx x x x x xx x x x xx xx x xx x x x 
x x x x x x x xx x x x x  x x x x x   xxxXx xx x xx x x xx  x 
x x xx x x xx x x x x xx x x x xx xx x xx x x x 
x x x x x x x xx x x x x  x x x x x x xx
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/uitest/writer_tests5/tdf142847.py 
b/sw/qa/uitest/writer_tests5/tdf142847.py
new file mode 100644
index ..bddc64e0e13c
--- /dev/null
+++ b/sw/qa/uitest/writer_tests5/tdf142847.py
@@ -0,0 +1,39 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+from uitest.framework import UITestCase
+import 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sd/qa sd/source

2021-10-21 Thread Attila Bakos (NISZ) (via logerrit)
 sd/qa/unit/data/pptx/LostPlaceholder.odp |binary
 sd/qa/unit/export-tests-ooxml1.cxx   |   35 ++-
 sd/source/filter/eppt/pptx-epptooxml.cxx |   17 +++
 3 files changed, 47 insertions(+), 5 deletions(-)

New commits:
commit 6dc0e26f9b88fc8490315ac97d23630f014ee4a9
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Apr 20 13:02:44 2021 +0200
Commit: Balazs Varga 
CommitDate: Thu Oct 21 09:39:59 2021 +0200

tdf#111903 tdf#137152 PPTX export: fix placeholders

Empty placeholders were exported as white empty
custom shapes, losing their visibility and usability.

Note: export of properties hasn't been implemented, yet.

Change-Id: Ie8bd6a611f5fb43bcaa55f6b2f5b07daf731b163
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114331
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123856
Tested-by: Balazs Varga 
Reviewed-by: Balazs Varga 

diff --git a/sd/qa/unit/data/pptx/LostPlaceholder.odp 
b/sd/qa/unit/data/pptx/LostPlaceholder.odp
new file mode 100644
index ..80ead189f260
Binary files /dev/null and b/sd/qa/unit/data/pptx/LostPlaceholder.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index d0837001ceca..a6b0c428aff1 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -62,6 +62,7 @@ public:
 void testN828390_4();
 void testN828390_5();
 void testFdo71961();
+void testLostPlaceholders();
 void testN828390();
 void testBnc880763();
 void testBnc862510_5();
@@ -114,6 +115,7 @@ public:
 CPPUNIT_TEST(testN828390_4);
 CPPUNIT_TEST(testN828390_5);
 CPPUNIT_TEST(testFdo71961);
+CPPUNIT_TEST(testLostPlaceholders);
 CPPUNIT_TEST(testN828390);
 CPPUNIT_TEST(testBnc880763);
 CPPUNIT_TEST(testBnc862510_5);
@@ -361,6 +363,37 @@ void SdOOXMLExportTest1::testN828390_5()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest1::testLostPlaceholders()
+{
+::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/LostPlaceholder.odp"),
 ODP);
+CPPUNIT_ASSERT(xDocShRef.is());
+
+xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
+CPPUNIT_ASSERT(xDocShRef.is());
+
+auto pDoc = xDocShRef->GetDoc();
+CPPUNIT_ASSERT(pDoc);
+auto pPage = pDoc->GetPage(1);
+CPPUNIT_ASSERT(pPage);
+auto pObj = pPage->GetObj(1);
+CPPUNIT_ASSERT(pObj);
+uno::Reference xShp (pObj->getUnoShape(), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShp);
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ShapeType!", 
OUString(u"com.sun.star.presentation.OutlinerShape"), xShp->getShapeType());
+uno::Reference xShpProps(xShp, uno::UNO_QUERY);
+// Without the fix in place there will be the following error:
+// Expected: com.sun.star.presentation.OutlinerShape
+// Actual: com.sun.star.drawing.CustomShape
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("It must be a placeholder!", true, 
xShpProps->getPropertyValue("IsPresentationObject").get());
+// Without the fix in place this will the following:
+// Expected: true
+// Actual: false
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest1::testFdo71961()
 {
 ::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo71961.odp"), ODP);
@@ -370,7 +403,7 @@ void SdOOXMLExportTest1::testFdo71961()
 
 // Export to .pptx changes all text frames to custom shape objects, which 
obey TextWordWrap property
 // (which is false for text frames otherwise and is ignored). Check that 
frames that should wrap still do.
-SdrObjCustomShape *pTxtObj = dynamic_cast( 
pPage->GetObj( 1 ));
+auto  pTxtObj = pPage->GetObj( 1 );
 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
 CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), 
pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
 CPPUNIT_ASSERT_EQUAL( true, 
pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP).GetValue());
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index c734bf10f0f5..2579d5627148 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1438,13 +1438,22 @@ ShapeExport& 
PowerPointShapeExport::WritePageShape(const Reference< XShape >& xS
 bool PowerPointShapeExport::WritePlaceholder(const Reference< XShape >& 
xShape, PlaceholderType ePlaceholder, bool bMaster)
 {
 SAL_INFO("sd.eppt", "WritePlaceholder " << bMaster << " " << 
ShapeExport::NonEmptyText(xShape));
-if (bMaster && ShapeExport::NonEmptyText(xShape))
+if (!xShape)
+return false;
+try
 {
-WritePlaceholderShape(xShape, ePlaceholder);
+Reference xShapeProps(xShape, UNO_QUERY);
+if 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sd/qa sd/source

2021-09-22 Thread Attila Bakos (NISZ) (via logerrit)
 sd/qa/uitest/impress_tests/data/tdf127900.fodp |  778 +
 sd/qa/uitest/impress_tests/tdf127900.py|   46 +
 sd/source/ui/view/drawview.cxx |3 
 3 files changed, 826 insertions(+), 1 deletion(-)

New commits:
commit dbfb7940e4e6b0a1f136a6d109d0e6926617208f
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Aug 24 16:48:07 2021 +0200
Commit: Xisco Fauli 
CommitDate: Wed Sep 22 10:45:49 2021 +0200

tdf#127900 sd: fix regression at applying master properties

Language settings of frames in slide master weren't applied
on the slides based on that master.

Regression since LO 6.3 by "tdf#126067 Fix slide scope
feature." (commit 40bb9ac690d979ef544d5aa759bd734a176912a0).

Co-developed-by: Dániel Arató (NISZ)

Change-Id: I559adbe00870ed8a3d2947fef8dae435a387e34a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120993
Tested-by: László Németh 
Reviewed-by: László Németh 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122397
Tested-by: Jenkins

diff --git a/sd/qa/uitest/impress_tests/data/tdf127900.fodp 
b/sd/qa/uitest/impress_tests/data/tdf127900.fodp
new file mode 100644
index ..adedafc2757a
--- /dev/null
+++ b/sd/qa/uitest/impress_tests/data/tdf127900.fodp
@@ -0,0 +1,778 @@
+
+
+http://openoffice.org/2004/office; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:rpt="http://openoffice.org/2005/report; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw; 
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: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: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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns
 :css3t="http://www.w3.org/TR/css3-text/; 
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" 
xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" 
xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.presentation">
+ 
2021-08-30T08:55:10.39400LibreOffice/7.1.1.2$Windows_X86_64
 
LibreOffice_project/fe0b08f4af1bacafe4c7ecc87ce55bb4261646762021-08-30T08:56:29.11600PT7S1
+ 
+  
+   0
+   0
+   14099
+   
+   
+
+ view1
+ false
+ false
+ true
+ true
+ true
+ true
+ false
+ false
+ true
+ 1500
+ false
+ Hw==
+ Hw==
+ 
+ false
+ true
+ false
+ 0
+ 1
+ false
+ true
+ true
+ 4
+ 0
+ -974
+ -423
+ 28894
+ 17739
+ 2000
+ 2000
+ 500
+ 500
+ 2000
+ 4
+ 2000
+ 4
+ false
+ 1500
+ true
+ false
+
+   
+  
+  
+   true
+   $(inst)/share/palette%3B$(user)/config/standard.sob
+   0
+   $(inst)/share/palette%3B$(user)/config/standard.soc
+   $(inst)/share/palette%3B$(user)/config/standard.sod
+   1250
+   true
+   true
+   false
+   true
+   false
+   $(inst)/share/palette%3B$(user)/config/standard.sog
+   true
+   $(inst)/share/palette%3B$(user)/config/standard.soh
+   false
+   false
+   true
+   true
+   false
+   true
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   false
+   $(inst)/share/palette%3B$(user)/config/standard.soe
+   false
+   4
+   false
+   0
+   low-resolution
+   Microsoft Print to PDF
+   false
+   

[Libreoffice-commits] core.git: sd/qa sd/source

2021-09-21 Thread Attila Bakos (NISZ) (via logerrit)
 sd/qa/uitest/impress_tests/data/tdf127900.fodp |  778 +
 sd/qa/uitest/impress_tests/tdf127900.py|   39 +
 sd/source/ui/view/drawview.cxx |3 
 3 files changed, 819 insertions(+), 1 deletion(-)

New commits:
commit ca5e344aec6a5848831101bc0d623b2bac754b6e
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Aug 24 16:48:07 2021 +0200
Commit: László Németh 
CommitDate: Tue Sep 21 12:12:51 2021 +0200

tdf#127900 sd: fix regression at applying master properties

Language settings of frames in slide master weren't applied
on the slides based on that master.

Regression since LO 6.3 by "tdf#126067 Fix slide scope
feature." (commit 40bb9ac690d979ef544d5aa759bd734a176912a0).

Co-developed-by: Dániel Arató (NISZ)

Change-Id: I559adbe00870ed8a3d2947fef8dae435a387e34a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120993
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sd/qa/uitest/impress_tests/data/tdf127900.fodp 
b/sd/qa/uitest/impress_tests/data/tdf127900.fodp
new file mode 100644
index ..adedafc2757a
--- /dev/null
+++ b/sd/qa/uitest/impress_tests/data/tdf127900.fodp
@@ -0,0 +1,778 @@
+
+
+http://openoffice.org/2004/office; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:rpt="http://openoffice.org/2005/report; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw; 
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: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: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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns
 :css3t="http://www.w3.org/TR/css3-text/; 
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" 
xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" 
xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.presentation">
+ 
2021-08-30T08:55:10.39400LibreOffice/7.1.1.2$Windows_X86_64
 
LibreOffice_project/fe0b08f4af1bacafe4c7ecc87ce55bb4261646762021-08-30T08:56:29.11600PT7S1
+ 
+  
+   0
+   0
+   14099
+   
+   
+
+ view1
+ false
+ false
+ true
+ true
+ true
+ true
+ false
+ false
+ true
+ 1500
+ false
+ Hw==
+ Hw==
+ 
+ false
+ true
+ false
+ 0
+ 1
+ false
+ true
+ true
+ 4
+ 0
+ -974
+ -423
+ 28894
+ 17739
+ 2000
+ 2000
+ 500
+ 500
+ 2000
+ 4
+ 2000
+ 4
+ false
+ 1500
+ true
+ false
+
+   
+  
+  
+   true
+   $(inst)/share/palette%3B$(user)/config/standard.sob
+   0
+   $(inst)/share/palette%3B$(user)/config/standard.soc
+   $(inst)/share/palette%3B$(user)/config/standard.sod
+   1250
+   true
+   true
+   false
+   true
+   false
+   $(inst)/share/palette%3B$(user)/config/standard.sog
+   true
+   $(inst)/share/palette%3B$(user)/config/standard.soh
+   false
+   false
+   true
+   true
+   false
+   true
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   false
+   $(inst)/share/palette%3B$(user)/config/standard.soe
+   false
+   4
+   false
+   0
+   low-resolution
+   Microsoft Print to PDF
+   false
+   

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2021-09-16 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |   14 
 sw/qa/uitest/writer_tests7/tdf143574.py  |3 
 sw/source/core/doc/DocumentLayoutManager.cxx |   81 +++-
 sw/source/core/doc/docdraw.cxx   |   30 +
 sw/source/core/doc/docfly.cxx|4 
 sw/source/core/doc/docfmt.cxx|7 
 sw/source/core/doc/textboxhelper.cxx |  456 ++-
 sw/source/core/draw/dcontact.cxx |   31 +
 sw/source/core/draw/dview.cxx|   12 
 sw/source/core/frmedt/fecopy.cxx |4 
 sw/source/core/frmedt/fefly1.cxx |   22 +
 sw/source/core/frmedt/feshview.cxx   |6 
 sw/source/core/layout/atrfrm.cxx |   15 
 sw/source/core/layout/flycnt.cxx |2 
 sw/source/core/text/porfly.cxx   |   13 
 sw/source/core/undo/undraw.cxx   |  110 ++
 sw/source/core/unocore/unodraw.cxx   |7 
 sw/source/uibase/shells/drawsh.cxx   |4 
 18 files changed, 531 insertions(+), 290 deletions(-)

New commits:
commit ba5156abace2e41ec4d21397c0875f7e1efd2beb
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Sep 1 16:38:07 2021 +0200
Commit: László Németh 
CommitDate: Thu Sep 16 12:56:10 2021 +0200

tdf#143574 tdf#144271 sw: textboxes in group shapes - part 2

Sync textboxes with group shapes, adding textboxes to
group shapes, copying textboxes with group shapes,
grouping/ungrouping group shapes with textboxes, removing
textboxes from group shapes.

This patch fixes a memory leak (tdf#144271) introduced
by commit 504d78acb866495fd954fcd6db22ea68f174a5ab
"tdf#143574 sw: textboxes in group shapes - part 1".

Note: AS_CHAR anchoring is far not the best for group
shapes and import/export is still missing.

Change-Id: I7dc3b8d36c4a04f792ae4742fe4a45af9227a17e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121449
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 3cd442ed7194..978cf77327b9 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -69,10 +69,10 @@ public:
 
 /// Sync property of TextBox with the one of the shape.
 static void syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 
nMemberID,
- const css::uno::Any& rValue);
+ const css::uno::Any& rValue, SdrObject* pObj = 
nullptr);
 /// Does the same, but works on properties which lack an sw-specific WID / 
MemberID.
 static void syncProperty(SwFrameFormat* pShape, std::u16string_view 
rPropertyName,
- const css::uno::Any& rValue);
+ const css::uno::Any& rValue, SdrObject* pObj = 
nullptr);
 /// Get a property of the underlying TextFrame.
 static void getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID, 
sal_uInt8 nMemberID,
 css::uno::Any& rValue);
@@ -83,7 +83,7 @@ public:
 static css::text::TextContentAnchorType mapAnchorType(const RndStdIds& 
rAnchorID);
 
 /// Similar to syncProperty(), but used by the internal API (e.g. for UI 
purposes).
-static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
rSet);
+static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
rSet, SdrObject* pObj);
 
 /// Copy shape attributes to the text frame
 static void updateTextBoxMargin(SdrObject* pObj);
@@ -94,11 +94,11 @@ public:
 
 /// Sets the anchor of the associated textframe of the given shape, and
 /// returns true on success.
-static bool changeAnchor(SwFrameFormat* pShape);
+static bool changeAnchor(SwFrameFormat* pShape, SdrObject* pObj);
 
 /// Does the positioning for the associated textframe of the shape, and
 /// returns true on success.
-static bool doTextBoxPositioning(SwFrameFormat* pShape);
+static bool doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pObj);
 
 /// Returns true if the anchor different for the  given shape, and the
 /// associated textframe of the given shape.
@@ -112,7 +112,7 @@ public:
 
 // Returns true on success. Synchronize z-order of the text frame of the 
given textbox
 // by setting it one level higher than the z-order of the shape of the 
textbox.
-static bool DoTextBoxZOrderCorrection(SwFrameFormat* pShape);
+static bool DoTextBoxZOrderCorrection(SwFrameFormat* pShape, SdrObject* 
pObj);
 
 /**
  * If we have an associated TextFrame, then return that.
@@ -134,7 +134,7 @@ public:
 static css::uno::Reference
 getUnoTextFrame(css::uno::Reference const& xShape);
 /// Return the textbox rectangle of a draw shape (in twips).
-static tools::Rectangle getTextRectangle(SwFrameFormat* pShape, bool 
bAbsolute = true);
+static tools::Rectangle getTextRectangle(SdrObject* pShape, bool bAbsolute 
= 

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2021-09-01 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/frmfmt.hxx|   10 -
 sw/inc/textboxhelper.hxx |   94 ++-
 sw/qa/extras/layout/layout.cxx   |2 
 sw/qa/extras/uiwriter/uiwriter3.cxx  |   10 -
 sw/qa/uitest/data/tdf143574.odt  |binary
 sw/qa/uitest/writer_tests7/tdf143574.py  |   39 
 sw/source/core/doc/DocumentLayoutManager.cxx |7 
 sw/source/core/doc/textboxhelper.cxx |  220 +++
 sw/source/core/draw/dflyobj.cxx  |2 
 sw/source/core/layout/atrfrm.cxx |   52 +-
 sw/source/core/layout/flycnt.cxx |2 
 sw/source/core/undo/undobj1.cxx  |   22 +-
 sw/source/core/unocore/unodraw.cxx   |4 
 sw/source/uibase/shells/drawsh.cxx   |4 
 14 files changed, 368 insertions(+), 100 deletions(-)

New commits:
commit 504d78acb866495fd954fcd6db22ea68f174a5ab
Author: Attila Bakos (NISZ) 
AuthorDate: Fri Aug 13 14:11:24 2021 +0200
Commit: László Németh 
CommitDate: Wed Sep 1 10:09:37 2021 +0200

tdf#143574 sw: textboxes in group shapes - part 1

Introduce SwTextBoxNode class to support grouped
textboxes, fixing the crash when entering a group
shape, trying to add a textbox to one of the shapes.

Test of crash fix: right click on a group shape.
Select the menu item "Enter group". Select one of
the shapes, and right click on it, and choose "Add
Text Box".

Note: textboxes in Writer are linked in SwFrameFormat
class. Each textbox consists of a text frame and a shape.
This object pair makes it possible to have complex
content inside any kind of shape (pictures, tables etc.
Group shapes have only one SwFrameFormat, but can have
many shapes so that means they can only have one textbox.
From now, each shape could have a textbox in a group.
Please note this is only a preparation for that. Filter
implementation and handlers are under development.

Change-Id: Iae35c118f0e67697b289c30d0fad4f5e16501c02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120452
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 24554c1171f2..59aee54a2f4a 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -27,6 +27,7 @@
 #include "hintids.hxx"
 #include "swdllapi.h"
 #include 
+#include "textboxhelper.hxx"
 
 class SwFlyFrame;
 class SwFlyDrawContact;
@@ -73,7 +74,7 @@ class SW_DLLPUBLIC SwFrameFormat
 // The assigned SwFrmFmt list.
 SwFrameFormats *m_ffList;
 
-SwFrameFormat *m_pOtherTextBoxFormat;
+SwTextBoxNode* m_pOtherTextBoxFormat;
 
 struct change_name
 {
@@ -99,10 +100,11 @@ protected:
 
 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
 
-SwFrameFormat* GetOtherTextBoxFormat() const { return 
m_pOtherTextBoxFormat; }
-void SetOtherTextBoxFormat( SwFrameFormat *pFormat );
-
 public:
+
+SwTextBoxNode* GetOtherTextBoxFormat() const { return 
m_pOtherTextBoxFormat; };
+void SetOtherTextBoxFormat(SwTextBoxNode* pNew) { m_pOtherTextBoxFormat = 
pNew; };
+
 virtual ~SwFrameFormat() override;
 
 SwFrameFormat(SwFrameFormat const &) = default;
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 3d1d4dce5827..3cd442ed7194 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -56,11 +56,14 @@ public:
 using SavedLink = std::map;
 /// Maps a draw format to content.
 using SavedContent = std::map;
-/// Create a TextBox for a shape. If the second parameter is true,
+/// Create a TextBox for a shape. If the third parameter is true,
 /// the original text in the shape will be copied to the frame
-static void create(SwFrameFormat* pShape, bool bCopyText = false);
-/// Destroy a TextBox for a shape.
-static void destroy(SwFrameFormat* pShape);
+/// The textbox is created for the shape given by the pObject parameter.
+static void create(SwFrameFormat* pShape, SdrObject* pObject, bool 
bCopyText = false);
+/// Destroy a TextBox for a shape. If the format has more textboxes
+/// like group shapes, it will destroy only that textbox what belongs
+/// to the given pObject shape.
+static void destroy(SwFrameFormat* pShape, SdrObject* pObject);
 /// Get interface of a shape's TextBox, if there is any.
 static css::uno::Any queryInterface(const SwFrameFormat* pShape, const 
css::uno::Type& rType);
 
@@ -114,12 +117,16 @@ public:
 /**
  * If we have an associated TextFrame, then return that.
  *
+ * If we have more textboxes for this format (group shape), that one will 
be
+ * returned, what belongs to the pObject.
+ *
  * @param nType Expected frame format type.
  *  Valid types are RES_DRAWFRMFMT and RES_FLYFRMFMT.
  *
  * @see isTextBox
  */
-static SwFrameFormat* getOtherTextBoxFormat(const 

[Libreoffice-commits] core.git: sw/qa sw/source

2021-08-30 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/uitest/data/tdf142847.fodt|   49 
 sw/qa/uitest/writer_tests5/tdf142847.py |   39 +
 sw/source/core/doc/docfmt.cxx   |   10 ++
 sw/source/core/doc/textboxhelper.cxx|8 -
 sw/source/core/text/porfly.cxx  |3 +
 5 files changed, 107 insertions(+), 2 deletions(-)

New commits:
commit 84888d6bbee16978774acb5d23b1b4eb006df67f
Author: Attila Bakos (NISZ) 
AuthorDate: Fri Jul 2 11:29:58 2021 +0200
Commit: László Németh 
CommitDate: Mon Aug 30 18:16:46 2021 +0200

tdf#142847 sw: fix textbox layout at wrap setting

Setting wrap spacing of a textbox via its Wrap->Edit...
dialog window, the textbox had fallen apart, if it
was anchored as character.

Change-Id: I6c48c7a631a93a874129f64e1bdc6b3e2051e64f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118281
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/uitest/data/tdf142847.fodt b/sw/qa/uitest/data/tdf142847.fodt
new file mode 100644
index ..5ceed7151808
--- /dev/null
+++ b/sw/qa/uitest/data/tdf142847.fodt
@@ -0,0 +1,49 @@
+
+
+http://openoffice.org/2004/office; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:rpt="http://openoffice.org/2005/report; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw; 
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: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: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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns
 :css3t="http://www.w3.org/TR/css3-text/; 
xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
2021-08-25T15:50:24.33400PT5M16S4LibreOffice/7.1.1.2$Windows_X86_64
 
LibreOffice_project/fe0b08f4af1bacafe4c7ecc87ce55bb426164676
+ 
+  
+  
+  
+  
+  
+  
+  
+  
+  
+ 
+ 
+  
+   
+  
+  
+   
+  
+  
+   
+
+   
+   
+   
+  
+ 
+ 
+  
+ 
+ 
+  
+   
+
+
+
+
+
+   
+   Xx xx x xx x x xx  x x x xx 
x x xx x x x x xx x x x xx xx x xx x x x x x x x x x x xx 
x x x x  x x x x x xxx  Xx xx x xx x x xx  x x x xx x 
x xx x x x x xx x x x xx xx x xx x x x x x x x x x x xx x 
x x x
+ 
+ 
+  x x x x x xx xXx xx x xx x x xx  x 
x x xx x x xx x x x x xx x x x xx xx x xx x x x 
x x x x x x x xx x x x x  x x x x x xx xXx xx x xx x x xx  x 
x x xx x x xx x x x x xx x x x xx xx x xx x x x 
x x x x x x x xx x x x x  x x x x x x  xxXx xx x xx x x xx  x 
x x xx x x xx x x x x xx x x x xx xx x xx x x x 
x x x x x x x xx x x x x  x x x x x   xxxXx xx x xx x x xx  x 
x x xx x x xx x x x x xx x x x xx xx x xx x x x 
x x x x x x x xx x x x x  x x x x x x xx
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/uitest/writer_tests5/tdf142847.py 
b/sw/qa/uitest/writer_tests5/tdf142847.py
new file mode 100644
index ..bddc64e0e13c
--- /dev/null
+++ b/sw/qa/uitest/writer_tests5/tdf142847.py
@@ -0,0 +1,39 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+from uitest.framework import UITestCase
+import org.libreoffice.unotest
+from uitest.uihelper.common import get_url_for_data_file
+from libreoffice.uno.propertyvalue import 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - svx/source sw/inc sw/qa sw/source

2021-08-19 Thread Attila Bakos (NISZ) (via logerrit)
 svx/source/svdraw/svdpage.cxx|5 -
 sw/inc/textboxhelper.hxx |4 
 sw/qa/extras/ooxmlexport/data/testTextBoxZOrder.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx   |   31 +++
 sw/source/core/doc/textboxhelper.cxx |   70 ++--
 sw/source/core/frmedt/feshview.cxx   |   82 +++
 6 files changed, 185 insertions(+), 7 deletions(-)

New commits:
commit 09aba686b452e3fa2d7ad3e06ebebba83aa0dfe7
Author: Attila Bakos (NISZ) 
AuthorDate: Fri May 7 10:18:01 2021 +0200
Commit: Gabor Kelemen 
CommitDate: Thu Aug 19 15:54:19 2021 +0200

tdf#138141 sw: fix textbox z-order

Textboxes are implemented as loosely connected
shape-text frame pairs. Missing synchronization
of their z-orders resulted e.g invisible or
only partially visible textbox content using
Arrange options with textboxes (see in local menu
or on Drawing Object Properties toolbar).

Note: because it's not possible to send frames
to the background, Arrange->To Background hasn't
supported, so likely it's worth to remove that
option later from local menu of textboxes.

Change-Id: I1aa50903ba55dd5b9e72ef203c4e30218bee68fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115227
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 0e6d963fbca16f98a3dbb6ef2fee3736a89d055b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120713
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index c1f8980f4236..be6907184c08 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -757,7 +757,10 @@ size_t SdrObjList::GetObjCount() const
 
 SdrObject* SdrObjList::GetObj(size_t nNum) const
 {
-return maList[nNum];
+if (nNum < maList.size())
+return maList[nNum];
+
+return nullptr;
 }
 
 
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 90e173046133..6bfd8ddfad00 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -123,6 +123,10 @@ public:
 /// Returns true if the given shape has a valid textframe.
 static bool 
isTextBoxShapeHasValidTextFrame(css::uno::Reference 
xShape);
 
+// Returns true on success. Synchronize z-order of the text frame of the 
given textbox
+// by setting it one level higher than the z-order of the shape of the 
textbox.
+static bool DoTextBoxZOrderCorrection(SwFrameFormat* pShape);
+
 /**
  * If we have an associated TextFrame, then return that.
  *
diff --git a/sw/qa/extras/ooxmlexport/data/testTextBoxZOrder.docx 
b/sw/qa/extras/ooxmlexport/data/testTextBoxZOrder.docx
new file mode 100644
index ..c6dd0b8f30c8
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/testTextBoxZOrder.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index f0664b1f002d..7e890145210d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -160,6 +161,36 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133473_shadowSize, 
"tdf133473.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(20), nSize1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTextBoxZOrder, "testTextBoxZOrder.docx")
+{
+// Is load successful?
+CPPUNIT_ASSERT(mxComponent);
+// Collect the z-order values of the textboxes
+std::vector ShapeZorders;
+std::vector FrameZorders;
+for (int i = 1; i < 4; i++)
+{
+uno::Reference xShape(getShape(i));
+CPPUNIT_ASSERT(xShape);
+uno::Reference xShapeProperties(xShape, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShapeProperties);
+uno::Reference xFrame = 
SwTextBoxHelper::getUnoTextFrame(xShape);
+CPPUNIT_ASSERT(xFrame.is());
+uno::Reference const xFrameProperties(xFrame, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xFrameProperties);
+
ShapeZorders.push_back(xShapeProperties->getPropertyValue("ZOrder").get());
+
FrameZorders.push_back(xFrameProperties->getPropertyValue("ZOrder").get());
+}
+// Check the z-order values.
+for (int i = 1; i < 3; i++)
+{
+CPPUNIT_ASSERT_GREATER(ShapeZorders[i - 1], ShapeZorders[i]);
+CPPUNIT_ASSERT_GREATER(FrameZorders[i - 1], FrameZorders[i]);
+CPPUNIT_ASSERT_GREATER(ShapeZorders[i - 1], FrameZorders[i - 1]);
+}
+// Without the fix it failed, because the z-order was wrong.
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf141550, "tdf141550.docx")
 {
 uno::Reference xShape(getShape(1));
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 88138f6aee10..e5ade0b38125 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - oox/source sd/qa sd/source

2021-07-08 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx   |3 --
 sd/qa/unit/data/odp/placeholder-box-textalignment.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx|   20 ++
 sd/source/filter/eppt/pptx-epptooxml.cxx  |9 +++-
 4 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit 3518b4cebdddc0446cf923c38acee52bf5d6a9b1
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jun 8 12:25:41 2021 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jul 8 14:11:30 2021 +0200

tdf#142235 PPTX export: fix styles with placeholders

inserting icons and alignment.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
(tdf#111903 tdf#137152 PPTX export: fix placeholders).

Note: in the unit test document, check fixed vertical position
of the second text boxes of Slide 2–4.

Change-Id: I3c649db69f94a2e9f49ae7aa11d9cd9d9f6d80d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116828
Tested-by: László Németh 
Reviewed-by: László Németh 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118446
Tested-by: Jenkins

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 0372ae804b13..d27b28cb7d1f 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2988,8 +2988,7 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
 const char* sVerticalAlignment = nullptr;
 if (GetProperty(rXPropSet, "TextVerticalAdjust"))
 mAny >>= eVerticalAlignment;
-if( eVerticalAlignment != TextVerticalAdjust_TOP )
-sVerticalAlignment = GetTextVerticalAdjust(eVerticalAlignment);
+sVerticalAlignment = GetTextVerticalAdjust(eVerticalAlignment);
 
 const char* sWritingMode = nullptr;
 bool bVertical = false;
diff --git a/sd/qa/unit/data/odp/placeholder-box-textalignment.odp 
b/sd/qa/unit/data/odp/placeholder-box-textalignment.odp
new file mode 100644
index ..df33291fbd40
Binary files /dev/null and 
b/sd/qa/unit/data/odp/placeholder-box-textalignment.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index fb2db18e8d22..6632934e430e 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -116,6 +116,7 @@ public:
 void testTdf125560_textDeflate();
 void testTdf125560_textInflateTop();
 void testTdf96061_textHighlight();
+void testTdf142235_TestPlaceholderTextAlignment();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -184,6 +185,7 @@ public:
 CPPUNIT_TEST(testTdf125560_textDeflate);
 CPPUNIT_TEST(testTdf125560_textInflateTop);
 CPPUNIT_TEST(testTdf96061_textHighlight);
+CPPUNIT_TEST(testTdf142235_TestPlaceholderTextAlignment);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -1688,6 +1690,24 @@ void SdOOXMLExportTest3::testTdf125560_textInflateTop()
 "type", "mso-spt164");
 }
 
+void SdOOXMLExportTest3::testTdf142235_TestPlaceholderTextAlignment()
+{
+auto xDocShRef = loadURL(
+
m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/placeholder-box-textalignment.odp"),
 ODP);
+
+utl::TempFile tmpfile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXml1 = parseExport(tmpfile, "ppt/slides/slide2.xml");
+xmlDocUniquePtr pXml2 = parseExport(tmpfile, "ppt/slides/slide3.xml");
+
+// Without the fix in place many of these asserts failed, because 
alignment was bad.
+
+assertXPath(pXml1, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr", 
"anchor", "t");
+assertXPath(pXml2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr", 
"anchor", "t");
+}
+
 void SdOOXMLExportTest3::testTdf96061_textHighlight()
 {
 ::sd::DrawDocShellRef xDocShRef
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 6a8502361061..f30a4d040fc6 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1555,8 +1555,15 @@ ShapeExport& 
PowerPointShapeExport::WritePlaceholderShape(const Reference< XShap
 default:
 SAL_INFO("sd.eppt", "warning: unhandled placeholder type: " << 
ePlaceholder);
 }
+
 SAL_INFO("sd.eppt", "write placeholder " << pType);
-mpFS->singleElementNS(XML_p, XML_ph, XML_type, pType);
+
+if ((mePageType == PageType::LAYOUT || mePageType == PageType::NORMAL)
+&& ePlaceholder == Outliner)
+mpFS->singleElementNS(XML_p, XML_ph);
+else
+mpFS->singleElementNS(XML_p, XML_ph, XML_type, pType);
+
 mpFS->endElementNS(XML_p, XML_nvPr);
 mpFS->endElementNS(XML_p, XML_nvSpPr);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sw/inc sw/qa sw/source

2021-07-05 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |   39 ++
 sw/qa/extras/ooxmlexport/data/tdf141550.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx   |   20 +
 sw/qa/extras/uiwriter/data/tdf140975.docx|binary
 sw/qa/extras/uiwriter/uiwriter3.cxx  |   30 ++
 sw/qa/uitest/data/tdf141557.docx |binary
 sw/qa/uitest/writer_tests7/tdf141557.py  |   40 ++
 sw/source/core/doc/textboxhelper.cxx |  363 +++
 sw/source/core/text/porfly.cxx   |1 
 9 files changed, 386 insertions(+), 107 deletions(-)

New commits:
commit f0915432398df9a726f05dfddd176c576e56443f
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Apr 1 17:08:58 2021 +0200
Commit: Gabor Kelemen 
CommitDate: Mon Jul 5 15:41:51 2021 +0200

tdf#141550 tdf#141557 tdf#140975 sw: fix textbox crash

and regressions by refactoring SwTextBoxHelper.

tdf#141550 was a DOCX import regression from
commit ff321dd36554d25f0817903becf4598065e0a194
(tdf#140828 sw textbox: fix AS_CHAR regression),
resulting bad horizontal position of the frame of
the textbox.

tdf#141557 was a regression resulting crash
by changing text box anchoring "To Paragraph".

tdf#140975 was an implementation error, resulting
broken textbox by changing box anchoring to
"As Character".

In the SwTextBoxHelper class there were many
repeating code parts for textbox positioning.
Now these parts have been replaced with
the calls of several new functions:

1) getShapeFormat() returns with the SwFrameFormat
   of the UNO XShape;

2) setWrapThrough() only sets the surround
   of the textframe (used in the code frequently);

3) changeAnchor() sets the anchor of the textframe
   according to the anchor of the shape;

4) doTextFramePositioning() sets the position of the
   textbox according to the shape (used in the code
   frequently);

5) isAnchorTypeDifferent() shows difference of the
   anchor types of the shape and the textframe. Also it
   handles the situation of anchoring "As Character";

6) isTextBoxHasValidTextFrame() checks if the shape
   is a part of a textbox or not.

Every function returns with true on success, otherwise
gives information to the log. All of them can be called
with ShapeFormat or UNO XShape.

The goal of this to make the possibility to advance this
class for further functions – rotation, grouped
textboxes etc. – without code copying.

Change-Id: I4441cab87931f161d0ace4983646d6d2a68a7321
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113463
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118437
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index a22086e0d97a..90e173046133 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -81,9 +81,48 @@ public:
 /// Similar to syncProperty(), but used by the internal API (e.g. for UI 
purposes).
 static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
rSet);
 
+/// Returns the SwFrameFormat* of the given UNO-XShape if exists otherwise 
nullptr.
+static SwFrameFormat* 
getShapeFormat(css::uno::Reference xShape);
+
 /// Copy shape attributes to the text frame
 static void updateTextBoxMargin(SdrObject* pObj);
 
+/// Sets the surround to through for the textframe of the given shape,
+/// not to interfere with the layout. Returns true on success.
+static bool setWrapThrough(SwFrameFormat* pShape);
+
+/// Sets the surround to through for the textframe of the given shape,
+/// not to interfere with the layout. Returns true on success.
+static bool setWrapThrough(css::uno::Reference 
xShape);
+
+/// Sets the anchor of the associated textframe of the given shape, and
+/// returns true on success.
+static bool changeAnchor(SwFrameFormat* pShape);
+
+/// Sets the anchor of the associated textframe of the given shape, and
+/// returns true on success.
+static bool changeAnchor(css::uno::Reference xShape);
+
+/// Does the positioning for the associated textframe of the shape, and
+/// returns true on success.
+static bool doTextBoxPositioning(SwFrameFormat* pShape);
+
+/// Does the positioning for the associated textframe of the shape, and
+/// returns true on success.
+static bool doTextBoxPositioning(css::uno::Reference 
xShape);
+
+/// Returns true if the anchor different for the  given shape, and the
+/// associated textframe of the given shape.
+/// Note: In case of AS_CHAR anchor the anchor type must be different,
+/// because if not, layout breaks, but this situation also handled by
+/// this function, and returns true in that case too.
+static 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sw/qa sw/source

2021-07-05 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/tdf138951.odt|binary
 sw/qa/extras/layout/layout2.cxx   |   32 ++
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |   15 --
 sw/source/core/doc/textboxhelper.cxx  |2 -
 4 files changed, 46 insertions(+), 3 deletions(-)

New commits:
commit c71cffdfc95c614fb2d5216bcf53a861dba04eb8
Author: Attila Bakos (NISZ) 
AuthorDate: Fri Jan 15 14:45:29 2021 +0100
Commit: Gabor Kelemen 
CommitDate: Mon Jul 5 15:15:54 2021 +0200

tdf#136516 add positioning to SwTextBoxHelper::syncProperty()

Before when the shape of the textbox moved, the anchor
and the position synched. However if the new position
of the shape required new anchor position, that was not
handled. In addition after positioning and new anchor
position the sync is necessary again, because anchor
moving can change the calculated position values and
that can change the anchor etc...

The OOXMLImport test modification was necessary because
a test failed during Jenkins tests however there was
no difference between the test document before and after the
fix. In addition I can not reproduce the fail of the test
in my local repository, and only the Linux- and Windows
builds showed the problem.

Solved also tdf#138951, tdf#139686 and tdf#139092.

Change-Id: Ibdfff89db01d75aeae74948e2ea41ce5a613b6fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109365
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit c96c386c5db45dc4d5e358915caad7474e373068)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118425
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/qa/extras/layout/data/tdf138951.odt 
b/sw/qa/extras/layout/data/tdf138951.odt
new file mode 100755
index ..5cb4940bd5fe
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138951.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 3e3d3b512be1..8cb41dde9b35 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -285,6 +286,37 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testRedlineShowHideFootnotePagination)
 "zzz. zzz  7 zzz zzz zzz zzz  zz 
 ");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testtdf138951)
+{
+// Open the bugdoc
+auto pDoc = createDoc("tdf138951.odt");
+
+// Get the only shape
+uno::Reference xShape(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShape);
+
+// Gather its formats: the shape and textbox
+const SwFrameFormat* pTxFrm = 
SwTextBoxHelper::getOtherTextBoxFormat(xShape);
+CPPUNIT_ASSERT(pTxFrm);
+const SwFrameFormat* pShFrm = 
SwTextBoxHelper::getOtherTextBoxFormat(pTxFrm, RES_FLYFRMFMT);
+CPPUNIT_ASSERT(pShFrm);
+
+pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
+
+// Get the bound rectangle of the textframe
+tools::Rectangle aTxtFrmRect(pTxFrm->FindRealSdrObject()->GetLogicRect());
+
+// Get the bound rectangle of the shape
+tools::Rectangle aShpRect(pShFrm->FindRealSdrObject()->GetLogicRect());
+
+// Check the anchor the same and the textbox is inside the shape
+const bool bIsAnchTheSame
+= *pShFrm->GetAnchor().GetContentAnchor() == 
*pShFrm->GetAnchor().GetContentAnchor();
+CPPUNIT_ASSERT_MESSAGE("The anchor is different for the textbox and 
shape!", bIsAnchTheSame);
+CPPUNIT_ASSERT_MESSAGE("The textbox has fallen apart!", 
aShpRect.IsInside(aTxtFrmRect));
+// Without the fix the anchor differs, and the frame ouside of the shape
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInNumbering)
 {
 SwDoc* pDoc = createDoc("tdf42748.fodt");
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 43608c5bd136..f81aeaec45a7 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -28,6 +28,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 class Test : public SwModelTestBase
 {
@@ -438,8 +440,17 @@ DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
 {
 // the position of the flying text frame should be off page
 // 30624 below its anchor
-OUString aTop = parseDump("//fly[1]/infos/bounds", "top");
-CPPUNIT_ASSERT_EQUAL(OUString("30624"), aTop);
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+SwRootFrame* pRootFrame = 
pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+const SwRect aPageRect = pRootFrame->getFrameArea();
+const SwRect 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sw/inc sw/qa sw/source

2021-07-05 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |2 +
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |3 -
 sw/qa/uitest/data/tdf137803.odt  |binary
 sw/qa/uitest/writer_tests7/tdf137803.py  |   61 +++
 sw/source/core/doc/textboxhelper.cxx |   30 +--
 sw/source/core/layout/flycnt.cxx |   27 +
 6 files changed, 118 insertions(+), 5 deletions(-)

New commits:
commit 653f2ceb8251dbbf38ea8dd4f1b41f3418e779bd
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Dec 10 10:36:12 2020 +0100
Commit: Gabor Kelemen 
CommitDate: Mon Jul 5 14:36:24 2021 +0200

tdf#137803 sw: fix AutoSize and Wrap of textboxes

When autosize (AutoGrowHeight) turned on
the textbox fell apart. After changing the text
of the textbox the positions still were different
for the shape and the textframe.

Now this fix solves, if the text changes,
the positions (with the size what worked only
before) synchronized so the textboxes are kept together.

Also Wrap text inside the shape now works like
the editeng text did, except in the case of empty
text boxes.

Note: this fixes only editing (without positioning
the textboxes by the mouse before or after the setting),
but not import/export, yet.

The ooxmlimport test has been restored to its original
state, because the fix for the tdf#135198 is fixed
by this commit.

To start the unit test just give the following command:

$ (cd sw && make UITest_writer_tests7 
UITEST_TEST_NAME="tdf137803.tdf137803.test_tdf137803" SAL_USE_VCLPLUGIN=gen)

Change-Id: Ie13a7a1e81e4099cd8540edd7e008118e58134bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107515
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118436
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 2043b1ffcfb3..a22086e0d97a 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -72,6 +72,8 @@ public:
 /// Get a property of the underlying TextFrame.
 static void getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID, 
sal_uInt8 nMemberID,
 css::uno::Any& rValue);
+/// Get a property of the underlying TextFrame.
+static css::uno::Any getProperty(SwFrameFormat const* pShape, OUString 
sPropName);
 
 /// There are two types of enum of anchor type, so this function maps this.
 static css::text::TextContentAnchorType mapAnchorType(const RndStdIds& 
rAnchorID);
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index d240abbfe628..6732a63a5679 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1066,8 +1066,7 @@ DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, 
"textbox-wps-only.docx")
 if ( nsScreen.frame.size.width * scaleFactor > 4000 )
 return;
 #endif
-// Vertically oriented to page due to tdf#135198
-CPPUNIT_ASSERT_EQUAL(sal_Int32(5304), getProperty(xFrame, 
"VertOrientPosition"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2805), getProperty(xFrame, 
"VertOrientPosition"));
 }
 
 DECLARE_OOXMLIMPORT_TEST(testGroupshapeRelsize, "groupshape-relsize.docx")
diff --git a/sw/qa/uitest/data/tdf137803.odt b/sw/qa/uitest/data/tdf137803.odt
new file mode 100644
index ..8f2f7d5dc49b
Binary files /dev/null and b/sw/qa/uitest/data/tdf137803.odt differ
diff --git a/sw/qa/uitest/writer_tests7/tdf137803.py 
b/sw/qa/uitest/writer_tests7/tdf137803.py
new file mode 100644
index ..249dbbb7cacc
--- /dev/null
+++ b/sw/qa/uitest/writer_tests7/tdf137803.py
@@ -0,0 +1,61 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict
+import importlib
+import time
+import org.libreoffice.unotest
+import pathlib
+
+def get_url_for_data_file(file_name):
+return 
pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+class tdf137803(UITestCase):
+def test_tdf137803(self):
+# load the sample file
+self.ui_test.load_file(get_url_for_data_file("tdf137803.odt"))
+xWriterDoc = self.xUITest.getTopFocusWindow()
+xWriterEdit = xWriterDoc.getChild("writer_edit")
+document = self.ui_test.get_component()
+
+# select the shape
+self.xUITest.executeCommand(".uno:JumpToNextFrame")
+self.ui_test.wait_until_child_is_available(xWriterEdit, 'metricfield')
+
+# open textattrs dialog
+

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sw/qa sw/source

2021-07-05 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/tdf137819.fodt |  284 
 sw/qa/extras/layout/layout2.cxx |   23 ++
 sw/source/core/doc/docfly.cxx   |8 
 sw/source/core/doc/textboxhelper.cxx|   58 ++
 4 files changed, 338 insertions(+), 35 deletions(-)

New commits:
commit 35cdcf47f40f0e5dac5c159c0d897a787a256bd4
Author: Attila Bakos (NISZ) 
AuthorDate: Fri Dec 4 13:42:09 2020 +0100
Commit: Gabor Kelemen 
CommitDate: Mon Jul 5 14:28:31 2021 +0200

tdf#137819 sw: fix textboxes anchoring "As Char"

Changing anchoring type of a textbox to "As Char",
shape position follows the new text frame position.
Also SwTextBoxHelper::mapAnchorType() was introduced
to map between text frames and shapes, with a small
cleanup.

Change-Id: Iea0abe6f12a293fb4270970fde53ea903b347fb2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107221
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit d00e7c651e80b9fd3d00262900e0938e2c392809)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118258
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/qa/extras/layout/data/tdf137819.fodt 
b/sw/qa/extras/layout/data/tdf137819.fodt
new file mode 100755
index ..cf6630e331d5
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf137819.fodt
@@ -0,0 +1,284 @@
+
+
+http://openoffice.org/2004/office; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:rpt="http://openoffice.org/2005/report; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw; 
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: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: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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns
 :css3t="http://www.w3.org/TR/css3-text/; 
xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
2020-12-15T15:05:53.737002020-12-15T15:10:45.23500PT1M9S2LibreOffice/7.0.1.2$Windows_X86_64
 
LibreOffice_project/7cbcfc562f6eb6708b5ff7d7397325de9e764452
+ 
+  
+   0
+   0
+   27651
+   17046
+   true
+   false
+   
+
+ view2
+ 13647
+ 7736
+ 0
+ 0
+ 27649
+ 17044
+ 0
+ 1
+ false
+ 120
+ false
+ false
+
+   
+  
+  
+   false
+   
+   
+   
+   1
+   true
+   false
+   false
+   true
+   false
+   false
+   true
+   true
+   
+   
+   true
+   false
+   false
+   0
+   true
+   false
+   true
+   false
+   false
+   0
+   false
+   true
+   false
+   false
+   false
+   false
+   high-resolution
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   false
+   true
+   false
+   true
+   false
+   
+   false
+   false
+   false
+   true
+   false
+   1901935
+   false
+   false
+   false
+   false
+   false
+   1991809
+   false
+   true
+   false
+   true
+   true
+   false
+   false
+   false
+   true
+   true
+   true
+   true
+   false
+   false
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   false
+   false
+   0
+   true
+   false
+   true
+   true
+   true
+   false
+   true
+   false
+   false
+   true
+   false
+   false
+   true
+   
+   false
+   true
+  
+ 
+ 
+  
+   http://openoffice.org/2004/office; 
xmlns:xlink="http://www.w3.org/1999/xlink"/>
+  
+ 
+ 
+  
+  
+  
+  
+  
+  
+ 
+ 
+  
+   
+   
+
+   
+   
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+   
+  
+  
+   
+   
+  
+  
+  
+  

[Libreoffice-commits] core.git: oox/source sd/qa sd/source

2021-07-02 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx   |3 --
 sd/qa/unit/data/odp/placeholder-box-textalignment.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx|   20 +
 sd/source/filter/eppt/pptx-epptooxml.cxx  |   21 +-
 4 files changed, 37 insertions(+), 7 deletions(-)

New commits:
commit dbdcceb9d77c602ea1161ab0f4e3899071333a92
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jun 8 12:25:41 2021 +0200
Commit: László Németh 
CommitDate: Fri Jul 2 14:23:17 2021 +0200

tdf#142235 PPTX export: fix styles with placeholders

inserting icons and alignment.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
(tdf#111903 tdf#137152 PPTX export: fix placeholders).

Note: in the unit test document, check fixed vertical position
of the second text boxes of Slide 2–4.

Change-Id: I3c649db69f94a2e9f49ae7aa11d9cd9d9f6d80d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116828
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 455e50159612..140445a5ee0f 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3081,8 +3081,7 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
 const char* sVerticalAlignment = nullptr;
 if (GetProperty(rXPropSet, "TextVerticalAdjust"))
 mAny >>= eVerticalAlignment;
-if( eVerticalAlignment != TextVerticalAdjust_TOP )
-sVerticalAlignment = GetTextVerticalAdjust(eVerticalAlignment);
+sVerticalAlignment = GetTextVerticalAdjust(eVerticalAlignment);
 
 const char* sWritingMode = nullptr;
 bool bVertical = false;
diff --git a/sd/qa/unit/data/odp/placeholder-box-textalignment.odp 
b/sd/qa/unit/data/odp/placeholder-box-textalignment.odp
new file mode 100644
index ..df33291fbd40
Binary files /dev/null and 
b/sd/qa/unit/data/odp/placeholder-box-textalignment.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index fb2db18e8d22..6632934e430e 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -116,6 +116,7 @@ public:
 void testTdf125560_textDeflate();
 void testTdf125560_textInflateTop();
 void testTdf96061_textHighlight();
+void testTdf142235_TestPlaceholderTextAlignment();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -184,6 +185,7 @@ public:
 CPPUNIT_TEST(testTdf125560_textDeflate);
 CPPUNIT_TEST(testTdf125560_textInflateTop);
 CPPUNIT_TEST(testTdf96061_textHighlight);
+CPPUNIT_TEST(testTdf142235_TestPlaceholderTextAlignment);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -1688,6 +1690,24 @@ void SdOOXMLExportTest3::testTdf125560_textInflateTop()
 "type", "mso-spt164");
 }
 
+void SdOOXMLExportTest3::testTdf142235_TestPlaceholderTextAlignment()
+{
+auto xDocShRef = loadURL(
+
m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/placeholder-box-textalignment.odp"),
 ODP);
+
+utl::TempFile tmpfile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXml1 = parseExport(tmpfile, "ppt/slides/slide2.xml");
+xmlDocUniquePtr pXml2 = parseExport(tmpfile, "ppt/slides/slide3.xml");
+
+// Without the fix in place many of these asserts failed, because 
alignment was bad.
+
+assertXPath(pXml1, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr", 
"anchor", "t");
+assertXPath(pXml2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr", 
"anchor", "t");
+}
+
 void SdOOXMLExportTest3::testTdf96061_textHighlight()
 {
 ::sd::DrawDocShellRef xDocShRef
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index d26cf6b0d061..ac7449fd38a6 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1568,14 +1568,25 @@ ShapeExport& 
PowerPointShapeExport::WritePlaceholderShape(const Reference< XShap
 SAL_INFO("sd.eppt", "write placeholder " << pType);
 if (bUsePlaceholderIndex)
 {
-mpFS->singleElementNS(
-XML_p, XML_ph, XML_type, pType, XML_idx,
-OString::number(
-
static_cast(GetFB())->CreateNewPlaceholderIndex(xShape)));
+if ((mePageType == PageType::LAYOUT || mePageType == PageType::NORMAL)
+&& ePlaceholder == Outliner)
+mpFS->singleElementNS(
+XML_p, XML_ph, XML_idx,
+OString::number(
+
static_cast(GetFB())->CreateNewPlaceholderIndex(xShape)));
+else
+mpFS->singleElementNS(
+XML_p, XML_ph, XML_type, pType, XML_idx,
+OString::number(
+
static_cast(GetFB())->CreateNewPlaceholderIndex(xShape)));

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - include/oox oox/source sw/qa

2021-07-02 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/export/DMLPresetShapeExport.hxx  |6 
 oox/source/export/DMLPresetShapeExport.cxx   |  191 +++
 sw/qa/extras/ooxmlexport/data/fail_bracePair.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx   |   10 +
 4 files changed, 145 insertions(+), 62 deletions(-)

New commits:
commit a871b36c3ba92e289367096aa0b44416b605d7e8
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jun 24 10:03:28 2021 +0200
Commit: László Németh 
CommitDate: Fri Jul 2 11:03:17 2021 +0200

tdf#143028 DOCX: fix corrupt export of shape "bracePair" etc.

Regression from commit 63cd67e5e18f01aca303131e148c80398a181a41
(tdf#92525 tdf#142398: fix export of simple custom shapes)

Missing property in the shape export property list
caused an exception. The return value false led to writing
the shape transformation again, resulting a corrupt DOCX file.
Optional values have been introduced and if one of the
required value is unset, writing of the transformation
happens only once.

Thanks to Regina Henschel for reporting the problem.

(cherry-picked from commit 99a459dfdfd9f82ed3506708e131dd52a1a62384
"tdf#143028 DOCX: fix corrupt export of shape "bracePair" etc."
and commit e190196f255b7d0147d61fd967a2b2a61a932185
"tdf#143028 DOCX export: fix RangeY regression of preset shapes")

Change-Id: Ifcb81a5df9dc568f8f21c39e072d58009ed04237
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118232
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/include/oox/export/DMLPresetShapeExport.hxx 
b/include/oox/export/DMLPresetShapeExport.hxx
index 1ab460d26845..1baf1d44cabc 100644
--- a/include/oox/export/DMLPresetShapeExport.hxx
+++ b/include/oox/export/DMLPresetShapeExport.hxx
@@ -86,9 +86,9 @@ public:
 private:
 struct AdjustmentPointValueBase
 {
-double nMaxVal;
-double nMinVal;
-double nCurrVal;
+std::optional nMaxVal;
+std::optional nMinVal;
+std::optional nCurrVal;
 };
 
 typedef AdjustmentPointValueBase RadiusAdjustmentValue;
diff --git a/oox/source/export/DMLPresetShapeExport.cxx 
b/oox/source/export/DMLPresetShapeExport.cxx
index 8e4ebafcce98..9da095bf2dc3 100644
--- a/oox/source/export/DMLPresetShapeExport.cxx
+++ b/oox/source/export/DMLPresetShapeExport.cxx
@@ -131,15 +131,22 @@ DMLPresetShapeExporter::RadiusAdjustmentValue
 DMLPresetShapeExporter::GetAdjustmentPointRadiusValue(sal_Int32 nPoint)
 {
 RadiusAdjustmentValue aRet;
-auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
-   .get();
-aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, 
u"RadiusRangeMinimum")
-   .get()
-   .Value.get();
-aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, 
u"RadiusRangeMaximum")
-   .get()
-   .Value.get();
-aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.First.Value.get()].Value.get();
+try
+{
+auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
+   .get();
+aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, 
u"RadiusRangeMinimum")
+   .get()
+   .Value.get();
+aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, 
u"RadiusRangeMaximum")
+   .get()
+   .Value.get();
+aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.First.Value.get()].Value.get();
+}
+catch (...)
+{
+// Do nothing.
+}
 return aRet;
 };
 
@@ -147,11 +154,18 @@ DMLPresetShapeExporter::AngleAdjustmentValue
 DMLPresetShapeExporter::GetAdjustmentPointAngleValue(sal_Int32 nPoint)
 {
 AngleAdjustmentValue aRet;
-auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
-   .get();
-aRet.nMinVal = 0;
-aRet.nMaxVal = 360;
-aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.Second.Value.get()].Value.get();
+try
+{
+auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
+   .get();
+aRet.nMinVal = 0;
+aRet.nMaxVal = 360;
+aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.Second.Value.get()].Value.get();
+}
+catch (...)
+{
+// Do nothing.
+}
 return aRet;
 };
 
@@ -159,15 +173,22 @@ DMLPresetShapeExporter::XAdjustmentValue
 DMLPresetShapeExporter::GetAdjustmentPointXValue(sal_Int32 nPoint)
 {
 XAdjustmentValue aRet;
-auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
-   .get();
-aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, u"RangeXMinimum")
-   .get()
-   .Value.get();
-aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, u"RangeXMaximum")
-   .get()
-   

[Libreoffice-commits] core.git: oox/source

2021-07-01 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/DMLPresetShapeExport.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e190196f255b7d0147d61fd967a2b2a61a932185
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jul 1 14:30:05 2021 +0200
Commit: László Németh 
CommitDate: Thu Jul 1 17:12:32 2021 +0200

tdf#143028 DOCX export: fix RangeY regression of preset shapes

Use property name "RangeYMaximum" instead of "RangeXMaximum"
in GetAdjustmentPointYValue().

Regression from commit 99a459dfdfd9f82ed3506708e131dd52a1a62384
(tdf#143028 DOCX: fix corrupt export of shape "bracePair" etc.)

Thanks to Regina Henschel for reporting the problem.

Change-Id: I2bdc4be9338d0fe4973a209ee97a4d5880aaac6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118223
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/DMLPresetShapeExport.cxx 
b/oox/source/export/DMLPresetShapeExport.cxx
index e8d2f26e2e5b..9da095bf2dc3 100644
--- a/oox/source/export/DMLPresetShapeExport.cxx
+++ b/oox/source/export/DMLPresetShapeExport.cxx
@@ -203,7 +203,7 @@ DMLPresetShapeExporter::GetAdjustmentPointYValue(sal_Int32 
nPoint)
 aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, 
u"RangeYMinimum")
.get()
.Value.get();
-aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, 
u"RangeXMaximum")
+aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, 
u"RangeYMaximum")
.get()
.Value.get();
 aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.Second.Value.get()].Value.get();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa sw/source

2021-07-01 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/Tdf121509.odt   |binary
 sw/qa/extras/layout/layout2.cxx  |   58 +++
 sw/source/filter/ww8/docxattributeoutput.cxx |   68 ++-
 sw/source/filter/ww8/docxattributeoutput.hxx |9 +++
 4 files changed, 134 insertions(+), 1 deletion(-)

New commits:
commit 68688b4ca2288ac815d1dff137177e632bbb5f9f
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Jun 14 15:24:06 2021 +0200
Commit: László Németh 
CommitDate: Thu Jul 1 16:06:34 2021 +0200

tdf#121509 DOCX export: fix corrupt shape anchoring in textbox

MSO doesn't support shapes anchored to character in a textbox.
Convert these shapes by re-anchoring them to the anchor
point of the textbox (also recalculating their positions in
simple cases), so Word can now open the exported document.

Change-Id: I28b244975981d69c50e5d4a46249918af089bae5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117163
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 35732c84b05e4f6e50349796636beb01f2a09907)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118179
Tested-by: Jenkins

diff --git a/sw/qa/extras/layout/data/Tdf121509.odt 
b/sw/qa/extras/layout/data/Tdf121509.odt
new file mode 100644
index ..856f60c88764
Binary files /dev/null and b/sw/qa/extras/layout/data/Tdf121509.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 72cdc908b6ca..1db5f1e69214 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -49,6 +49,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/layout/data/";
 
@@ -1442,6 +1445,61 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf127118)
 assertXPath(pXmlDoc, "/root/page[2]/body/tab/row[1]/cell[1]/txt[1]", 
"WritingMode", "VertBTLR");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf121509)
+{
+auto pDoc = createSwDoc(DATA_DIRECTORY, "Tdf121509.odt");
+CPPUNIT_ASSERT(pDoc);
+
+// Get all shape/frame formats
+auto vFrameFormats = pDoc->GetSpzFrameFormats();
+// Get the textbox
+auto xTextFrame = SwTextBoxHelper::getUnoTextFrame(getShape(1));
+// Get The triangle
+auto pTriangleShapeFormat = vFrameFormats->GetFormat(2);
+CPPUNIT_ASSERT(xTextFrame);
+CPPUNIT_ASSERT(pTriangleShapeFormat);
+
+// Get the position inside the textbox
+auto xTextContentStart = xTextFrame->getText()->getStart();
+SwUnoInternalPaM aCursor(*pDoc);
+CPPUNIT_ASSERT(sw::XTextRangeToSwPaM(aCursor, xTextContentStart));
+
+// Put the triangle into the textbox
+SwFormatAnchor aNewAnch(pTriangleShapeFormat->GetAnchor());
+aNewAnch.SetAnchor(aCursor.Start());
+CPPUNIT_ASSERT(pTriangleShapeFormat->SetFormatAttr(aNewAnch));
+
+// Reload (docx)
+auto aTemp = utl::TempFile();
+save("Office Open XML Text", aTemp);
+
+// The second part: check if the reloaded doc has flys inside a fly
+uno::Reference xComponent
+= loadFromDesktop(aTemp.GetURL(), "com.sun.star.text.TextDocument");
+uno::Reference xTextDoc(xComponent, uno::UNO_QUERY);
+auto pTextDoc = dynamic_cast(xTextDoc.get());
+CPPUNIT_ASSERT(pTextDoc);
+auto pSecondDoc = pTextDoc->GetDocShell()->GetDoc();
+auto pSecondFormats = pSecondDoc->GetSpzFrameFormats();
+
+bool bFlyInFlyFound = false;
+for (auto secondformat : *pSecondFormats)
+{
+auto& pNd = 
secondformat->GetAnchor().GetContentAnchor()->nNode.GetNode();
+if (pNd.FindFlyStartNode())
+{
+// So there is a fly inside another -> problem.
+bFlyInFlyFound = true;
+break;
+}
+}
+// Drop the tempfile
+aTemp.CloseStream();
+
+// With the fix this cannot be true, if it is, that means Word unable to 
read the file..
+CPPUNIT_ASSERT_MESSAGE("Corrupt exported docx file!", !bFlyInFlyFound);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134685)
 {
 createSwDoc(DATA_DIRECTORY, "tdf134685.docx");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 7cbf2a8a0df0..02da5d32096f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6082,7 +6082,7 @@ void DocxAttributeOutput::WritePostponedDMLDrawing()
 m_pPostponedOLEs = std::move(pPostponedOLEs);
 }
 
-void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame , const 
Point& /*rNdTopLeft*/ )
+void DocxAttributeOutput::WriteFlyFrame(const ww8::Frame& rFrame)
 {
 m_pSerializer->mark(Tag_OutputFlyFrame);
 
@@ -6254,6 +6254,71 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const 
ww8::Frame , const P
 m_pSerializer->mergeTopMarks(Tag_OutputFlyFrame);
 }
 
+void DocxAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const 
Point& 

[Libreoffice-commits] core.git: include/oox oox/source sw/qa

2021-07-01 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/export/DMLPresetShapeExport.hxx  |6 
 oox/source/export/DMLPresetShapeExport.cxx   |  191 +++
 sw/qa/extras/ooxmlexport/data/fail_bracePair.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx   |   10 +
 4 files changed, 145 insertions(+), 62 deletions(-)

New commits:
commit 99a459dfdfd9f82ed3506708e131dd52a1a62384
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jun 24 10:03:28 2021 +0200
Commit: László Németh 
CommitDate: Thu Jul 1 13:50:59 2021 +0200

tdf#143028 DOCX: fix corrupt export of shape "bracePair" etc.

Regression from commit 63cd67e5e18f01aca303131e148c80398a181a41
(tdf#92525 tdf#142398: fix export of simple custom shapes)

Missing property in the shape export property list
caused an exception. The return value false led to writing
the shape transformation again, resulting a corrupt DOCX file.
Optional values have been introduced and if one of the
required value is unset, writing of the transformation
happens only once.

Thanks to Regina Henschel for reporting the problem.

Change-Id: Ieae69bb1d2629fdbb91a84325cb100f0ad9d3e12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117763
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/include/oox/export/DMLPresetShapeExport.hxx 
b/include/oox/export/DMLPresetShapeExport.hxx
index 1ab460d26845..1baf1d44cabc 100644
--- a/include/oox/export/DMLPresetShapeExport.hxx
+++ b/include/oox/export/DMLPresetShapeExport.hxx
@@ -86,9 +86,9 @@ public:
 private:
 struct AdjustmentPointValueBase
 {
-double nMaxVal;
-double nMinVal;
-double nCurrVal;
+std::optional nMaxVal;
+std::optional nMinVal;
+std::optional nCurrVal;
 };
 
 typedef AdjustmentPointValueBase RadiusAdjustmentValue;
diff --git a/oox/source/export/DMLPresetShapeExport.cxx 
b/oox/source/export/DMLPresetShapeExport.cxx
index 8e4ebafcce98..e8d2f26e2e5b 100644
--- a/oox/source/export/DMLPresetShapeExport.cxx
+++ b/oox/source/export/DMLPresetShapeExport.cxx
@@ -131,15 +131,22 @@ DMLPresetShapeExporter::RadiusAdjustmentValue
 DMLPresetShapeExporter::GetAdjustmentPointRadiusValue(sal_Int32 nPoint)
 {
 RadiusAdjustmentValue aRet;
-auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
-   .get();
-aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, 
u"RadiusRangeMinimum")
-   .get()
-   .Value.get();
-aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, 
u"RadiusRangeMaximum")
-   .get()
-   .Value.get();
-aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.First.Value.get()].Value.get();
+try
+{
+auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
+   .get();
+aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, 
u"RadiusRangeMinimum")
+   .get()
+   .Value.get();
+aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, 
u"RadiusRangeMaximum")
+   .get()
+   .Value.get();
+aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.First.Value.get()].Value.get();
+}
+catch (...)
+{
+// Do nothing.
+}
 return aRet;
 };
 
@@ -147,11 +154,18 @@ DMLPresetShapeExporter::AngleAdjustmentValue
 DMLPresetShapeExporter::GetAdjustmentPointAngleValue(sal_Int32 nPoint)
 {
 AngleAdjustmentValue aRet;
-auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
-   .get();
-aRet.nMinVal = 0;
-aRet.nMaxVal = 360;
-aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.Second.Value.get()].Value.get();
+try
+{
+auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
+   .get();
+aRet.nMinVal = 0;
+aRet.nMaxVal = 360;
+aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.Second.Value.get()].Value.get();
+}
+catch (...)
+{
+// Do nothing.
+}
 return aRet;
 };
 
@@ -159,15 +173,22 @@ DMLPresetShapeExporter::XAdjustmentValue
 DMLPresetShapeExporter::GetAdjustmentPointXValue(sal_Int32 nPoint)
 {
 XAdjustmentValue aRet;
-auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
-   .get();
-aRet.nMinVal = GetHandleValueOfModificationPoint(nPoint, u"RangeXMinimum")
-   .get()
-   .Value.get();
-aRet.nMaxVal = GetHandleValueOfModificationPoint(nPoint, u"RangeXMaximum")
-   .get()
-   .Value.get();
-aRet.nCurrVal = 
GetAdjustmentValues()[aValPos.First.Value.get()].Value.get();
+try
+{
+auto aValPos = GetHandleValueOfModificationPoint(nPoint, u"Position")
+   .get();
+

[Libreoffice-commits] core.git: sw/qa sw/source

2021-07-01 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/Tdf121509.odt   |binary
 sw/qa/extras/layout/layout2.cxx  |   58 +++
 sw/source/filter/ww8/docxattributeoutput.cxx |   68 ++-
 sw/source/filter/ww8/docxattributeoutput.hxx |9 +++
 4 files changed, 134 insertions(+), 1 deletion(-)

New commits:
commit 35732c84b05e4f6e50349796636beb01f2a09907
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Jun 14 15:24:06 2021 +0200
Commit: László Németh 
CommitDate: Thu Jul 1 12:47:35 2021 +0200

tdf#121509 DOCX export: fix corrupt shape anchoring in textbox

MSO doesn't support shapes anchored to character in a textbox.
Convert these shapes by re-anchoring them to the anchor
point of the textbox (also recalculating their positions in
simple cases), so Word can now open the exported document.

Change-Id: I28b244975981d69c50e5d4a46249918af089bae5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117163
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/layout/data/Tdf121509.odt 
b/sw/qa/extras/layout/data/Tdf121509.odt
new file mode 100644
index ..856f60c88764
Binary files /dev/null and b/sw/qa/extras/layout/data/Tdf121509.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 72cdc908b6ca..1db5f1e69214 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -49,6 +49,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/layout/data/";
 
@@ -1442,6 +1445,61 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf127118)
 assertXPath(pXmlDoc, "/root/page[2]/body/tab/row[1]/cell[1]/txt[1]", 
"WritingMode", "VertBTLR");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf121509)
+{
+auto pDoc = createSwDoc(DATA_DIRECTORY, "Tdf121509.odt");
+CPPUNIT_ASSERT(pDoc);
+
+// Get all shape/frame formats
+auto vFrameFormats = pDoc->GetSpzFrameFormats();
+// Get the textbox
+auto xTextFrame = SwTextBoxHelper::getUnoTextFrame(getShape(1));
+// Get The triangle
+auto pTriangleShapeFormat = vFrameFormats->GetFormat(2);
+CPPUNIT_ASSERT(xTextFrame);
+CPPUNIT_ASSERT(pTriangleShapeFormat);
+
+// Get the position inside the textbox
+auto xTextContentStart = xTextFrame->getText()->getStart();
+SwUnoInternalPaM aCursor(*pDoc);
+CPPUNIT_ASSERT(sw::XTextRangeToSwPaM(aCursor, xTextContentStart));
+
+// Put the triangle into the textbox
+SwFormatAnchor aNewAnch(pTriangleShapeFormat->GetAnchor());
+aNewAnch.SetAnchor(aCursor.Start());
+CPPUNIT_ASSERT(pTriangleShapeFormat->SetFormatAttr(aNewAnch));
+
+// Reload (docx)
+auto aTemp = utl::TempFile();
+save("Office Open XML Text", aTemp);
+
+// The second part: check if the reloaded doc has flys inside a fly
+uno::Reference xComponent
+= loadFromDesktop(aTemp.GetURL(), "com.sun.star.text.TextDocument");
+uno::Reference xTextDoc(xComponent, uno::UNO_QUERY);
+auto pTextDoc = dynamic_cast(xTextDoc.get());
+CPPUNIT_ASSERT(pTextDoc);
+auto pSecondDoc = pTextDoc->GetDocShell()->GetDoc();
+auto pSecondFormats = pSecondDoc->GetSpzFrameFormats();
+
+bool bFlyInFlyFound = false;
+for (auto secondformat : *pSecondFormats)
+{
+auto& pNd = 
secondformat->GetAnchor().GetContentAnchor()->nNode.GetNode();
+if (pNd.FindFlyStartNode())
+{
+// So there is a fly inside another -> problem.
+bFlyInFlyFound = true;
+break;
+}
+}
+// Drop the tempfile
+aTemp.CloseStream();
+
+// With the fix this cannot be true, if it is, that means Word unable to 
read the file..
+CPPUNIT_ASSERT_MESSAGE("Corrupt exported docx file!", !bFlyInFlyFound);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134685)
 {
 createSwDoc(DATA_DIRECTORY, "tdf134685.docx");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 7d185f5ce9c0..19dc42aa119c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6082,7 +6082,7 @@ void DocxAttributeOutput::WritePostponedDMLDrawing()
 m_pPostponedOLEs = std::move(pPostponedOLEs);
 }
 
-void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame , const 
Point& /*rNdTopLeft*/ )
+void DocxAttributeOutput::WriteFlyFrame(const ww8::Frame& rFrame)
 {
 m_pSerializer->mark(Tag_OutputFlyFrame);
 
@@ -6254,6 +6254,71 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const 
ww8::Frame , const P
 m_pSerializer->mergeTopMarks(Tag_OutputFlyFrame);
 }
 
+void DocxAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const 
Point& /*rNdTopLeft*/)
+{
+/// The old OutputFlyFrame_Impl() moved to WriteFlyFrame().
+/// Now if a frame anchored inside another frame, it will
+/// not be exported 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - include/oox oox/Library_oox.mk oox/source sw/qa

2021-06-24 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/export/DMLPresetShapeExport.hxx   |  138 +
 oox/Library_oox.mk|1 
 oox/source/export/DMLPresetShapeExport.cxx| 1287 ++
 oox/source/export/shapes.cxx  |   15 
 sw/qa/extras/ooxmlexport/data/testCustomShapePresetExport.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|   31 
 6 files changed, 1471 insertions(+), 1 deletion(-)

New commits:
commit 0cfa76c0a1883289f8406551d0494cc2a30df926
Author: Attila Bakos (NISZ) 
AuthorDate: Fri May 14 13:53:32 2021 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 24 10:33:36 2021 +0200

tdf#92525 tdf#142398: fix export of simple custom shapes

Most of the custom shapes were exported with DrawingML custom
geometry instead of DOCX preset shapes, losing their preset type,
adjust handles and text position. Add a preset exporter class to
handle all possible preset shapes later, and fix the export of
the following shapes now: "bevel", "blockArc", "bracePair",
"bracketPair", "hexagon", "octagon", "parallelogram", "plus",
"roundRect" and "triangle".

tdf#92525: keep text position in triangles with different
adjustments, too.

tdf#142398: part 1: export simple shapes as preset shapes.

Change-Id: I6aee74f7670bea8c1fe5909cbf307778ea728669
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115606
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 63cd67e5e18f01aca303131e148c80398a181a41)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117715
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/include/oox/export/DMLPresetShapeExport.hxx 
b/include/oox/export/DMLPresetShapeExport.hxx
new file mode 100644
index ..1ab460d26845
--- /dev/null
+++ b/include/oox/export/DMLPresetShapeExport.hxx
@@ -0,0 +1,138 @@
+/* -*- 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/.
+*/
+
+#ifndef INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
+#define INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+namespace com::sun::star::beans
+{
+struct PropertyValue;
+}
+
+namespace com::sun::star::drawing
+{
+class XShape;
+struct EnhancedCustomShapeAdjustmentValue;
+}
+
+namespace oox::core
+{
+class XmlFilterBase;
+}
+
+namespace oox::drawingml
+{
+/// Class for exporting the custom shapes to OOXML preset ones, if possible.
+/// This functionality needed for keeping the information for the office 
programs
+/// about the shape type, and geometry data. Before these shapes were exported
+/// with custom geometry, and they kept their geometry but has no information
+/// about the shape itself. This lead to lost textbox size/position/padding for
+/// example.
+class DMLPresetShapeExporter
+{
+private:
+// the shape to export
+css::uno::Reference m_xShape;
+// the DMLwriter
+DrawingML* m_pDMLexporter;
+// the type of the custom shape (diamond/rectangle/circle/triangle...)
+OUString m_sPresetShapeType;
+// True if the shape has points where its geometry can be modified
+bool m_bHasHandleValues;
+// The first the x the second the y coordinate, of flipping
+std::pair m_bIsFlipped;
+
+// Custom Shape Geometry information for export:
+
+// The adjusting values stored in this sequence:
+css::uno::Sequence 
m_AdjustmentValues;
+// Shapes what have adjusting points, the range of these points
+// and the index of the value stored in this sequence:
+css::uno::Sequence> 
m_HandleValues;
+
+//TODO:
+//css::awt::Rectangle m_ViewBox;
+//css::uno::Sequence m_Path;
+//css::uno::Sequence m_Equations;
+
+public:
+DMLPresetShapeExporter() = delete;
+~DMLPresetShapeExporter();
+
+DMLPresetShapeExporter(DrawingML* pDMLExporter,
+   css::uno::Reference xShape);
+
+// Writes the preset shape to the xml
+bool WriteShape();
+
+private:
+struct AdjustmentPointValueBase
+{
+double nMaxVal;
+double nMinVal;
+double nCurrVal;
+};
+
+typedef AdjustmentPointValueBase RadiusAdjustmentValue;
+typedef AdjustmentPointValueBase AngleAdjustmentValue;
+typedef AdjustmentPointValueBase XAdjustmentValue;
+typedef AdjustmentPointValueBase YAdjustmentValue;
+
+// Returns true, if the shape has adjusting points
+bool HasHandleValue();
+
+// Returns true if the shape flipped.
+bool IsXFlipped() { return m_bIsFlipped.first; };
+bool IsYFlipped() { return m_bIsFlipped.second; };
+
+// 

[Libreoffice-commits] core.git: include/oox oox/Library_oox.mk oox/source sw/qa

2021-06-23 Thread Attila Bakos (NISZ) (via logerrit)
 include/oox/export/DMLPresetShapeExport.hxx   |  138 +
 oox/Library_oox.mk|1 
 oox/source/export/DMLPresetShapeExport.cxx| 1287 ++
 oox/source/export/shapes.cxx  |   15 
 sw/qa/extras/ooxmlexport/data/testCustomShapePresetExport.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|   31 
 6 files changed, 1471 insertions(+), 1 deletion(-)

New commits:
commit 63cd67e5e18f01aca303131e148c80398a181a41
Author: Attila Bakos (NISZ) 
AuthorDate: Fri May 14 13:53:32 2021 +0200
Commit: László Németh 
CommitDate: Wed Jun 23 12:57:40 2021 +0200

tdf#92525 tdf#142398: fix export of simple custom shapes

Most of the custom shapes were exported with DrawingML custom
geometry instead of DOCX preset shapes, losing their preset type,
adjust handles and text position. Add a preset exporter class to
handle all possible preset shapes later, and fix the export of
the following shapes now: "bevel", "blockArc", "bracePair",
"bracketPair", "hexagon", "octagon", "parallelogram", "plus",
"roundRect" and "triangle".

tdf#92525: keep text position in triangles with different
adjustments, too.

tdf#142398: part 1: export simple shapes as preset shapes.

Change-Id: I6aee74f7670bea8c1fe5909cbf307778ea728669
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115606
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/include/oox/export/DMLPresetShapeExport.hxx 
b/include/oox/export/DMLPresetShapeExport.hxx
new file mode 100644
index ..1ab460d26845
--- /dev/null
+++ b/include/oox/export/DMLPresetShapeExport.hxx
@@ -0,0 +1,138 @@
+/* -*- 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/.
+*/
+
+#ifndef INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
+#define INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+namespace com::sun::star::beans
+{
+struct PropertyValue;
+}
+
+namespace com::sun::star::drawing
+{
+class XShape;
+struct EnhancedCustomShapeAdjustmentValue;
+}
+
+namespace oox::core
+{
+class XmlFilterBase;
+}
+
+namespace oox::drawingml
+{
+/// Class for exporting the custom shapes to OOXML preset ones, if possible.
+/// This functionality needed for keeping the information for the office 
programs
+/// about the shape type, and geometry data. Before these shapes were exported
+/// with custom geometry, and they kept their geometry but has no information
+/// about the shape itself. This lead to lost textbox size/position/padding for
+/// example.
+class DMLPresetShapeExporter
+{
+private:
+// the shape to export
+css::uno::Reference m_xShape;
+// the DMLwriter
+DrawingML* m_pDMLexporter;
+// the type of the custom shape (diamond/rectangle/circle/triangle...)
+OUString m_sPresetShapeType;
+// True if the shape has points where its geometry can be modified
+bool m_bHasHandleValues;
+// The first the x the second the y coordinate, of flipping
+std::pair m_bIsFlipped;
+
+// Custom Shape Geometry information for export:
+
+// The adjusting values stored in this sequence:
+css::uno::Sequence 
m_AdjustmentValues;
+// Shapes what have adjusting points, the range of these points
+// and the index of the value stored in this sequence:
+css::uno::Sequence> 
m_HandleValues;
+
+//TODO:
+//css::awt::Rectangle m_ViewBox;
+//css::uno::Sequence m_Path;
+//css::uno::Sequence m_Equations;
+
+public:
+DMLPresetShapeExporter() = delete;
+~DMLPresetShapeExporter();
+
+DMLPresetShapeExporter(DrawingML* pDMLExporter,
+   css::uno::Reference xShape);
+
+// Writes the preset shape to the xml
+bool WriteShape();
+
+private:
+struct AdjustmentPointValueBase
+{
+double nMaxVal;
+double nMinVal;
+double nCurrVal;
+};
+
+typedef AdjustmentPointValueBase RadiusAdjustmentValue;
+typedef AdjustmentPointValueBase AngleAdjustmentValue;
+typedef AdjustmentPointValueBase XAdjustmentValue;
+typedef AdjustmentPointValueBase YAdjustmentValue;
+
+// Returns true, if the shape has adjusting points
+bool HasHandleValue();
+
+// Returns true if the shape flipped.
+bool IsXFlipped() { return m_bIsFlipped.first; };
+bool IsYFlipped() { return m_bIsFlipped.second; };
+
+// Returns with the shape type, like triangle for example
+OUString GetShapeType();
+// Returns with the handle points
+css::uno::Sequence> 
GetHandleValues();
+// Returns with 

[Libreoffice-commits] core.git: sd/qa sd/source

2021-05-31 Thread Attila Bakos (NISZ) (via logerrit)
 sd/qa/unit/data/pptx/LostPlaceholderFill.odp |binary
 sd/qa/unit/export-tests-ooxml1.cxx   |   53 +++
 sd/source/filter/eppt/pptx-epptooxml.cxx |   18 +
 3 files changed, 71 insertions(+)

New commits:
commit 8acc6bc43e0334157b97b36f570987a49c5febdd
Author: Attila Bakos (NISZ) 
AuthorDate: Tue May 25 16:48:51 2021 +0200
Commit: László Németh 
CommitDate: Mon May 31 11:43:02 2021 +0200

tdf#142537 PPTX export: fix placeholder style export

Regression from: b6b02e0b4c9d739836e1f61a886ea45b01e6696e
(tdf#111903 tdf#137152 PPTX export: fix placeholders)

Placeholders lost the formatting, which has been fixed.
(fill, effects, and outline)

Change-Id: I2b9300b85cf3641d89d748a03377f950e668a2af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116113
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sd/qa/unit/data/pptx/LostPlaceholderFill.odp 
b/sd/qa/unit/data/pptx/LostPlaceholderFill.odp
new file mode 100644
index ..d2ea8dab6d4a
Binary files /dev/null and b/sd/qa/unit/data/pptx/LostPlaceholderFill.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 08504c8286a6..b5222c40f913 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -115,6 +115,7 @@ public:
 void testNarrationMimeType();
 void testTdf140865Wordart3D();
 void testTdf124457();
+void testPlaceholderFillAndOutlineExport();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
@@ -172,6 +173,7 @@ public:
 CPPUNIT_TEST(testNarrationMimeType);
 CPPUNIT_TEST(testTdf140865Wordart3D);
 CPPUNIT_TEST(testTdf124457);
+CPPUNIT_TEST(testPlaceholderFillAndOutlineExport);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -442,6 +444,57 @@ void SdOOXMLExportTest1::testLostPlaceholders()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest1::testPlaceholderFillAndOutlineExport()
+{
+::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/LostPlaceholderFill.odp"),
 ODP);
+
+uno::Any aFillStyle;
+uno::Any aFillColor;
+uno::Any aLineStyle;
+uno::Any aLineColor;
+
+for (int i = 1; i <= 2; i++)
+{
+CPPUNIT_ASSERT(xDocShRef.is());
+
+auto pDoc = xDocShRef->GetDoc();
+CPPUNIT_ASSERT(pDoc);
+auto pPage = pDoc->GetPage(1);
+CPPUNIT_ASSERT(pPage);
+auto pObj = pPage->GetObj(1);
+CPPUNIT_ASSERT(pObj);
+
+uno::Reference xShp(pObj->getUnoShape(), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShp);
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ShapeType!", 
OUString(u"com.sun.star.presentation.OutlinerShape"), xShp->getShapeType());
+uno::Reference xShpProps(xShp, uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("It must be a placeholder!", true, 
xShpProps->getPropertyValue("IsPresentationObject").get());
+
+if (i == 1)
+{
+aFillStyle = xShpProps->getPropertyValue("FillStyle");
+aFillColor = xShpProps->getPropertyValue("FillColor");
+
+aLineStyle = xShpProps->getPropertyValue("LineStyle");
+aLineColor = xShpProps->getPropertyValue("LineColor");
+
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
+continue;
+}
+else
+{
+CPPUNIT_ASSERT_EQUAL_MESSAGE("The Placeholder fillstyle has not 
been exported!", aFillStyle, xShpProps->getPropertyValue("FillStyle"));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("The Placeholder fillcolor has not 
been exported!", aFillColor, xShpProps->getPropertyValue("FillColor"));
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("The Placeholder linestyle has not 
been exported!", aLineStyle, xShpProps->getPropertyValue("LineStyle"));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("The Placeholder linecolor has not 
been exported!", aLineColor, xShpProps->getPropertyValue("LineColor"));
+break;
+}
+}
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest1::testFdo71961()
 {
 ::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/fdo71961.odp"), ODP);
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 089e3bbdffa5..a1a6dd6cad5d 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1534,7 +1534,25 @@ ShapeExport& 
PowerPointShapeExport::WritePlaceholderShape(const Reference< XShap
 WritePresetShape("rect");
 Reference< XPropertySet > xProps(xShape, UNO_QUERY);
 if (xProps.is())
+{
 WriteBlipFill(xProps, "Graphic");
+// Do not forget to export the visible properties.
+WriteFill( xProps );
+WriteOutline( xProps );
+WriteShapeEffects( xProps );
+
+bool bHas3DEffectinShape = false;
+uno::Sequence grabBag;
+if 

[Libreoffice-commits] core.git: svx/source sw/inc sw/qa sw/source

2021-05-25 Thread Attila Bakos (NISZ) (via logerrit)
 svx/source/svdraw/svdpage.cxx|5 -
 sw/inc/textboxhelper.hxx |4 
 sw/qa/extras/ooxmlexport/data/testTextBoxZOrder.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx   |   31 +++
 sw/source/core/doc/textboxhelper.cxx |   70 ++--
 sw/source/core/frmedt/feshview.cxx   |   82 +++
 6 files changed, 185 insertions(+), 7 deletions(-)

New commits:
commit 0e6d963fbca16f98a3dbb6ef2fee3736a89d055b
Author: Attila Bakos (NISZ) 
AuthorDate: Fri May 7 10:18:01 2021 +0200
Commit: László Németh 
CommitDate: Tue May 25 13:06:22 2021 +0200

tdf#138141 sw: fix textbox z-order

Textboxes are implemented as loosely connected
shape-text frame pairs. Missing synchronization
of their z-orders resulted e.g invisible or
only partially visible textbox content using
Arrange options with textboxes (see in local menu
or on Drawing Object Properties toolbar).

Note: because it's not possible to send frames
to the background, Arrange->To Background hasn't
supported, so likely it's worth to remove that
option later from local menu of textboxes.

Change-Id: I1aa50903ba55dd5b9e72ef203c4e30218bee68fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115227
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index adcbb8f713f6..c1d412a7c207 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -769,7 +769,10 @@ size_t SdrObjList::GetObjCount() const
 
 SdrObject* SdrObjList::GetObj(size_t nNum) const
 {
-return maList[nNum];
+if (nNum < maList.size())
+return maList[nNum];
+
+return nullptr;
 }
 
 
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 0db804424332..1c9fdc66e703 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -107,6 +107,10 @@ public:
 /// Returns true if the given shape has a valid textframe.
 static bool isTextBoxShapeHasValidTextFrame(SwFrameFormat* pShape);
 
+// Returns true on success. Synchronize z-order of the text frame of the 
given textbox
+// by setting it one level higher than the z-order of the shape of the 
textbox.
+static bool DoTextBoxZOrderCorrection(SwFrameFormat* pShape);
+
 /**
  * If we have an associated TextFrame, then return that.
  *
diff --git a/sw/qa/extras/ooxmlexport/data/testTextBoxZOrder.docx 
b/sw/qa/extras/ooxmlexport/data/testTextBoxZOrder.docx
new file mode 100644
index ..c6dd0b8f30c8
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/testTextBoxZOrder.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 16cd111e9e54..165f104c2f57 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -338,6 +339,36 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133473_shadowSize, 
"tdf133473.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(20), nSize1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTextBoxZOrder, "testTextBoxZOrder.docx")
+{
+// Is load successful?
+CPPUNIT_ASSERT(mxComponent);
+// Collect the z-order values of the textboxes
+std::vector ShapeZorders;
+std::vector FrameZorders;
+for (int i = 1; i < 4; i++)
+{
+uno::Reference xShape(getShape(i));
+CPPUNIT_ASSERT(xShape);
+uno::Reference xShapeProperties(xShape, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShapeProperties);
+uno::Reference xFrame = 
SwTextBoxHelper::getUnoTextFrame(xShape);
+CPPUNIT_ASSERT(xFrame.is());
+uno::Reference const xFrameProperties(xFrame, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xFrameProperties);
+
ShapeZorders.push_back(xShapeProperties->getPropertyValue("ZOrder").get());
+
FrameZorders.push_back(xFrameProperties->getPropertyValue("ZOrder").get());
+}
+// Check the z-order values.
+for (int i = 1; i < 3; i++)
+{
+CPPUNIT_ASSERT_GREATER(ShapeZorders[i - 1], ShapeZorders[i]);
+CPPUNIT_ASSERT_GREATER(FrameZorders[i - 1], FrameZorders[i]);
+CPPUNIT_ASSERT_GREATER(ShapeZorders[i - 1], FrameZorders[i - 1]);
+}
+// Without the fix it failed, because the z-order was wrong.
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf141550, "tdf141550.docx")
 {
 uno::Reference xShape(getShape(1));
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index cba67e1bf74d..f901beab461c 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -38,6 +38,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -135,6 +138,7 @@ void SwTextBoxHelper::create(SwFrameFormat* 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/qa writerfilter/source

2021-05-05 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/tdf138782.docx  |binary
 sw/qa/extras/layout/layout2.cxx  |   16 
 writerfilter/source/dmapper/DomainMapper.cxx |5 +
 writerfilter/source/filter/WriterFilter.cxx  |1 -
 4 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 4e7ef3f7421febc08e621bf9ca276cec7b032808
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Apr 22 13:26:58 2021 +0200
Commit: Xisco Fauli 
CommitDate: Wed May 5 10:58:03 2021 +0200

tdf#138782 DOCX import: fix frame positions of old docs

by limiting AddFrameOffsets compatibility option
for docs created by MSO 2010 or older.

Likely regression from commit 355d25eac764713f4d52eac801ade6e2ff1deab0
(n#779627: added quite some compat options from the ww8
filter on writerfilter).

This patch fixes several bugs, which were
collected as duplicates by Gábor Kelemen.

Change-Id: I106e90c4bf00bb0b6a8986615cb3ad9c4828d5b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114476
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 5812fb81013cc124a9b6a0b9912a34cc715fc495)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115077
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

diff --git a/sw/qa/extras/layout/data/tdf138782.docx 
b/sw/qa/extras/layout/data/tdf138782.docx
new file mode 100644
index ..8bad2ae1b8c4
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138782.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index f0fb593df6a9..9894ceac418c 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -2654,6 +2654,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf137185)
 // Before the patch it failed, because the text appeared 2 times on each 
other.
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138782)
+{
+CPPUNIT_ASSERT(createDoc("tdf138782.docx"));
+auto pXml = parseLayoutDump();
+CPPUNIT_ASSERT(pXml);
+
+// Without the fix it failed because the 3rd shape was outside the page:
+// - Expected less than: 13327
+// - Actual  : 14469
+
+CPPUNIT_ASSERT_LESS(
+getXPath(pXml, "/root/page/infos/bounds", "right").toInt32(),
+getXPath(pXml, 
"/root/page/body/txt[8]/anchored/SwAnchoredDrawObject/bounds", "right")
+.toInt32());
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf135035)
 {
 createDoc("tdf135035.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 4a1481f3ea44..b2765a8c572c 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -249,6 +249,11 @@ DomainMapper::~DomainMapper()
 aGrabBag.update(aProperties);
 xDocProps->setPropertyValue("InteropGrabBag", 
uno::Any(aGrabBag.getAsConstPropertyValueList()));
 }
+
+// tdf#138782: for docs created in MS Word 2010 and older 
(compatibilityMode <= 14)
+m_pImpl->SetDocumentSettingsProperty(
+"AddFrameOffsets",
+uno::Any(14 >= 
m_pImpl->GetSettingsTable()->GetWordCompatibilityMode()));
 }
 catch( const uno::Exception& ) {}
 
diff --git a/writerfilter/source/filter/WriterFilter.cxx 
b/writerfilter/source/filter/WriterFilter.cxx
index 0f0fcdb63391..d866981dd438 100644
--- a/writerfilter/source/filter/WriterFilter.cxx
+++ b/writerfilter/source/filter/WriterFilter.cxx
@@ -304,7 +304,6 @@ void WriterFilter::setTargetDocument(const 
uno::Reference& xDo
 uno::Reference xSettings(
 xFactory->createInstance("com.sun.star.document.Settings"), 
uno::UNO_QUERY);
 
-xSettings->setPropertyValue("AddFrameOffsets", uno::makeAny(true));
 xSettings->setPropertyValue("AddVerticalFrameOffsets", uno::makeAny(true));
 xSettings->setPropertyValue("UseOldNumbering", uno::makeAny(false));
 xSettings->setPropertyValue("IgnoreFirstLineIndentInNumbering", 
uno::makeAny(false));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sw/qa writerfilter/source

2021-05-04 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/tdf138782.docx  |binary
 sw/qa/extras/layout/layout2.cxx  |   16 
 writerfilter/source/dmapper/DomainMapper.cxx |5 +
 writerfilter/source/filter/WriterFilter.cxx  |1 -
 4 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 5812fb81013cc124a9b6a0b9912a34cc715fc495
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Apr 22 13:26:58 2021 +0200
Commit: László Németh 
CommitDate: Tue May 4 19:33:39 2021 +0200

tdf#138782 DOCX import: fix frame positions of old docs

by limiting AddFrameOffsets compatibility option
for docs created by MSO 2010 or older.

Likely regression from commit 355d25eac764713f4d52eac801ade6e2ff1deab0
(n#779627: added quite some compat options from the ww8
filter on writerfilter).

This patch fixes several bugs, which were
collected as duplicates by Gábor Kelemen.

Change-Id: I106e90c4bf00bb0b6a8986615cb3ad9c4828d5b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114476
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/layout/data/tdf138782.docx 
b/sw/qa/extras/layout/data/tdf138782.docx
new file mode 100644
index ..8bad2ae1b8c4
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138782.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index c8919f155c60..074f099d963e 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -2801,6 +2801,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf137185)
 // Before the patch it failed, because the text appeared 2 times on each 
other.
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138782)
+{
+CPPUNIT_ASSERT(createDoc("tdf138782.docx"));
+auto pXml = parseLayoutDump();
+CPPUNIT_ASSERT(pXml);
+
+// Without the fix it failed because the 3rd shape was outside the page:
+// - Expected less than: 13327
+// - Actual  : 14469
+
+CPPUNIT_ASSERT_LESS(
+getXPath(pXml, "/root/page/infos/bounds", "right").toInt32(),
+getXPath(pXml, 
"/root/page/body/txt[8]/anchored/SwAnchoredDrawObject/bounds", "right")
+.toInt32());
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf135035)
 {
 createDoc("tdf135035.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index fddbea557c6c..fa6018f9e940 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -249,6 +249,11 @@ DomainMapper::~DomainMapper()
 aGrabBag.update(aProperties);
 xDocProps->setPropertyValue("InteropGrabBag", 
uno::Any(aGrabBag.getAsConstPropertyValueList()));
 }
+
+// tdf#138782: for docs created in MS Word 2010 and older 
(compatibilityMode <= 14)
+m_pImpl->SetDocumentSettingsProperty(
+"AddFrameOffsets",
+uno::Any(14 >= 
m_pImpl->GetSettingsTable()->GetWordCompatibilityMode()));
 }
 catch( const uno::Exception& ) {}
 
diff --git a/writerfilter/source/filter/WriterFilter.cxx 
b/writerfilter/source/filter/WriterFilter.cxx
index dcfdf29a60f7..772ca5032b76 100644
--- a/writerfilter/source/filter/WriterFilter.cxx
+++ b/writerfilter/source/filter/WriterFilter.cxx
@@ -304,7 +304,6 @@ void WriterFilter::setTargetDocument(const 
uno::Reference& xDo
 uno::Reference xSettings(
 xFactory->createInstance("com.sun.star.document.Settings"), 
uno::UNO_QUERY);
 
-xSettings->setPropertyValue("AddFrameOffsets", uno::makeAny(true));
 xSettings->setPropertyValue("AddVerticalFrameOffsets", uno::makeAny(true));
 xSettings->setPropertyValue("UseOldNumbering", uno::makeAny(false));
 xSettings->setPropertyValue("IgnoreFirstLineIndentInNumbering", 
uno::makeAny(false));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sd/qa sd/source

2021-04-29 Thread Attila Bakos (NISZ) (via logerrit)
 sd/qa/unit/data/pptx/LostPlaceholder.odp |binary
 sd/qa/unit/export-tests-ooxml1.cxx   |   35 ++-
 sd/source/filter/eppt/pptx-epptooxml.cxx |   17 +++
 3 files changed, 47 insertions(+), 5 deletions(-)

New commits:
commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Apr 20 13:02:44 2021 +0200
Commit: László Németh 
CommitDate: Thu Apr 29 10:48:27 2021 +0200

tdf#111903 tdf#137152 PPTX export: fix placeholders

Empty placeholders were exported as white empty
custom shapes, losing their visibility and usability.

Note: export of properties hasn't been implemented, yet.

Change-Id: Ie8bd6a611f5fb43bcaa55f6b2f5b07daf731b163
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114331
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sd/qa/unit/data/pptx/LostPlaceholder.odp 
b/sd/qa/unit/data/pptx/LostPlaceholder.odp
new file mode 100644
index ..80ead189f260
Binary files /dev/null and b/sd/qa/unit/data/pptx/LostPlaceholder.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index fded47a1c2c9..0be65e22ee13 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -69,6 +69,7 @@ public:
 void testN828390_4();
 void testN828390_5();
 void testFdo71961();
+void testLostPlaceholders();
 void testN828390();
 void testBnc880763();
 void testBnc862510_5();
@@ -122,6 +123,7 @@ public:
 CPPUNIT_TEST(testN828390_4);
 CPPUNIT_TEST(testN828390_5);
 CPPUNIT_TEST(testFdo71961);
+CPPUNIT_TEST(testLostPlaceholders);
 CPPUNIT_TEST(testN828390);
 CPPUNIT_TEST(testBnc880763);
 CPPUNIT_TEST(testBnc862510_5);
@@ -370,6 +372,37 @@ void SdOOXMLExportTest1::testN828390_5()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest1::testLostPlaceholders()
+{
+::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/LostPlaceholder.odp"),
 ODP);
+CPPUNIT_ASSERT(xDocShRef.is());
+
+xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
+CPPUNIT_ASSERT(xDocShRef.is());
+
+auto pDoc = xDocShRef->GetDoc();
+CPPUNIT_ASSERT(pDoc);
+auto pPage = pDoc->GetPage(1);
+CPPUNIT_ASSERT(pPage);
+auto pObj = pPage->GetObj(1);
+CPPUNIT_ASSERT(pObj);
+uno::Reference xShp (pObj->getUnoShape(), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShp);
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ShapeType!", 
OUString(u"com.sun.star.presentation.OutlinerShape"), xShp->getShapeType());
+uno::Reference xShpProps(xShp, uno::UNO_QUERY);
+// Without the fix in place there will be the following error:
+// Expected: com.sun.star.presentation.OutlinerShape
+// Actual: com.sun.star.drawing.CustomShape
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("It must be a placeholder!", true, 
xShpProps->getPropertyValue("IsPresentationObject").get());
+// Without the fix in place this will the following:
+// Expected: true
+// Actual: false
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest1::testFdo71961()
 {
 ::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/fdo71961.odp"), ODP);
@@ -379,7 +412,7 @@ void SdOOXMLExportTest1::testFdo71961()
 
 // Export to .pptx changes all text frames to custom shape objects, which 
obey TextWordWrap property
 // (which is false for text frames otherwise and is ignored). Check that 
frames that should wrap still do.
-SdrObjCustomShape *pTxtObj = dynamic_cast( 
pPage->GetObj( 1 ));
+auto  pTxtObj = pPage->GetObj( 1 );
 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
 CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), 
pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
 CPPUNIT_ASSERT_EQUAL( true, 
pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP).GetValue());
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index d87f51a07712..fa1a55ac6b5f 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1439,13 +1439,22 @@ ShapeExport& 
PowerPointShapeExport::WritePageShape(const Reference< XShape >& xS
 bool PowerPointShapeExport::WritePlaceholder(const Reference< XShape >& 
xShape, PlaceholderType ePlaceholder, bool bMaster)
 {
 SAL_INFO("sd.eppt", "WritePlaceholder " << bMaster << " " << 
ShapeExport::NonEmptyText(xShape));
-if (bMaster && ShapeExport::NonEmptyText(xShape))
+if (!xShape)
+return false;
+try
 {
-WritePlaceholderShape(xShape, ePlaceholder);
+Reference xShapeProps(xShape, UNO_QUERY);
+if (xShapeProps->getPropertyValue("IsPresentationObject").get())
+{
+WritePlaceholderShape(xShape, ePlaceholder);
 
-return true;
+return true;
+}
+}
+catch 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/source

2021-04-21 Thread Attila Bakos (NISZ) (via logerrit)
 sw/source/core/doc/textboxhelper.cxx |   54 +++
 1 file changed, 54 insertions(+)

New commits:
commit 09df81f33b1ed286aa8c544a32a530d1fcf53adf
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Oct 21 15:50:25 2020 +0200
Commit: Gabor Kelemen 
CommitDate: Wed Apr 21 14:32:30 2021 +0200

tdf#137798 sw: apply textbox Text alignment

set in "Text" dialog window using "Text Anchor"
in Format -> Text Box and Shape -> Text
attributes... on the selected text box.

Follow up of commit 726c911b90b9a3170fa6b3a34bb952a8d2dbe148
(tdf#137025 sw: apply textbox padding set in Text).

Change-Id: I8c575ceb1d0b0772c1f7d99dc746531b0cd7ceb4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104632
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 0b5801fc2c768d1774957c2c122c9061d3a74756)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114371
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 43e77acd9fea..2fc1c1474ff6 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -47,6 +47,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 using namespace com::sun::star;
 
@@ -164,6 +166,8 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, bool 
bCopyText)
 if (xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_WRITINGMODE) >>= 
eMode)
 syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(sal_Int16(eMode)));
 
+// TODO: Text dialog attr setting to frame
+
 const SwFormatAnchor& rAnch = pShape->GetAnchor();
 if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE && rAnch.GetPageNum() 
!= 0)
 || ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA
@@ -429,6 +433,45 @@ tools::Rectangle 
SwTextBoxHelper::getTextRectangle(SwFrameFormat* pShape, bool b
 void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, const OUString& 
rPropertyName,
const css::uno::Any& rValue)
 {
+// Textframes does not have valid horizontal adjust property, so map it to 
paragraph adjust property
+if (rPropertyName == UNO_NAME_TEXT_HORZADJUST)
+{
+SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT);
+if (!pFormat)
+return;
+
+auto xTextFrame = SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), 
pFormat);
+uno::Reference xCursor = 
xTextFrame->getText()->createTextCursor();
+
+// Select all paragraps in the textframe
+xCursor->gotoStart(false);
+xCursor->gotoEnd(true);
+uno::Reference xFrameParaProps(xCursor, 
uno::UNO_QUERY);
+
+// And simply map the property
+switch (rValue.get())
+{
+case drawing::TextHorizontalAdjust::TextHorizontalAdjust_CENTER:
+xFrameParaProps->setPropertyValue(
+UNO_NAME_PARA_ADJUST,
+
uno::makeAny(style::ParagraphAdjust::ParagraphAdjust_CENTER)); //3
+break;
+case drawing::TextHorizontalAdjust::TextHorizontalAdjust_LEFT:
+xFrameParaProps->setPropertyValue(
+UNO_NAME_PARA_ADJUST,
+
uno::makeAny(style::ParagraphAdjust::ParagraphAdjust_LEFT)); //0
+break;
+case drawing::TextHorizontalAdjust::TextHorizontalAdjust_RIGHT:
+xFrameParaProps->setPropertyValue(
+UNO_NAME_PARA_ADJUST,
+
uno::makeAny(style::ParagraphAdjust::ParagraphAdjust_RIGHT)); //1
+break;
+default:
+break;
+}
+return;
+}
+
 if (rPropertyName == "CustomShapeGeometry")
 {
 // CustomShapeGeometry changes the textbox position offset and size, 
so adjust both.
@@ -870,6 +913,7 @@ void SwTextBoxHelper::updateTextBoxMargin(SdrObject* pObj)
 if (!pParentFormat)
 return;
 
+// Sync the padding
 syncProperty(pParentFormat, UNO_NAME_TEXT_LEFTDIST,
  xPropertySet->getPropertyValue(UNO_NAME_TEXT_LEFTDIST));
 syncProperty(pParentFormat, UNO_NAME_TEXT_RIGHTDIST,
@@ -878,6 +922,16 @@ void SwTextBoxHelper::updateTextBoxMargin(SdrObject* pObj)
  xPropertySet->getPropertyValue(UNO_NAME_TEXT_UPPERDIST));
 syncProperty(pParentFormat, UNO_NAME_TEXT_LOWERDIST,
  xPropertySet->getPropertyValue(UNO_NAME_TEXT_LOWERDIST));
+
+// Sync the text aligning
+syncProperty(pParentFormat, UNO_NAME_TEXT_VERTADJUST,
+ xPropertySet->getPropertyValue(UNO_NAME_TEXT_VERTADJUST));
+syncProperty(pParentFormat, UNO_NAME_TEXT_HORZADJUST,
+ xPropertySet->getPropertyValue(UNO_NAME_TEXT_HORZADJUST));
+
+//FIXME: Sync autogrow: needs repositioning after sync
+//syncProperty(pParentFormat, 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/qa sw/source

2021-04-21 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data3/txbx_crash.odt |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx|   31 +
 sw/source/core/doc/textboxhelper.cxx   |7 +-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit f9a26bd2f5fae14ed99d8240a090b9a5aae1fcc2
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Oct 15 16:45:15 2020 +0200
Commit: Gabor Kelemen 
CommitDate: Wed Apr 21 14:11:37 2021 +0200

tdf#137802 sw: fix crash on deleting last paragraph

if the last paragraph of document had a text box
anchored to.

Change-Id: Ibe29a0f37d06223c31f3add0c194e4414f65d5ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104379
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 056933bc55608d0ca061539ae124d7b9386cdb62)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114354
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/qa/extras/uiwriter/data3/txbx_crash.odt 
b/sw/qa/extras/uiwriter/data3/txbx_crash.odt
new file mode 100755
index ..0a029da88289
Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/txbx_crash.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 245c57ebb788..60e2d5067166 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -772,6 +772,37 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107893)
 CPPUNIT_ASSERT_MESSAGE("Textbox cannot be readd after Undo!", pTxBxFrm);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, TestTextBoxCrashAfterLineDel)
+{
+// Open the desired file
+load(DATA_DIRECTORY, "txbx_crash.odt");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+
+// Get the Writer shell
+SwWrtShell* pWrtSh = pTextDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtSh);
+
+// Get the format of the shape
+const SwFrameFormats& rFrmFormats = 
*pWrtSh->GetDoc()->GetSpzFrameFormats();
+CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1)));
+SwFrameFormat* pShape = rFrmFormats.front();
+CPPUNIT_ASSERT(pShape);
+
+// Add a textbox
+SwTextBoxHelper::create(pShape);
+SwFrameFormat* pTxBxFrm = 
SwTextBoxHelper::getOtherTextBoxFormat(getShape(1));
+CPPUNIT_ASSERT(pTxBxFrm);
+
+// remove the last paragraph
+auto xCursor = getParagraph(1)->getText()->createTextCursor();
+xCursor->gotoEnd(false);
+xCursor->goLeft(3, true);
+
+// This caused crash before, now it should pass with the patch.
+xCursor->setString(OUString());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf96067)
 {
 mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 98debf9b59d4..43e77acd9fea 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -89,7 +89,12 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, bool 
bCopyText)
 }
 catch (uno::Exception&)
 {
-xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence());
+// Before the textframe was appended now it is inserted to the begin 
of the doc in order
+// to prevent crash when someone removes the para where the textframe 
anchored:
+uno::Reference xCursor = 
xTextDocument->getText()->createTextCursor();
+xCursor->gotoStart(false);
+xTextContentAppend->insertTextContentWithProperties(
+xTextFrame, uno::Sequence(), 
xCursor->getStart());
 }
 // Link FLY and DRAW formats, so it becomes a text box (needed for 
syncProperty calls).
 uno::Reference xRealTextFrame(xTextFrame, 
uno::UNO_QUERY);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/source

2021-04-20 Thread Attila Bakos (NISZ) (via logerrit)
 sw/source/uibase/shells/drwbassh.cxx |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

New commits:
commit 26b492e47bb0688b3c996698a7e1bd0c544c24c1
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Nov 3 15:05:00 2020 +0100
Commit: Gabor Kelemen 
CommitDate: Tue Apr 20 17:38:09 2021 +0200

tdf#137546 sw: fix text position at textbox alignment

Follow-up of commit 06fd06597796d9e92117602245f3968c93707708
(tdf#124430 Writer Editing: Fix textbox aligning).

Testing:

1. Insert a shape. Choose menu item "Add Text Box" of
   its local menu, and write a short text in it.

2. Choose menu item "Align->Right" of the local menu of
   the shape. The textbox is aligned to the right margin
   and before the fix, text position had changed slightly
   within the shape. (Only moving the textbox fixed it.)

Change-Id: I758e0f65c8b51e09ac15a96e19819cb3ad3beacb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105253
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 3347d71b23595919e167bd49932675e77cbbdbbb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106449
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit 7c21121f7caa8667d86fc1946ef2a337c5b15da9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114290
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/source/uibase/shells/drwbassh.cxx 
b/sw/source/uibase/shells/drwbassh.cxx
index c707b803736b..f502061d7a0d 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -443,7 +443,8 @@ void SwDrawBaseShell::Execute(SfxRequest const )
 if ( bAlignPossible )
 {
 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
-if ( rMarkList.GetMarkCount() == 1 )
+if (rMarkList.GetMarkCount() == 1
+&& 
!SwTextBoxHelper::hasTextFrame(rMarkList.GetMark(0)->GetMarkedSdrObj()))
 {
 sal_Int16 nHorizOrient = -1, nVertOrient = -1;
 
@@ -479,8 +480,6 @@ void SwDrawBaseShell::Execute(SfxRequest const )
 SwFormatHoriOrient 
aHOrient(pFrameFormat->GetFormatAttr(RES_HORI_ORIENT));
 aHOrient.SetHoriOrient( nHorizOrient );
 pFrameFormat->SetFormatAttr(aHOrient);
-if (auto pTxFrm = 
SwTextBoxHelper::getOtherTextBoxFormat(pFrameFormat, RES_DRAWFRMFMT))
-pTxFrm->SetFormatAttr(aHOrient);
 pSh->EndAction();
 }
 
@@ -492,8 +491,6 @@ void SwDrawBaseShell::Execute(SfxRequest const )
 SwFormatVertOrient 
aVOrient(pFrameFormat->GetFormatAttr(RES_VERT_ORIENT));
 aVOrient.SetVertOrient( nVertOrient );
 pFrameFormat->SetFormatAttr(aVOrient);
-if (auto pTxFrm = 
SwTextBoxHelper::getOtherTextBoxFormat(pFrameFormat, RES_DRAWFRMFMT))
-pTxFrm->SetFormatAttr(aVOrient);
 pSh->EndAction();
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/inc sw/qa sw/source

2021-04-20 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx|6 ++
 sw/qa/extras/layout/data/tdf137025.docx |binary
 sw/qa/extras/layout/layout.cxx  |   69 
 sw/source/core/doc/textboxhelper.cxx|   34 +++
 sw/source/uibase/shells/drawdlg.cxx |8 +++
 5 files changed, 117 insertions(+)

New commits:
commit f97331f691588aa42c004fe19d7874092ab45e4f
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Sep 30 11:24:14 2020 +0200
Commit: Gabor Kelemen 
CommitDate: Tue Apr 20 17:17:22 2021 +0200

tdf#137025 sw: apply textbox padding set in Text

dialog window using Spacing to Borders in
Format->Text Box and Shape->Text attributes...
on the selected text box.

There are two types of text boxes in sw, the
older editeng one, what worked fine, and
the newer one, the shape + text frame one,
where modifying Spacing to Borders had no
effect. This has been fixed by copying the
modified shape attributes to the associated
text frame.

Change-Id: I8da0b414fd4771fa86851d9a6affbd9502894ebf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103674
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 726c911b90b9a3170fa6b3a34bb952a8d2dbe148)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114352
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index e6c991d8acfa..58f5deba8485 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -79,6 +79,9 @@ public:
 /// Similar to syncProperty(), but used by the internal API (e.g. for UI 
purposes).
 static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
rSet);
 
+/// Copy shape attributes to the text frame
+static void updateTextBoxMargin(SdrObject* pObj);
+
 /**
  * If we have an associated TextFrame, then return that.
  *
@@ -105,6 +108,9 @@ public:
  */
 static bool isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType);
 
+/// Returns true if the SdrObject has a SwTextFrame otherwise false
+static bool hasTextFrame(const SdrObject* pObj);
+
 /// Count number of shapes in the document, excluding TextBoxes.
 static sal_Int32 getCount(const SwDoc* pDoc);
 /// Count number of shapes on the page, excluding TextBoxes.
diff --git a/sw/qa/extras/layout/data/tdf137025.docx 
b/sw/qa/extras/layout/data/tdf137025.docx
new file mode 100755
index ..89f33a911ebe
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf137025.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 02c754b8404c..b45474ac4245 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -44,6 +44,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -796,6 +800,71 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testRedlineFlysInHeader)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025)
+{
+// Check the padding of the textbox
+SwDoc* pDoc = createDoc("tdf137025.docx");
+CPPUNIT_ASSERT(pDoc);
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+CPPUNIT_ASSERT(pXmlDoc);
+
+// Check the layout xml
+assertXPath(pXmlDoc,
+"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
+"/DefaultProperties/SfxItemSet/SfxInt32Item[3]",
+"value", "567");
+assertXPath(pXmlDoc,
+"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
+"/DefaultProperties/SfxItemSet/SfxInt32Item[4]",
+"value", "1134");
+assertXPath(pXmlDoc,
+"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
+"/DefaultProperties/SfxItemSet/SfxInt32Item[5]",
+"value", "1701");
+assertXPath(pXmlDoc,
+"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
+"/DefaultProperties/SfxItemSet/SfxInt32Item[6]",
+"value", "2268");
+
+// Check the textbox-shape import too
+auto xShp = getShape(1);
+CPPUNIT_ASSERT(xShp);
+
+uno::Reference xShapeProps(xShp, uno::UNO_QUERY);
+
+SwFrameFormat* pFrameFormat = SwTextBoxHelper::getOtherTextBoxFormat(xShp);
+CPPUNIT_ASSERT(pFrameFormat);
+
+// The shape has these values to copy to the associated text frame after 
modification::
+const long nLPaddng = 
xShapeProps->getPropertyValue("TextLeftDistance").get();
+const long nRPaddng = 
xShapeProps->getPropertyValue("TextRightDistance").get();
+const long nTPaddng = 
xShapeProps->getPropertyValue("TextUpperDistance").get();
+const long nBPaddng = 
xShapeProps->getPropertyValue("TextLowerDistance").get();
+
+CPPUNIT_ASSERT_EQUAL(long(1000), nLPaddng);
+CPPUNIT_ASSERT_EQUAL(long(2000), nRPaddng);
+CPPUNIT_ASSERT_EQUAL(long(3000), nTPaddng);
+ 

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2021-04-19 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |   39 ++
 sw/qa/extras/ooxmlexport/data/tdf141550.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx   |   17 +
 sw/qa/extras/uiwriter/data/tdf140975.docx|binary
 sw/qa/extras/uiwriter/uiwriter3.cxx  |   30 ++
 sw/qa/uitest/data/tdf141557.docx |binary
 sw/qa/uitest/writer_tests7/tdf141557.py  |   40 ++
 sw/source/core/doc/textboxhelper.cxx |  362 +++
 sw/source/core/text/porfly.cxx   |1 
 9 files changed, 384 insertions(+), 105 deletions(-)

New commits:
commit cb965f2cf6d68c284ccbd8a9635abfdfcc0538ca
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Apr 1 17:08:58 2021 +0200
Commit: László Németh 
CommitDate: Mon Apr 19 10:44:28 2021 +0200

tdf#141550 tdf#141557 tdf#140975 sw: fix textbox crash

and regressions by refactoring SwTextBoxHelper.

tdf#141550 was a DOCX import regression from
commit ff321dd36554d25f0817903becf4598065e0a194
(tdf#140828 sw textbox: fix AS_CHAR regression),
resulting bad horizontal position of the frame of
the textbox.

tdf#141557 was a regression resulting crash
by changing text box anchoring "To Paragraph".

tdf#140975 was an implementation error, resulting
broken textbox by changing box anchoring to
"As Character".

In the SwTextBoxHelper class there were many
repeating code parts for textbox positioning.
Now these parts have been replaced with
the calls of several new functions:

1) getShapeFormat() returns with the SwFrameFormat
   of the UNO XShape;

2) setWrapThrough() only sets the surround
   of the textframe (used in the code frequently);

3) changeAnchor() sets the anchor of the textframe
   according to the anchor of the shape;

4) doTextFramePositioning() sets the position of the
   textbox according to the shape (used in the code
   frequently);

5) isAnchorTypeDifferent() shows difference of the
   anchor types of the shape and the textframe. Also it
   handles the situation of anchoring "As Character";

6) isTextBoxHasValidTextFrame() checks if the shape
   is a part of a textbox or not.

Every function returns with true on success, otherwise
gives information to the log. All of them can be called
with ShapeFormat or UNO XShape.

The goal of this to make the possibility to advance this
class for further functions – rotation, grouped
textboxes etc. – without code copying.

Change-Id: I4441cab87931f161d0ace4983646d6d2a68a7321
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113463
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 51261a8f77a3..21a1c5a97d83 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -81,9 +81,48 @@ public:
 /// Similar to syncProperty(), but used by the internal API (e.g. for UI 
purposes).
 static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
rSet);
 
+/// Returns the SwFrameFormat* of the given UNO-XShape if exists otherwise 
nullptr.
+static SwFrameFormat* 
getShapeFormat(css::uno::Reference xShape);
+
 /// Copy shape attributes to the text frame
 static void updateTextBoxMargin(SdrObject* pObj);
 
+/// Sets the surround to through for the textframe of the given shape,
+/// not to interfere with the layout. Returns true on success.
+static bool setWrapThrough(SwFrameFormat* pShape);
+
+/// Sets the surround to through for the textframe of the given shape,
+/// not to interfere with the layout. Returns true on success.
+static bool setWrapThrough(css::uno::Reference 
xShape);
+
+/// Sets the anchor of the associated textframe of the given shape, and
+/// returns true on success.
+static bool changeAnchor(SwFrameFormat* pShape);
+
+/// Sets the anchor of the associated textframe of the given shape, and
+/// returns true on success.
+static bool changeAnchor(css::uno::Reference xShape);
+
+/// Does the positioning for the associated textframe of the shape, and
+/// returns true on success.
+static bool doTextBoxPositioning(SwFrameFormat* pShape);
+
+/// Does the positioning for the associated textframe of the shape, and
+/// returns true on success.
+static bool doTextBoxPositioning(css::uno::Reference 
xShape);
+
+/// Returns true if the anchor different for the  given shape, and the
+/// associated textframe of the given shape.
+/// Note: In case of AS_CHAR anchor the anchor type must be different,
+/// because if not, layout breaks, but this situation also handled by
+/// this function, and returns true in that case too.
+static std::optional isAnchorTypeDifferent(SwFrameFormat* pShape);
+
+/// Returns true if the given shape has a valid textframe.
+

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source writerfilter/source

2021-03-31 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/pagedesc.hxx   |6 +
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|5 -
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|3 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |6 -
 sw/qa/extras/uiwriter/uiwriter.cxx|4 
 sw/qa/uitest/data/TestHiddenHeadersFooters.docx   |binary
 sw/qa/uitest/writer_tests7/tdf141158.py   |   47 ++
 sw/source/core/doc/docdesc.cxx|   30 +-
 sw/source/core/doc/docfmt.cxx |   11 ++
 sw/source/core/layout/pagedesc.cxx|   96 --
 sw/source/core/unocore/unostyle.cxx   |   32 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   24 +
 12 files changed, 247 insertions(+), 17 deletions(-)

New commits:
commit b802ab694a8a7357d4657f3e11b571144fa7c7bf
Author: Attila Bakos (NISZ) 
AuthorDate: Fri Mar 12 14:33:08 2021 +0100
Commit: László Németh 
CommitDate: Wed Mar 31 14:44:27 2021 +0200

tdf#141158 DOCX: import discarded headers/footers

Before the inactive DOCX headers/footers lost during
import time. Now it can be restored by disabling
the options “Same content on left and right pages” and
“Same content on first page” on the Header and the
Footer panes of the Page style. This is for improving
the interoperability with other Office programs, e.g.
supporting DOCX text document templates better.

Follow-up of commit f5dc6b11d2218d94c9effe7a1ab418d0133da5e3
(tdf#140117 sw UI: keep headers/footers when inactive).

To start the py-UItest run:

$ make UITest_writer_tests7 
UITEST_TEST_NAME="tdf141158.TestTdf141158.test_tdf141158"

Note: In spite of this patch implements the
left/first/first_left page header/footer stash
at import time, the left one works correctly at now.
This is because the first pages have different
page styles so changing the right page style will
restore the hidden header/footer content.
For this problem further improvements are planned,
exactly in the filter part. Number of unit tests
had to be modified, because before these headers
and footers were dropped.

Co-developed-with: Daniel Arato (NISZ)

Change-Id: I3dd452a648bc465710698707c083734dc762ed94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112580
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index 0d29eb0ca6e3..4178361349d6 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -223,6 +223,12 @@ public:
 /// Used to restore hidden header/footer formats.
 const SwFrameFormat* GetStashedFrameFormat(bool bHeader, bool bLeft, bool 
bFirst) const;
 
+/// Checks if the pagedescriptor has a stashed format according to the 
parameters or not.
+bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst);
+
+/// Gives the feature of removing the stashed format by hand if it is 
neccessarry.
+void RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst);
+
 /// Same as WriteUseOn(), but the >= HeaderShare part of the bitfield is 
not modified.
 inline void  SetUseOn( UseOnPage eNew );
 inline UseOnPage GetUseOn() const;
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index c33f99cb4322..ba6a6a6a98e2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -688,7 +688,9 @@ DECLARE_OOXMLEXPORT_TEST(testBnc875718, "bnc875718.docx")
 // is not SwXBodyText but rather SwXHeadFootText
 uno::Reference xTextFramesSupplier(mxComponent, 
uno::UNO_QUERY);
 uno::Reference 
xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
-for( int i = 0;
+// The sample bugdoc has 3 footer.xml and has a textframe in each. The 
first one is hidden
+// and it has no text in its anchored text range: it is anchored to body 
text. Ignoring...
+for( int i = 1;
  i < xIndexAccess->getCount();
  ++i )
 {
@@ -700,6 +702,7 @@ DECLARE_OOXMLEXPORT_TEST(testBnc875718, "bnc875718.docx")
 // Also check that the footer contents are not in the body text.
 uno::Reference textDocument(mxComponent, 
uno::UNO_QUERY);
 uno::Reference text = textDocument->getText();
+CPPUNIT_ASSERT(text); //Do not crash on empty content
 CPPUNIT_ASSERT_EQUAL( OUString( "Text" ), text->getString());
 }
 
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index cd3ca2f39e46..951a4d8650f2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -670,7 +670,8 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf130167_spilloverHeaderShape, "testTdf130167_spil
 uno::Reference xNameAccess(
 xTextGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY);
 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/qa sw/source

2021-03-31 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data3/tdf140828.docx |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx|   32 +
 sw/source/core/doc/textboxhelper.cxx   |5 ++--
 sw/source/core/text/porfly.cxx |4 +++
 4 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit 9e90062dfc39b023c988d7982457dea2e0d1a923
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Mar 9 16:32:27 2021 +0100
Commit: Xisco Fauli 
CommitDate: Wed Mar 31 12:06:28 2021 +0200

tdf#140828 sw textbox: fix AS_CHAR regression

Textboxes anchored as characters don't lose
their text frames after changing the anchor
"To character".

Regression from commit 493a916a3113e877835c9bc7c93faef0d29f9a33
(tdf#140158 tdf#138598 tdf#140598 sw: fix sync of AS_CHAR textboxes).

Change-Id: I0e6d88c9dcdeff515744bc4c201a5640eb810d1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112209
Tested-by: László Németh 
Reviewed-by: László Németh 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113321
Tested-by: Jenkins
Reviewed-by: Attila Bakos 

diff --git a/sw/qa/extras/uiwriter/data3/tdf140828.docx 
b/sw/qa/extras/uiwriter/data3/tdf140828.docx
new file mode 100755
index ..bfdabc5d77ea
Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf140828.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index a2b8c8bc1c38..e0623c817a91 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -854,6 +855,37 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf76636_2)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getColumns()->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf140828)
+{
+load(DATA_DIRECTORY, "tdf140828.docx");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+uno::Reference xShp = getShape(1);
+CPPUNIT_ASSERT(xShp);
+
+uno::Reference ShpProps(xShp, uno::UNO_QUERY_THROW);
+dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {});
+Scheduler::ProcessEventsToIdle();
+
+dispatchCommand(mxComponent, ".uno:SetAnchorAtChar", {});
+Scheduler::ProcessEventsToIdle();
+
+
CPPUNIT_ASSERT(ShpProps->getPropertyValue("AnchorType").get()
+   != 
text::TextContentAnchorType::TextContentAnchorType_AS_CHARACTER);
+
+uno::Reference 
xTxBx(SwTextBoxHelper::getUnoTextFrame(xShp));
+CPPUNIT_ASSERT(xTxBx);
+
+uno::Reference TxBxProps(xTxBx, uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(OUString("top left image"), 
xTxBx->getText()->getString());
+
+CPPUNIT_ASSERT_MESSAGE("Bad Relative Orientation and Position!",
+   
TxBxProps->getPropertyValue("HoriOrientRelation").get()
+   != text::RelOrientation::CHAR);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132725)
 {
 load(DATA_DIRECTORY, "tdf132725.odt");
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 5257d448bd55..6b9f87655d8d 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -165,8 +165,6 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, bool 
bCopyText)
 if (xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_WRITINGMODE) >>= 
eMode)
 syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(sal_Int16(eMode)));
 
-// TODO: Text dialog attr setting to frame
-
 const SwFormatAnchor& rAnch = pShape->GetAnchor();
 if (!((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE && rAnch.GetPageNum() 
!= 0)
   || ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA
@@ -723,6 +721,9 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, 
sal_uInt16 nWID, sal_u
 }
 else // Otherwise copy the anchor type of the shape
 {
+// tdf#140828: Do not keep CHAR rel-orientation:
+
xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION,
+   
uno::Any(text::RelOrientation::FRAME));
 xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_TYPE, 
aValue);
 }
 // After anchoring the position must be set as well:
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index cafa70c48227..9426359156f1 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -351,9 +351,11 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, 
const Point ,
 // Both rectangles are absolute, SwFormatHori/VertOrient's position
 // is relative to the print area of the anchor text 

[Libreoffice-commits] core.git: sw/qa sw/source

2021-03-29 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data3/tdf140828.docx |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx|   32 +
 sw/source/core/doc/textboxhelper.cxx   |5 ++--
 sw/source/core/text/porfly.cxx |4 +++
 4 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit ff321dd36554d25f0817903becf4598065e0a194
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Mar 9 16:32:27 2021 +0100
Commit: László Németh 
CommitDate: Mon Mar 29 11:33:52 2021 +0200

tdf#140828 sw textbox: fix AS_CHAR regression

Textboxes anchored as characters don't lose
their text frames after changing the anchor
"To character".

Regression from commit 493a916a3113e877835c9bc7c93faef0d29f9a33
(tdf#140158 tdf#138598 tdf#140598 sw: fix sync of AS_CHAR textboxes).

Change-Id: I0e6d88c9dcdeff515744bc4c201a5640eb810d1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112209
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/data3/tdf140828.docx 
b/sw/qa/extras/uiwriter/data3/tdf140828.docx
new file mode 100755
index ..bfdabc5d77ea
Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf140828.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 63a322af868e..cf14ac853264 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1089,6 +1090,37 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf76636_2)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getColumns()->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf140828)
+{
+load(DATA_DIRECTORY, "tdf140828.docx");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+uno::Reference xShp = getShape(1);
+CPPUNIT_ASSERT(xShp);
+
+uno::Reference ShpProps(xShp, uno::UNO_QUERY_THROW);
+dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {});
+Scheduler::ProcessEventsToIdle();
+
+dispatchCommand(mxComponent, ".uno:SetAnchorAtChar", {});
+Scheduler::ProcessEventsToIdle();
+
+
CPPUNIT_ASSERT(ShpProps->getPropertyValue("AnchorType").get()
+   != 
text::TextContentAnchorType::TextContentAnchorType_AS_CHARACTER);
+
+uno::Reference 
xTxBx(SwTextBoxHelper::getUnoTextFrame(xShp));
+CPPUNIT_ASSERT(xTxBx);
+
+uno::Reference TxBxProps(xTxBx, uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(OUString("top left image"), 
xTxBx->getText()->getString());
+
+CPPUNIT_ASSERT_MESSAGE("Bad Relative Orientation and Position!",
+   
TxBxProps->getPropertyValue("HoriOrientRelation").get()
+   != text::RelOrientation::CHAR);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132725)
 {
 load(DATA_DIRECTORY, "tdf132725.odt");
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 9bcd522e4277..08fccb737b6c 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -165,8 +165,6 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, bool 
bCopyText)
 if (xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_WRITINGMODE) >>= 
eMode)
 syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(sal_Int16(eMode)));
 
-// TODO: Text dialog attr setting to frame
-
 // Check if the shape had text before and move it to the new textframe
 if (!bCopyText || sCopyableText.isEmpty())
 return;
@@ -747,6 +745,9 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, 
sal_uInt16 nWID, sal_u
 }
 else // Otherwise copy the anchor type of the shape
 {
+// tdf#140828: Do not keep CHAR rel-orientation:
+
xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION,
+   
uno::Any(text::RelOrientation::FRAME));
 xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_TYPE, 
aValue);
 }
 // After anchoring the position must be set as well:
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index e41afd83d7cb..cb071be3c512 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -351,9 +351,11 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, 
const Point ,
 // Both rectangles are absolute, SwFormatHori/VertOrient's position
 // is relative to the print area of the anchor text frame.
 tools::Rectangle aTextRectangle = 
SwTextBoxHelper::getTextRectangle(pShape);
+tools::Long nXoffs  = SwTextBoxHelper::getTextRectangle(pShape, 
false).getX();
 
 const 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/inc sw/qa sw/source

2021-03-02 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx|5 
 sw/qa/extras/uiwriter/data3/AsCharTxBxTest.docx |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx |   52 +
 sw/source/core/doc/textboxhelper.cxx|  137 ++--
 sw/source/core/text/porfly.cxx  |   32 +++--
 5 files changed, 204 insertions(+), 22 deletions(-)

New commits:
commit 6edeb6a8209a990e83f07c02753d606226f59be7
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Feb 22 14:28:59 2021 +0100
Commit: Xisco Fauli 
CommitDate: Tue Mar 2 12:14:28 2021 +0100

tdf#140158 tdf#138598 tdf#140598 sw: fix sync of AS_CHAR textboxes

Textboxes anchored "As Character" fell apart, when
typing before some characters or inserting a page break.

By fixing that, the tdf#138598 bug also have fixed which
was a regression from commit b6850bbe95418ecfde404be1696548f18d200c9b
(tdf#106153 sw compatibility: fix textboxes exceeding the page).

In addition, tdf140598 is also fixed, which was
a regression from commit c96c386c5db45dc4d5e358915caad7474e373068
(tdf#136516 add positioning to SwTextBoxHelper::syncProperty()).

Change-Id: Ifeadd8b2055ce52a019d651369ca41185de7bbe3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111338
Tested-by: László Németh 
Reviewed-by: László Németh 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111796
Tested-by: Jenkins

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 45d8a6c56f5d..2043b1ffcfb3 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -16,6 +16,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 #include "swdllapi.h"
 
@@ -71,6 +73,9 @@ public:
 static void getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID, 
sal_uInt8 nMemberID,
 css::uno::Any& rValue);
 
+/// There are two types of enum of anchor type, so this function maps this.
+static css::text::TextContentAnchorType mapAnchorType(const RndStdIds& 
rAnchorID);
+
 /// Similar to syncProperty(), but used by the internal API (e.g. for UI 
purposes).
 static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
rSet);
 
diff --git a/sw/qa/extras/uiwriter/data3/AsCharTxBxTest.docx 
b/sw/qa/extras/uiwriter/data3/AsCharTxBxTest.docx
new file mode 100755
index ..7603b80d2c2d
Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/AsCharTxBxTest.docx 
differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index e568e695000a..018a96a78ee6 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -725,6 +725,58 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134253)
 CPPUNIT_ASSERT_EQUAL(6, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, TestAsCharTextBox)
+{
+// Releated tickets:
+// tdf#138598 Replace vertical alignment of As_char textboxes in footer
+// tdf#140158 Remove horizontal positioning of As_char textboxes, because
+// the anchor moving does the same for it.
+
+load(DATA_DIRECTORY, "AsCharTxBxTest.docx");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+
+// Add 3x tab to the doc
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+Scheduler::ProcessEventsToIdle();
+
+auto pExportDump = parseLayoutDump();
+CPPUNIT_ASSERT(pExportDump);
+
+// Check if the texbox fallen apart due to the tabs
+const double nLeftSideOfShape1
+= getXPath(pExportDump, 
"/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "left")
+  .toDouble();
+const double nLeftSideOfTxBx1
+= getXPath(pExportDump, 
"/root/page/body/txt/anchored/fly/infos/bounds", "left").toDouble();
+
+CPPUNIT_ASSERT(nLeftSideOfShape1 < nLeftSideOfTxBx1);
+
+// Another test is for the tdf#138598: Check footer textbox
+const double nLeftSideOfShape2
+= getXPath(pExportDump, 
"/root/page[2]/footer/txt/anchored/SwAnchoredDrawObject/bounds",
+   "left")
+  .toDouble();
+const double nLeftSideOfTxBx2
+= getXPath(pExportDump, 
"/root/page[2]/footer/txt/anchored/fly/infos/bounds", "left")
+  .toDouble();
+
+CPPUNIT_ASSERT(nLeftSideOfShape2 < nLeftSideOfTxBx2);
+
+const double nTopSideOfShape2
+= getXPath(pExportDump, 
"/root/page[2]/footer/txt/anchored/SwAnchoredDrawObject/bounds",
+   "top")
+  .toDouble();
+const double nTopSideOfTxBx2
+= getXPath(pExportDump, 
"/root/page[2]/footer/txt/anchored/fly/infos/bounds", "top")
+  .toDouble();
+
+CPPUNIT_ASSERT(nTopSideOfShape2 < nTopSideOfTxBx2);
+// Without the fix in place the two texboxes 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/source

2021-03-02 Thread Attila Bakos (NISZ) (via logerrit)
 sw/source/core/frmedt/fecopy.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 35d74bf25163178b3bebefe08cddc06de56cd641
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Nov 25 14:06:49 2020 +0100
Commit: Gabor Kelemen 
CommitDate: Tue Mar 2 09:54:07 2021 +0100

tdf#135044 sw: fix Ctrl + drag textbox copy

Text content was missing in the new textbox
after Ctrl + drag and drop copying of a text box
with text content.

Change-Id: Ib93096df0028ee0e02c73804c1518aec4490b57f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106585
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 64819ab91555b5afe360cf25aba6431546c4d905)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111777
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 67027a4c5b9e..4272996d822c 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -404,6 +404,11 @@ bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const 
Point& rSttPt,
 
static_cast(pFormat)->PosAttrSet();
 }
 }
+if (SwTextBoxHelper::getOtherTextBoxFormat(pFormat, 
RES_DRAWFRMFMT))
+{
+SwTextBoxHelper::syncFlyFrameAttr(*pFormat, 
pFormat->GetAttrSet());
+}
+
 if( bSelectInsert )
 pDestDrwView->MarkObj( pNew, pDestPgView );
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sw/qa sw/source

2021-03-01 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data3/AsCharTxBxTest.docx |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx |   52 ++
 sw/source/core/doc/textboxhelper.cxx|   89 +++-
 sw/source/core/text/porfly.cxx  |   32 +---
 4 files changed, 144 insertions(+), 29 deletions(-)

New commits:
commit 493a916a3113e877835c9bc7c93faef0d29f9a33
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Feb 22 14:28:59 2021 +0100
Commit: László Németh 
CommitDate: Mon Mar 1 16:04:05 2021 +0100

tdf#140158 tdf#138598 tdf#140598 sw: fix sync of AS_CHAR textboxes

Textboxes anchored "As Character" fell apart, when
typing before some characters or inserting a page break.

By fixing that, the tdf#138598 bug also have fixed which
was a regression from commit b6850bbe95418ecfde404be1696548f18d200c9b
(tdf#106153 sw compatibility: fix textboxes exceeding the page).

In addition, tdf140598 is also fixed, which was
a regression from commit c96c386c5db45dc4d5e358915caad7474e373068
(tdf#136516 add positioning to SwTextBoxHelper::syncProperty()).

Change-Id: Ifeadd8b2055ce52a019d651369ca41185de7bbe3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111338
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/data3/AsCharTxBxTest.docx 
b/sw/qa/extras/uiwriter/data3/AsCharTxBxTest.docx
new file mode 100755
index ..7603b80d2c2d
Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/AsCharTxBxTest.docx 
differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 7bb002b03ae9..6ee8609b5a24 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -960,6 +960,58 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134253)
 CPPUNIT_ASSERT_EQUAL(6, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, TestAsCharTextBox)
+{
+// Releated tickets:
+// tdf#138598 Replace vertical alignment of As_char textboxes in footer
+// tdf#140158 Remove horizontal positioning of As_char textboxes, because
+// the anchor moving does the same for it.
+
+load(DATA_DIRECTORY, "AsCharTxBxTest.docx");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+
+// Add 3x tab to the doc
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+Scheduler::ProcessEventsToIdle();
+
+auto pExportDump = parseLayoutDump();
+CPPUNIT_ASSERT(pExportDump);
+
+// Check if the texbox fallen apart due to the tabs
+const double nLeftSideOfShape1
+= getXPath(pExportDump, 
"/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "left")
+  .toDouble();
+const double nLeftSideOfTxBx1
+= getXPath(pExportDump, 
"/root/page/body/txt/anchored/fly/infos/bounds", "left").toDouble();
+
+CPPUNIT_ASSERT(nLeftSideOfShape1 < nLeftSideOfTxBx1);
+
+// Another test is for the tdf#138598: Check footer textbox
+const double nLeftSideOfShape2
+= getXPath(pExportDump, 
"/root/page[2]/footer/txt/anchored/SwAnchoredDrawObject/bounds",
+   "left")
+  .toDouble();
+const double nLeftSideOfTxBx2
+= getXPath(pExportDump, 
"/root/page[2]/footer/txt/anchored/fly/infos/bounds", "left")
+  .toDouble();
+
+CPPUNIT_ASSERT(nLeftSideOfShape2 < nLeftSideOfTxBx2);
+
+const double nTopSideOfShape2
+= getXPath(pExportDump, 
"/root/page[2]/footer/txt/anchored/SwAnchoredDrawObject/bounds",
+   "top")
+  .toDouble();
+const double nTopSideOfTxBx2
+= getXPath(pExportDump, 
"/root/page[2]/footer/txt/anchored/fly/infos/bounds", "top")
+  .toDouble();
+
+CPPUNIT_ASSERT(nTopSideOfShape2 < nTopSideOfTxBx2);
+// Without the fix in place the two texboxes has been fallen apart, and  
asserts will broken.
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf76636)
 {
 load(DATA_DIRECTORY, "tdf76636.doc");
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 37b612034d44..abe8f38d2124 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -711,10 +711,39 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, 
sal_uInt16 nWID, sal_u
 if (aValue.get()
 == 
text::TextContentAnchorType::TextContentAnchorType_AS_CHARACTER)
 {
-xPropertySet->setPropertyValue(
-UNO_NAME_ANCHOR_TYPE,
-uno::makeAny(
-
text::TextContentAnchorType::TextContentAnchorType_AT_PARAGRAPH));
+if (const auto aPos = 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - oox/source sw/qa writerfilter/source

2021-03-01 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/vml/vmlshape.cxx   |2 -
 sw/qa/extras/layout/data/tdf138465min.docx|binary
 sw/qa/extras/layout/layout2.cxx   |   16 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   29 ++
 4 files changed, 36 insertions(+), 11 deletions(-)

New commits:
commit 2b20826a6a5d06a9e47c90918375a40465567716
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Feb 18 13:42:00 2021 +0100
Commit: Xisco Fauli 
CommitDate: Mon Mar 1 12:58:04 2021 +0100

tdf#136570 OOXML import: fix height of OLE objects

e.g. OLE icons or math formulas by skipping unset
border properties.

Regression from 636d16efe45a55c1a5a7a451c46fbb8618bf0393
(tdf#135653 OOXML import: fix OLE background color).

Change-Id: I64bd68037d063de81fbb302b90d65b77af50a622
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/19
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit ca7855c24af858f52a11a593761ee9e6b9d6ba79)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111581
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 7ee10203341e..5bceff932a24 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1454,7 +1454,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( 
const Reference< XShapes
 oox::drawingml::ShapePropertyMap 
aPropMap(mrDrawing.getFilter().getModelObjectHelper());
 const GraphicHelper& rGraphicHelper = 
mrDrawing.getFilter().getGraphicHelper();
 maTypeModel.maStrokeModel.pushToPropMap(aPropMap, rGraphicHelper);
-//And, fill-color properties as well...
+// And, fill-color properties as well...
 maTypeModel.maFillModel.pushToPropMap(aPropMap, rGraphicHelper);
 PropertySet(xShape).setProperties(aPropMap);
 
diff --git a/sw/qa/extras/layout/data/tdf138465min.docx 
b/sw/qa/extras/layout/data/tdf138465min.docx
new file mode 100755
index ..d576a54f281f
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138465min.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 46ce68a04572..ff07375bfabb 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -488,6 +488,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf126425)
 assertXPath(pXmlDoc, "//textarray", 14);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testUnusedOLEprops)
+{
+CPPUNIT_ASSERT(createDoc("tdf138465min.docx"));
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+CPPUNIT_ASSERT(pXmlDoc);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: >300
+// - Actual  : 142
+// i.e. the formula squashed
+CPPUNIT_ASSERT_GREATEREQUAL(
+double(300),
+getXPath(pXmlDoc, 
"/root/page/body/txt[2]/anchored/fly/notxt/infos/bounds", "height")
+.toDouble());
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf123268)
 {
 SwDoc* pDoc = createDoc("tdf123268.odt");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 2d79c618b8a1..ee7cf88dfbc8 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2303,11 +2303,13 @@ void DomainMapper_Impl::appendOLE( const OUString& 
rStreamName, const std::share
 xReplacementProperties->getPropertyValue("LineWidth") >>= 
aBorderProps.LineWidth;
 xReplacementProperties->getPropertyValue("LineStyle") >>= 
aBorderProps.LineStyle;
 
-xOLEProperties->setPropertyValue("RightBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("TopBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("LeftBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("BottomBorder", 
uno::Any(aBorderProps));
-
+if (aBorderProps.LineStyle) // Set line props only if LineStyle is 
set
+{
+xOLEProperties->setPropertyValue("RightBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("TopBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("LeftBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("BottomBorder", 
uno::Any(aBorderProps));
+}
 OUString pProperties[] = {
 "AnchorType",
 "Surround",
@@ -2321,17 +2323,24 @@ void DomainMapper_Impl::appendOLE( const OUString& 
rStreamName, const std::share
 "LeftMargin",
 "RightMargin",
 "TopMargin",
-"BottomMargin",
-"FillStyle",
-"FillColor",
-"FillColor2",
-"LineStyle",
+   

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/inc sw/qa sw/source

2021-03-01 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx   |5 ++-
 sw/qa/extras/layout/data/tdf137185.odt |binary
 sw/qa/extras/layout/layout.cxx |   43 +
 sw/source/core/doc/textboxhelper.cxx   |   36 ++-
 sw/source/uibase/shells/drawsh.cxx |2 -
 5 files changed, 82 insertions(+), 4 deletions(-)

New commits:
commit 07b856e94b6e6af25394f2b18adf7ad33ebc7256
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Oct 28 15:11:08 2020 +0100
Commit: Gabor Kelemen 
CommitDate: Mon Mar 1 12:36:21 2021 +0100

tdf#137185 sw: move shape text on adding textbox

The original text of the shape is moved to the new
(text frame of the) text box instead of overlapping
the text content added later.

Change-Id: I2ad8865cdbe3c424c70985737ecda3ac9315cabc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104942
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit ae8bc80952fafc791ce8bbddd99c99626a93989c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111700
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 746a5e90b356..e6c991d8acfa 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -58,8 +58,9 @@ public:
 using SavedLink = std::map;
 /// Maps a draw format to content.
 using SavedContent = std::map;
-/// Create a TextBox for a shape.
-static void create(SwFrameFormat* pShape);
+/// Create a TextBox for a shape. If the second parameter is true,
+/// the original text in the shape will be copied to the frame
+static void create(SwFrameFormat* pShape, bool bCopyText = false);
 /// Destroy a TextBox for a shape.
 static void destroy(SwFrameFormat* pShape);
 /// Get interface of a shape's TextBox, if there is any.
diff --git a/sw/qa/extras/layout/data/tdf137185.odt 
b/sw/qa/extras/layout/data/tdf137185.odt
new file mode 100755
index ..65d1f5de672d
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf137185.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 11bdd07c9771..c41681b93f36 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -35,6 +35,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -4464,6 +4470,43 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf135035)
 CPPUNIT_ASSERT_GREATER(nParentWidth, nFly3Width);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf137185)
+{
+// First load the sample bugdoc
+load(DATA_DIRECTORY, "tdf137185.odt");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+// Get the doc shell
+SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
+
+// Get the DrawObject from page
+auto pModel = pDoc->getIDocumentDrawModelAccess().GetDrawModel();
+CPPUNIT_ASSERT(pModel);
+auto pPage = pModel->GetPage(0);
+CPPUNIT_ASSERT(pModel);
+auto pObj = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObj);
+
+// Get the format of the draw object
+auto pShape = FindFrameFormat(pObj);
+CPPUNIT_ASSERT(pShape);
+
+// Check the text of the shape
+uno::Reference xTxt(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("Align me!"), xTxt->getText()->getString());
+
+// Add a textbox to the shape
+SwTextBoxHelper::create(pShape, true);
+
+// Check if the text moved from the shape to the frame
+auto pFormat = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1));
+auto xTextFrame = SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), 
pFormat);
+
+CPPUNIT_ASSERT_EQUAL(OUString("Align me!"), 
xTextFrame->getText()->getString());
+CPPUNIT_ASSERT_EQUAL(OUString(), xTxt->getText()->getString());
+// Before the patch it failled, because the text appeared 2 times on each 
other.
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 69b369e2525c..c900255a1a7e 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -49,12 +50,27 @@
 
 using namespace com::sun::star;
 
-void SwTextBoxHelper::create(SwFrameFormat* pShape)
+void SwTextBoxHelper::create(SwFrameFormat* pShape, bool bCopyText)
 {
 // If TextBox wasn't enabled previously
 if (pShape->GetAttrSet().HasItem(RES_CNTNT) && 
pShape->GetOtherTextBoxFormat())
 return;
 
+// Store the current text conent of the shape
+OUString sCopyableText;
+
+if (bCopyText)
+{
+if (auto pSdrShape = pShape->FindRealSdrObject())
+{
+uno::Reference xSrcCnt(pSdrShape->getWeakUnoShape(), 
uno::UNO_QUERY);

[Libreoffice-commits] core.git: oox/source sw/qa writerfilter/source

2021-02-25 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/vml/vmlshape.cxx   |2 -
 sw/qa/extras/layout/data/tdf138465min.docx|binary
 sw/qa/extras/layout/layout2.cxx   |   16 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   29 ++
 4 files changed, 36 insertions(+), 11 deletions(-)

New commits:
commit ca7855c24af858f52a11a593761ee9e6b9d6ba79
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Feb 18 13:42:00 2021 +0100
Commit: László Németh 
CommitDate: Thu Feb 25 16:23:50 2021 +0100

tdf#136570 OOXML import: fix height of OLE objects

e.g. OLE icons or math formulas by skipping unset
border properties.

Regression from 636d16efe45a55c1a5a7a451c46fbb8618bf0393
(tdf#135653 OOXML import: fix OLE background color).

Change-Id: I64bd68037d063de81fbb302b90d65b77af50a622
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/19
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index b6caaa0f3214..2d4e99c7be3f 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1457,7 +1457,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( 
const Reference< XShapes
 oox::drawingml::ShapePropertyMap 
aPropMap(mrDrawing.getFilter().getModelObjectHelper());
 const GraphicHelper& rGraphicHelper = 
mrDrawing.getFilter().getGraphicHelper();
 maTypeModel.maStrokeModel.pushToPropMap(aPropMap, rGraphicHelper);
-//And, fill-color properties as well...
+// And, fill-color properties as well...
 maTypeModel.maFillModel.pushToPropMap(aPropMap, rGraphicHelper);
 PropertySet(xShape).setProperties(aPropMap);
 
diff --git a/sw/qa/extras/layout/data/tdf138465min.docx 
b/sw/qa/extras/layout/data/tdf138465min.docx
new file mode 100755
index ..d576a54f281f
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138465min.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index de6c48d56783..0b3f23d48bc7 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -518,6 +518,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf126425)
 assertXPath(pXmlDoc, "//textarray", 14);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testUnusedOLEprops)
+{
+CPPUNIT_ASSERT(createDoc("tdf138465min.docx"));
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+CPPUNIT_ASSERT(pXmlDoc);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: >300
+// - Actual  : 142
+// i.e. the formula squashed
+CPPUNIT_ASSERT_GREATEREQUAL(
+double(300),
+getXPath(pXmlDoc, 
"/root/page/body/txt[2]/anchored/fly/notxt/infos/bounds", "height")
+.toDouble());
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf123268)
 {
 SwDoc* pDoc = createDoc("tdf123268.odt");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8ace7179ad18..c102d7bcc565 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2321,11 +2321,13 @@ void DomainMapper_Impl::appendOLE( const OUString& 
rStreamName, const std::share
 xReplacementProperties->getPropertyValue("LineWidth") >>= 
aBorderProps.LineWidth;
 xReplacementProperties->getPropertyValue("LineStyle") >>= 
aBorderProps.LineStyle;
 
-xOLEProperties->setPropertyValue("RightBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("TopBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("LeftBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("BottomBorder", 
uno::Any(aBorderProps));
-
+if (aBorderProps.LineStyle) // Set line props only if LineStyle is 
set
+{
+xOLEProperties->setPropertyValue("RightBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("TopBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("LeftBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("BottomBorder", 
uno::Any(aBorderProps));
+}
 OUString pProperties[] = {
 "AnchorType",
 "Surround",
@@ -2339,17 +2341,24 @@ void DomainMapper_Impl::appendOLE( const OUString& 
rStreamName, const std::share
 "LeftMargin",
 "RightMargin",
 "TopMargin",
-"BottomMargin",
-"FillStyle",
-"FillColor",
-"FillColor2",
-"LineStyle",
+"BottomMargin"
 };
 for (const OUString& s : pProperties)
 {
 const uno::Any aVal = 

[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/qa sw/source

2021-02-23 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/uiwriter/data3/tdf107893.odt |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx   |   34 +-
 sw/source/core/doc/textboxhelper.cxx  |2 -
 3 files changed, 34 insertions(+), 2 deletions(-)

New commits:
commit 989d8fe502bc100580a4f0c32c4a46b14fd2
Author: Attila Bakos (NISZ) 
AuthorDate: Mon Sep 28 11:47:20 2020 +0200
Commit: Gabor Kelemen 
CommitDate: Tue Feb 23 15:48:28 2021 +0100

tdf#107893 sw: fix broken "Add Text Box" after Undo

Adding text frame to a shape by "Add Text Box"
menu item of its local menu and undoing the text
frame by Undo resulted inoperative "Add Text Box",
i.e. it was not possible to readd the text frame.

Change-Id: Id871cecf9682cec040e9db7a0a3a68262c505833
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103541
Tested-by: Jenkins
Reviewed-by: László Németh 
(cherry picked from commit e2a2165f27d2e5f9b6ac2d349e8b588921667ba4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111331
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/qa/extras/uiwriter/data3/tdf107893.odt 
b/sw/qa/extras/uiwriter/data3/tdf107893.odt
new file mode 100755
index ..9c24eccfa367
Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf107893.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index da425a13e071..4391bccc8ff0 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -696,7 +696,39 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130805)
 CPPUNIT_ASSERT(pShpAnch);
 
 CPPUNIT_ASSERT_EQUAL_MESSAGE("The textbox got apart!", pTxAnch->nNode, 
pShpAnch->nNode);
-//CPPUNIT_ASSERT_EQUAL_MESSAGE("", xShp->getPosition().Y, 
xShp2->getPosition().Y);
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107893)
+{
+//Open the sample doc
+load(DATA_DIRECTORY, "tdf107893.odt");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+
+//Get the Writer shell
+SwWrtShell* pWrtSh = pTextDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtSh);
+
+//Get the format of the shape
+const SwFrameFormats& rFrmFormats = 
*pWrtSh->GetDoc()->GetSpzFrameFormats();
+CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1)));
+SwFrameFormat* pShape = rFrmFormats.front();
+CPPUNIT_ASSERT(pShape);
+
+//Add a textbox
+SwTextBoxHelper::create(pShape);
+SwFrameFormat* pTxBxFrm = 
SwTextBoxHelper::getOtherTextBoxFormat(getShape(1));
+CPPUNIT_ASSERT(pTxBxFrm);
+
+//Remove the textbox using Undo
+dispatchCommand(mxComponent, ".uno:Undo", {});
+
+//Add again
+SwTextBoxHelper::create(pShape);
+pTxBxFrm = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1));
+
+//This was nullptr because of unsuccessful re-adding
+CPPUNIT_ASSERT_MESSAGE("Textbox cannot be readd after Undo!", pTxBxFrm);
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf96067)
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index d00d039647d4..69b369e2525c 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -52,7 +52,7 @@ using namespace com::sun::star;
 void SwTextBoxHelper::create(SwFrameFormat* pShape)
 {
 // If TextBox wasn't enabled previously
-if (pShape->GetAttrSet().HasItem(RES_CNTNT))
+if (pShape->GetAttrSet().HasItem(RES_CNTNT) && 
pShape->GetOtherTextBoxFormat())
 return;
 
 // Create the associated TextFrame and insert it into the document.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sw/qa sw/source

2021-02-04 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/uitest/data/tdf138512.odt |binary
 sw/qa/uitest/writer_tests7/tdf138512.py |   56 
 sw/source/uibase/shells/drwbassh.cxx|   38 +
 3 files changed, 86 insertions(+), 8 deletions(-)

New commits:
commit 54302a574a98d6fc071472f1fa64adaf70864a26
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Jan 20 10:52:26 2021 +0100
Commit: László Németh 
CommitDate: Thu Feb 4 13:45:13 2021 +0100

tdf#138512 sw: fix crash on textbox alignment

Regression from 3347d71b23595919e167bd49932675e77cbbdbbb
(sw: fix text position at textbox alignment) has been
fixed by this commit. Hopefully there won't not be newer
regressions.

Please note the crash only occur on GTK vcl backend so,
the py-test only with that case will show the problem.
In the other case there were no crash.

Change-Id: I3280547a6195e240e5b33e0d0931fb60d4d19fff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109669
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/uitest/data/tdf138512.odt b/sw/qa/uitest/data/tdf138512.odt
new file mode 100755
index ..e72fb8eb37d5
Binary files /dev/null and b/sw/qa/uitest/data/tdf138512.odt differ
diff --git a/sw/qa/uitest/writer_tests7/tdf138512.py 
b/sw/qa/uitest/writer_tests7/tdf138512.py
new file mode 100755
index ..5b0191051d85
--- /dev/null
+++ b/sw/qa/uitest/writer_tests7/tdf138512.py
@@ -0,0 +1,56 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from com.sun.star.text.TextContentAnchorType import  AS_CHARACTER
+import org.libreoffice.unotest
+import pathlib
+import time
+
+
+def get_url_for_data_file(file_name):
+return 
pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+class tdf138512(UITestCase):
+
+def test_tdf138512(self):
+
+# Open the bugdoc
+self.ui_test.load_file(get_url_for_data_file("tdf138512.odt"))
+
+xWriterDoc = self.xUITest.getTopFocusWindow()
+xWriterEdit = xWriterDoc.getChild("writer_edit")
+document = self.ui_test.get_component()
+
+# Check that the anchortype is as_char
+self.assertEqual( AS_CHARACTER, 
document.DrawPage.getByIndex(0).AnchorType)
+
+# Select the textbox
+self.xUITest.executeCommand(".uno:JumpToNextFrame")
+self.xUITest.executeCommand(".uno:JumpToNextFrame")
+
+# Align the shape to bottom
+time.sleep(1)
+self.xUITest.executeCommand(".uno:AlignDown")
+time.sleep(1)
+
+# Align the shape up
+self.xUITest.executeCommand(".uno:AlignUp")
+time.sleep(1)
+
+# Deselect the shape
+xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ESC"}))
+
+# Without the fix this will crash at this point with gtk vcl backend
+time.sleep(1)
+self.assertEqual( AS_CHARACTER, 
document.DrawPage.getByIndex(0).AnchorType)
+
+self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/uibase/shells/drwbassh.cxx 
b/sw/source/uibase/shells/drwbassh.cxx
index f901f32cc15d..b73dccb6036d 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -443,8 +443,7 @@ void SwDrawBaseShell::Execute(SfxRequest const )
 if ( bAlignPossible )
 {
 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
-if (rMarkList.GetMarkCount() == 1
-&& 
!SwTextBoxHelper::hasTextFrame(rMarkList.GetMark(0)->GetMarkedSdrObj()))
+if (rMarkList.GetMarkCount() == 1)
 {
 sal_Int16 nHorizOrient = -1, nVertOrient = -1;
 
@@ -472,13 +471,16 @@ void SwDrawBaseShell::Execute(SfxRequest const )
 break;
 }
 
+SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+SwFrameFormat* pFrameFormat = FindFrameFormat(pObj);
+SwFrameFormat* pTextBox
+= SwTextBoxHelper::getOtherTextBoxFormat(pFrameFormat, 
RES_DRAWFRMFMT);
+
 if (nHorizOrient != -1)
 {
 pSh->StartAction();
-SdrObject* pObj = 
rMarkList.GetMark(0)->GetMarkedSdrObj();
-SwFrameFormat* pFrameFormat = FindFrameFormat( pObj );
 SwFormatHoriOrient 

[Libreoffice-commits] core.git: sw/qa sw/source

2021-02-04 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf136059.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx  |7 ++
 sw/source/filter/ww8/docxsdrexport.cxx  |   74 
 3 files changed, 81 insertions(+)

New commits:
commit ec33be1d135c1523b4d872eb2f86c515f0419509
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Jan 7 11:31:39 2021 +0100
Commit: László Németh 
CommitDate: Thu Feb 4 13:26:04 2021 +0100

tdf#136059 OOXML export: fix shape wrap "Contour"

Custom shapes lost their contour setting, e.g. the
text was wrapped around the bounding box of a diamond
instead of the shape.

Change-Id: Ic1e276b8957751aad95cc2624e9f54dcb853ddad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108930
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf136059.odt 
b/sw/qa/extras/ooxmlexport/data/tdf136059.odt
new file mode 100755
index ..50d808d12f2f
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf136059.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index c35db2c88cd1..37610a23f43f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -31,6 +31,13 @@ protected:
 }
 };
 
+DECLARE_OOXMLEXPORT_TEST(testTdf136059, "tdf136059.odt")
+{
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Contour has not been exported!", true,
+getProperty(getShape(1), "SurroundContour"));
+// With the fix this shall pass, see tdf136059.
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf138892_noNumbering, 
"tdf138892_noNumbering.docx")
 {
 CPPUNIT_ASSERT_MESSAGE("Para1: Bullet point", 
!getProperty(getParagraph(1), "NumberingStyleName").isEmpty());
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index 1af1dce13942..297ecf30a2f6 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -10,6 +10,7 @@
 #include "docxsdrexport.hxx"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -34,6 +35,8 @@
 #include 
 #include 
 
+#include 
+
 using namespace com::sun::star;
 using namespace oox;
 
@@ -792,6 +795,77 @@ void DocxSdrExport::startDMLAnchorInline(const 
SwFrameFormat* pFrameFormat, cons
 m_pImpl->getSerializer()->endElementNS(XML_wp, nWrapToken);
 }
 }
+else
+{
+// In this case we likely had an odt document to be exported to 
docx.
+// There is no grab-bag or something else so for a workaround,
+// let's export the geometry of the shape...
+// First get the UNO-shape
+uno::Reference xShape(
+
const_cast(pFrameFormat->FindRealSdrObject())->getUnoShape(),
+uno::UNO_QUERY);
+
+if (xShape && xShape->getShapeType() == 
u"com.sun.star.drawing.CustomShape")
+{
+try
+{
+// Get the properties of the Xshape
+uno::Reference XProps(xShape, 
uno::UNO_QUERY);
+// Get the "CustomShapeGeometry" property and from its 
Any() make a hashMap
+comphelper::SequenceAsHashMap aCustomShapeGeometry(
+XProps->getPropertyValue("CustomShapeGeometry"));
+// Get the "Path" property and from its Any() make a 
hashMap
+comphelper::SequenceAsHashMap 
aPath(aCustomShapeGeometry.getValue("Path"));
+// From the Any() of the "Coordinates" property get the 
points
+
uno::Sequence aCoords
+= aPath.getValue("Coordinates")
+  
.get>();
+
+// Check if only one side wrap allowed
+OUString sWrapType;
+switch (pFrameFormat->GetSurround().GetSurround())
+{
+case text::WrapTextMode_DYNAMIC:
+sWrapType = OUString("largest");
+break;
+case text::WrapTextMode_LEFT:
+sWrapType = OUString("left");
+break;
+case text::WrapTextMode_RIGHT:
+sWrapType = OUString("right");
+break;
+case text::WrapTextMode_PARALLEL:
+default:
+sWrapType = OUString("bothSides");
+break;
+}
+
+// And export:
+nWrapToken = XML_wrapTight;
+m_pImpl->getSerializer()->startElementNS(XML_wp, 
nWrapToken, XML_wrapText,
+ sWrapType);
+
+

[Libreoffice-commits] core.git: sw/qa sw/source

2021-02-04 Thread Attila Bakos (NISZ) (via logerrit)
 sw/qa/extras/layout/data/tdf138951.odt|binary
 sw/qa/extras/layout/layout2.cxx   |   32 ++
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |   15 --
 sw/source/core/doc/textboxhelper.cxx  |   28 ++
 4 files changed, 73 insertions(+), 2 deletions(-)

New commits:
commit c96c386c5db45dc4d5e358915caad7474e373068
Author: Attila Bakos (NISZ) 
AuthorDate: Fri Jan 15 14:45:29 2021 +0100
Commit: László Németh 
CommitDate: Thu Feb 4 12:56:11 2021 +0100

tdf#136516 add positioning to SwTextBoxHelper::syncProperty()

Before when the shape of the textbox moved, the anchor
and the position synched. However if the new position
of the shape required new anchor position, that was not
handled. In addition after positioning and new anchor
position the sync is necessary again, because anchor
moving can change the calculated position values and
that can change the anchor etc...

The OOXMLImport test modification was necessary because
a test failed during Jenkins tests however there was
no difference between the test document before and after the
fix. In addition I can not reproduce the fail of the test
in my local repository, and only the Linux- and Windows
builds showed the problem.

Solved also tdf#138951, tdf#139686 and tdf#139092.

Change-Id: Ibdfff89db01d75aeae74948e2ea41ce5a613b6fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109365
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/layout/data/tdf138951.odt 
b/sw/qa/extras/layout/data/tdf138951.odt
new file mode 100755
index ..5cb4940bd5fe
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138951.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 253783a9e146..b84a2c51d5e5 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -26,6 +26,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -283,6 +284,37 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testRedlineShowHideFootnotePagination)
 "zzz. zzz  7 zzz zzz zzz zzz  zz 
 ");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testtdf138951)
+{
+// Open the bugdoc
+auto pDoc = createDoc("tdf138951.odt");
+
+// Get the only shape
+uno::Reference xShape(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShape);
+
+// Gather its formats: the shape and textbox
+const SwFrameFormat* pTxFrm = 
SwTextBoxHelper::getOtherTextBoxFormat(xShape);
+CPPUNIT_ASSERT(pTxFrm);
+const SwFrameFormat* pShFrm = 
SwTextBoxHelper::getOtherTextBoxFormat(pTxFrm, RES_FLYFRMFMT);
+CPPUNIT_ASSERT(pShFrm);
+
+pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
+
+// Get the bound rectangle of the textframe
+tools::Rectangle aTxtFrmRect(pTxFrm->FindRealSdrObject()->GetLogicRect());
+
+// Get the bound rectangle of the shape
+tools::Rectangle aShpRect(pShFrm->FindRealSdrObject()->GetLogicRect());
+
+// Check the anchor the same and the textbox is inside the shape
+const bool bIsAnchTheSame
+= *pShFrm->GetAnchor().GetContentAnchor() == 
*pShFrm->GetAnchor().GetContentAnchor();
+CPPUNIT_ASSERT_MESSAGE("The anchor is different for the textbox and 
shape!", bIsAnchTheSame);
+CPPUNIT_ASSERT_MESSAGE("The textbox has fallen apart!", 
aShpRect.IsInside(aTxtFrmRect));
+// Without the fix the anchor differs, and the frame ouside of the shape
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInNumbering)
 {
 SwDoc* pDoc = createDoc("tdf42748.fodt");
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index f7114235cc77..474cfbe2b13d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -28,6 +28,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 class Test : public SwModelTestBase
 {
@@ -398,8 +400,17 @@ DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
 {
 // the position of the flying text frame should be off page
 // 30624 below its anchor
-OUString aTop = parseDump("//fly[1]/infos/bounds", "top");
-CPPUNIT_ASSERT_EQUAL(OUString("30624"), aTop);
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+SwRootFrame* pRootFrame = 
pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+const SwRect aPageRect = pRootFrame->getFrameArea();
+const SwRect aShapeRect(getShape(1)->getPosition().X, 
getShape(1)->getPosition().Y,
+getShape(1)->getSize().Width, 
getShape(1)->getSize().Height);
+CPPUNIT_ASSERT_MESSAGE("The textframe must be 

[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

2021-01-26 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx |2 +
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |3 -
 sw/qa/uitest/data/tdf137803.odt  |binary
 sw/qa/uitest/writer_tests7/tdf137803.py  |   61 +++
 sw/source/core/doc/textboxhelper.cxx |   30 +--
 sw/source/core/layout/flycnt.cxx |   27 +
 6 files changed, 118 insertions(+), 5 deletions(-)

New commits:
commit 26bd8f5a1d39801f69232c22673cb0da7c76d3d5
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Dec 10 10:36:12 2020 +0100
Commit: László Németh 
CommitDate: Tue Jan 26 13:59:48 2021 +0100

tdf#137803 sw: fix AutoSize and Wrap of textboxes

When autosize (AutoGrowHeight) turned on
the textbox fell apart. After changing the text
of the textbox the positions still were different
for the shape and the textframe.

Now this fix solves, if the text changes,
the positions (with the size what worked only
before) synchronized so the textboxes are kept together.

Also Wrap text inside the shape now works like
the editeng text did, except in the case of empty
text boxes.

Note: this fixes only editing (without positioning
the textboxes by the mouse before or after the setting),
but not import/export, yet.

The ooxmlimport test has been restored to its original
state, because the fix for the tdf#135198 is fixed
by this commit.

To start the unit test just give the following command:

$ (cd sw && make UITest_writer_tests7 
UITEST_TEST_NAME="tdf137803.tdf137803.test_tdf137803" SAL_USE_VCLPLUGIN=gen)

Change-Id: Ie13a7a1e81e4099cd8540edd7e008118e58134bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107515
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 0c20711b109c..51261a8f77a3 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -72,6 +72,8 @@ public:
 /// Get a property of the underlying TextFrame.
 static void getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID, 
sal_uInt8 nMemberID,
 css::uno::Any& rValue);
+/// Get a property of the underlying TextFrame.
+static css::uno::Any getProperty(SwFrameFormat const* pShape, OUString 
sPropName);
 
 /// There are two types of enum of anchor type, so this function maps this.
 static css::text::TextContentAnchorType mapAnchorType(const RndStdIds& 
rAnchorID);
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 3d185a72afb9..cf9781f00606 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1067,8 +1067,7 @@ DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, 
"textbox-wps-only.docx")
 if ( nsScreen.frame.size.width * scaleFactor > 4000 )
 return;
 #endif
-// Vertically oriented to page due to tdf#135198
-CPPUNIT_ASSERT_EQUAL(sal_Int32(5304), getProperty(xFrame, 
"VertOrientPosition"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2805), getProperty(xFrame, 
"VertOrientPosition"));
 }
 
 DECLARE_OOXMLIMPORT_TEST(testGroupshapeRelsize, "groupshape-relsize.docx")
diff --git a/sw/qa/uitest/data/tdf137803.odt b/sw/qa/uitest/data/tdf137803.odt
new file mode 100644
index ..8f2f7d5dc49b
Binary files /dev/null and b/sw/qa/uitest/data/tdf137803.odt differ
diff --git a/sw/qa/uitest/writer_tests7/tdf137803.py 
b/sw/qa/uitest/writer_tests7/tdf137803.py
new file mode 100644
index ..249dbbb7cacc
--- /dev/null
+++ b/sw/qa/uitest/writer_tests7/tdf137803.py
@@ -0,0 +1,61 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict
+import importlib
+import time
+import org.libreoffice.unotest
+import pathlib
+
+def get_url_for_data_file(file_name):
+return 
pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+class tdf137803(UITestCase):
+def test_tdf137803(self):
+# load the sample file
+self.ui_test.load_file(get_url_for_data_file("tdf137803.odt"))
+xWriterDoc = self.xUITest.getTopFocusWindow()
+xWriterEdit = xWriterDoc.getChild("writer_edit")
+document = self.ui_test.get_component()
+
+# select the shape
+self.xUITest.executeCommand(".uno:JumpToNextFrame")
+self.ui_test.wait_until_child_is_available(xWriterEdit, 'metricfield')
+
+# open textattrs dialog
+self.ui_test.execute_dialog_through_command(".uno:TextAttributes")
+TextDialog = self.xUITest.getTopFocusWindow();
+
+

  1   2   >