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

2022-05-19 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf148132.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   32 ++
 sw/qa/extras/rtfexport/data/numbering-font.rtf|8 --
 sw/qa/extras/rtfexport/rtfexport.cxx  |3 
 writerfilter/source/dmapper/DomainMapper.cxx  |   14 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   67 --
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |2 
 writerfilter/source/rtftok/rtfdispatchvalue.cxx   |9 ++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx|9 ++
 9 files changed, 54 insertions(+), 90 deletions(-)

New commits:
commit a309c671b5f7ac536d7624a2bbc95e23f19bb42d
Author: Vasily Melenchuk 
AuthorDate: Wed May 11 09:44:22 2022 +0300
Commit: Miklos Vajna 
CommitDate: Thu May 19 17:08:00 2022 +0200

tdf#148132: Revert "n#758883 dmapper: paragraph-level..."

Seems original problem is no longer reprodicible with recent builds
but ovewriting of numbering style params with inline values leads
to another problems.

Removing this mechanics do some impact on RTF filter: it tries to
modify numbering styles, so this was also corrected. It is not ideal
yet but looks better in support numbering char properties different
from paragraph ones.

This reverts commit 2123ede032ca64f696ef54af4ad3238974ca2b5d.

Change-Id: If8c79d6191de13b2f09c128b59d17efcfdb1a4ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133877
Reviewed-by: Michael Stahl 
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134636

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148132.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148132.docx
new file mode 100644
index ..6ee2359795a3
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148132.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 9e17190c0260..7915ade87d6d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -16,9 +16,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -361,6 +364,35 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf147978enhancedPathABVW)
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148132, "tdf148132.docx")
+{
+{
+uno::Reference xParagraph = getParagraph(1);
+auto xLevels = getProperty< uno::Reference 
>(xParagraph, "NumberingRules");
+// Get level 2 char style
+comphelper::SequenceAsHashMap levelProps(xLevels->getByIndex(1));
+OUString aCharStyleName = levelProps["CharStyleName"].get();
+// Ensure that numbering in this paragraph is 24pt bold italic
+// Previously it got overriden by paragraph properties and became 6pt, 
no bold, no italic
+uno::Reference 
xStyle(getStyles("CharacterStyles")->getByName(aCharStyleName), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(24.f, getProperty(xStyle, "CharHeight"));
+CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty(xStyle, 
"CharWeight"));
+CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, 
getProperty(xStyle, "CharPosture"));
+}
+// And do the same for second paragraph. Numbering should be identical
+{
+uno::Reference xParagraph = getParagraph(2);
+auto xLevels = getProperty< uno::Reference 
>(xParagraph, "NumberingRules");
+comphelper::SequenceAsHashMap levelProps(xLevels->getByIndex(1));
+OUString aCharStyleName = levelProps["CharStyleName"].get();
+
+uno::Reference 
xStyle(getStyles("CharacterStyles")->getByName(aCharStyleName), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(24.f, getProperty(xStyle, "CharHeight"));
+CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty(xStyle, 
"CharWeight"));
+CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, 
getProperty(xStyle, "CharPosture"));
+}
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf148273_sectionBulletFormatLeak, 
"tdf148273_sectionBulletFormatLeak.docx")
 {
 // get a paragraph with bullet point after section break
diff --git a/sw/qa/extras/rtfexport/data/numbering-font.rtf 
b/sw/qa/extras/rtfexport/data/numbering-font.rtf
index 46fdb7ed4d1e..8b57875c29bc 100644
--- a/sw/qa/extras/rtfexport/data/numbering-font.rtf
+++ b/sw/qa/extras/rtfexport/data/numbering-font.rtf
@@ -1,7 +1,7 @@
 {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\deff0\deflang1033
 {\fonttbl
 {\f0\fbidi \froman\fcharset238\fprq2 Times New Roman;}
-{\f40\fbidi \fswiss\fcharset238\fprq2 Verdana;}
+{\f40\fbidi \fswiss\fcharset238\fprq2 Impact;}
 }
 {\*\listtable
 {\list\listtemplateid645944990
@@ -9,14 +9,12 @@
 \levelfollow0\levelstartat1
 {\leveltext\'02\'00.;}
 {\levelnumbers\'01;}
-\rtlch \af0\afs18 \ltrch \fs18 \fi-360\li720\lin720 }
+\f40\fs144\b0\i0\fi-360\li720\lin720 }
 {\listname ;}
 

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

2022-05-04 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf146346.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |9 +
 writerfilter/source/dmapper/PropertyMap.cxx  |   19 ++-
 3 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit e3cca5bb02c52f92b8fc7b4b87ca2fc2b9615ead
Author: László Németh 
AuthorDate: Tue May 3 11:06:59 2022 +0200
Commit: Xisco Fauli 
CommitDate: Wed May 4 16:05:20 2022 +0200

tdf#146346 DOCX import: fix table margins in footnotes

Paragraph of the anchoring point of the floating table
needs zero top and bottom margins, if the table was a
not floating table in the footnote originally, otherwise
docDefault (Standard) margins could result bigger vertical
spaces around the table.

Quasi regression from commit c46950fee11f5207fb8324947280cd565ae483e7
"tdf#143583 DOCX import: fix lost empty paragraphs of footnotes"
(before this commit, empty paragraphs at the end of the footnotes
were removed by accident, which hid the real problem fixed now).

See also commit e11c51eefe8c3210cef2b5850f401ba67a401d01
"tdf#95806 tdf#125877 tdf#141172 DOCX: fix tables in footnotes"
(Note: before this commit, only a single table was shown instead
of the eight tables of the eight footnotes.)

Change-Id: I4180a6f7d7c49faf0842637b23aa1c8c5680a76c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133752
Tested-by: Jenkins
Reviewed-by: László Németh 
(cherry picked from commit d1ac8df139a2a65db45d1970ccc0b80e17d827f6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133728

diff --git a/sw/qa/extras/ooxmlexport/data/tdf146346.docx 
b/sw/qa/extras/ooxmlexport/data/tdf146346.docx
new file mode 100644
index ..846a33e9ae56
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf146346.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index a8e416951a8c..ffa1968648ef 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1245,6 +1245,15 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf143583)
 assertXPath(pXml, "/w:footnotes/w:footnote[6]/w:p", 3);
 }
 
+// skip test for macOS (missing fonts?)
+#if !defined(MACOSX)
+DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx")
+{
+// This was 2 (by bad docDefault vertical margins around tables in 
footnotes)
+CPPUNIT_ASSERT_EQUAL(1, getPages());
+}
+#endif
+
 DECLARE_OOXMLEXPORT_TEST(testContSectBreakHeaderFooter, 
"cont-sect-break-header-footer.docx")
 {
 // Load a document with a continuous section break on page 2.
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index dabdff851a9c..34058d9c4702 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1468,9 +1468,26 @@ void SectionPropertyMap::CloseSectionGroup( 
DomainMapper_Impl& rDM_Impl )
 }
 }
 
-xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd,
+const uno::Reference< text::XTextContent >& xTextContent =
+xBodyText->convertToTextFrame(rInfo.m_xStart, 
rInfo.m_xEnd,
   rInfo.m_aFrameProperties);
 
+// paragraph of the anchoring point of the floating table 
needs zero top and bottom
+// margins, if the table was a not floating table in the 
footnote, otherwise
+// docDefault margins could result bigger vertical spaces 
around the table
+if ( rInfo.m_bConvertToFloatingInFootnote && xTextContent.is() 
)
+{
+uno::Reference xParagraph(
+xTextContent->getAnchor(), uno::UNO_QUERY);
+if ( xParagraph.is() )
+{
+xParagraph->setPropertyValue("ParaTopMargin",
+uno::makeAny(static_cast(0)));
+xParagraph->setPropertyValue("ParaBottomMargin",
+uno::makeAny(static_cast(0)));
+}
+}
+
 uno::Reference 
xTextDocument(rDM_Impl.GetTextDocument(), uno::UNO_QUERY);
 uno::Reference xTables = 
xTextDocument->getTextTables();
 for( size_t i = 0; i < aFramedRedlines.size(); i+=3)


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

2022-04-27 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf148515.rtf |   14 ++
 sw/qa/extras/rtfexport/rtfexport4.cxx |   19 +++
 writerfilter/source/rtftok/rtfsprm.cxx|2 +-
 3 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit b6deb063ac182b631dc9b61b4baca18744794ab1
Author: Vasily Melenchuk 
AuthorDate: Thu Apr 21 10:04:50 2022 +0300
Commit: Xisco Fauli 
CommitDate: Wed Apr 27 10:45:33 2022 +0200

tdf#148515: RTF filter: do not use char prop defaults for tables

During deduplication of table row (when nStyleType == 0) we should
not deduplicate character properties against default style: this
leads to invalid default settings for table rows/cells.

Attempts to do so are already made during \pard processing when
default style is checked if it is paragraph style. But this is
not enough: style definition can contain paragraph and character
properties as well.

Change-Id: If520c5a248897728b7de08a017136ca1a01a5f13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132943
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 3a05acb8f0d94728ea6cbfd7a69dac6ffa7ffc68)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133477
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/rtfexport/data/tdf148515.rtf 
b/sw/qa/extras/rtfexport/data/tdf148515.rtf
new file mode 100644
index ..f8e27e577425
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf148515.rtf
@@ -0,0 +1,14 @@
+{\rtf1\ansi
+{\fonttbl
+{\f1 Impact;}
+}
+
+{\stylesheet
+{\fs20\f1\af1 Normal;}
+}
+
+\trowd\cellx5000\cellx1
+\pard\intbl\f1\fs10 XX\cell
+\pard\intbl\cell
+\row
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx 
b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 31469fc0ef02..0a39524f24d3 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -602,6 +602,25 @@ DECLARE_RTFEXPORT_TEST(testTdf139948, "tdf139948.rtf")
 sal_uInt32(0), getProperty(getParagraph(5), 
"BottomBorder").LineWidth);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf148515, "tdf148515.rtf")
+{
+uno::Reference xTable(getParagraphOrTable(1), 
uno::UNO_QUERY);
+
+uno::Reference xCell1(xTable->getCellByName("A1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("XX"), xCell1->getString());
+CPPUNIT_ASSERT_EQUAL(
+5.0f,
+getProperty(getRun(getParagraphOfText(1, xCell1->getText()), 
1), "CharHeight"));
+
+uno::Reference xCell2(xTable->getCellByName("B1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString(""), xCell2->getString());
+CPPUNIT_ASSERT_EQUAL(
+5.0f,
+getProperty(getRun(getParagraphOfText(1, xCell2->getText()), 
1), "CharHeight"));
+
+CPPUNIT_ASSERT_EQUAL(10.f, getProperty(getRun(getParagraph(2), 1), 
"CharHeight"));
+}
+
 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 04df49bc0287..2edfec829edf 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -159,7 +159,7 @@ void RTFSprms::eraseLast(Id nKeyword)
 
 static RTFValue::Pointer_t getDefaultSPRM(Id const id, Id nStyleType)
 {
-if (!nStyleType || nStyleType == NS_ooxml::LN_Value_ST_StyleType_character)
+if (nStyleType == NS_ooxml::LN_Value_ST_StyleType_character)
 {
 switch (id)
 {


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

2022-04-26 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf139948.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   26 +
 sw/qa/extras/rtfexport/data/tdf139948.rtf |8 +
 sw/qa/extras/rtfexport/rtfexport4.cxx |   32 ++
 writerfilter/source/dmapper/DomainMapper.cxx  |   11 ++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   25 +
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |3 ++
 writerfilter/source/dmapper/PropertyIds.cxx   |1 
 writerfilter/source/dmapper/PropertyIds.hxx   |1 
 writerfilter/source/rtftok/rtfdispatchflag.cxx|4 ++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx|5 ++-
 11 files changed, 113 insertions(+), 3 deletions(-)

New commits:
commit 537b2616b9c8639b2f1108047f39693ac6bd5500
Author: Vasily Melenchuk 
AuthorDate: Fri Apr 1 16:35:40 2022 +0300
Commit: Xisco Fauli 
CommitDate: Tue Apr 26 14:20:42 2022 +0200

tdf#139948: docx and rtf import: emulate border in between

Writer does not support border in between available in all MS
formats. Since this feature is missing in core it will be
better to emulate it with top borders than to ignore it
completely.

Change-Id: I4e5a99cde5908066c4bb483136cfe9a1316df53c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132429
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit e3a996bf72a16f5b22e6ff021745af5cec70a632)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132594
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf139948.docx 
b/sw/qa/extras/ooxmlexport/data/tdf139948.docx
new file mode 100644
index ..1b3f7df00031
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf139948.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index c0b693247828..41c188a3532e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -260,6 +260,32 @@ DECLARE_OOXMLEXPORT_TEST(testTdf81507, "tdf81507.docx")
 xmlXPathFreeObject(pXmlObj);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf139948, "tdf139948.docx")
+{
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(0),
+getProperty(getParagraph(1, "No border"), 
"TopBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(0),
+getProperty(getParagraph(2, "Border below"), 
"TopBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(88),
+getProperty(getParagraph(3, "Borders below and 
above"), "TopBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(88),
+getProperty(getParagraph(4, "Border above"), 
"TopBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(0),
+getProperty(getParagraph(5, "No border"), 
"TopBorder").LineWidth);
+
+
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(0),
+getProperty(getParagraph(1), 
"BottomBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(0),
+getProperty(getParagraph(2), 
"BottomBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(0),
+getProperty(getParagraph(3), 
"BottomBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(0),
+getProperty(getParagraph(4), 
"BottomBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_uInt32(0),
+getProperty(getParagraph(5), 
"BottomBorder").LineWidth);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf144563, "tdf144563.docx")
 {
 uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
diff --git a/sw/qa/extras/rtfexport/data/tdf139948.rtf 
b/sw/qa/extras/rtfexport/data/tdf139948.rtf
new file mode 100644
index ..0b601a764adf
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf139948.rtf
@@ -0,0 +1,8 @@
+{\rtf1\ansi
+No border\par
+\pard\brdrbtw\brdrs\brdrw50 
+Border below\par
+Borders below and above\par
+Border above\par
+\pard No border\par
+}
\ No newline at end of file
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx 
b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 33a2a246a181..31469fc0ef02 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -570,6 +570,38 @@ DECLARE_RTFEXPORT_TEST(testTdf111851, "tdf111851.rtf")
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xCell6, 
"BackColor"));
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf139948, "tdf139948.rtf")
+{
+CPPUNIT_ASSERT_EQUAL(
+sal_uInt32(0),
+getProperty(getParagraph(1, "No border"), 
"TopBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(
+sal_uInt32(0),
+getProperty(getParagraph(2, "Border below"), 
"TopBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(
+sal_uInt32(88),
+getProperty(getParagraph(3, "Borders below and 
above"), "TopBorder")
+.LineWidth);
+CPPUNIT_ASSERT_EQUAL(
+sal_uInt32(88),
+getProperty(getParagraph(4, "Border above"), 
"TopBorder").LineWidth);
+CPPUNIT_ASSERT_EQUAL(
+sal_uInt32(0),
+   

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

2022-04-11 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf95706_2.rtf  |   17 ++
 sw/qa/extras/rtfexport/rtfexport4.cxx   |   12 +
 writerfilter/source/rtftok/rtfdispatchvalue.cxx |4 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx  |  162 +---
 writerfilter/source/rtftok/rtfdocumentimpl.hxx  |1 
 5 files changed, 122 insertions(+), 74 deletions(-)

New commits:
commit 8daac72b7a0b7cdf6eb520273829c0c0c15ddef5
Author: Vasily Melenchuk 
AuthorDate: Thu Apr 7 20:59:08 2022 +0300
Commit: Xisco Fauli 
CommitDate: Mon Apr 11 11:53:51 2022 +0200

tdf#95706: RTF import: tolerant font table parsing

While font name in font table should end with semicolon
({\fonttbl{\f42 Arial;}}) it is not always true and
MS Word is tolerant to it: it still able to parse this
correctly. Seems LO also should not require strict spec
conformance.

So idea of font parsing is changed: instead of inserting
font on semicolon, it is done on next \fN or destination
end. All collected text to this moment is a font name.

Change-Id: I6b41951217442a71fd2ebbfc58a3fc79f6f913db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132686
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 844be7358f1eec00094a55fa1fb4fadadb8cd1bf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132699
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/rtfexport/data/tdf95706_2.rtf 
b/sw/qa/extras/rtfexport/data/tdf95706_2.rtf
new file mode 100644
index ..d36d2ccd2396
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf95706_2.rtf
@@ -0,0 +1,17 @@
+{\rtf\ansi
+{\fonttbl
+{\f1 Arial}
+\f2 Impact
+\f3 T\'69mes New Roman
+\f4 T
+a
+h
+o
+m
+a
+}
+\pard\f1\fs26 Arial\par
+\pard\f2\fs26 Impact\par
+\pard\f3\fs26 Times New Roman\par
+\pard\f4\fs26 Tahoma\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx 
b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 1f1434054085..33a2a246a181 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -522,6 +522,18 @@ DECLARE_RTFEXPORT_TEST(testTdf95706, "tdf95706.rtf")
 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun16, 
"CharFontName"));
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf95706_2, "tdf95706_2.rtf")
+{
+CPPUNIT_ASSERT_EQUAL(OUString("Arial"),
+ getProperty(getRun(getParagraph(1), 1), 
"CharFontName"));
+CPPUNIT_ASSERT_EQUAL(OUString("Impact"),
+ getProperty(getRun(getParagraph(2), 1), 
"CharFontName"));
+CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"),
+ getProperty(getRun(getParagraph(3), 1), 
"CharFontName"));
+CPPUNIT_ASSERT_EQUAL(OUString("Tahoma"),
+ getProperty(getRun(getParagraph(4), 1), 
"CharFontName"));
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf111851, "tdf111851.rtf")
 {
 uno::Reference xTable(getParagraphOrTable(1), 
uno::UNO_QUERY);
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx 
b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index d78f087d76e3..35d3e0128c84 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -762,6 +762,10 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword 
nKeyword, int nParam)
 if (m_aStates.top().getDestination() == Destination::FONTTABLE
 || m_aStates.top().getDestination() == Destination::FONTENTRY)
 {
+// Some text in buffer? It is font name. So previous font 
definition is complete
+if (m_aStates.top().getCurrentDestinationText()->getLength())
+handleFontTableEntry();
+
 m_aFontIndexes.push_back(nParam);
 m_nCurrentFontIndex = getFontIndex(nParam);
 }
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 8ea858abada5..9e77cbf4602e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1332,6 +1332,74 @@ void RTFDocumentImpl::singleChar(sal_uInt8 nValue, bool 
bRunProps)
 }
 }
 
+void RTFDocumentImpl::handleFontTableEntry()
+{
+OUString aName = 
m_aStates.top().getCurrentDestinationText()->makeStringAndClear();
+
+if (aName.isEmpty())
+return;
+
+if (aName.endsWith(";"))
+{
+aName = aName.copy(0, aName.getLength() - 1);
+}
+
+// Old documents can contain no encoding information in fontinfo,
+// but there can be font name suffixes: Arial CE is not a special
+// font, it is ordinal Arial, but with used cp 1250 encoding.
+// Moreover these suffixes have priority over \cpgN and \fcharsetN
+// in MS Word.
+OUString aFontSuffix;
+OUString aNameNoSuffix(aName);
+sal_Int32 nLastSpace = aName.lastIndexOf(' ');
+if (nLastSpace >= 0)
+{
+aFontSuffix = aName.copy(nLastSpace + 1);
+   

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

2022-04-08 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf95706.rtf   |   36 ++
 sw/qa/extras/rtfexport/rtfexport4.cxx  |   61 +
 writerfilter/source/rtftok/rtfcharsets.cxx |9 +++
 writerfilter/source/rtftok/rtfcharsets.hxx |   13 +
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   39 +++
 5 files changed, 156 insertions(+), 2 deletions(-)

New commits:
commit d72dece2bc61e3bab8db5968d53dc0e98a3bea4d
Author: Vasily Melenchuk 
AuthorDate: Tue Apr 5 19:13:05 2022 +0300
Commit: Miklos Vajna 
CommitDate: Fri Apr 8 11:20:10 2022 +0200

tdf#95706: RTF import: Use fontname suffixes to detect encoding

Font names like "Arial CE", "Times New Roman Cyr" are not special
fonts. They are classical Arial, Times New Roman... And these
suffixes can be used to detect encoding used for RTF text.

Most interesting: for MS Word these suffixes have priority:
{\f34\cpg1253\fcharset161 Arial Baltic;} will have cp1257
and not cp1253.

Looks like compatibility issue came from dark ages.

Change-Id: Ife8e781d5d04c3f6a8c11fcf604357c74bf33055
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132584
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132681
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/rtfexport/data/tdf95706.rtf 
b/sw/qa/extras/rtfexport/data/tdf95706.rtf
new file mode 100644
index ..64c97930441d
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf95706.rtf
@@ -0,0 +1,36 @@
+{\rtf\ansi
+{\fonttbl
+{\f1 Arial Baltic;}
+{\f2 Arial CE;}
+{\f3 Arial Cyr;}
+{\f4 Arial Greek;}
+{\f5 Arial Tur;}
+{\f6 Arial (Hebrew);}
+{\f7 Arial (Arabic);}
+{\f8 Arial (Vietnamese);}
+{\f9 Arial BlaBlaBla;}
+
+{\f10\cpg1253\fcharset161 Arial;}
+{\f11\fcharset161 Arial;}
+{\f12\cpg1253 Arial;}
+{\f13\cpg1253\fcharset161 Arial Baltic;}
+{\f14 Arial Baltic;\cpg1253\fcharset161}
+
+}
+\pard Font name suffixes:\par
+\pard\f1\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f2\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f3\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f4\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f5\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f6\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f7\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f8\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f9\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard Font entry charset values:\par
+\pard\f10\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f11\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f12\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f13\fs26 \'c0\'c1\'c2\'c3\'c4\par
+\pard\f14\fs26 \'c0\'c1\'c2\'c3\'c4\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx 
b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 32f1a5f88cad..1f1434054085 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -461,6 +461,67 @@ CPPUNIT_TEST_FIXTURE(Test, testGutterTop)
 CPPUNIT_ASSERT(bGutterAtTop);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf95706, "tdf95706.rtf")
+{
+uno::Reference xRun2
+= getRun(getParagraph(2), 1, u"\u0104\u012e\u0100\u0106\u00c4");
+CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun2, 
"CharFontName"));
+
+uno::Reference xRun3
+= getRun(getParagraph(3), 1, u"\u0154\u00c1\u00c2\u0102\u00c4");
+CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun3, 
"CharFontName"));
+
+uno::Reference xRun4
+= getRun(getParagraph(4), 1, u"\u0410\u0411\u0412\u0413\u0414");
+CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun4, 
"CharFontName"));
+
+uno::Reference xRun5
+= getRun(getParagraph(5), 1, u"\u0390\u0391\u0392\u0393\u0394");
+CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun5, 
"CharFontName"));
+
+uno::Reference xRun6
+= getRun(getParagraph(6), 1, u"\u00c0\u00c1\u00c2\u00c3\u00c4");
+CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun6, 
"CharFontName"));
+
+uno::Reference xRun7
+= getRun(getParagraph(7), 1, u"\u05b0\u05b1\u05b2\u05b3\u05b4");
+// Do not check font for Hebrew: it can be substituted by smth able to 
handle these chars
+//CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun7, 
"CharFontName"));
+
+uno::Reference xRun8
+= getRun(getParagraph(8), 1, u"\u06c1\u0621\u0622\u0623\u0624");
+// Do not check font for Arabic: it can be substituted by smth able to 
handle these chars
+//CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun8, 
"CharFontName"));
+
+uno::Reference xRun9
+= getRun(getParagraph(9), 1, u"\u00c0\u00c1\u00c2\u0102\u00c4");
+CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun9, 
"CharFontName"));
+
+// Ensure strange font remains strange. No reason to check content: in 
this case it can vary on locale
+uno::Reference xRun10 = getRun(getParagraph(10), 1);
+CPPUNIT_ASSERT_EQUAL(OUString("Arial BlaBlaBla"),
+ getProperty(xRun10, "CharFontName"));
+
+

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

