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

2023-07-14 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/ooxmlimport/data/tdf154319-ToC_with_s_and_d.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |2 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   37 --
 3 files changed, 32 insertions(+), 7 deletions(-)

New commits:
commit 2093a4b0b42f33ac9b00de5bf8357e2b3ec470ca
Author: Mike Kaganski 
AuthorDate: Mon Jul 10 21:16:32 2023 +0300
Commit: Xisco Fauli 
CommitDate: Fri Jul 14 11:24:14 2023 +0200

tdf#156130: Use default tab stop when TOC*N style doesn't define one

When TOC*N style only defines one tab stop, it's used by Word as the
page number position, and the tab between chapter number and chapter
name is set to a default position. When the style has no tab stops,
they are both defaulted.

testTdf154319 is updated to test this.

Change-Id: I561995a8e96882e1f17ee9982e3fc640e621cda2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154281
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit b915dd9e1559870045481403806dd073f4fb5818)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154260
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf154319-ToC_with_s_and_d.docx 
b/sw/qa/extras/ooxmlimport/data/tdf154319-ToC_with_s_and_d.docx
index dc5a67824c9d..91a9d0b8adea 100644
Binary files a/sw/qa/extras/ooxmlimport/data/tdf154319-ToC_with_s_and_d.docx 
and b/sw/qa/extras/ooxmlimport/data/tdf154319-ToC_with_s_and_d.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index ca1aeafccc5e..304346b09250 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -1047,7 +1047,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf154319)
 // tdf#154360: check tab stops between the number and the entry text
 // The last (10th) level does not correspont to any MS level (only 9 
levels there)
 constexpr sal_Int32 levelTabStops[]
-= { 776, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, -1 };
+= { 776, 1552, 2328, 3104, 3881, 4657, 5433, 6209, 6985, -1 };
 
 //start with level 1, 0 is the header level
 for (sal_Int32 nLevel = 1; nLevel < xLevelFormats->getCount(); ++nLevel)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 4b8c36521f7e..4d3dd4e1568b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -6068,7 +6068,7 @@ void DomainMapper_Impl::handleAuthor
 }
 
 static uno::Sequence< beans::PropertyValues > lcl_createTOXLevelHyperlinks( 
bool bHyperlinks, const OUString& sChapterNoSeparator,
-   const uno::Sequence< beans::PropertyValues 
>& aLevel, const uno::Sequence& tabs)
+   const uno::Sequence< beans::PropertyValues 
>& aLevel, const std::optional numtab)
 {
 //create a copy of the level and add new entries
 
@@ -6107,12 +6107,12 @@ static uno::Sequence< beans::PropertyValues > 
lcl_createTOXLevelHyperlinks( bool
 
 aNewLevel.push_back(item);
 
-if (tabs.hasElements() && tokenType == tokENum)
+if (numtab && tokenType == tokENum)
 {
 // There is a fixed tab stop position needed in the level after 
the numbering
 aNewLevel.push_back(
 { comphelper::makePropertyValue(tokType, 
OUString("TokenTabStop")),
-  comphelper::makePropertyValue("TabStopPosition", 
tabs[0].Position) });
+  comphelper::makePropertyValue("TabStopPosition", 
numtab->Position) });
 }
 }
 
@@ -6494,7 +6494,7 @@ void DomainMapper_Impl::handleToc
 xLevelFormats->getByIndex( nLevel ) >>= aLevel;
 
 // Get the tab stops coming from the styles; store to the level 
definitions
-uno::Sequence tabStops;
+std::optional numTab;
 if (xChapterNumberingRules && xStyles)
 {
 // This relies on the chapter numbering rules already defined
@@ -6519,13 +6519,38 @@ void DomainMapper_Impl::handleToc
 xTOC->getPropertyValue("ParaStyleLevel" + 
OUString::number(nLevel)) >>= style;
 uno::Reference xStyle;
 if (xStyles->getByName(style) >>= xStyle)
-xStyle->getPropertyValue("ParaTabStops") >>= tabStops;
+{
+if (uno::Reference xPropState{ 
xStyle,
+  
uno::UNO_QUERY })
+{
+if (xPropState->getPropertyState("ParaTabStops")
+== beans::PropertyState_DIRECT_VALUE)
+{
+if (uno::Sequence tabStops;
+  

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

2023-07-09 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153804.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|   17 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |2 +-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |2 +-
 4 files changed, 19 insertions(+), 2 deletions(-)

New commits:
commit 1e9e2ff5316a6d934205f1c01a57f80ef4e8657d
Author: László Németh 
AuthorDate: Thu Jul 6 17:31:20 2023 +0200
Commit: László Németh 
CommitDate: Sun Jul 9 21:42:04 2023 +0200

tdf#153804 DOCX import: fix lost footnotes in case of comments

Incomplete handling of m_bIsFootnote had a conflict with
XNote stream COMMENTS (i.e. not FOOTNOTES and ENDNOTES)
since commit 96a856f87f16cca2e039c973c18d57c8b9dca362
in DomainMapper::lcl_checkId(), resulting lost (order or
content) of footnotes, when were comments in the document.

Regression from commit 96a856f87f16cca2e039c973c18d57c8b9dca362
"tdf#152206 DOCX import: fix mixed first footnote".

Change-Id: I8d6901e8db1e183b959fecd350d6a263e79b5591
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154147
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 6d153fa9f5277b7324885e18b0a63e1af830b6c5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154186
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153804.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153804.docx
new file mode 100644
index ..65a1fdfa8e17
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153804.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index c6949b14e6bc..458235ca26aa 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1342,6 +1342,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153255)
 CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg4."), 
xFootnote4->getString().trim() );
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf153804)
+{
+loadAndSave("tdf153804.docx");
+xmlDocUniquePtr pXml = parseExport("word/footnotes.xml");
+CPPUNIT_ASSERT(pXml);
+
+uno::Reference xFootnotesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xFootnotes = 
xFootnotesSupplier->getFootnotes();
+uno::Reference xLastFootnote(xFootnotes->getByIndex(1), 
uno::UNO_QUERY);
+// This was empty
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg 6"), 
xLastFootnote->getString().trim() );
+
+uno::Reference xLastButOne(xFootnotes->getByIndex(0), 
uno::UNO_QUERY);
+// This was empty
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg5"), 
xLastButOne->getString().trim() );
+}
+
 // skip test for macOS (missing fonts?)
 #if !defined(MACOSX)
 DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 05f39d264e67..4b8c36521f7e 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3852,7 +3852,7 @@ void DomainMapper_Impl::PopFootOrEndnote()
 }
 m_aRedlines.pop();
 m_eSkipFootnoteState = SkipFootnoteSeparator::OFF;
-m_bInFootOrEndnote = false;
+m_bInFootOrEndnote = m_bInFootnote = false;
 m_pFootnoteContext = nullptr;
 m_bFirstParagraphInCell = m_bSaveFirstParagraphInCell;
 }
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 168f3bfb8b08..fab303cf3e3e 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -872,7 +872,7 @@ public:
 void PushFootOrEndnote( bool bIsFootnote );
 void PopFootOrEndnote();
 bool IsInFootOrEndnote() const { return m_bInFootOrEndnote; }
-bool IsInFootnote() const { return m_bInFootnote; }
+bool IsInFootnote() const { return IsInFootOrEndnote() && m_bInFootnote; }
 
 void StartCustomFootnote(const PropertyMapPtr pContext);
 void EndCustomFootnote();


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