2022-04-06 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf148361.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   16 
 writerfilter/source/dmapper/SdtHelper.cxx|   20 ++--
 writerfilter/source/dmapper/SdtHelper.hxx|3 +++
 4 files changed, 33 insertions(+), 6 deletions(-)

New commits:
commit 2d1bd913d9f896d55c03dd509eb11c81667c5436
Author: Vasily Melenchuk 
AuthorDate: Mon Apr 4 18:05:18 2022 +0300
Commit: Xisco Fauli 
CommitDate: Wed Apr 6 09:34:49 2022 +0200

tdf#148361: docx sdt: cleanup databinding data after inserting

Databinding data is used only for current sdt block. It should
be clean up after usage to avoid impact on next sdt blocks.

Change-Id: I53f47dd655ed027d40eb518784dcae69813e612f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132524
Tested-by: Jenkins
Tested-by: Xisco Fauli 
Reviewed-by: Vasily Melenchuk 
(cherry picked from commit fafadd7aee8c384af210008f693b5007a9f5ea48)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132595
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148361.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148361.docx
new file mode 100644
index ..ecf9a5f0087c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148361.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 370989a9d6b7..51f0d9fb9345 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -143,6 +143,22 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, 
"tdf123642.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("Bookmark1"), getXPath(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:bookmarkStart[1]", "name"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148361, "tdf148361.docx")
+{
+// Refresh fields and ensure cross-reference to numbered para is okay
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xFieldsAccess(xTextFieldsSupplier->getTextFields());
+
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+CPPUNIT_ASSERT(xFields->hasMoreElements());
+
+uno::Reference xTextField1(xFields->nextElement(), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("itadmin"), 
xTextField1->getPresentation(false));
+
+uno::Reference xTextField2(xFields->nextElement(), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("[Type text]"), 
xTextField2->getPresentation(false));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf142407, "tdf142407.docx")
 {
 uno::Reference xPageStyles = 
getStyles("PageStyles");
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index 576d63d430c6..f4b02fab4d02 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -264,8 +264,7 @@ void SdtHelper::createDropDownControl()
 }
 
 // clean up
-m_aDropDownItems.clear();
-setControlType(SdtControlType::unknown);
+clear();
 }
 
 void SdtHelper::createPlainTextControl()
@@ -296,8 +295,7 @@ void SdtHelper::createPlainTextControl()
uno::makeAny(getInteropGrabBagAndClear()));
 
 // clean up
-m_aDropDownItems.clear();
-setControlType(SdtControlType::unknown);
+clear();
 }
 
 void SdtHelper::createDateContentControl()
@@ -372,11 +370,11 @@ void SdtHelper::createDateContentControl()
 uno::UNO_QUERY);
 xRefreshable->refresh();
 
-setControlType(SdtControlType::unknown);
-
 // Store all unused sdt parameters from grabbag
 xNameCont->insertByName(UNO_NAME_MISC_OBJ_INTEROPGRABBAG,
 uno::makeAny(getInteropGrabBagAndClear()));
+
+clear();
 }
 
 void SdtHelper::createControlShape(awt::Size aSize,
@@ -423,6 +421,16 @@ bool SdtHelper::containedInInteropGrabBag(const OUString& 
rValueName)
 [](const beans::PropertyValue& i) { return i.Name == 
rValueName; });
 }
 
+void SdtHelper::clear()
+{
+m_aDropDownItems.clear();
+setControlType(SdtControlType::unknown);
+m_sDataBindingPrefixMapping.clear();
+m_sDataBindingXPath.clear();
+m_sDataBindingStoreItemID.clear();
+m_aGrabBag.clear();
+}
+
 } // namespace writerfilter::dmapper
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/SdtHelper.hxx 
b/writerfilter/source/dmapper/SdtHelper.hxx
index e58d73168d79..d9a6115a1251 100644
--- a/writerfilter/source/dmapper/SdtHelper.hxx
+++ b/writerfilter/source/dmapper/SdtHelper.hxx
@@ -102,6 +102,9 @@ class SdtHelper final : public virtual SvRefBase
 
 void loadPropertiesXMLs();
 
+/// Clear all collected attributes for futher reuse
+void clear();
+
 public:
 explicit SdtHelper(DomainMapper_Impl& rDM_Impl,
css::uno::Reference const& 
xContext);


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

2022-03-28 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf148111.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   28 +++
 writerfilter/source/dmapper/SdtHelper.cxx|3 +-
 3 files changed, 30 insertions(+), 1 deletion(-)

New commits:
commit cebca5086b42ff9462d8c6f8ed2344a0138b2f4a
Author: Vasily Melenchuk 
AuthorDate: Fri Mar 25 11:14:10 2022 +0300
Commit: Xisco Fauli 
CommitDate: Mon Mar 28 11:32:10 2022 +0200

tdf#148111: docx std fields: use placeholder text for empty data

It is quite unexpected Word behavior: if data source for sdt field
exists but contains empty string it is not used. Placeholder is
inserted instead.

In general behavior is more complex: logic of replacement is defined
by  property and results can vary (see testcase).
But LO does not support this property correctly yet.