2023-06-15 Thread Michael Stahl (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf155690.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx|   47 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |6 ++
 3 files changed, 53 insertions(+)

New commits:
commit 7f9f6fdd6f74d0b9c824a8a0c0384addb5c2ffe6
Author: Michael Stahl 
AuthorDate: Wed Jun 14 15:35:24 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 15 08:59:19 2023 +0200

tdf#155690 writerfilter: fix import of bookmark in table...

... at start of section.

(regression from commit 2e8aad6d45c53d554ccaf26de998ede708cfc289)

Change-Id: I1e0e720758b607b69645b29c46f4092264289f9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153053
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 142aa77265361492e74707b08c5bcd366e7205ad)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153072
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf155690.docx 
b/sw/qa/extras/ooxmlexport/data/tdf155690.docx
new file mode 100644
index ..1839862688ee
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf155690.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index f42b5e7f9a28..a5176b5d32e6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -58,6 +58,53 @@ DECLARE_OOXMLEXPORT_TEST(testTdf126994_lostPageBreak, 
"tdf126994_lostPageBreak.d
 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 3, getPages() );
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf155690, "tdf155690.docx")
+{
+uno::Reference xBookmarksSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xBookmarks = 
xBookmarksSupplier->getBookmarks();
+{
+uno::Reference 
xMark(xBookmarks->getByName("row1_1"), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xMark.is());
+// the problem was that the start was after the H
+CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), 
xMark->getAnchor()->getString());
+}
+{
+uno::Reference 
xMark(xBookmarks->getByName("row1_2"), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xMark.is());
+CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), 
xMark->getAnchor()->getString());
+}
+{
+uno::Reference 
xMark(xBookmarks->getByName("row1_3"), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xMark.is());
+CPPUNIT_ASSERT_EQUAL(OUString("ello world"), 
xMark->getAnchor()->getString());
+}
+{
+uno::Reference 
xMark(xBookmarks->getByName("row1_4"), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xMark.is());
+CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), 
xMark->getAnchor()->getString());
+}
+{
+uno::Reference 
xMark(xBookmarks->getByName("row2_1"), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xMark.is());
+CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), 
xMark->getAnchor()->getString());
+}
+{
+uno::Reference 
xMark(xBookmarks->getByName("row2_1"), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xMark.is());
+CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), 
xMark->getAnchor()->getString());
+}
+{
+uno::Reference 
xMark(xBookmarks->getByName("row2_3"), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xMark.is());
+CPPUNIT_ASSERT_EQUAL(OUString("ello world"), 
xMark->getAnchor()->getString());
+}
+{
+uno::Reference 
xMark(xBookmarks->getByName("row2_4"), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xMark.is());
+CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), 
xMark->getAnchor()->getString());
+}
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf121374_sectionHF)
 {
 loadAndReload("tdf121374_sectionHF.odt");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6616407836de..7fb017154135 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -8102,6 +8102,9 @@ void DomainMapper_Impl::StartOrEndBookmark( const 
OUString& rId )
 else
 {
 xCursor = xText->createTextCursorByRange( 
aBookmarkIter->second.m_xTextRange );
+}
+if (!aBookmarkIter->second.m_bIsStartOfText)
+{
 xCursor->goRight( 1, false );
 }
 
@@ -8243,6 +8246,9 @@ void 
DomainMapper_Impl::startOrEndPermissionRange(sal_Int32 permissinId)
 else
 {
 xCursor = 
xText->createTextCursorByRange(aPermIter->second.m_xTextRange);
+}
+if (!aPermIter->second.m_bIsStartOfText)
+{
 xCursor->goRight(1, false);
 }
 


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

2023-04-28 Thread Czeber László Ádám (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf131722.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   56 +++
 writerfilter/source/dmapper/SdtHelper.cxx|5 +-
 3 files changed, 59 insertions(+), 2 deletions(-)

New commits:
commit 855a14d4ca43b517884046eec7e7c75f44a9e975
Author: Czeber László Ádám 
AuthorDate: Thu Apr 27 09:48:50 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Apr 28 17:48:49 2023 +0200

tdf#131722 DOCX import: fix lost first character in date selector

Fix another date selector control bug, date picker first character
goes out of the control. The first character of the date separator
in the first row of the table is out of control. The fix takes into
account the placement of the dummy paragraph in the first row of
the table, which caused the date separator to be corrupted.

Thanks to Gabor Kelemen for pointing out this error to me.

Follow-up to commit e898f95bfab16ddd9b04e516293cb6eb7e0a3847
"tdf#138093 DOCX import: fix broken date selector control in table".

Change-Id: I91d272b786a3d3dc047334c2a4a039f987c94ce0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151087
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/+/151164
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf131722.docx 
b/sw/qa/extras/ooxmlexport/data/tdf131722.docx
new file mode 100644
index ..8b72ad4b86a7
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf131722.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 2f412a7d85f1..9bde0369e108 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -1202,6 +1202,62 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf148273_sectionBulletFormatLeak, "tdf148273_secti
 CPPUNIT_ASSERT_EQUAL(false, aValue.hasValue());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf131722, "tdf131722.docx")
+{
+if (isExported())
+{
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+assertXPath(pXmlDoc, "//w:sdt", 4);
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+uno::Reference xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+uno::Reference xCell = xTable->getCellByName("A1");
+uno::Reference xParagraphsAccess(xCell, 
uno::UNO_QUERY);
+uno::Reference xParagraphs
+= xParagraphsAccess->createEnumeration();
+uno::Reference 
xParagraph(xParagraphs->nextElement(),
+ 
uno::UNO_QUERY);
+uno::Reference xPortions = 
xParagraph->createEnumeration();
+uno::Reference 
xTextPortion(xPortions->nextElement(), uno::UNO_QUERY);
+
+OUString aPortionType;
+xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType;
+CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType);
+
+uno::Reference xContentControl;
+xTextPortion->getPropertyValue("ContentControl") >>= xContentControl;
+uno::Reference 
xContentControlProps(xContentControl, uno::UNO_QUERY);
+bool bDate{};
+xContentControlProps->getPropertyValue("Date") >>= bDate;
+CPPUNIT_ASSERT(bDate);
+uno::Reference 
xContentControlEnumAccess(xContentControl,
+   
 uno::UNO_QUERY);
+uno::Reference xContentControlEnum
+= xContentControlEnumAccess->createEnumeration();
+uno::Reference 
xTextPortionRange(xContentControlEnum->nextElement(),
+   uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("Enter a date here!"), 
xTextPortionRange->getString());
+}
+else
+{
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+
+for (auto aIter = pMarkAccess->getFieldmarksBegin();
+ aIter != pMarkAccess->getFieldmarksEnd(); ++aIter)
+{
+::sw::mark::IDateFieldmark* pFieldmark
+= dynamic_cast<::sw::mark::IDateFieldmark*>(*aIter);
+CPPUNIT_ASSERT(pFieldmark);
+CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), 
pFieldmark->GetFieldname());
+CPPUNIT_ASSERT_EQUAL(OUString("Enter a date here!"), 
pFieldmark->GetContent());
+}
+}
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf149089, "tdf149089.docx")
 {
 uno::Reference xPageStyles = 
getStyles("PageStyles");
diff --git 

[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: Branch 'libreoffice-7-5' - sw/qa writerfilter/source

2023-04-08 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/ooxmlimport/data/tdf154695-ToC_no_numbers.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx   |   80 ++--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx   |   37 -
 3 files changed, 98 insertions(+), 19 deletions(-)

New commits:
commit 8914765ec9330d250e220b1ef51f7c62b82b8e2f
Author: Mike Kaganski 
AuthorDate: Sat Apr 8 00:03:31 2023 +0300
Commit: Adolfo Jayme Barrientos 
CommitDate: Sat Apr 8 23:18:53 2023 +0200

tdf#154695: use Chapter Numbering Rules to confirm that ToC needs tabs

Indeed, this still can't handle it per-element, like Word does: the latter
would omit both the number and the tab for headings without numbering. But
at least the most common case should be handled better now.

Change-Id: I0be5d61a5d2cbbf778ee88a11129a6e7655593ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150133
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit b6a5f16a9bf3227867bf46b88d012440138b6f24)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150142
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf154695-ToC_no_numbers.docx 
b/sw/qa/extras/ooxmlimport/data/tdf154695-ToC_no_numbers.docx
new file mode 100644
index ..fb86250fd415
Binary files /dev/null and 
b/sw/qa/extras/ooxmlimport/data/tdf154695-ToC_no_numbers.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 532ad030b28d..37f1a48ca834 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -1045,8 +1045,9 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf154319)
 };
 
 // tdf#154360: check tab stops between the number and the entry text
+// The last (10th) level does not correspont to any MS level (only 9 
levels there)
 constexpr sal_Int32 levelTabStops[]
-= { 776, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270 };
+= { 776, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, -1 };
 
 //start with level 1, 0 is the header level
 for (sal_Int32 nLevel = 1; nLevel < xLevelFormats->getCount(); ++nLevel)
@@ -1054,27 +1055,80 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf154319)
 css::uno::Sequence aLevel;
 xLevelFormats->getByIndex(nLevel) >>= aLevel;
 
-CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aLevel.getLength());
+sal_Int32 nTabStop = levelTabStops[nLevel - 1];
+sal_Int32 nExpectedTokens = nTabStop < 0 ? 8 : 9;
+CPPUNIT_ASSERT_EQUAL(nExpectedTokens, aLevel.getLength());
+sal_Int32 nIndex = 0;
 
-checkPropVal(OUString("TokenHyperlinkStart"), aLevel[0], "TokenType", 
nLevel);
+checkPropVal(OUString("TokenHyperlinkStart"), aLevel[nIndex++], 
"TokenType", nLevel);
 
-checkPropVal(OUString("TokenEntryNumber"), aLevel[1], "TokenType", 
nLevel);
+checkPropVal(OUString("TokenEntryNumber"), aLevel[nIndex++], 
"TokenType", nLevel);
+
+if (nTabStop >= 0)
+{
+checkPropVal(OUString("TokenTabStop"), aLevel[nIndex], 
"TokenType", nLevel);
+checkPropVal(levelTabStops[nLevel - 1], aLevel[nIndex++], 
"TabStopPosition", nLevel);
+}
+
+checkPropVal(OUString("TokenEntryText"), aLevel[nIndex++], 
"TokenType", nLevel);
+
+checkPropVal(OUString("TokenTabStop"), aLevel[nIndex++], "TokenType", 
nLevel);
+
+checkPropVal(OUString("TokenChapterInfo"), aLevel[nIndex++], 
"TokenType", nLevel);
+
+checkPropVal(OUString("TokenText"), aLevel[nIndex], "TokenType", 
nLevel);
+checkPropVal(OUString("\""), aLevel[nIndex++], "Text", nLevel);
+
+checkPropVal(OUString("TokenPageNumber"), aLevel[nIndex++], 
"TokenType", nLevel);
+
+checkPropVal(OUString("TokenHyperlinkEnd"), aLevel[nIndex++], 
"TokenType", nLevel);
+}
+}
 