Change-Id: I2ec8efe05f79a01af5d74d21bfcd05f3b19e3970
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132096
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 9d033508af5257aeebbd8c22a053db5e74a814d3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132050
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148111.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148111.docx
new file mode 100644
index ..a46fb508dc0e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148111.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 9937d86b0f88..ea1d894f67ad 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -181,6 +181,34 @@ DECLARE_OOXMLEXPORT_TEST(testTdf146851_2, 
"tdf146851_2.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("Schedule"), 
xTextField->getPresentation(false));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148111, "tdf148111.docx")
+{
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xFieldsAccess(xTextFieldsSupplier->getTextFields());
+
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+std::vector aExpectedValues = {
+// These field values are NOT in order in document: getTextFields did 
provide
+// fields in a strange but fixed order
+"Title", "Placeholder", "Placeholder", "Placeholder",
+"Placeholder", "Placeholder", "Placeholder", "Placeholder",
+"Placeholder", "Placeholder", "Placeholder", "Placeholder",
+"Placeholder", "Placeholder", "Placeholder", "Placeholder",
+"Placeholder", "Title", "Title", "Title",
+"Title", "Title", "Title", "Title"
+};
+
+sal_uInt16 nIndex = 0;
+while (xFields->hasMoreElements())
+{
+uno::Reference xTextField(xFields->nextElement(), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(aExpectedValues[nIndex++], 
xTextField->getPresentation(false));
+}
+
+// No more fields
+CPPUNIT_ASSERT(!xFields->hasMoreElements());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf81507, "tdf81507.docx")
 {
 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index c5ec47f2be23..576d63d430c6 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -197,7 +197,8 @@ std::optional SdtHelper::getValueFromDataBinding()
 {
 uno::Reference xResult = xXpathAPI->eval(xDocument, 
m_sDataBindingXPath);
 
-if (xResult.is() && xResult->getNodeList() && 
xResult->getNodeList()->getLength())
+if (xResult.is() && xResult->getNodeList() && 
xResult->getNodeList()->getLength()
+&& xResult->getString().getLength())
 {
 return xResult->getString();
 }


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

2022-03-25 Thread Caolán McNamara (via logerrit)
 sw/qa/core/data/rtf/fail/forcepoint-82.rtf   |   28 +++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |2 +
 2 files changed, 30 insertions(+)

New commits:
commit 2cc8d314123353c5fb9ece2fefd82fb3bce25ec2
Author: Caolán McNamara 
AuthorDate: Wed Mar 23 10:45:15 2022 +
Commit: Xisco Fauli 
CommitDate: Fri Mar 25 09:58:03 2022 +0100

forcepoint#82 back() called on empty vector

Change-Id: I801a58f1fef41d1545899868e333c2184c5c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131866
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/core/data/rtf/fail/forcepoint-82.rtf 
b/sw/qa/core/data/rtf/fail/forcepoint-82.rtf
new file mode 100644
index ..54b1dee42c5b
--- /dev/null
+++ b/sw/qa/core/data/rtf/fail/forcepoint-82.rtf
@@ -0,0 +1,28 @@
+{\rtf1
+{\trowd
+\clbrdrl\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\clbrdrt\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\cellx2000
+\pard
+Text 1
+\itap0
+\cell
+\row}
+\pard
+\par
+\itap0
+{\trowd
+\clbrdrl\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\clbrdrt\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\cellx2000
+\pard
+Text 2
+\itap0
+\cell
+\row}
+\itap-1
+{\trowd
+\clbrdrl\brdrs\brdrw2147483649\clbrdrr\brdrs\brdrw9\clbrdrt\brdrs\brdrw10\clPbrdrb\brdrs\brdrw185\cellx1000
+\nestro)w}
+\itap0
+\cell
+\row}
+\itap0
+\par
+}
\ No newline at end of file
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx 
b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 3b927642348d..127f9b067c4d 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -387,6 +387,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
 
 DomainMapperTableManager::IntVectorPtr const & 
DomainMapperTableManager::getCurrentGrid( )
 {
+if (m_aTableGrid.empty())
+throw std::out_of_range("no current grid");
 return m_aTableGrid.back( );
 }
 


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

2022-03-23 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf111851.rtf   |   17 +++
 sw/qa/extras/rtfexport/rtfexport4.cxx   |   36 ++
 writerfilter/source/rtftok/rtfdispatchvalue.cxx |  136 ++--
 3 files changed, 111 insertions(+), 78 deletions(-)

New commits:
commit ca26781a82b8155c40f850557f7399b0543fcc1a
Author: Vasily Melenchuk 
AuthorDate: Tue Mar 22 14:02:35 2022 +0300
Commit: Xisco Fauli 
CommitDate: Wed Mar 23 12:23:09 2022 +0100

tdf#111851: rtf import: fifty shades of grey

Unlike in DOCX in RTF token \clshdngN can represent much more
transitional cell shade values from 0 (white) to 1 (black).
So we should not match these values strictly but use ranges
instead.

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

diff --git a/sw/qa/extras/rtfexport/data/tdf111851.rtf 
b/sw/qa/extras/rtfexport/data/tdf111851.rtf
new file mode 100644
index ..242354364e76
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf111851.rtf
@@ -0,0 +1,17 @@
+{\rtf
+
+\trowd
+\clshdng-2\cellx200
+\clshdng0\cellx400
+\clshdng666\cellx600
+\clshdng3275\cellx800
+\clshdng1\cellx1000
+\clshdng2\cellx1200
+\intbl a\cell
+\intbl b\cell
+\intbl c\cell
+\intbl d\cell
+\intbl e\cell
+\intbl f\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 1b29939ac4fc..55ae121a695b 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -431,6 +431,42 @@ CPPUNIT_TEST_FIXTURE(Test, testGutterTop)
 CPPUNIT_ASSERT(bGutterAtTop);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf111851, "tdf111851.rtf")
+{
+uno::Reference xTable(getParagraphOrTable(1), 
uno::UNO_QUERY);
+
+// No shading
+uno::Reference xCell1(xTable->getCellByName("A1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell1->getString());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty(xCell1, 
"BackColor"));
+
+uno::Reference xCell2(xTable->getCellByName("B1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("b"), xCell2->getString());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty(xCell2, 
"BackColor"));
+
+// Check some random not standard shading values and ensure some non-white 
background color
+uno::Reference xCell3(xTable->getCellByName("C1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("c"), xCell3->getString());
+sal_Int32 nShadingColor3 = getProperty(xCell3, "BackColor");
+CPPUNIT_ASSERT(0x00FF > nShadingColor3);
+CPPUNIT_ASSERT(0 < nShadingColor3);
+
+uno::Reference xCell4(xTable->getCellByName("D1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("d"), xCell4->getString());
+sal_Int32 nShadingColor4 = getProperty(xCell4, "BackColor");
+CPPUNIT_ASSERT(0x00FF > nShadingColor4);
+CPPUNIT_ASSERT(0 < nShadingColor4);
+
+// Values 1 and more - black
+uno::Reference xCell5(xTable->getCellByName("E1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("e"), xCell5->getString());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xCell5, 
"BackColor"));
+
+uno::Reference xCell6(xTable->getCellByName("F1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("f"), xCell6->getString());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xCell6, 
"BackColor"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx 
b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index 14d0b3993a54..d78f087d76e3 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -485,84 +485,64 @@ bool RTFDocumentImpl::dispatchTableValue(RTFKeyword 
nKeyword, int nParam)
 case RTFKeyword::CLSHDNG:
 {
 int nValue = -1;
-switch (nParam)
-{
-case 500:
-nValue = NS_ooxml::LN_Value_ST_Shd_pct5;
-break;
-case 1000:
-nValue = NS_ooxml::LN_Value_ST_Shd_pct10;
-break;
-case 1200:
-nValue = NS_ooxml::LN_Value_ST_Shd_pct12;
-break;
-case 1500:
-nValue = NS_ooxml::LN_Value_ST_Shd_pct15;
-break;
-case 2000:
-nValue = NS_ooxml::LN_Value_ST_Shd_pct20;
-break;
-case 2500:
-nValue = NS_ooxml::LN_Value_ST_Shd_pct25;
-break;
-case 3000:
-nValue = NS_ooxml::LN_Value_ST_Shd_pct30;
-break;
-case 

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

2022-03-22 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf104390.rtf  |6 ++
 sw/qa/extras/rtfexport/rtfexport5.cxx  |   15 +++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   20 +---
 3 files changed, 34 insertions(+), 7 deletions(-)

New commits:
commit 07ab51a3ac3d2c2af417c950d095c1fba49ab2a9
Author: Vasily Melenchuk 
AuthorDate: Mon Mar 21 17:12:12 2022 +0300
Commit: Xisco Fauli 
CommitDate: Tue Mar 22 14:28:21 2022 +0100

tdf#104390: rtf import: init default font for entire state stack

If first document element is buried deep in destinations and thus
deep in state stack (m_aStates) initialization of default font
is very local and will be lost after closing these destinations.

So let's initialize entire states stack with default font if none
is provided istead of initialization just a top element.

Change-Id: I966c282f43b84baece909a4c3cd359cbcd317e63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131906
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 24b5490cb0fd8de19415509fbf452874669106ad)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131864
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/rtfexport/data/tdf104390.rtf 
b/sw/qa/extras/rtfexport/data/tdf104390.rtf
new file mode 100644
index ..842e73e19a85
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf104390.rtf
@@ -0,0 +1,6 @@
+{\rtf1\deff0
+{\fonttbl
+{\f0 Courier New;}}
+\fs72
+Hello }}}{World!}}
+}
\ No newline at end of file
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx 
b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 36bf6c839b65..297635fce37e 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -1339,6 +1339,21 @@ DECLARE_RTFEXPORT_TEST(testTdf118047, "tdf118047.rtf")
 CPPUNIT_ASSERT_MESSAGE("Header is too large", 1000 > nHeight);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf104390, "tdf104390.rtf")
+{
+uno::Reference xPara = getParagraph(1);
+uno::Reference xRunEnumAccess(xPara, 
uno::UNO_QUERY);
+uno::Reference xRunEnum = 
xRunEnumAccess->createEnumeration();
+
+// Check font in first run
+uno::Reference xRun(xRunEnum->nextElement(), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(36.f, getProperty(xRun, "CharHeight"));
+CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty(xRun, 
"CharFontName"));
+
+// Ensure there is only one run
+CPPUNIT_ASSERT_MESSAGE("Extra elements in paragraph", 
!xRunEnum->hasMoreElements());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 072430ebe15f..af4ba47158c3 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -397,16 +397,22 @@ void RTFDocumentImpl::checkFirstRun()
 assert(!m_bNeedSect || m_bFirstRunException);
 setNeedSect(true); // first call that succeeds
 
-// set the requested default font, if there are none
+// set the requested default font, if there are none for each state in 
stack
 RTFValue::Pointer_t pFont
 = getNestedAttribute(m_aDefaultState.getCharacterSprms(), 
NS_ooxml::LN_EG_RPrBase_rFonts,
  NS_ooxml::LN_CT_Fonts_ascii);
-RTFValue::Pointer_t pCurrentFont
-= getNestedAttribute(m_aStates.top().getCharacterSprms(), 
NS_ooxml::LN_EG_RPrBase_rFonts,
- NS_ooxml::LN_CT_Fonts_ascii);
-if (pFont && !pCurrentFont)
-putNestedAttribute(m_aStates.top().getCharacterSprms(), 
NS_ooxml::LN_EG_RPrBase_rFonts,
-   NS_ooxml::LN_CT_Fonts_ascii, pFont);
+if (!pFont)
+return;
+
+for (size_t i = 0; i < m_aStates.size(); i++)
+{
+RTFValue::Pointer_t pCurrentFont
+= getNestedAttribute(m_aStates[i].getCharacterSprms(), 
NS_ooxml::LN_EG_RPrBase_rFonts,
+ NS_ooxml::LN_CT_Fonts_ascii);
+if (!pCurrentFont)
+putNestedAttribute(m_aStates[i].getCharacterSprms(), 
NS_ooxml::LN_EG_RPrBase_rFonts,
+   NS_ooxml::LN_CT_Fonts_ascii, pFont);
+}
 }
 
 void RTFDocumentImpl::setNeedPar(bool bNeedPar) { m_bNeedPar = bNeedPar; }


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

2022-03-22 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf118047.rtf  |   14 
 sw/qa/extras/rtfexport/rtfexport5.cxx  |   15 +
 writerfilter/source/rtftok/rtfdispatchflag.cxx |6 -
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   27 +
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |3 +-
 5 files changed, 47 insertions(+), 18 deletions(-)

New commits:
commit 462e1c7911d917a5edf2c963ad8b47115a607f52
Author: Vasily Melenchuk 
AuthorDate: Mon Mar 21 13:54:28 2022 +0300
Commit: Xisco Fauli 
CommitDate: Tue Mar 22 09:55:03 2022 +0100

tdf#118047: RTF import: better deduplication for header/footer

Here are two related fixes in one patch:

1. By default current style index is 0, not -1. Due to this we
can assume usage of default "Normal" style during deduplication.
Seems there is no difference in case of no style mentioning in
run or mentioning "Normal" one (\s0), so value -1 looks
unnesesary.

2. During header/footer "substreams" processing StyleTableEntires
was not reused in new domain mapper impl instance. So deduplication
did not work well.

2a. To avoid copying of whole StyleTableEntries between instances
it is stored as pointer in domain mapper impl.

Change-Id: Id003d35554e9b43186238920d9a6373452095121
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131899
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 79b5ff92b17fde902c2f9db3e806f1c77a387dff)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131862
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/rtfexport/data/tdf118047.rtf 
b/sw/qa/extras/rtfexport/data/tdf118047.rtf
new file mode 100644
index ..258d99de9bef
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf118047.rtf
@@ -0,0 +1,14 @@
+{\rtf1\ansi
+
+{\stylesheet
+{\fs72\sa3200 Normal;}
+}
+
+\sectd 
+{
+\headerr 
+Header\par
+}
+
+Text\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx 
b/sw/qa/extras/rtfexport/rtfexport5.cxx
index b9a7321d724b..36bf6c839b65 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -1324,6 +1324,21 @@ DECLARE_RTFEXPORT_TEST(testTdf131234, "tdf131234.rtf")
 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, 
getProperty(xRun, "CharPosture"));
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf118047, "tdf118047.rtf")
+{
+uno::Reference xPara = getParagraph(1);
+
+// Ensure that default "Normal" style properties are not applied to text:
+// text remains with fontsize 12pt and no huge margin below
+CPPUNIT_ASSERT_EQUAL(12.f, getProperty(getRun(xPara, 1), 
"CharHeight"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(getParagraph(1), 
"ParaBottomMargin"));
+
+// Same for header, it should not derive props from "Normal" style
+CPPUNIT_ASSERT_EQUAL(OUString("Header"), 
parseDump("/root/page[1]/header/txt/text()"));
+sal_Int32 nHeight = parseDump("/root/page[1]/header/infos/bounds", 
"height").toInt32();
+CPPUNIT_ASSERT_MESSAGE("Header is too large", 1000 > nHeight);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx 
b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 2acb4d59f977..83c5a0966259 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -520,12 +520,8 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
 {
 
m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle,
 new 
RTFValue(aName));
-m_aStates.top().setCurrentStyleIndex(0);
-}
-else
-{
-m_aStates.top().setCurrentStyleIndex(-1);
 }
+m_aStates.top().setCurrentStyleIndex(0);
 }
 // Need to send paragraph properties again, if there will be any.
 m_bNeedPap = true;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index fb331f4b265a..072430ebe15f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -324,6 +324,8 @@ 
RTFDocumentImpl::RTFDocumentImpl(uno::Reference const& x
 
 m_pTokenizer = new RTFTokenizer(*this, m_pInStream.get(), 
m_xStatusIndicator);
 m_pSdrImport = new RTFSdrImport(*this, m_xDstDoc);
+
+m_pStyleTableEntries = std::make_shared();
 }
 
 RTFDocumentImpl::~RTFDocumentImpl() = default;
@@ -363,6 +365,7 @@ void RTFDocumentImpl::resolveSubstream(std::size_t nPos, Id 
nId, OUString const&
 m_aAuthorInitials.clear();
 }
 pImpl->m_nDefaultFontIndex = m_nDefaultFontIndex;
+pImpl->m_pStyleTableEntries = m_pStyleTableEntries;
 pImpl->Strm().Seek(nPos);
 

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

2022-03-21 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf131234.rtf |   12 
 sw/qa/extras/rtfexport/rtfexport5.cxx |   17 +
 writerfilter/source/rtftok/rtfsprm.cxx|   12 
 3 files changed, 41 insertions(+)

New commits:
commit 39d4246652fd678ea47b315f433f279f08d61318
Author: Vasily Melenchuk 
AuthorDate: Sun Mar 20 08:48:17 2022 +0300
Commit: Xisco Fauli 
CommitDate: Mon Mar 21 17:22:47 2022 +0100

tdf#131234: RTF import: extend default char props list

There are much more character attributes should be applied
wth default values if style contain them, but they were
not mentioned in current run.

These are obviously not a complete set yet, but most common
ones are included.

Change-Id: Ide52245bc98628febc2f3bd2e25166f0dcdf35cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131853
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 494020efe6d29bc319c3abcd3245425e394674ec)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131857
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/rtfexport/data/tdf131234.rtf 
b/sw/qa/extras/rtfexport/data/tdf131234.rtf
new file mode 100644
index ..976987bee113
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf131234.rtf
@@ -0,0 +1,12 @@
+{\rtf1\ansi
+{\fonttbl
+{\f3 Tahoma;}
+}
+{\colortbl;\red123\green0\blue0;\red0\green0\blue255;}
+{\stylesheet
+{\s1\f3\fs64\cf2\b1\i1\ul1 Test112;}
+}
+
+\s1 Hello\par
+
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx 
b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 28daa538f677..b9a7321d724b 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -35,6 +35,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -1307,6 +1310,20 @@ DECLARE_RTFEXPORT_TEST(testTdf144437, "tdf144437.odt")
 CPPUNIT_ASSERT_MESSAGE("Bookmark start & end are wrong", nBmkEndPos > 
nBmkStartPos);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf131234, "tdf131234.rtf")
+{
+uno::Reference xRun = getRun(getParagraph(1), 1, 
OUString(u"Hello"));
+
+// Ensure that text has default font attrs in spite of style referenced
+// E.g. 12pt, Times New Roman, black, no bold, no italic, no underline
+CPPUNIT_ASSERT_EQUAL(12.f, getProperty(xRun, "CharHeight"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xRun, 
"CharColor"));
+CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), 
getProperty(xRun, "CharFontName"));
+CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty(xRun, 
"CharWeight"));
+CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE, 
getProperty(xRun, "CharUnderline"));
+CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, 
getProperty(xRun, "CharPosture"));
+}
+
 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 8c54fe95e345..04df49bc0287 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -163,8 +163,20 @@ static RTFValue::Pointer_t getDefaultSPRM(Id const id, Id 
nStyleType)
 {
 switch (id)
 {
+case NS_ooxml::LN_EG_RPrBase_szCs:
+case NS_ooxml::LN_EG_RPrBase_sz:
+return new RTFValue(24);
+case NS_ooxml::LN_CT_Color_val:
+return new RTFValue(0);
 case NS_ooxml::LN_EG_RPrBase_b:
+case NS_ooxml::LN_EG_RPrBase_i:
 return new RTFValue(0);
+case NS_ooxml::LN_CT_Underline_val:
+return new RTFValue(NS_ooxml::LN_Value_ST_Underline_none);
+case NS_ooxml::LN_CT_Fonts_ascii:
+case NS_ooxml::LN_CT_Fonts_eastAsia:
+case NS_ooxml::LN_CT_Fonts_cs:
+return new RTFValue("Times New Roman");
 default:
 break;
 }


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

2022-03-16 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf146851_1.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   11 +++
 writerfilter/source/dmapper/NumberingManager.cxx |9 ++---
 3 files changed, 17 insertions(+), 3 deletions(-)

New commits:
commit b6fed2ef5b5a30a3364eccec27991e26c86254ee
Author: Vasily Melenchuk 
AuthorDate: Thu Mar 10 12:04:20 2022 +0300
Commit: Xisco Fauli 
CommitDate: Wed Mar 16 11:44:17 2022 +0100

tdf#146851: writerfilter: do not recreate list levels on override

AddLevel() can be called on w:lvl and on w:lvlOverride. But if
we have level override and some extra level definition level is
recreated and override information is lost.

Change-Id: I6f1b9b50bdd3410b4ae2d403e760e4d6df5677d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131304
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131647
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf146851_1.docx 
b/sw/qa/extras/ooxmlexport/data/tdf146851_1.docx
new file mode 100644
index ..b4456bf40074
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf146851_1.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 52465ed66d90..d8e15116eb48 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -151,6 +151,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf142407, "tdf142407.docx")
 CPPUNIT_ASSERT_EQUAL( sal_Int16(36), nGridLines);   // was 23, left large 
space before text.
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf146851_1, "tdf146851_1.docx")
+{
+uno::Reference xPara;
+
+xPara.set(getParagraph(1, "qwerty"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty(xPara, 
"ListLabelString"));
+
+xPara.set(getParagraph(2, "asdfg"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("1/"), getProperty(xPara, 
"ListLabelString"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf81507, "tdf81507.docx")
 {
 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx 
b/writerfilter/source/dmapper/NumberingManager.cxx
index 8829aa52697f..1c79e0eece99 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -371,9 +371,12 @@ void AbstractListDef::AddLevel( sal_uInt16 nLvl )
 if ( nLvl >= m_aLevels.size() )
 m_aLevels.resize( nLvl+1 );
 
-ListLevel::Pointer pLevel( new ListLevel );
-m_pCurrentLevel = pLevel;
-m_aLevels[nLvl] = pLevel;
+if (!m_aLevels[nLvl])
+{
+m_aLevels[nLvl] = new ListLevel;
+}
+
+m_pCurrentLevel = m_aLevels[nLvl];
 }
 
 uno::Sequence> 
AbstractListDef::GetPropertyValues(bool bDefaults)


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

2022-03-03 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf146171.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx|4 ++--
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|   18 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   11 ++-
 4 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit 902e23d6e95f86a6ffbc642e57e35dcd27a6e83b
Author: László Németh 
AuthorDate: Wed Mar 2 16:41:04 2022 +0100
Commit: Xisco Fauli 
CommitDate: Thu Mar 3 17:18:21 2022 +0100

tdf#146171 DOCX: fix loss of change tracking, if no date

was specified, or it was specified as zero date (e.g. in
a LO DOCX export).

DateTime attribute w:date is optional in w:ins/w:del
according to the OOXML standard. Not specified w:date was
imported as invalid zero date "0-00-00T00:00:00Z" resulting
loss of change tracking data completely during an ODF
roundtrip.

Import this invalid zero date as Epoch time to avoid losing
change tracking data.

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf146171.docx 
b/sw/qa/extras/ooxmlexport/data/tdf146171.docx
new file mode 100644
index ..bdd534527a99
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf146171.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index d2922e940bf8..d39c1fdd6bcd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -933,8 +933,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf145720, "tdf104797.docx")
 // mandatory authors and dates
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "author", 
u"Tekijä");
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "author", u"Tekijä");
-assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "date", 
"0-00-00T00:00:00Z");
-assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "date", 
"0-00-00T00:00:00Z");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "date", 
"1970-01-01T00:00:00Z");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "date", 
"1970-01-01T00:00:00Z");
 }
 }
 
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index e3eb50c29ea4..78db013bc159 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -647,6 +647,24 @@ CPPUNIT_TEST_FIXTURE(Test, testTextframeHyperlink)
 assertXPath(pXmlDoc, "//w:pict/v:rect", "href", 
"https://libreoffice.org/;);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf146171_invalid_change_date)
+{
+load(mpTestDocumentPath, "tdf146171.docx");
+// false alarm? during ODF roundtrip:
+// 'Error: "1970-01-01" does not satisfy the "dateTime" type'
+// disable and check only the conversion of the invalid (zeroed) change 
date
+// reload("writer8", "tdf146171.odt");
+reload("Office Open XML Text", "tdf146171.docx");
+
+xmlDocUniquePtr pXmlDoc = parseExport();
+// This was 0
+assertXPath(pXmlDoc, "//w:ins", 4);
+// This was 0
+assertXPath(pXmlDoc, "//w:del", 1);
+// This was -00-00T00:00:00Z, resulting loss of change tracking during 
ODF roundtrip
+assertXPath(pXmlDoc, "//w:del", "date", "1970-01-01T00:00:00Z");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf139580, "tdf139580.odt")
 {
 // Without the fix in place, this test would have crashed at export time
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 13f1fb9056b9..8afcede51d13 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3144,7 +3144,16 @@ void 
DomainMapper_Impl::CreateRedline(uno::Reference const& xR
 pRedlineProperties[0].Name = getPropertyName( PROP_REDLINE_AUTHOR );
 pRedlineProperties[0].Value <<= pRedline->m_sAuthor;
 pRedlineProperties[1].Name = getPropertyName( PROP_REDLINE_DATE_TIME );
-pRedlineProperties[1].Value <<= 
ConversionHelper::ConvertDateStringToDateTime( pRedline->m_sDate );
+util::DateTime aDateTime = 
ConversionHelper::ConvertDateStringToDateTime( pRedline->m_sDate );
+// tdf#146171 import not specified w:date (or specified as zero date 
"0-00-00")
+// as Epoch time to avoid of losing change tracking data during ODF 
roundtrip
+if ( aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0 
)
+{
+

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

2022-02-11 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf132752.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|   32 ++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   59 --
 3 files changed, 83 insertions(+), 8 deletions(-)

New commits:
commit a1ee86ebe1f3106d9601c989e4feeacfc1941331
Author: Vasily Melenchuk 
AuthorDate: Wed Feb 9 09:41:51 2022 +0300
Commit: Vasily Melenchuk 
CommitDate: Fri Feb 11 10:42:29 2022 +0100

tdf#146917: docx import: better support for style with num reset

When paragraph style is disabling numbering defined in parent
style we should apply margin properties (like we already do
in other numbering cases), but we should include only properties
from styles not affected by numbering. In other words, only
styles without w:numId are used.

Unittest was extended to cover different combinations of this
situation.

Change-Id: Ic19e00fcfe16b2357cdfe763b4f969cc63122e89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129701
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 96e1be11540bada172fbdbfbbe3f9b7dc3e58462)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129827
Reviewed-by: Vasily Melenchuk 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf132752.docx 
b/sw/qa/extras/ooxmlexport/data/tdf132752.docx
index 57eddc455fca..a94fc498a101 100644
Binary files a/sw/qa/extras/ooxmlexport/data/tdf132752.docx and 
b/sw/qa/extras/ooxmlexport/data/tdf132752.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 1e6938bcecc4..e3eb50c29ea4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -384,9 +384,35 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf143692_outlineLevelTortureTest, "tdf143692_outli
 
 DECLARE_OOXMLEXPORT_TEST(testTdf132752, "tdf132752.docx")
 {
-CPPUNIT_ASSERT_EQUAL(sal_Int32(1801), 
getProperty(getParagraph(1), "ParaLeftMargin"));
-CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), 
getProperty(getParagraph(1), "ParaRightMargin"));
-CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(getParagraph(1), 
"ParaFirstLineIndent"));
+uno::Reference xPara1(getParagraph(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1801), getProperty(xPara1, 
"ParaLeftMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), getProperty(xPara1, 
"ParaRightMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara1, 
"ParaFirstLineIndent"));
+
+uno::Reference xPara2(getParagraph(2), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1801), getProperty(xPara2, 
"ParaLeftMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), getProperty(xPara2, 
"ParaRightMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(-630), getProperty(xPara2, 
"ParaFirstLineIndent"));
+
+uno::Reference xPara3(getParagraph(3), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara3, 
"ParaLeftMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(5891), getProperty(xPara3, 
"ParaRightMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara3, 
"ParaFirstLineIndent"));
+
+uno::Reference xPara4(getParagraph(4), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1801), getProperty(xPara4, 
"ParaLeftMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), getProperty(xPara4, 
"ParaRightMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4157), getProperty(xPara4, 
"ParaFirstLineIndent"));
+
+uno::Reference xPara5(getParagraph(5), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1801), getProperty(xPara5, 
"ParaLeftMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), getProperty(xPara5, 
"ParaRightMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(-630), getProperty(xPara5, 
"ParaFirstLineIndent"));
+
+uno::Reference xPara6(getParagraph(6), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3565), getProperty(xPara6, 
"ParaLeftMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2764), getProperty(xPara6, 
"ParaRightMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(-2394), getProperty(xPara6, 
"ParaFirstLineIndent"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testGutterLeft, "gutter-left.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 4b0f3f6c4e75..13f1fb9056b9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -183,6 +183,45 @@ static void lcl_handleTextField( const uno::Reference< 
beans::XPropertySet >& rx
 }
 }
 