-checkPropVal(OUString("TokenTabStop"), aLevel[2], "TokenType", nLevel);
-checkPropVal(levelTabStops[nLevel - 1], aLevel[2], "TabStopPosition", 
nLevel);
+CPPUNIT_TEST_FIXTURE(Test, testTdf154695)
+{
+createSwDoc("tdf154695-ToC_no_numbers.docx");
 
-checkPropVal(OUString("TokenEntryText"), aLevel[3], "TokenType", 
nLevel);
+css::uno::Reference 
xSupplier(mxComponent,
+   
css::uno::UNO_QUERY_THROW);
+auto xIndexes = xSupplier->getDocumentIndexes();
+css::uno::Reference 
xTOCIndex(xIndexes->getByIndex(0),
+
css::uno::UNO_QUERY_THROW);
+css::uno::Reference xLevelFormats;
+CPPUNIT_ASSERT(xTOCIndex->getPropertyValue("LevelFormat") >>= 
xLevelFormats);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(11), xLevelFormats->getCount());
+
+const auto checkPropVal = [](const auto& expected, const 
css::beans::PropertyValues& entry,
+ const OUString& name, sal_Int32 level) {
+  

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

2023-04-04 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |   31 +---
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   76 ++
 2 files changed, 69 insertions(+), 38 deletions(-)

New commits:
commit 364051901c555d9609ea5f9e9427f3098a2f0bab
Author: Mike Kaganski 
AuthorDate: Fri Mar 24 11:01:56 2023 +0300
Commit: Miklos Vajna 
CommitDate: Tue Apr 4 10:55:58 2023 +0200

tdf#154360: use TOC(N) styles in DOCX as the source of ToC tab stop position

Change-Id: Iab8001f8be8a8af437e8898079d55ff57dd6fa3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149494
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149548
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 406812ab7fa5..04d23a4c1bc0 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -1035,39 +1035,46 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf154319)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(11), xLevelFormats->getCount());
 
 const auto checkPropVal = [](const auto& expected, const 
css::beans::PropertyValues& entry,
- const OUString& name) {
+ const OUString& name, sal_Int32 level) {
 auto it
 = std::find_if(entry.begin(), entry.end(),
[](const css::beans::PropertyValue& p) { 
return p.Name == name; });
-OString msg = "Property: " + name.toUtf8();
+OString msg = "Property: " + name.toUtf8() + ", level: " + 
OString::number(level);
 CPPUNIT_ASSERT_MESSAGE(msg.getStr(), it != entry.end());
 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), css::uno::Any(expected), 
it->Value);
 };
 
+// tdf#154360: check tab stops between the number and the entry text
+constexpr sal_Int32 levelTabStops[]
+= { 776, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270 };
+
 //start with level 1, 0 is the header level
 for (sal_Int32 nLevel = 1; nLevel < xLevelFormats->getCount(); ++nLevel)
 {
 css::uno::Sequence aLevel;
 xLevelFormats->getByIndex(nLevel) >>= aLevel;
 
-CPPUNIT_ASSERT_EQUAL(sal_Int32(8), aLevel.getLength());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aLevel.getLength());
+
+checkPropVal(OUString("TokenHyperlinkStart"), aLevel[0], "TokenType", 
nLevel);
 
-checkPropVal(OUString("TokenHyperlinkStart"), aLevel[0], "TokenType");
+checkPropVal(OUString("TokenEntryNumber"), aLevel[1], "TokenType", 
nLevel);
 
-checkPropVal(OUString("TokenEntryNumber"), aLevel[1], "TokenType");
+checkPropVal(OUString("TokenTabStop"), aLevel[2], "TokenType", nLevel);
+checkPropVal(levelTabStops[nLevel - 1], aLevel[2], "TabStopPosition", 
nLevel);
 
-checkPropVal(OUString("TokenEntryText"), aLevel[2], "TokenType");
+checkPropVal(OUString("TokenEntryText"), aLevel[3], "TokenType", 
nLevel);
 
-checkPropVal(OUString("TokenTabStop"), aLevel[3], "TokenType");
+checkPropVal(OUString("TokenTabStop"), aLevel[4], "TokenType", nLevel);
 
-checkPropVal(OUString("TokenChapterInfo"), aLevel[4], "TokenType");
+checkPropVal(OUString("TokenChapterInfo"), aLevel[5], "TokenType", 
nLevel);
 
-checkPropVal(OUString("TokenText"), aLevel[5], "TokenType");
-checkPropVal(OUString("\""), aLevel[5], "Text");
+checkPropVal(OUString("TokenText"), aLevel[6], "TokenType", nLevel);
+checkPropVal(OUString("\""), aLevel[6], "Text", nLevel);
 
-checkPropVal(OUString("TokenPageNumber"), aLevel[6], "TokenType");
+checkPropVal(OUString("TokenPageNumber"), aLevel[7], "TokenType", 
nLevel);
 
-checkPropVal(OUString("TokenHyperlinkEnd"), aLevel[7], "TokenType");
+checkPropVal(OUString("TokenHyperlinkEnd"), aLevel[8], "TokenType", 
nLevel);
 }
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 663e47a1fa70..ebcd8bebbbfa 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -6029,35 +6029,34 @@ void DomainMapper_Impl::handleAuthor
 }
 
 static uno::Sequence< beans::PropertyValues > lcl_createTOXLevelHyperlinks( 
bool bHyperlinks, const OUString& sChapterNoSeparator,
-   const uno::Sequence< beans::PropertyValues 
>& aLevel )
+   const uno::Sequence< beans::PropertyValues 
>& aLevel, const uno::Sequence& tabs)
 {
 //create a copy of the level and add new entries
 
 std::vector aNewLevel;
-aNewLevel.reserve(aLevel.getLength() + 4); // at most 4 added items
+aNewLevel.reserve(aLevel.getLength() + 5); // at most 5 added items
 
 static constexpr OUStringLiteral tokType(u"TokenType");
 static constexpr 

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

2023-04-04 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf150542.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|   21 +
 writerfilter/source/dmapper/SettingsTable.cxx |   58 +-
 writerfilter/source/ooxml/model.xml   |3 +
 4 files changed, 81 insertions(+), 1 deletion(-)

New commits:
commit 184a805bc50c593cde950fb0b3253665cc748999
Author: Vasily Melenchuk 
AuthorDate: Tue Mar 28 13:15:09 2023 +0300
Commit: Thorsten Behrens 
CommitDate: Tue Apr 4 08:54:46 2023 +0200

tdf#150542: DOCX import: support for document varibles

Writer does insert document variables only if they are in
document body as DOCVARIABLE fields. But ones given in
settings.xml (w:docVars/w:docVar) were ignored.

Moreover variables in settings should have priority and
overwrite ones in fields. Word by default does show only
field results, but refreshing field values will override
values with ones from settings.

Change-Id: I7103c90eef59ab18f8a25e616dcf8a8b1c6dcb08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149646
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 992d86b1b67a6bd28bbf5e63b2d2406881f476b7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149889

diff --git a/sw/qa/extras/ooxmlexport/data/tdf150542.docx 
b/sw/qa/extras/ooxmlexport/data/tdf150542.docx
new file mode 100644
index ..3f115fa69370
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf150542.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index d7dfbf73890e..044c6f3055fd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -976,6 +976,27 @@ CPPUNIT_TEST_FIXTURE(Test, Test_ShadowDirection)
 "rotWithShape", "0");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf150542)
+{
+loadAndSave("tdf150542.docx");
+
+xmlDocUniquePtr pSettingsDoc = parseExport("word/settings.xml");
+// Ensure that all docvars from input are written back and with correct 
values.
+// Order of document variables is not checked. So this can fail at some 
time if order is changed.
+assertXPath(pSettingsDoc,
+"/w:settings/w:docVars/w:docVar[1]", "name", 
u"LocalChars\u00C1\u0072\u0076\u00ED\u007A\u0074\u0075\u0072\u006F\u0054\u00FC\u006B\u00F6\u0072\u0066\u00FA\u0072\u00F3\u0067\u00E9\u0070");
+assertXPath(pSettingsDoc,
+"/w:settings/w:docVars/w:docVar[1]", "val", u"Correct value 
(\u00E1\u0072\u0076\u00ED\u007A\u0074\u0075\u0072\u006F\u0020\u0074\u00FC\u006B\u00F6\u0072\u0066\u00FA\u0072\u00F3\u0067\u00E9\u0070)");
+assertXPath(pSettingsDoc,
+"/w:settings/w:docVars/w:docVar[2]", "name", "DocVar1");
+assertXPath(pSettingsDoc,
+"/w:settings/w:docVars/w:docVar[2]", "val", "DocVar1 Value");
+assertXPath(pSettingsDoc,
+"/w:settings/w:docVars/w:docVar[3]", "name", "DocVar3");
+assertXPath(pSettingsDoc,
+"/w:settings/w:docVars/w:docVar[3]", "val", "DocVar3 Value");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf139549)
 {
 loadAndSave("tdf139549.docx");
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx 
b/writerfilter/source/dmapper/SettingsTable.cxx
index 45dc67b9f43b..d24dae617c01 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -26,6 +26,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -95,6 +97,7 @@ struct SettingsTable_Impl
 boolm_bNoLeading = false;
 OUStringm_sDecimalSymbol;
 OUStringm_sListSeparator;
+std::vector> m_aDocVars;
 
 uno::Sequence m_pThemeFontLangProps;
 
@@ -136,7 +139,6 @@ struct SettingsTable_Impl
 , m_pThemeFontLangProps(3)
 , m_pCurrentCompatSetting(3)
 {}
-
 };
 
 SettingsTable::SettingsTable(const DomainMapper& rDomainMapper)
@@ -187,6 +189,12 @@ void SettingsTable::lcl_attribute(Id nName, Value & val)
 case NS_ooxml::LN_CT_View_val:
 m_pImpl->m_nView = nIntValue;
 break;
+case NS_ooxml::LN_CT_DocVar_name:
+m_pImpl->m_aDocVars.back().first = sStringValue;
+break;
+case NS_ooxml::LN_CT_DocVar_val:
+m_pImpl->m_aDocVars.back().second = sStringValue;
+break;
 case NS_ooxml::LN_CT_CompatSetting_name:
 m_pImpl->m_pCurrentCompatSetting.getArray()[0]
 = comphelper::makePropertyValue("name", sStringValue);
@@ -342,6 +350,25 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
 }
 }
 break;