+/**
+ Very similar to DomainMapper_Impl::GetPropertyFromStyleSheet
+ It is focused on paragraph properties search in current & parent stylesheet 
entries.
+ But it will not take into account propeties with listid: these are "list 
paragraph styles" and
+ not used in some cases.
+*/
+static uno::Any lcl_GetPropertyFromParaStyleSheetNoNum(PropertyIds eId, 
StyleSheetEntryPtr pEntry, 

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

2022-02-10 Thread Michael Stahl (via logerrit)
 sw/qa/extras/uiwriter/uiwriter3.cxx   |   65 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |9 ++-
 2 files changed, 73 insertions(+), 1 deletion(-)

New commits:
commit 5c0497337cb2cc34091d1ae58dab288a8a9a5454
Author: Michael Stahl 
AuthorDate: Mon Feb 7 17:26:32 2022 +0100
Commit: Miklos Vajna 
CommitDate: Thu Feb 10 13:18:47 2022 +0100

tdf#147206 writerfilter: fix end position of hyperlink in ToX

(regression from commit 58a86af36295b4fc1e07c0bd38f74530a2ce0f08)

Change-Id: Ied4c26255b60f4320f38432ef5e2e27882b7a135
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129681
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 9d30e168112bc5c3c7f2dfc029f293c540ebb280)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129618
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index faad2989afec..cf8c4e07e9b6 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -535,6 +536,70 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139737)
 Scheduler::ProcessEventsToIdle();
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147206)
+{
+SwDoc* pDoc = createSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+// insert empty paragraph and heading text
+pWrtShell->SplitNode();
+pWrtShell->Insert("abc");
+pWrtShell->SplitNode();
+
+// set one to heading so there will be an entry in the tox
+pWrtShell->Up(false, 1);
+uno::Sequence aPropertyValues = 
comphelper::InitPropertySequence({
+{ "Style", uno::makeAny(OUString("Heading 1")) },
+{ "FamilyName", uno::makeAny(OUString("ParagraphStyles")) },
+});
+dispatchCommand(mxComponent, ".uno:StyleApply", aPropertyValues);
+
+pWrtShell->EndOfSection(false);
+
+// insert table of contents
+SwTOXMgr mgr(pWrtShell);
+SwTOXDescription desc{ TOX_CONTENT };
+mgr.UpdateOrInsertTOX(desc, nullptr, nullptr);
+
+// get url of heading cross reference mark
+IDocumentMarkAccess& rIDMA(*pDoc->getIDocumentMarkAccess());
+auto const headingMark
+= std::find_if(rIDMA.getAllMarksBegin(), rIDMA.getAllMarksEnd(), 
[](auto const* const it) {
+  return it->GetName().startsWith(
+  IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix());
+  });
+CPPUNIT_ASSERT(headingMark != rIDMA.getAllMarksEnd());
+OUString const headingLink("#" + (*headingMark)->GetName());
+
+// select tox entry
+pWrtShell->SttEndDoc(false);
+pWrtShell->Up(false, 1);
+pWrtShell->EndPara(true);
+
+rtl::Reference xTransfer = new SwTransferable(*pWrtShell);
+xTransfer->Copy();
+
+pWrtShell->SttEndDoc(true);
+
+// Paste special as RTF
+TransferableDataHelper helper(xTransfer);
+SwTransferable::PasteFormat(*pWrtShell, helper, SotClipboardFormatId::RTF);
+Scheduler::ProcessEventsToIdle();
+
+// check hyperlinkering
+CPPUNIT_ASSERT_EQUAL(
+headingLink, getProperty(getRun(getParagraph(1), 1, 
"abc\t1"), "HyperLinkURL"));
+CPPUNIT_ASSERT_EQUAL(
+OUString(), getProperty(getRun(getParagraph(2), 1, 
OUString()), "HyperLinkURL"));
+CPPUNIT_ASSERT_EQUAL(
+OUString(),
+getProperty(getRun(getParagraph(3), 1, "Table of Contents"), 
"HyperLinkURL"));
+CPPUNIT_ASSERT_EQUAL(
+headingLink, getProperty(getRun(getParagraph(4), 1, 
"abc\t1"), "HyperLinkURL"));
+CPPUNIT_ASSERT_EQUAL(
+OUString(), getProperty(getRun(getParagraph(5), 1, 
OUString()), "HyperLinkURL"));
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf144840)
 {
 SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf144840.odt");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6080f2a70ae1..4b0f3f6c4e75 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -7042,7 +7042,14 @@ void DomainMapper_Impl::PopFieldContext()
 }
 else if (!pContext->GetHyperlinkURL().isEmpty() && 
xCrsr.is())
 {
-xCrsr->gotoEnd( true );
+if (m_aTextAppendStack.top().xInsertPosition.is())
+{
+
xCrsr->gotoRange(m_aTextAppendStack.top().xInsertPosition, true);
+}
+else
+{
+xCrsr->gotoEnd(true);
+}
 
 // Draw components (like comments) need hyperlinks 
set differently
 SvxUnoTextRangeBase* pDrawText = 

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

2022-02-09 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/testParaListRightIndent.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |8 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |4 
 3 files changed, 12 insertions(+)

New commits:
commit 8d505b4140c8cd0b89f9981977f9a5024684104d
Author: Vasily Melenchuk 
AuthorDate: Mon Feb 7 14:31:02 2022 +0300
Commit: Thorsten Behrens 
CommitDate: Wed Feb 9 14:25:56 2022 +0100

docx import: right margin was not respected for para with list

If paragpraph has list defined somewhere in styles and right
margin defined in current style this margin was overriden with
older value from parent styles.

Change-Id: Ic0a2e9a1ce5f77b9ef38c549a62f1494c050982c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129595
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 42c5506a9e9ef58efd8193a193464e3b49d481ca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129617

diff --git a/sw/qa/extras/ooxmlexport/data/testParaListRightIndent.docx 
b/sw/qa/extras/ooxmlexport/data/testParaListRightIndent.docx
new file mode 100644
index ..975b598f476e
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/testParaListRightIndent.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 962574d871b1..ec07a5a946f0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -79,6 +79,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf137466, "tdf137466.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("FF"), sColor);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testParaListRightIndent, 
"testParaListRightIndent.docx")
+{
+CPPUNIT_ASSERT_EQUAL(1, getPages());
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), 
getProperty(getParagraph(1), "ParaRightMargin"));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(5001), 
getProperty(getParagraph(2), "ParaRightMargin"));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testDontAddNewStyles)
 {
 // Given a document that lacks builtin styles, and addition of them is 
disabled:
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1a7fbfda6b9b..c7385a2f4103 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1744,6 +1744,10 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
 if (nParaLeftMargin != 0)
 pParaContext->Insert(PROP_PARA_LEFT_MARGIN, 
uno::makeAny(nParaLeftMargin), /*bOverwrite=*/false);
 
+// Override right margin value with value from current style, 
if any
+if (pStyleSheetProperties && 
pStyleSheetProperties->isSet(PROP_PARA_RIGHT_MARGIN))
+nParaRightMargin = 
pStyleSheetProperties->getProperty(PROP_PARA_RIGHT_MARGIN)->second.get();
+
 pParaContext->Insert(PROP_PARA_RIGHT_MARGIN, 
uno::makeAny(nParaRightMargin), /*bOverwrite=*/false);
 }
 }


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

2022-02-09 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf126287.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|5 ++
 writerfilter/source/dmapper/DomainMapper.cxx  |   44 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   15 ++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |4 +-
 5 files changed, 65 insertions(+), 3 deletions(-)

New commits:
commit 2b1826a0078fc43b0f0f9078561cec7df1dd92df
Author: Vasily Melenchuk 
AuthorDate: Fri Jul 30 17:22:38 2021 +0300
Commit: Xisco Fauli 
CommitDate: Wed Feb 9 10:15:52 2022 +0100

tdf#126287: docx import: use defered linebreak

In some cases when we have combo linebreak, endparagraph and
end section at very bottom of page, MS Word does ignores linebreak
to avoid empty page with same section and lonely end paragraph mark.

With defered linebreak we could simulate and ignore such linebreaks
during import.

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf126287.docx 
b/sw/qa/extras/ooxmlexport/data/tdf126287.docx
new file mode 100644
index ..cf2250b9f9a4
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf126287.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index af90d8697de7..962574d871b1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -107,6 +107,11 @@ CPPUNIT_TEST_FIXTURE(Test, testDontAddNewStyles)
 assertXPath(pXmlDoc, "/w:styles/w:style[@w:styleId='Caption']", 0);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf126287, "tdf126287.docx")
+{
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, "tdf123642.docx")
 {
 // get bookmark interface
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 33db1c2cef4e..ffa829351baa 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3225,6 +3225,18 @@ void DomainMapper::lcl_startParagraphGroup()
 
 void DomainMapper::lcl_endParagraphGroup()
 {
+if (m_pImpl->isBreakDeferred(LINE_BREAK))
+{
+if (m_pImpl->GetIsLastParagraphInSection())
+m_pImpl->clearDeferredBreak(LINE_BREAK);
+
+while (m_pImpl->isBreakDeferred(LINE_BREAK))
+{
+m_pImpl->clearDeferredBreak(LINE_BREAK);
+m_pImpl->appendTextPortion("\n", m_pImpl->GetTopContext());
+}
+}
+
 m_pImpl->PopProperties(CONTEXT_PARAGRAPH);
 if (m_pImpl->hasTableManager())
m_pImpl->getTableManager().endParagraphGroup();
@@ -3374,6 +3386,13 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, 
size_t len)
 case 0x0e: //column break
 m_pImpl->deferBreak(COLUMN_BREAK);
 return;
+case 0x0a: //line break
+if (m_pImpl->GetIsLastParagraphInSection())
+{
+m_pImpl->deferBreak(LINE_BREAK);
+return;
+}
+break;
 case 0x07:
 m_pImpl->getTableManager().text(data_, len);
 return;
@@ -3406,6 +3425,13 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, 
size_t len)
 
 // GetTopContext() is changed by inserted breaks, but we want to keep 
the current context
 PropertyMapPtr pContext = m_pImpl->GetTopContext();
+
+while (m_pImpl->isBreakDeferred(LINE_BREAK))
+{
+m_pImpl->clearDeferredBreak(LINE_BREAK);
+m_pImpl->appendTextPortion("\n", pContext);
+}
+
 if (!m_pImpl->GetFootnoteContext())
 {
 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
@@ -3629,6 +3655,18 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
 m_pImpl->m_bHasFtnSep = true;
 return;
 }