+case NS_ooxml::LN_CT_Settings_docVars:
+{
+writerfilter::Reference::Pointer_t pProperties = 
rSprm.getProps();
+if (pProperties)
+{
+pProperties->resolve(*this);
+}
+}
+break;
+case NS_ooxml::LN_CT_DocVar:
+{
+

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

2023-03-22 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153255.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|   35 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   14 ++--
 3 files changed, 46 insertions(+), 3 deletions(-)

New commits:
commit 76ab4aad33f6a019b5bc28af17917dd58e7cf9f7
Author: László Németh 
AuthorDate: Mon Mar 20 17:27:32 2023 +0100
Commit: Xisco Fauli 
CommitDate: Wed Mar 22 14:24:36 2023 +

tdf#153255 DOCX import: fix footnote order

Simple unit test for tdf#152203 allowed to create
bad ordering algorithm by accident without noticing
the problem, which caused problem for most of the DOCX
files, where serialization in footnotes.xml doesn't follow
the order of the footnotes.

Regression from commit 9b39ce0e66acfe812e1d50e530dc2ccdef3e1357
"tdf#76260 DOCX import: fix slow footnote import".

Follow-up to commit 09ae3c01940bbc25ffde51963683b04e3cb4bb6a
"tdf#152203 DOCX import: fix mixed footnotes/endnotes".

Change-Id: I0628d96e3b8ad4df38d26e9288b47d39b958c441
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149176
Tested-by: Jenkins
Reviewed-by: László Németh 
(cherry picked from commit 93a20c1d9c2f379906970bbe8a15905fc1a328bc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149242
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153255.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153255.docx
new file mode 100644
index ..e9f2892d5670
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153255.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 3916866b9ff4..c6949b14e6bc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1307,6 +1307,41 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152206)
 CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg5"), 
xLastButOne->getString().trim() );
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf153255)
+{
+loadAndSave("tdf153255.docx");
+xmlDocUniquePtr pXml = parseExport("word/footnotes.xml");
+CPPUNIT_ASSERT(pXml);
+
+uno::Reference xFootnotesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xFootnotes = 
xFootnotesSupplier->getFootnotes();
+uno::Reference xLastFootnote(xFootnotes->getByIndex(5), 
uno::UNO_QUERY);
+// This was "Footnote for pg2" (replaced footnotes)
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg 6"), 
xLastFootnote->getString().trim() );
+
+uno::Reference xLastButOne(xFootnotes->getByIndex(4), 
uno::UNO_QUERY);
+// This was "Footnote for pg 6" (replaced footnotes)
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg5"), 
xLastButOne->getString().trim() );
+
+// check all the remaining footnotes
+
+uno::Reference xFootnote1(xFootnotes->getByIndex(0), 
uno::UNO_QUERY);
+// This was "Footnote for pg3" (replaced footnotes)
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg1"), 
xFootnote1->getString().trim() );
+
+uno::Reference xFootnote2(xFootnotes->getByIndex(1), 
uno::UNO_QUERY);
+// This was "Footnote for pg5" (replaced footnotes)
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg2"), 
xFootnote2->getString().trim() );
+
+uno::Reference xFootnote3(xFootnotes->getByIndex(2), 
uno::UNO_QUERY);
+// This was "Footnote for pg4." (replaced footnotes)
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg3"), 
xFootnote3->getString().trim() );
+
+uno::Reference xFootnote4(xFootnotes->getByIndex(3), 
uno::UNO_QUERY);
+// This was "Footnote for pg1" (replaced footnotes)
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg4."), 
xFootnote4->getString().trim() );
+}
+
 // skip test for macOS (missing fonts?)
 #if !defined(MACOSX)
 DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index e9fda3f50101..449c75e9b8ce 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3716,15 +3716,23 @@ void DomainMapper_Impl::RemoveTemporaryFootOrEndnotes()
 
 static void lcl_convertToNoteIndices(std::deque& rNoteIds, 
sal_Int32& rFirstNoteIndex)
 {
-// convert arbitrary footnote identifiers to 0, 1, 2...
-// indices, keeping their possible random order
+// rNoteIds contains XML footnote identifiers in the loaded order of the 
footnotes
+// (the same order as in footnotes.xml), i.e. it maps temporary footnote 
positions to the
+// identifiers. For example: Ids[0] = 100; Ids[1] = -1, Ids[2] = 5.
+// To copy the footnotes in their final place, create an array, which map 
the (normalized)
+// footnote identifiers to the temporary footnote positions. Using the 
previous example,
+// Pos[0] = 1; Pos[1] = 2; Pos[2] = 0 (where [0], [1], [2] are the 
normalized
+// -1, 5 and 100 

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

2023-03-13 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf104394_lostTextbox.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |6 ++
 writerfilter/source/dmapper/DomainMapper.cxx |2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 5ee30d863a310d2f6ddb18c613283a80b36e7c5c
Author: Justin Luth 
AuthorDate: Fri Mar 10 12:45:35 2023 -0500
Commit: Michael Stahl 
CommitDate: Mon Mar 13 10:29:21 2023 +

tdf#104394 writerfilter: no addDummyParaForTable when PrevFramed

The dummy paragraph is only supposed to be added when the table
starts the section. In this case, a framed paragraph was
the first item in the section.

Since it ends up being a floating item, it is probably not
correct to turn off GetIsFirstParagraphInSection.

In any case, this is a much more targetted fix,
and thus much less likely to lead to regressions.

Change-Id: I7fb2c6189ddbff5d46828b27d68667c9d4a31122
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148656
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148670
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf104394_lostTextbox.docx 
b/sw/qa/extras/ooxmlexport/data/tdf104394_lostTextbox.docx
new file mode 100644
index ..472d0723a9ac
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf104394_lostTextbox.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index ce1aec0fa07f..1d2c3712570e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -87,6 +87,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153526_commentInNumbering, 
"tdf153526_commentInN
 CPPUNIT_ASSERT_EQUAL(13, getParagraphs());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf104394_lostTextbox, 
"tdf104394_lostTextbox.docx")
+{
+// This was only one page b/c the textbox was missing.
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
 // Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index ae4a82c1a6db..3565b131084d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3044,7 +3044,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
  */
 if(m_pImpl->m_nTableDepth == 0 && 
m_pImpl->GetIsFirstParagraphInSection()
 && !m_pImpl->GetIsDummyParaAddedForTableInSection() && 
!m_pImpl->GetIsTextFrameInserted()
-&& !IsInHeaderFooter())
+&& !m_pImpl->GetIsPreviousParagraphFramed() && 
!IsInHeaderFooter())
 {
 m_pImpl->AddDummyParaForTableInSection();
 }


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

2023-03-03 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153891.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx|5 +
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |4 +++-
 3 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 2a7ec5f17e01041418262dcb0229fe537fa8139f
Author: László Németh 
AuthorDate: Wed Mar 1 14:11:30 2023 +0100
Commit: Xisco Fauli 
CommitDate: Fri Mar 3 12:02:51 2023 +

tdf#153891 DOCX import: crash fix at missing cell properties

Regression from commit 81ce88aa80f8e7cde4fdc5b211e9500a3599643c
"tdf#132514 DOCX import: fix lost table style with footer".

Note: no crash without this fix by removing styles.xml from
the test document.

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153891.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153891.docx
new file mode 100644
index ..6fe8092982b6
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153891.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index f80526a74e9b..213b8842f866 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -518,6 +518,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf132514)
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p[2]/w:pPr/w:spacing", "after", 
"0");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153891, "tdf153891.docx")
+{
+// This document simply crashed the importer.
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testFdo69636)
 {
 loadAndSave("fdo69636.docx");
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 58d96a9cd8f5..c8c4bb9712de 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1426,7 +1426,9 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
 if (bApply)
 {
 bool bEndOfApply = 
(xTextRangeCompare->compareRegionEnds(rEndPara, aIt->m_rEndParagraph) == 0);
-ApplyParagraphPropertiesFromTableStyle(*aIt, 
aAllTableParaProperties, aCellProperties[nRow][nCell]);
+// tdf#153891 handle missing cell properties 
(exception in style handling?)
+if ( nCell < 
sal::static_int_cast(aCellProperties[nRow].getLength()) )
+
ApplyParagraphPropertiesFromTableStyle(*aIt, aAllTableParaProperties, 
aCellProperties[nRow][nCell]);
 // erase processed paragraph from list of 
pending paragraphs
 aIt = pTableParagraphs->erase(aIt);
 if (bEndOfApply)


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

2023-03-02 Thread Michael Stahl (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|3 +++
 writerfilter/source/dmapper/GraphicImport.cxx |2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit cc1c04346861afba69215115c026174f758d7272
Author: Michael Stahl 
AuthorDate: Tue Feb 28 18:36:26 2023 +0100
Commit: Caolán McNamara 
CommitDate: Thu Mar 2 09:15:28 2023 +

tdf#143311 writerfilter: import decorative flag on as-char flys too

Change-Id: I9704d35a8286b92169dffd8de7e57e286884f607
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148016
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit d4355f14d1483a57fa08579b143a762f0aad4631)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148019
Reviewed-by: Caolán McNamara 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 70d3ed4bf137..d7dfbf73890e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -830,6 +830,9 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153874, 
"image_through_shape.docx")
 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, 
xShape1->getPropertyValue("AnchorType").get());
 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, 
xShape2->getPropertyValue("AnchorType").get());
 CPPUNIT_ASSERT_LESS(xShape2->getPropertyValue("ZOrder").get(), 
xShape1->getPropertyValue("ZOrder").get());
+CPPUNIT_ASSERT(xShape1->getPropertyValue("Decorative").get());
+// not implemented on shape yet
+//CPPUNIT_ASSERT(xShape2->getPropertyValue("Decorative").get());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTextBoxZOrder, "testTextBoxZOrder.docx")
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx 
b/writerfilter/source/dmapper/GraphicImport.cxx
index b1ca37f871d1..b5a5e8bf743c 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1792,10 +1792,10 @@ uno::Reference 
GraphicImport::createGraphicObject(uno::Refer
 xGraphicObjectProperties->setPropertyValue(getPropertyName( 
PROP_SIZE_PROTECTED ),
 uno::Any(true));
 
+
xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_DECORATIVE), 
uno::Any(m_pImpl->bDecorative));
 sal_Int32 nWidth = - m_pImpl->nLeftPosition;
 if (m_pImpl->m_rGraphicImportType == IMPORT_AS_DETECTED_ANCHOR)
 {
-
xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_DECORATIVE), 
uno::Any(m_pImpl->bDecorative));
 //adjust margins
 if( (m_pImpl->nHoriOrient == text::HoriOrientation::LEFT &&
 (m_pImpl->nHoriRelation == 
text::RelOrientation::PAGE_PRINT_AREA ||


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

2023-03-02 Thread Michael Stahl (via logerrit)
 sw/qa/extras/ooxmlexport/data/image_through_shape.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx |9 +++
 writerfilter/source/dmapper/DomainMapper.cxx   |   14 ++---
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |   22 -
 writerfilter/source/dmapper/DomainMapper_Impl.hxx  |5 +-
 writerfilter/source/dmapper/GraphicImport.cxx  |   41 -
 writerfilter/source/dmapper/GraphicImport.hxx  |2 
 7 files changed, 53 insertions(+), 40 deletions(-)

New commits:
commit e420f47ec10bf6be73972da2c1afbe1c0e02cb9e
Author: Michael Stahl 
AuthorDate: Tue Feb 28 14:40:08 2023 +0100
Commit: Caolán McNamara 
CommitDate: Thu Mar 2 09:15:01 2023 +

tdf#153874 writerfilter: fix anchoring of decorative shapes

Turns out as-char flys can be decorative too.

The confusing GraphicImport takes a GraphicImportType by value but
everything else is a reference to a DomainMapper_Impl member.

The latter appears to work better so handle GraphicImportType the same
way and remove the function parameter.

(regression from commit 31084ebb59093be7dfe5ab53a20fdb3bcfde34b6)

Change-Id: I18c1d47d39751e8ddcaa52498077d89c43a934e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147998
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 
(cherry picked from commit 043c349f144b615836091707147e57616a1261e7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148012
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/qa/extras/ooxmlexport/data/image_through_shape.docx 
b/sw/qa/extras/ooxmlexport/data/image_through_shape.docx
new file mode 100644
index ..dd90f9d9bf29
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/image_through_shape.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index f5230adb643a..70d3ed4bf137 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -823,6 +823,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133473_shadowSize, 
"tdf133473.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(20), nSize1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153874, "image_through_shape.docx")
+{
+uno::Reference const 
xShape1(getShapeByName(u"Test1"),  uno::UNO_QUERY);
+uno::Reference const 
xShape2(getShapeByName(u"Rectangle 1"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, 
xShape1->getPropertyValue("AnchorType").get());
+CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, 
xShape2->getPropertyValue("AnchorType").get());
+CPPUNIT_ASSERT_LESS(xShape2->getPropertyValue("ZOrder").get(), 
xShape1->getPropertyValue("ZOrder").get());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTextBoxZOrder, "testTextBoxZOrder.docx")
 {
 // Is load successful?
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index e5582d097d55..ae4a82c1a6db 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -779,8 +779,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
 {
 //looks a bit like a hack - and it is. The graphic import is split 
into the inline_inline part and
 //afterwards the adding of the binary data.
-m_pImpl->GetGraphicImport( IMPORT_AS_DETECTED_INLINE 
)->attribute(nName, val);
-m_pImpl->ImportGraphic( val.getProperties(), 
IMPORT_AS_DETECTED_INLINE );
+m_pImpl->m_eGraphicImportType = IMPORT_AS_DETECTED_INLINE; // 
really ???
+m_pImpl->GetGraphicImport()->attribute(nName, val);
+m_pImpl->ImportGraphic(val.getProperties());
 }
 break;
 case NS_ooxml::LN_Value_math_ST_Jc_centerGroup:
@@ -1345,7 +1346,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
 }
 break;
 case NS_ooxml::LN_OfficeArtExtension_Decorative_val:
-
m_pImpl->GetGraphicImport(IMPORT_AS_DETECTED_ANCHOR)->attribute(nName, val);
+m_pImpl->GetGraphicImport()->attribute(nName, val);
 break;
 default:
 SAL_WARN("writerfilter", "DomainMapper::lcl_attribute: unhandled 
token: " << nName);
@@ -2497,15 +2498,14 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
 writerfilter::Reference::Pointer_t pProperties = 
rSprm.getProps();
 if( pProperties )
 {
-GraphicImportType eGraphicType =
+m_pImpl->m_eGraphicImportType =
 (NS_ooxml::LN_anchor_anchor ==
  sal::static_int_cast(nSprmId)) ?
 IMPORT_AS_DETECTED_ANCHOR :
 IMPORT_AS_DETECTED_INLINE;
-GraphicImportPtr pGraphicImport =
-m_pImpl->GetGraphicImport(eGraphicType);
+   

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

2023-02-22 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx  |7 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx   |   11 
++
 3 files changed, 14 insertions(+), 4 deletions(-)

New commits:
commit bf9e8ce3a810e2989fb0b486b3398d523f69da97
Author: Justin Luth 
AuthorDate: Wed Feb 22 11:19:40 2023 -0500
Commit: Miklos Vajna 
CommitDate: Thu Feb 23 07:35:15 2023 +

tdf#153526 writerfilter: catch exception from no NumberingRules

This fixes a LO 7.5 regression (well, exposed some other flaws) from
commit cf02b94bc513ee1b742b4c5d7174632b568e8b72.

I first tried testing if hasPropertyByName,
but that returns true(), even though this is an editeng component.

Well, ignoring the fundamental issues at play here
(and there are many - like having a comment
take over m_xPreviousParagraph)
the issue is easily solved with a try/catch
instead of a redundant if clause.

Change-Id: I4f27fce3e2984235df19dc3ed4be558891b28a90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147486
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147494
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx
new file mode 100644
index ..f26240092c10
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index be8e5cf663bd..ce1aec0fa07f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -80,6 +80,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf147646, 
"tdf147646_mergedCellNumbering.docx")
 
CPPUNIT_ASSERT_EQUAL(OUString("2."),parseDump("/root/page/body/tab/row[4]/cell/txt/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']","expand"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153526_commentInNumbering, 
"tdf153526_commentInNumbering.docx")
+{
+// an exception was prematurely ending finishParagraph, losing numbering 
and CRs
+// so before the patch, this was 6.
+CPPUNIT_ASSERT_EQUAL(13, getParagraphs());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
 // Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 16ce9c9b5f96..592897313bc7 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2309,11 +2309,14 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
 uno::Reference 
xCurrentNumberingRules(itNumberingRules->Value, uno::UNO_QUERY);
 if (xCurrentNumberingRules.is())
 aCurrentNumberingName = 
xCurrentNumberingRules->getName();
-if (m_xPreviousParagraph.is())
+try
+{
+uno::Reference 
xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"),
 uno::UNO_QUERY_THROW);
+aPreviousNumberingName = 
xPreviousNumberingRules->getName();
+}
+catch (const uno::Exception&)
 {
-uno::Reference 
xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"),
 uno::UNO_QUERY);
-if (xPreviousNumberingRules.is())
-aPreviousNumberingName = 
xPreviousNumberingRules->getName();
+TOOLS_WARN_EXCEPTION("writerfilter", 
"DomainMapper_Impl::finishParagraph NumberingRules");
 }
 }
 else if ( 
m_xPreviousParagraph->getPropertySetInfo()->hasPropertyByName("NumberingStyleName")
 &&


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

2023-01-19 Thread Michael Stahl (via logerrit)
 sw/qa/extras/ooxmlexport/data/custom-styles-TOC-comma.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |   25 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |4 +
 writerfilter/source/dmapper/StyleSheetTable.cxx|   29 +
 4 files changed, 57 insertions(+), 1 deletion(-)

New commits:
commit d42e7d50225d5ff7359cfc765ec9694cf83c9749
Author: Michael Stahl 
AuthorDate: Wed Jan 18 15:41:57 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Jan 19 12:43:03 2023 +

tdf#153083 writerfilter: import locale-dependent TOC \t style names

The bugdoc contains this style:

  




...

which is referred to by:

  TOC \o "1-3" \h \z \t "Intensives Zitat;3;Custom1;3;_MyStyle0;3"

Word in an "en" locale is unable to match the "Intensives Zitat" in the
TOC field with the style "Intense Quote", which is a built-in style
in Word (no equivalent in Writer).

At first glance nothing in styles.xml matches the localised built-in
style name in the TOC field.

But it looks like the w:styleId value is somehow generated from the
localised style name by omitting certain characters like SPACE and
non-ASCII letters.

Change-Id: I2050f7cf7f8d80bee1f667ee53b7f9981bbf7b49
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145745
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit ecbad22fdf81c6f072b6c9f9c16dbba47fe4748c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145721
Tested-by: Michael Stahl 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlexport/data/custom-styles-TOC-comma.docx 
b/sw/qa/extras/ooxmlexport/data/custom-styles-TOC-comma.docx
new file mode 100644
index ..1b013086dcc6
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/custom-styles-TOC-comma.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index d9d5802e0606..b216e14d22fe 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -701,6 +702,30 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148361, "tdf148361.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("[Type text]"), aActual);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153082_comma, "custom-styles-TOC-comma.docx")
+{
+uno::Reference xIndexSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xIndexes = 
xIndexSupplier->getDocumentIndexes();
+uno::Reference xTOC(xIndexes->getByIndex(0), 
uno::UNO_QUERY);
+// check styles
+uno::Reference xParaStyles =
+getProperty>(xTOC, 
"LevelParagraphStyles");
+uno::Sequence styles;
+xParaStyles->getByIndex(0) >>= styles;
+CPPUNIT_ASSERT_EQUAL(uno::Sequence{"_MyStyle0"}, styles);
+xParaStyles->getByIndex(1) >>= styles;
+CPPUNIT_ASSERT_EQUAL(uno::Sequence{"Custom1"}, styles);
+xParaStyles->getByIndex(2) >>= styles;
+// the first one is built-in Word style that was localised DE "Intensives 
Zitat" in the file
+CPPUNIT_ASSERT_EQUAL(uno::Sequence{"Intense Quote"}, styles);
+xTOC->update();
+OUString const tocContent(xTOC->getAnchor()->getString());
+CPPUNIT_ASSERT(tocContent.startsWith("Table of Contents"));
+CPPUNIT_ASSERT(tocContent.indexOf("Lorem ipsum dolor sit amet, 
consectetuer adipiscing elit.") != -1);
+CPPUNIT_ASSERT(tocContent.indexOf("Fusce posuere, magna sed pulvinar 
ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis 
urna.") != -1);
+CPPUNIT_ASSERT(tocContent.indexOf("Pellentesque habitant morbi tristique 
senectus et netus et malesuada fames ac turpis egestas.") != -1);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf142407, "tdf142407.docx")
 {
 uno::Reference xPageStyles = 
getStyles("PageStyles");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index bcfcbc7c72dd..3f33280f5a22 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -6279,7 +6279,9 @@ void DomainMapper_Impl::handleToc
 uno::Sequence< OUString> aStyles( nLevelCount );
 for ( auto& rStyle : asNonConstRange(aStyles) )
 {
-rStyle = (aTOCStyleIter++)->second;
+// tdf#153082 must map w:styleId to w:name
+rStyle = 
GetStyleSheetTable()->ConvertStyleName(aTOCStyleIter->second, true);
+++aTOCStyleIter;
 }
 xParaStyles->replaceByIndex(nLevel - 1, uno::Any(aStyles));
 }
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx 
b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 

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

2023-01-10 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf103956.rtf   |8 +
 sw/qa/extras/rtfexport/rtfexport4.cxx   |   37 
 writerfilter/source/rtftok/rtfdispatchvalue.cxx |   13 ++--
 3 files changed, 55 insertions(+), 3 deletions(-)

New commits:
commit 84aea0a29962cf11a63bdb550f522b3d5574cf64
Author: Vasily Melenchuk 
AuthorDate: Fri Jan 6 17:31:16 2023 +0300
Commit: Xisco Fauli 
CommitDate: Wed Jan 11 07:57:41 2023 +

tdf#103956: RTF import: fix for \cellx0 or no params.

If cell width is not given or zero lets not confuse it with too
narrow cell. Lets keep zero to allow domain mapper define some
width.

This patch does not solves autofit issue completely, but finally
tables with autofit are visible somehow and do not contain cells
with minimal almost invisible width (41).

Change-Id: I640228ed117f1d65dde9753a00b8403dda45dd40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145148
Tested-by: Jenkins
Reviewed-by: Vasily Melenchuk 
(cherry picked from commit 26d74a57d54327b9fd562065d04d867852ce8e8a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145227
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/rtfexport/data/tdf103956.rtf 
b/sw/qa/extras/rtfexport/data/tdf103956.rtf
new file mode 100644
index ..f41be5b54aba
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf103956.rtf
@@ -0,0 +1,8 @@
+{\rtf\ansi\deff0
+
+\trowd\trautofit0\cellx \cellx \pard \intbl 1 \cell \pard \intbl 2 \cell \row 
+\pard\par
+\trowd\trautofit0\trgaph100\cellx0 \cellx0 \pard \intbl 1 \cell \pard \intbl 2 
\cell \row
+\pard\par
+\trowd\trautofit0\cellx500 \cellx1000 \pard \intbl 1 \cell \pard \intbl 2 
\cell \row
+}
\ No newline at end of file
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx 
b/sw/qa/extras/rtfexport/rtfexport4.cxx
index c55c74a4f6b3..6912948c57db 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -784,6 +784,43 @@ DECLARE_RTFEXPORT_TEST(testTdf139948, "tdf139948.rtf")
 sal_uInt32(0), getProperty(getParagraph(5), 
"BottomBorder").LineWidth);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf103956, "tdf103956.rtf")
+{
+// Ensure that RTF tables without column width (\cellx or \cellx0) are 
displayed with some
+// suitable width. Currently there is no good support for autofit for RTF 
docs, so ensure
+// that table cells are somehow visible. Width for it is not clear, so 
here we will check
+// table & cell widths are more than default minimal value of 41.
+CPPUNIT_ASSERT_MESSAGE(
+"Table #1 is too narrow!",
+82 < parseDump("/root/page/body/tab[1]/row/infos/bounds", 
"width").toInt32());
+CPPUNIT_ASSERT_MESSAGE(
+"Table #1 cell#1 is too narrow!",
+41 < parseDump("/root/page/body/tab[1]/row/cell[1]/infos/bounds", 
"width").toInt32());
+CPPUNIT_ASSERT_MESSAGE(
+"Table #1 cell#2 is too narrow!",
+41 < parseDump("/root/page/body/tab[1]/row/cell[2]/infos/bounds", 
"width").toInt32());
+
+CPPUNIT_ASSERT_MESSAGE(
+"Table #2 is too narrow!",
+82 < parseDump("/root/page/body/tab[2]/row/infos/bounds", 
"width").toInt32());
+CPPUNIT_ASSERT_MESSAGE(
+"Table #2 cell#1 is too narrow!",
+41 < parseDump("/root/page/body/tab[2]/row/cell[1]/infos/bounds", 
"width").toInt32());
+CPPUNIT_ASSERT_MESSAGE(
+"Table #2 cell#2 is too narrow!",
+41 < parseDump("/root/page/body/tab[2]/row/cell[2]/infos/bounds", 
"width").toInt32());
+
+CPPUNIT_ASSERT_MESSAGE(
+"Table #3 is too narrow!",
+82 < parseDump("/root/page/body/tab[3]/row/infos/bounds", 
"width").toInt32());
+CPPUNIT_ASSERT_MESSAGE(
+"Table #3 cell#1 is too narrow!",
+41 < parseDump("/root/page/body/tab[3]/row/cell[1]/infos/bounds", 
"width").toInt32());
+CPPUNIT_ASSERT_MESSAGE(
+"Table #3 cell#2 is too narrow!",
+41 < parseDump("/root/page/body/tab[3]/row/cell[2]/infos/bounds", 
"width").toInt32());
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf148515, "tdf148515.rtf")
 {
 uno::Reference xTable(getParagraphOrTable(1), 
uno::UNO_QUERY);
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx 
b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index 2bea9dc9ec8f..a56d8e00d819 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -393,10 +393,17 @@ bool RTFDocumentImpl::dispatchTableValue(RTFKeyword 
nKeyword, int nParam)
 ? m_nNestedCurrentCellX
 : m_nTopLevelCurrentCellX);
 int nCellX = nParam - rCurrentCellX;
-const int COL_DFLT_WIDTH
-= 41; // sw/source/filter/inc/wrtswtbl.hxx, minimal possible 
width of cells.
-if (!nCellX)
+
+if (!nCellX && nParam > 0)
+{
+// If width of cell is 0, BUT there is a value for \cellxN use 
minimal
+ 

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

2023-01-09 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf152784_1.rtf |   20 
 sw/qa/extras/rtfexport/rtfexport3.cxx   |9 +
 writerfilter/source/rtftok/rtfsprm.cxx  |4 ++--
 3 files changed, 31 insertions(+), 2 deletions(-)

New commits:
commit 588ff9a228f4894142264c68392ed1e9800a4d7d
Author: Vasily Melenchuk 
AuthorDate: Tue Dec 27 15:31:37 2022 +0300
Commit: Miklos Vajna 
CommitDate: Tue Jan 10 07:15:00 2023 +

tdf#152784: RTF import: more default paragraph params

If numbering is not explicitly mentioned in para properties
it should not be used from referred paragraph style. So
default value of 0 (no numbering) is used by default.

Change-Id: If8e8f2aaf19190f64a557444188f67b24a699b54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144839
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145195

diff --git a/sw/qa/extras/rtfexport/data/tdf152784_1.rtf 
b/sw/qa/extras/rtfexport/data/tdf152784_1.rtf
new file mode 100644
index ..19dcaa36e4df
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf152784_1.rtf
@@ -0,0 +1,20 @@
+{\rtf1
+
+{\stylesheet
+{\s3 \ls1\outlinelevel2  heading 3;}}
+{\*\listtable
+{\list\listtemplateid-374154644
+{\listlevel{\leveltext\'02\'00.;}{\levelnumbers\'01;}}
+{\listlevel{\leveltext\'02\'01.;}{\levelnumbers\'01;}}
+{\listlevel{\leveltext\'02\'02.;}{\levelnumbers\'01;}}
+{\listname ;}\listid773479173}
+}
+{\*\listoverridetable
+{\listoverride\listid773479173\listoverridecount0\ls1}
+}
+
+\pard\s3 Here should be no numbering!
+\par
+
+}
+
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx 
b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 5cbf173d35fb..8fcddf78dbb6 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -544,6 +544,15 @@ DECLARE_RTFEXPORT_TEST(testInvalidParagraphStyle, 
"invalidParagraphStyle.rtf")
 CPPUNIT_ASSERT_EQUAL(style::NumberingType::ARABIC, numFormat);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf152784_1, "tdf152784_1.rtf")
+{
+// Ensure that paragraph having style with numbering does not have 
numbering
+// since it is not explitly defined in paragraph properties
+uno::Reference xPara(getParagraph(1, "Here should be 
no numbering!"),
+  uno::UNO_QUERY);
+CPPUNIT_ASSERT(getProperty(xPara, 
"NumberingStyleName").isEmpty());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx 
b/writerfilter/source/rtftok/rtfsprm.cxx
index 90bc97001d27..7a3e4d454687 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -192,13 +192,13 @@ static RTFValue::Pointer_t getDefaultSPRM(Id const id, Id 
nStyleType)
 case NS_ooxml::LN_CT_Ind_right:
 case NS_ooxml::LN_CT_Ind_firstLine:
 return new RTFValue(0);
-
 case NS_ooxml::LN_CT_Spacing_lineRule:
 return new 
RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto);
 case NS_ooxml::LN_CT_Spacing_line:
 // presumably this means 100%, cf. static const int 
nSingleLineSpacing = 240;
 return new RTFValue(240);
-
+case NS_ooxml::LN_CT_NumPr_numId:
+return new RTFValue(0);
 case NS_ooxml::LN_CT_PrBase_pBdr:
 { // tdf#150382 default all paragraph borders to none
 RTFSprms attributes;


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

2023-01-09 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf148578.rtf|   12 
 sw/qa/extras/rtfexport/rtfexport3.cxx|   21 +++
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |5 ---
 3 files changed, 34 insertions(+), 4 deletions(-)

New commits:
commit 78e91fd2bf7fe7d92020e7d9d9a2c6c25c8da830
Author: Vasily Melenchuk 
AuthorDate: Thu Jan 5 18:17:12 2023 +0300
Commit: Thorsten Behrens 
CommitDate: Mon Jan 9 23:45:03 2023 +

tdf#148578: Do not apply table shift for RTF

Table shift based on cell lect margin should be applied
for DOCX (earlier compat options) but not actual for RTF.

Maybe earlier RTF version did behave this way, but nowadays
this behavior does not match MS Word 365.

Change-Id: Icdc4fa6298167fe5f263c85164d7c4c4176be25f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145088
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145196

diff --git a/sw/qa/extras/rtfexport/data/tdf148578.rtf 
b/sw/qa/extras/rtfexport/data/tdf148578.rtf
new file mode 100644
index ..256d63898770
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf148578.rtf
@@ -0,0 +1,12 @@
+{\rtf1
+
+\trowd
+\trgaph567
+\cellx1851
+\cellx9206
+\pard\plain\intbl 1000\cell
+\pard\plain\intbl XX_XX_XXX1\cell 
+\row
+
+\pard 
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx 
b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 6c1a4d524b7f..5cbf173d35fb 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -514,6 +514,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf127806)
 CPPUNIT_ASSERT_EQUAL(static_cast(635), aSize.Width);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf148578, "tdf148578.rtf")
+{
+// \trgaph567 should affect only table cell margings (~1cm),
+// but do not shift table, since \trleft is not provided
+uno::Reference xTable(getParagraphOrTable(1), 
uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(0), 
getProperty(xTable, "LeftMargin"));
+
+uno::Reference xCell(xTable->getCellByName("A1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(static_cast(1000),
+ getProperty(xCell, "LeftBorderDistance"));
+CPPUNIT_ASSERT_EQUAL(static_cast(1000),
+ getProperty(xCell, "RightBorderDistance"));
+
+xCell.set(xTable->getCellByName("B1"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(static_cast(1000),
+ getProperty(xCell, "LeftBorderDistance"));
+CPPUNIT_ASSERT_EQUAL(static_cast(1000),
+ getProperty(xCell, "RightBorderDistance"));
+}
+
 DECLARE_RTFEXPORT_TEST(testInvalidParagraphStyle, "invalidParagraphStyle.rtf")
 {
 // Given test has character style #30, but referred as paragraph style #30
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 2e962260c79c..97fea78eba2a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -618,12 +618,9 @@ TableStyleSheetEntry * 
DomainMapperTableHandler::endTableGetTableStyle(TableInfo
 
 // tdf#106742: since MS Word 2013 (compatibilityMode >= 15), top-level 
tables are handled the same as nested tables;
 // the default behavior when DOCX doesn't define "compatibilityMode" 
option is to add the cell spacing
-
-// Undefined should not be possible any more for DOCX, but it is for 
RTF.
-// In any case, continue to treat undefined as version 12 during 
import.
 sal_Int32 nMode = 
m_rDMapper_Impl.GetSettingsTable()->GetWordCompatibilityMode();
 
-if (((nMode < 0) || (0 < nMode && nMode <= 14)) && rInfo.nNestLevel == 
1)
+if (0 < nMode && nMode <= 14 && rInfo.nNestLevel == 1)
 {
 const sal_Int32 nAdjustedMargin = nLeftMargin - nGapHalf - 
rInfo.nLeftBorderDistance;
 m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::Any( 
nAdjustedMargin ) );


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

2023-01-09 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/invalidParagraphStyle.rtf |   14 ++
 sw/qa/extras/rtfexport/rtfexport3.cxx |9 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   10 +-
 3 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit 466cc615de49a646c82af14657a05e240e4a640c
Author: Vasily Melenchuk 
AuthorDate: Wed Dec 28 23:52:10 2022 +0300
Commit: Thorsten Behrens 
CommitDate: Mon Jan 9 23:44:41 2023 +

ms format import: better handling for invalid styles

If referred paragraph style is not found or it is not a paragraph
style, this can lead to exceptions in writer core and thus current
paragraph can be not corretly initialized. For example, numbering
can be not applied because of exception of not found style earlier.
This is not a critical error, we should just not apply a style
we could not resolve.

Of course such documents are invalid but bit more tolerance to errors
will not harm.

Change-Id: I9150786e6357a7d6098440bac29ec501fc6aa802
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144852
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145194

diff --git a/sw/qa/extras/rtfexport/data/invalidParagraphStyle.rtf 
b/sw/qa/extras/rtfexport/data/invalidParagraphStyle.rtf
new file mode 100644
index ..cb5ec80eb3cf
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/invalidParagraphStyle.rtf
@@ -0,0 +1,14 @@
+{\rtf1
+
+{\stylesheet
+{\cs30\fs72 Super Duper Style;}}
+
+{\*\listtable
+{\list
+{\listlevel\levelstartat1{\leveltext\'02\'00.;}{\levelnumbers\'01;}}
+{\listname ;}\listid1235362366}}
+{\*\listoverridetable{\listoverride\listid1235362366\listoverridecount0\ls1}}
+
+\pard\s30\ls1\fs24 AAA BBB CCC\par 
+
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx 
b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 90adb69f2bf7..6c1a4d524b7f 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -514,6 +514,15 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf127806)
 CPPUNIT_ASSERT_EQUAL(static_cast(635), aSize.Width);
 }
 
+DECLARE_RTFEXPORT_TEST(testInvalidParagraphStyle, "invalidParagraphStyle.rtf")
+{
+// Given test has character style #30, but referred as paragraph style #30
+// This was causing exception in finishParagraph(), so numbering and other
+// properties were not applied. Ensure numbering is still here
+sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
+CPPUNIT_ASSERT_EQUAL(style::NumberingType::ARABIC, numFormat);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f0fbd05209c5..bcfcbc7c72dd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1934,13 +1934,21 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
 #endif
 
 const StyleSheetEntryPtr pEntry = 
GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( 
GetCurrentParaStyleName() );
-OSL_ENSURE( pEntry, "no style sheet found" );
+SAL_WARN_IF(!pEntry, "writerfilter.dmapper", "no style sheet found");
 const StyleSheetPropertyMap* pStyleSheetProperties = pEntry ? 
pEntry->pProperties.get() : nullptr;
 sal_Int32 nListId = pParaContext ? pParaContext->props().GetListId() : -1;
 bool isNumberingViaStyle(false);
 bool isNumberingViaRule = nListId > -1;
 if ( !bRemove && pStyleSheetProperties && pParaContext )
 {
+if (!pEntry || pEntry->nStyleTypeCode != StyleType::STYLE_TYPE_PARA) {
+// We could not resolve paragraph style or it is not a paragraph 
style
+// Remove this style reference, otherwise it will cause exceptions 
during further
+// processing and not all paragraph styles will be initialized.
+SAL_WARN("writerfilter.dmapper", "Paragraph style is incorrect. 
Ignored");
+pParaContext->Erase(PROP_PARA_STYLE_NAME);
+}
+
 bool bNumberingFromBaseStyle = false;
 if (!isNumberingViaRule)
 nListId = lcl_getListId(pEntry, GetStyleSheetTable(), 
bNumberingFromBaseStyle);


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

2023-01-06 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf131203.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx|8 +++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |   17 +++
 3 files changed, 17 insertions(+), 8 deletions(-)

New commits:
commit e9a3755182db2a0e06278977e9d8af376ac4eefa
Author: László Németh 
AuthorDate: Thu Jan 5 10:21:10 2023 +0100
Commit: László Németh 
CommitDate: Fri Jan 6 10:32:36 2023 +

tdf#131203 DOCX import: fix lost table when w:tblGrid is missing

Load tables in case of incomplete text table definition, i.e.
missing w:tblGrid and its w:gridCol elements, like MSO does.

Note: Apache POI, and maybe old MSO versions generated such DOCX documents.

divide_by_zero() was thrown from 975884fbbc3f80a634258ee562037688a42027a9
"ofz#7110 ensure join is called on std::exceptions as well as 
uno::Exception".

See also commit 9279b0bb5397d0520b727ab0d271f328807c8749
"writerfilter: avoid divide by zero" and
commit 116cadb5d2582532c69677a2f8499e8e9b7b9b80
"tdf#59274 DOCX import: fix tables with incomplete grid".

Change-Id: I991807da13e22e551f81c3fb60580be7a9c0fb50
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145069
Tested-by: Jenkins
Reviewed-by: László Németh 
(cherry picked from commit e17b4df3fe5441ca66e4203c725a578eb1797eb2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145008
Reviewed-by: Michael Stahl 
Tested-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf131203.docx 
b/sw/qa/extras/ooxmlexport/data/tdf131203.docx
new file mode 100644
index ..2fd0dcabded4
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf131203.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index d282675b07ad..f33013413a1c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -249,6 +249,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf131959)
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblInd", "w", "360");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf131203)
+{
+loadAndSave("tdf131203.docx");
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// loading thrown divide_by_zero()
+assertXPath(pXmlDoc, "//w:tbl", 2);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testFDO76597)
 {
 loadAndSave("fdo76597.docx");
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx 
b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index bc8b59642714..004f34971b6a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -807,15 +807,16 @@ void DomainMapperTableManager::endOfRowAction()
 nFullWidthRelative += nFixLastCellWidth - 
(*pCellWidths)[nWidthsBound];
 }
 
-if (nFullWidthRelative == 0)
-throw o3tl::divide_by_zero();
-
-for (size_t i = 0; i < nWidthsBound; ++i)
+// tdf#131203 handle missing w:tblGrid
+if (nFullWidthRelative > 0)
 {
-nSum += (*pCellWidths)[i];
-pSeparators[nPos].Position = (nSum * 1) / 
nFullWidthRelative; // Relative position
-pSeparators[nPos].IsVisible = true;
-nPos++;
+for (size_t i = 0; i < nWidthsBound; ++i)
+{
+nSum += (*pCellWidths)[i];
+pSeparators[nPos].Position = (nSum * 1) / 
nFullWidthRelative; // Relative position
+pSeparators[nPos].IsVisible = true;
+nPos++;
+}
 }
 }
 


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

2022-12-20 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf152206.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|   17 +++
 writerfilter/source/dmapper/DomainMapper.cxx  |   13 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   98 ++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |   10 +-
 5 files changed, 100 insertions(+), 38 deletions(-)

New commits:
commit 8e7995a748bb0b9b77265bdcd74ce4800bc8afa2
Author: László Németh 
AuthorDate: Fri Dec 16 13:20:25 2022 +0100
Commit: Xisco Fauli 
CommitDate: Tue Dec 20 08:46:54 2022 +

tdf#152506 DOCX import: fix mixed first footnote

Also the first footnote can be at arbitrary
place in footnote.xml.

Follow-up to commit 09ae3c01940bbc25ffde51963683b04e3cb4bb6a
"tdf#152203 DOCX import: fix mixed footnotes/endnotes".

Change-Id: Iab356f7373483d812f0e802a994357fdad831d9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144380
Tested-by: Jenkins
Reviewed-by: László Németh 
(cherry picked from commit 96a856f87f16cca2e039c973c18d57c8b9dca362)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144422
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf152206.docx 
b/sw/qa/extras/ooxmlexport/data/tdf152206.docx
new file mode 100644
index ..34f0130fdd7b
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf152206.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 9ce06be528e9..3916866b9ff4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1290,6 +1290,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152203)
 CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg5"), 
xLastButOne->getString().trim() );
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf152206)
+{
+loadAndSave("tdf152206.docx");
+xmlDocUniquePtr pXml = parseExport("word/footnotes.xml");
+CPPUNIT_ASSERT(pXml);
+
+uno::Reference xFootnotesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xFootnotes = 
xFootnotesSupplier->getFootnotes();
+uno::Reference xLastFootnote(xFootnotes->getByIndex(1), 
uno::UNO_QUERY);
+// This was "Footnote for pg5" (replaced footnotes)
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg 6"), 
xLastFootnote->getString().trim() );
+
+uno::Reference xLastButOne(xFootnotes->getByIndex(0), 
uno::UNO_QUERY);
+// This was "Footnote for pg 6" (replaced footnotes)
+CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg5"), 
xLastButOne->getString().trim() );
+}
+
 // skip test for macOS (missing fonts?)
 #if !defined(MACOSX)
 DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 1e0f9597b3b4..e5582d097d55 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3746,11 +3746,18 @@ void DomainMapper::lcl_checkId(const sal_Int32 nId)
 {
 if (m_pImpl->IsInFootnote())
 {
-if (m_pImpl->GetFootnoteCount() > -1)
-m_pImpl->m_aFootnoteIds.push_back(nId);
+m_pImpl->m_aFootnoteIds.push_back(nId);
+// keep only the first real footnote
+if (m_pImpl->GetFootnoteCount() == -1 && 
m_pImpl->m_aFootnoteIds.size() == 2)
+m_pImpl->m_aFootnoteIds.pop_front();
 }
-else if (m_pImpl->GetEndnoteCount() > -1)
+else
+{
 m_pImpl->m_aEndnoteIds.push_back(nId);
+// keep only the first real endnote
+if (m_pImpl->GetEndnoteCount() == -1 && m_pImpl->m_aEndnoteIds.size() 
== 2)
+m_pImpl->m_aEndnoteIds.pop_front();
+}
 }
 
 void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 5365b302c6d2..1227d448a057 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -356,6 +356,8 @@ DomainMapper_Impl::DomainMapper_Impl(
 m_eSkipFootnoteState(SkipFootnoteSeparator::OFF),
 m_nFootnotes(-1),
 m_nEndnotes(-1),
+m_nFirstFootnoteIndex(-1),
+m_nFirstEndnoteIndex(-1),
 m_bLineNumberingSet( false ),
 m_bIsInFootnoteProperties( false ),
 m_bIsParaMarkerChange( false ),
@@ -3617,6 +3619,36 @@ static void lcl_PasteRedlines(
 }
 }
 
+bool DomainMapper_Impl::CopyTemporaryNotes(
+uno::Reference< text::XFootnote > xNoteSrc,
+uno::Reference< text::XFootnote > xNoteDest )
+{
+if (!m_bSaxError && xNoteSrc != xNoteDest)
+{
+uno::Reference< text::XText > xSrc( xNoteSrc, uno::UNO_QUERY_THROW );
+uno::Reference< text::XText > xDest( xNoteDest, uno::UNO_QUERY_THROW );
+uno::Reference< text::XTextCopy > xTxt, xTxt2;
+xTxt.set(  xSrc, uno::UNO_QUERY_THROW );
+