+else if (len == 1 && sText[0] == '\r')
+{
+// Clear "last" one linebreak at end of section
+if (m_pImpl->GetIsLastParagraphInSection() && 
m_pImpl->isBreakDeferred(LINE_BREAK))
+m_pImpl->clearDeferredBreak(LINE_BREAK);
+// And emit all other linebreaks
+while (m_pImpl->isBreakDeferred(LINE_BREAK))
+{
+m_pImpl->clearDeferredBreak(LINE_BREAK);
+m_pImpl->appendTextPortion("\n", m_pImpl->GetTopContext());
+}
+}
 else if (len == 1 && sText[0] == '\t' )
 {
 if ( m_pImpl->m_bCheckFirstFootnoteTab && m_pImpl->IsInFootOrEndnote() 
)
@@ -3659,6 +3697,12 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t 

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

2022-02-03 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf147115_defaultStyle.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx|5 +
 writerfilter/source/dmapper/StyleSheetTable.cxx   |6 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 8e9830755c17c3351f074b251f30f3216b481214
Author: Justin Luth 
AuthorDate: Wed Feb 2 13:56:22 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Feb 3 09:23:43 2022 +0100

tdf#147115 writerfilter: style is only default if default=true

This was a dumb mistake in LO 2018 (so perhaps LO 6.2).
Regression from commit 6b7f12f6108f136d60bd77e3787ef6a2632038cd

Change-Id: I2adc642ffe9c2af1037fcc0a5d2b83c993511258
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129386
Tested-by: Jenkins
Reviewed-by: Justin Luth 
(cherry picked from commit 71303d77febfd51a493ce797933143cc318818cf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129339
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf147115_defaultStyle.docx 
b/sw/qa/extras/ooxmlexport/data/tdf147115_defaultStyle.docx
new file mode 100644
index ..e75099c6aa9e
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf147115_defaultStyle.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index a0960ae35c7f..d2922e940bf8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -365,6 +365,11 @@ DECLARE_OOXMLEXPORT_TEST(testDefaultStyle, 
"defaultStyle.docx")
 CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf147115_defaultStyle, 
"tdf147115_defaultStyle.docx")
+{
+CPPUNIT_ASSERT_EQUAL_MESSAGE( "Default Style", OUString("Standard"), 
getProperty(getParagraph(1), "ParaStyleName") );
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf117988, "tdf117988.docx")
 {
 CPPUNIT_ASSERT_EQUAL(1, getPages());
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx 
b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 5f45672fe915..fe5d718827f0 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -464,8 +464,12 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val)
 if (m_pImpl->m_pCurrentEntry->nStyleTypeCode != STYLE_TYPE_UNKNOWN)
 {
 // "If this attribute is specified by multiple styles, then 
the last instance shall be used."
-if ( m_pImpl->m_pCurrentEntry->nStyleTypeCode == 
STYLE_TYPE_PARA && !m_pImpl->m_pCurrentEntry->sStyleIdentifierD.isEmpty() )
+if (m_pImpl->m_pCurrentEntry->bIsDefaultStyle
+&& m_pImpl->m_pCurrentEntry->nStyleTypeCode == 
STYLE_TYPE_PARA
+&& !m_pImpl->m_pCurrentEntry->sStyleIdentifierD.isEmpty())
+{
 m_pImpl->m_sDefaultParaStyleName = 
m_pImpl->m_pCurrentEntry->sStyleIdentifierD;
+}
 
 beans::PropertyValue aValue;
 aValue.Name = "default";


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

2022-02-02 Thread Justin Luth (via logerrit)
 sw/qa/extras/rtfexport/data/tdf129578_lostBI.rtf |   31 +++
 sw/qa/extras/rtfexport/rtfexport4.cxx|9 ++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx   |4 +-
 3 files changed, 42 insertions(+), 2 deletions(-)

New commits:
commit 0d3d6e1eba9b10bc334a769c275312a828b82a00
Author: Justin Luth 
AuthorDate: Fri Jan 7 14:08:52 2022 +0200
Commit: Xisco Fauli 
CommitDate: Wed Feb 2 15:07:47 2022 +0100

tdf#129578 rtfimport: CJK char properties are not CS

This fixes a LO 6.4/6.3.0.1 regression caused by
commit fd95fb975b754d71d3750e85431a4e596a40e659
which was focused on export, and not import.

The code originally didn't have any
mention of DBCH, so it used the default.
However, in the 6.4 change, it was wrongly tied together
with the Complex Script indicator.

So revert that part of the change.
Mark fixed the same problem in 7.1 for font size.

Change-Id: I1c87ae856de93ebc693135585574f2eb144b214b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128113
Tested-by: Jenkins
Reviewed-by: Justin Luth 
(cherry picked from commit 9d50307b2e1fd26d415539d3ed8624c7a449e45b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129327
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/rtfexport/data/tdf129578_lostBI.rtf 
b/sw/qa/extras/rtfexport/data/tdf129578_lostBI.rtf
new file mode 100644
index ..8a0e96218bca
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf129578_lostBI.rtf
@@ -0,0 +1,31 @@
+{\rtf1\ansi\deff4\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New 
Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 
Arial;}{\f3\froman\fprq2\fcharset0 Liberation Serif{\*\falt Times New 
Roman};}{\f4\froman\fprq0\fcharset128 Calibri;}{\f5\froman\fprq0\fcharset128 
Times New Roman;}{\f6\froman\fprq0\fcharset128 
Cambria;}{\f7\froman\fprq0\fcharset128 Tahoma;}{\f8\fnil\fprq2\fcharset0 MS 
Mincho;}{\f9\fnil\fprq2\fcharset128 
\'91\'76\'91\'cc;}{\f10\fnil\fprq2\fcharset0 DejaVu 
Sans;}{\f11\froman\fprq0\fcharset128 Arial;}}
+{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\red82\green125\blue85;}
+{\stylesheet{\s0\snext0\rtlch\af11\afs22\alang1037 
\ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa200\ltrpar\cf0\f4\fs22\lang1033\kerning0\dbch\af9\langfe2052
 Normal;}
+{\s1\sbasedon0\snext0\rtlch\af5\afs28\alang1037\ab 
\ltrch\lang1033\langfe2052\hich\af6\loch\sl276\slmult1\ql\keep\widctlpar\hyphpar0\sb480\sa0\keepn\ltrpar\cf17\f6\fs28\lang1033\b\kerning0\dbch\af9\langfe2052
 Heading 1;}
+{\*\cs15\snext15 Default Paragraph Font;}
+{\*\cs16\sbasedon15\snext16 Header Char;}
+{\*\cs17\sbasedon15\snext17 Footer Char;}
+{\*\cs18\sbasedon15\snext18\rtlch\af5\afs28\ab 
\ltrch\hich\af6\loch\cf17\f6\fs28\b\dbch\af9 Heading 1 Char;}
+{\*\cs19\sbasedon15\snext19\rtlch\af7\afs16 \ltrch\hich\af7\loch\f7\fs16 
Balloon Text Char;}
+{\s20\sbasedon0\snext21\rtlch\af5\afs28\alang1037 
\ltrch\lang1033\langfe2052\hich\af5\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f5\fs28\lang1033\kerning0\dbch\af10\langfe2052
 Heading;}
+{\s21\sbasedon0\snext21\rtlch\af11\afs22\alang1037 
\ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs22\lang1033\kerning0\dbch\af9\langfe2052
 Text Body;}
+{\s22\sbasedon21\snext22\rtlch\af5\afs22\alang1037 
\ltrch\lang1033\langfe2052\hich\af5\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f5\fs22\lang1033\kerning0\dbch\af9\langfe2052
 List;}
+{\s23\sbasedon0\snext23\rtlch\af5\afs24\alang1037\ai 
\ltrch\lang1033\langfe2052\hich\af5\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb120\sa120\noline\ltrpar\cf0\f5\fs24\lang1033\i\kerning0\dbch\af9\langfe2052
 Caption;}
+{\s24\sbasedon0\snext24\rtlch\af5\afs22\alang1037 
\ltrch\lang1033\langfe2052\hich\af5\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa200\noline\ltrpar\cf0\f5\fs22\lang1033\kerning0\dbch\af9\langfe2052
 Index;}
+{\s25\sbasedon0\snext25\rtlch\af11\afs22\alang1037 
\ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa200\ltrpar\cf0\f4\fs22\lang1033\kerning0\dbch\af9\langfe2052
 Header and Footer;}
+{\s26\sbasedon0\snext26\rtlch\af11\afs22\alang1037 
\ltrch\lang1033\langfe2052\hich\af4\loch\sl240\slmult1\ql\widctlpar\tqc\tx4680\tqr\tx9360\hyphpar0\sb0\sa0\ltrpar\cf0\f4\fs22\lang1033\kerning0\dbch\af9\langfe2052
 Header;}
+{\s27\sbasedon0\snext27\rtlch\af11\afs22\alang1037 

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

2022-01-05 Thread Justin Luth (via logerrit)
 sw/qa/extras/rtfexport/data/tdf146489.rtf |   56 ++
 sw/qa/extras/rtfexport/rtfexport4.cxx |6 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |4 +
 3 files changed, 65 insertions(+), 1 deletion(-)

New commits:
commit 411cc8af8490ba307245c689ed5714f612bb9d6f
Author: Justin Luth 
AuthorDate: Tue Jan 4 15:36:35 2022 +0200
Commit: Justin Luth 
CommitDate: Wed Jan 5 11:35:55 2022 +0100

tdf#146489 writerfilter: ensure only character properties

This is another RTF regression found against LO 6.0's
commit fdfdea4d5af51a68f2d497cc5c3359d74c385fd5
   tdf#82173 writerfilter: apply char properties to footnote

The original commit in LO 6.0 intended that only character properties
were used. A follow-up commit for RTF tried to ensure that
these would be on the top of the stack.

However, in this case, it seems like somehow the table is
getting involved in putting the paragraph context
on the top. (Actually, there is no
GetTopContextOfType(CONTEXT_CHARACTER) at all.)

In any case, aFontProperties should only contain
character properties, so ensure that.

The unit test shows that there is still some kind
of import problem, because the footnote marker
should be a large, red character, but it is just
normal text. See tdf#108949.

Change-Id: I1ea7256891b198046f79f0d3a36e43d6c2ae3383
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127943
Tested-by: Jenkins
Reviewed-by: Justin Luth 
(cherry picked from commit 44c37c4af2d23d1469cdeeb56f2f5a2bef493986)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127954

diff --git a/sw/qa/extras/rtfexport/data/tdf146489.rtf 
b/sw/qa/extras/rtfexport/data/tdf146489.rtf
new file mode 100644
index ..d8e198114052
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf146489.rtf
@@ -0,0 +1,56 @@
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New 
Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 
Arial;}{\f3\froman\fprq2\fcharset0 Liberation Serif{\*\falt Times New 
Roman};}{\f4\fswiss\fprq2\fcharset0 Liberation Sans{\*\falt 
Arial};}{\f5\fnil\fprq2\fcharset0 DejaVu Sans;}{\f6\fswiss\fprq0\fcharset0 
FreeSans;}{\f7\fnil\fprq2\fcharset0 FreeSans;}}
+{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\red201\green33\blue30;\red255\green233\blue148;}
+{\stylesheet{\s0\snext0\rtlch\af7\afs24\alang1081 
\ltrch\lang1033\langfe2052\hich\af3\loch\widctlpar\hyphpar0\aspalpha\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af5\langfe2052
 Normal;}
+{\*\cs15\snext15 Numbering Symbols;}
+{\*\cs16\snext16\loch\super Footnote Anchor;}
+{\*\cs17\snext17 Footnote Characters;}
+{\*\cs18\snext18\loch\super Endnote Anchor;}
+{\*\cs19\snext19 Endnote Characters;}
+{\s20\sbasedon0\snext21\rtlch\af7\afs28 
\ltrch\hich\af4\loch\sb240\sa120\keepn\f4\fs28\dbch\af5 Heading;}
+{\s21\sbasedon0\snext21\loch\sl276\slmult1\sb0\sa140 Text Body;}
+{\s22\sbasedon21\snext22\rtlch\af6 \ltrch\loch\sl276\slmult1\sb0\sa140 List;}
+{\s23\sbasedon0\snext23\rtlch\af6\afs24\ai 
\ltrch\loch\sb120\sa120\noline\fs24\i Caption;}
+{\s24\sbasedon0\snext24\rtlch\af6\alang255 
\ltrch\lang255\langfe255\loch\noline\lang255\dbch\langfe255 Index;}
+{\s25\sbasedon0\snext25\loch\nowidctlpar\noline Table Contents;}
+{\s26\sbasedon0\snext26\rtlch\afs20 
\ltrch\loch\li340\ri0\lin340\rin0\fi-340\noline\fs20 Footnote;}
+}{\*\listtable{\list\listtemplateid1
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'01.;}{\levelnumbers\'01;}\fi-360\li1080}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'02.;}{\levelnumbers\'01;}\fi-360\li1440}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'03.;}{\levelnumbers\'01;}\fi-360\li1800}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'04.;}{\levelnumbers\'01;}\fi-360\li2160}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'05.;}{\levelnumbers\'01;}\fi-360\li2520}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'06.;}{\levelnumbers\'01;}\fi-360\li2880}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'07.;}{\levelnumbers\'01;}\fi-360\li3240}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext 
\'02\'08.;}{\levelnumbers\'01;}\fi-360\li3600}\listid1}
+{\list\listtemplateid2
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext 

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

2021-11-30 Thread Tünde Tóth (via logerrit)
 sw/qa/extras/uiwriter/uiwriter3.cxx  |   36 +++
 writerfilter/source/dmapper/NumberingManager.cxx |   19 +---
 2 files changed, 45 insertions(+), 10 deletions(-)

New commits:
commit 5d0f0d1a70a0b001be9db95d85f1d33a5f23f13f
Author: Tünde Tóth 
AuthorDate: Fri Nov 19 12:23:41 2021 +0100
Commit: Xisco Fauli 
CommitDate: Tue Nov 30 10:07:47 2021 +0100

tdf#97899 DOCX import: allow character formatting only of numbering

After the DOCX round-trip of a numbering created in Writer
using direct formatting (e.g. using Toggle Ordered/Unordered
List icons), it was not possible to format only the numbering
or bullets, e.g. selecting and formatting them by positioning
the text cursor on the numbering. Set CharStyleName property
during the DOCX import to allow this formatting.

Note: default list styles of Writer is still not supported,
resulting missing numbering after DOCX import.

Change-Id: I6f2c5d6e0d63b15e9c28367181af1e9e083ae68d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125649
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 7b8ae6f90c37c18ff724c0751b5f73cca6ae02ac)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125999
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 80874d041267..43ef4250aaba 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -3250,6 +3250,42 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf103612)
 "Text after section");
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf97899)
+{
+SwDoc* pDoc = createSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
+IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations());
+
+// Create an Ordered List
+rIDCO.InsertString(*pCursor, "a");
+pWrtShell->SplitNode();
+rIDCO.InsertString(*pCursor, "b");
+pWrtShell->SplitNode();
+rIDCO.InsertString(*pCursor, "c");
+
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+dispatchCommand(mxComponent, ".uno:DefaultNumbering", {});
+
+// Save it as DOCX & load it again
+reload("Office Open XML Text", "tdf97899-tmp.docx");
+uno::Reference xNumberingRules
+= 
getProperty>(getParagraph(1), 
"NumberingRules");
+CPPUNIT_ASSERT(xNumberingRules->getCount());
+uno::Sequence aNumbering;
+xNumberingRules->getByIndex(0) >>= aNumbering;
+OUString sCharStyleName;
+for (const auto& prop : aNumbering)
+{
+if (prop.Name == "CharStyleName")
+{
+prop.Value >>= sCharStyleName;
+break;
+}
+}
+CPPUNIT_ASSERT(!sCharStyleName.isEmpty());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx 
b/writerfilter/source/dmapper/NumberingManager.cxx
index 61dbea4a5563..8829aa52697f 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -568,16 +568,15 @@ void ListDef::CreateNumberingRules( DomainMapper& 
rDMapper,
 lcl_mergeProperties( rAbsCharStyleProps, rCharStyleProps );
 }
 
-if( aAbsCharStyleProps.hasElements() )
-{
-// Change the sequence into a vector
-auto aStyleProps = 
comphelper::sequenceToContainer(aAbsCharStyleProps);
-
-//create (or find) a character style containing the character
-// attributes of the symbol and apply it to the numbering level
-OUString sStyle = rDMapper.getOrCreateCharStyle( aStyleProps, 
/*bAlwaysCreate=*/true );
-
aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_CHAR_STYLE_NAME),
 sStyle));
-}
+// Change the sequence into a vector
+auto aStyleProps
+= 
comphelper::sequenceToContainer(aAbsCharStyleProps);
+
+//create (or find) a character style containing the character
+// attributes of the symbol and apply it to the numbering level
+OUString sStyle = rDMapper.getOrCreateCharStyle(aStyleProps, 
/*bAlwaysCreate=*/true);
+aLvlProps.push_back(
+
comphelper::makePropertyValue(getPropertyName(PROP_CHAR_STYLE_NAME), sStyle));
 
 OUString sText = pAbsLevel
? pAbsLevel->GetBulletChar()