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

2023-12-04 Thread Justin Luth (via logerrit)
 sw/qa/extras/rtfexport/rtfexport6.cxx|2 ++
 writerfilter/source/rtftok/rtfdispatchflag.cxx   |9 +
 writerfilter/source/rtftok/rtfdispatchsymbol.cxx |4 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx   |1 -
 writerfilter/source/rtftok/rtfdocumentimpl.hxx   |3 ---
 5 files changed, 3 insertions(+), 16 deletions(-)

New commits:
commit b63a12d481cd26f960f97f74e5a4d764966db338
Author: Justin Luth 
AuthorDate: Fri Dec 1 14:30:45 2023 -0500
Commit: Miklos Vajna 
CommitDate: Tue Dec 5 08:49:33 2023 +0100

tdf#148540 Revert "tdf#109790 RTF import: keep remembering...

... paragraph style between \cell and \row"
This reverts 5.4.1 commit aaa6a5202a447fb4e86d5f016d8e79fbc34a3ed7,
and rtfexport7's tdf109790.rtf unit test still passes.
I also did a visual test, which looks good.

After \cell, we normally get more \cells, so an impending
\row is completely unexpected most of the time.
I'm not really sure why that patch was ever thought to be good.

The problem was that \pard was not removing the paragraph style
that was assigned to an earlier column. The end result seemed
innocent (no bad formatting noticed),
but that is probably based on other work
done in the meantime which allows the unit test to still pass
even after all of "its code" has been reverted.

[If this causes a regression, perhaps m_pLastCharacterContext
could be of value?]

Change-Id: Ide9b65f5e5fa39c21bac6d8ed354bb88e0bbefe5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160233
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/rtfexport/rtfexport6.cxx 
b/sw/qa/extras/rtfexport/rtfexport6.cxx
index f4ff562c37e8..e65e57fd3192 100644
--- a/sw/qa/extras/rtfexport/rtfexport6.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport6.cxx
@@ -172,6 +172,8 @@ DECLARE_RTFEXPORT_TEST(testTdf108505_fieldCharFormat, 
"tdf108505_fieldCharFormat
 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty(xRun, 
"CharWeight"));
 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, 
getProperty(xRun, "CharPosture"));
 CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, getProperty(xRun, 
"CharColor"));
+
+CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty(xPara, 
"ParaStyleName"));
 }
 
 DECLARE_RTFEXPORT_TEST(testTdf108505_fieldCharFormat2, 
"tdf108505_fieldCharFormat2.rtf")
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx 
b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 23d8f5d1f59f..72c777aab1fb 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -579,8 +579,6 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
 dispatchSymbol(RTFKeyword::PAR);
 // \pard is allowed between \cell and \row, but in that case it 
should not reset the fact that we're inside a table.
 // It should not reset the paragraph style, either, so remember 
the old paragraph style.
-RTFValue::Pointer_t pOldStyle
-= 
m_aStates.top().getParagraphSprms().find(NS_ooxml::LN_CT_PPrBase_pStyle);
 m_aStates.top().getParagraphSprms() = 
m_aDefaultState.getParagraphSprms();
 m_aStates.top().getParagraphAttributes() = 
m_aDefaultState.getParagraphAttributes();
 
@@ -593,19 +591,14 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword 
nKeyword)
 {
 // We are still in a table.
 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_inTbl, 
new RTFValue(1));
-if (m_bAfterCellBeforeRow && pOldStyle)
-// And we still have the same paragraph style.
-
m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle,
-pOldStyle);
 // Ideally getDefaultSPRM() would take care of this, but it 
would not when we're buffering.
 
m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_tabs,
 new RTFValue());
 }
 resetFrame();
 
-// Reset currently selected paragraph style as well, unless we are 
in the special "after \cell, before \row" state.
+// Reset currently selected paragraph style as well.
 // By default the style with index 0 is applied.
-if (!m_bAfterCellBeforeRow)
 {
 OUString const aName = getStyleName(0);
 // But only in case it's not a character style.
diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx 
b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
index d5b196790a50..61499aac04b5 100644
--- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
@@ -180,9 +180,6 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword 
nKeyword)
 

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

2023-12-04 Thread Justin Luth (via logerrit)
 sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat2.rtf |   37 +
 sw/qa/extras/rtfexport/rtfexport6.cxx  |   21 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |   28 +++--
 3 files changed, 68 insertions(+), 18 deletions(-)

New commits:
commit caecfff1adbe9715260ef9e2009333e523d61123
Author: Justin Luth 
AuthorDate: Fri Dec 1 14:16:14 2023 -0500
Commit: Miklos Vajna 
CommitDate: Tue Dec 5 08:48:38 2023 +0100

tdf#108505 writerfilter: fix field direct char settings

Instead of adding characters properties one at a time,
lets take care of everything all at once.

The results seem to be good so far.
There is even some similarity between
how MS Word has these properties on the
"in-between" pseudo end character, where
placing the cursor after the field gets these properties.
I don't see it happening in MS Word
at the pseudo start character, but it does in LO now...

Hopefully that doesn't end up doing bad things.

In the unit test, replacing the content ends up
in red, italic. However, I see the same thing in MSO
when testing with my second FORMTEXT example,
so I think everything is "working as expected".

I tried to see if I could limit doing this
for only certain types of fields or conditions.
However, pContext->GetResult() doesn't have a \fldrslt
yet at the time this is happening. Also, TextField.is()
happens less than I expected. I'm sure I could limit it
to just certain pContext->GetFieldId(),
but so far no problems are noticed for all field types.

make CppunitTest_sw_rtfexport6 \
CPPUNIT_TEST_NAME=testTdf108505_fieldCharFormat

make CppunitTest_sw_rtfexport6 \
CPPUNIT_TEST_NAME=testTdf108505_fieldCharFormat2

Change-Id: I3223437fd0d694f5e5733a9f7323f10f03d7802f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160232
Tested-by: Jenkins
Tested-by: Gabor Kelemen 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat2.rtf 
b/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat2.rtf
new file mode 100644
index ..bb45e3052011
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat2.rtf
@@ -0,0 +1,37 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang2057\deflangfe2057\themelang3079\themelangfe0\themelangcs0
+
+\noqfpromote {\stylesheet{\ql 
\li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
 \rtlch\fcs1 
+\af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079 \snext0 \sqformat 
\spriority0 Normal;}{\s17\ql \li0\ri0\widctlpar
+\tqc\tx4819\tqr\tx9071\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
 \rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079 \sbasedon0 \snext17 
\slink18 header;}
+}
+\paperw16834\paperh11913\margl1134\margr1418\margt1418\margb567\gutter0\ltrsect
 
+\deftab708\widowctrl\ftnbj\aenddoc\hyphhotz425\trackmoves0\trackformatting1\donotembedsysfont0\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0
+\showxmlerrors1\noextrasprl\prcolbl\cvmme\sprsspbf\brkfrm\swpbdr\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\lytprtmet\hyphcaps0\formshade\horzdoc\fracwidth\dghspace180\dgvspace180\dghorigin1701\dgvorigin1984\dghshow0\dgvshow0
+\jexpand\viewkind1\viewscale70\pgbrdrhead\pgbrdrfoot\nolnhtadjtbl\nojkernpunct\rsidroot3825670
 \fet0
+
+\ltrrow\trowd \irow0\irowband0\lastrow \ltrrow
+\ts11\trgaph70\trleft-70\trkeep\trftsWidth3\trwWidth8931\trftsWidthB3\trftsWidthA3\trpaddl70\trpaddr70\trpaddfl3\trpaddfr3\tblrsid16408416\tblind0\tblindtype3
 \clvertalc\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl \clbrdrr\brdrtbl 
+\cltxlrtb\clftsWidth3\clwWidth1276\clshdrawnil 
\cellx1206\clvertalc\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl 
\clbrdrr\brdrs\brdrw30 \cltxlrtb\clftsWidth3\clwWidth3969\clshdrawnil 
\cellx5175\clvertalt\clbrdrt\brdrs\brdrw30 \clbrdrl\brdrs\brdrw30 
+\clbrdrb\brdrs\brdrw30 \clbrdrr\brdrs\brdrw30 
\cltxlrtb\clftsWidth3\clwWidth2126\clshdrawnil 
\cellx7301\clvertalt\clbrdrt\brdrtbl \clbrdrl\brdrs\brdrw30 \clbrdrb\brdrtbl 
\clbrdrr\brdrs\brdrw30 \cltxlrtb\clftsWidth3\clwWidth1560\clshdrawnil \cellx8861
+\pard\plain \ltrpar\s17\ql 
\li72\ri0\sb120\sa120\widctlpar\intbl\tqr\tx1561\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin72\pararsid8918882
 \rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079
+
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New 
Roman;}{\f5\fnil\fprq2\fcharset128 Linux Biolinum Keyboard O;}}
+

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

2023-12-04 Thread Justin Luth (via logerrit)
 sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat.rtf |   34 ++
 sw/qa/extras/rtfexport/rtfexport6.cxx |   14 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   11 
 3 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit 59a0be15b097dc4f2529837d128f52cc3fb497d9
Author: Justin Luth 
AuthorDate: Fri Dec 1 10:34:36 2023 -0500
Commit: Miklos Vajna 
CommitDate: Tue Dec 5 08:30:29 2023 +0100

tdf#108505 writerfilter: fix legacy dropdown fields direct bold setting

Any character property should be passed on,
but do that in a follow-up commit, so that
at least the bold case will remain intact
if the broader fix gets reverted for any reason.

make CppunitTest_sw_rtfexport6 \
CPPUNIT_TEST_NAME=testTdf108505_fieldCharFormat

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

diff --git a/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat.rtf 
b/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat.rtf
new file mode 100644
index ..b05c2deec6b6
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat.rtf
@@ -0,0 +1,34 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang2057\deflangfe2057\themelang3079\themelangfe0\themelangcs0
+
+\noqfpromote {\stylesheet{\ql 
\li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
 \rtlch\fcs1 
+\af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079 \snext0 \sqformat 
\spriority0 Normal;}{\s17\ql \li0\ri0\widctlpar
+\tqc\tx4819\tqr\tx9071\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
 \rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079 \sbasedon0 \snext17 
\slink18 header;}
+}
+\paperw16834\paperh11913\margl1134\margr1418\margt1418\margb567\gutter0\ltrsect
 
+\deftab708\widowctrl\ftnbj\aenddoc\hyphhotz425\trackmoves0\trackformatting1\donotembedsysfont0\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0
+\showxmlerrors1\noextrasprl\prcolbl\cvmme\sprsspbf\brkfrm\swpbdr\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\lytprtmet\hyphcaps0\formshade\horzdoc\fracwidth\dghspace180\dgvspace180\dghorigin1701\dgvorigin1984\dghshow0\dgvshow0
+\jexpand\viewkind1\viewscale70\pgbrdrhead\pgbrdrfoot\nolnhtadjtbl\nojkernpunct\rsidroot3825670
 \fet0
+
+\ltrrow\trowd \irow0\irowband0\lastrow \ltrrow
+\ts11\trgaph70\trleft-70\trkeep\trftsWidth3\trwWidth8931\trftsWidthB3\trftsWidthA3\trpaddl70\trpaddr70\trpaddfl3\trpaddfr3\tblrsid16408416\tblind0\tblindtype3
 \clvertalc\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl \clbrdrr\brdrtbl 
+\cltxlrtb\clftsWidth3\clwWidth1276\clshdrawnil 
\cellx1206\clvertalc\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl 
\clbrdrr\brdrs\brdrw30 \cltxlrtb\clftsWidth3\clwWidth3969\clshdrawnil 
\cellx5175\clvertalt\clbrdrt\brdrs\brdrw30 \clbrdrl\brdrs\brdrw30 
+\clbrdrb\brdrs\brdrw30 \clbrdrr\brdrs\brdrw30 
\cltxlrtb\clftsWidth3\clwWidth2126\clshdrawnil 
\cellx7301\clvertalt\clbrdrt\brdrtbl \clbrdrl\brdrs\brdrw30 \clbrdrb\brdrtbl 
\clbrdrr\brdrs\brdrw30 \cltxlrtb\clftsWidth3\clwWidth1560\clshdrawnil \cellx8861
+\pard\plain \ltrpar\s17\ql 
\li72\ri0\sb120\sa120\widctlpar\intbl\tqr\tx1561\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin72\pararsid8918882
 \rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079
+
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New 
Roman;}{\f5\fnil\fprq2\fcharset128 Linux Biolinum Keyboard O;}}
+
+{\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;}
+
+{\rtlch\fcs1 \af0 \ltrch\fcs0 \f5\fs32\chcbpat7\insrsid16408416 
Header}{\rtlch\fcs1 \af0 \ltrch\fcs0 \fs32\insrsid16408416\charrsid8918882 
\cell }\pard\plain \ltrpar\ql 
\li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\pararsid5246913
 
+\rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079 {\rtlch\fcs1 \af0 
\ltrch\fcs0 \insrsid16408416\charrsid8918882 Normal\cell }\pard \ltrpar
+\qc 
\li0\ri0\sb120\sa120\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0
 {\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5701682\charrsid5701682 {\*\bkmkstart 
Dropdown1}x}{\field\fldpriv{\*\fldinst {\ltrch\fcs0 
+\b\fs48\cf4  FORMDROPDOWN }{{\*\datafield 0abcd}

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

2023-11-16 Thread Michael Stahl (via logerrit)
 sw/qa/extras/rtfimport/data/section-pagebreak.rtf |   15 ++
 sw/qa/extras/rtfimport/rtfimport.cxx  |   48 ++
 writerfilter/source/dmapper/DomainMapper.cxx  |1 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx|4 +
 4 files changed, 68 insertions(+)

New commits:
commit 454e5010aec9953f586fe8af671765358f6cafc4
Author: Michael Stahl 
AuthorDate: Wed Nov 15 18:24:50 2023 +0100
Commit: Michael Stahl 
CommitDate: Thu Nov 16 15:36:03 2023 +0100

tdf#153194 writerfilter: RTF import: testContSectionPageBreak last para

For testContSectionPageBreak, Word inserts an additional empty paragraph
at the end of the document that was missing in Writer.

Ensure markLastSectionGroup() is always called at the end of the
document so that the \par that is dispatched in m_bNeedPar case will be
inserted and not automatically removed immediately.

Also add a test for the same document without \sbknone, which has 4
pages instead of 2.

Change-Id: Ib3e4fbdb66df55941e4a487d4b249cd98fe42008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159472
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/rtfimport/data/section-pagebreak.rtf 
b/sw/qa/extras/rtfimport/data/section-pagebreak.rtf
new file mode 100644
index ..077cd71e5d48
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/section-pagebreak.rtf
@@ -0,0 +1,15 @@
+{\rtf1 \ansi
+\fet0 \ftnbj \paperw11905 \paperh16837 \margt2267 \margb1133 \margl1417 
\margr1417
+
+\sectd
+FIRST
+\par
+\sect
+SECOND
+\par
+\page
+\sect
+THIRD
+\par
+\sect
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx 
b/sw/qa/extras/rtfimport/rtfimport.cxx
index 3533b7a77f92..d561969f8989 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -877,10 +877,58 @@ CPPUNIT_TEST_FIXTURE(Test, testContSectionPageBreak)
 CPPUNIT_ASSERT_EQUAL(uno::Any(),
  uno::Reference(xParaThird, 
uno::UNO_QUERY_THROW)
  ->getPropertyValue("PageDescName"));
+// there is an empty paragraph after THIRD
+uno::Reference xParaLast = getParagraph(5);
+CPPUNIT_ASSERT_EQUAL(OUString(), xParaLast->getString());
+try
+{
+getParagraph(6);
+}
+catch (container::NoSuchElementException const&)
+{
+// does not exist - expected
+}
 
 CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testSectionPageBreak)
+{
+createSwDoc("section-pagebreak.rtf");
+uno::Reference xParaSecond = getParagraph(2);
+CPPUNIT_ASSERT_EQUAL(OUString("SECOND"), xParaSecond->getString());
+CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE,
+ getProperty(xParaSecond, 
"BreakType"));
+CPPUNIT_ASSERT(uno::Any() != getProperty(xParaSecond, 
"PageDescName"));
+// actually not sure how many paragraph there should be between
+// SECOND and THIRD - important is that the page break is on there
+// (could be either 1 or 2; in Word it's a 2-line paragraph with the 1st
+// line containing only the page break being ~0 height)
+uno::Reference xParaNext = getParagraph(3);
+CPPUNIT_ASSERT_EQUAL(OUString(), xParaNext->getString());
+//If PageDescName is not empty, a page break / switch to page style is 
defined
+CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE,
+ getProperty(xParaNext, 
"BreakType"));
+uno::Reference xParaThird = getParagraph(4);
+CPPUNIT_ASSERT_EQUAL(OUString("THIRD"), xParaThird->getString());
+CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE,
+ getProperty(xParaThird, 
"BreakType"));
+CPPUNIT_ASSERT(uno::Any() != getProperty(xParaThird, 
"PageDescName"));
+// there is an empty paragraph after THIRD
+uno::Reference xParaLast = getParagraph(5);
+CPPUNIT_ASSERT_EQUAL(OUString(), xParaLast->getString());
+try
+{
+getParagraph(6);
+}
+catch (container::NoSuchElementException const&)
+{
+// does not exist - expected
+}
+
+CPPUNIT_ASSERT_EQUAL(4, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testBackground)
 {
 createSwDoc("background.rtf");
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index dc863f3f5e8b..8cf91bcf859f 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -4410,6 +4410,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
(!m_pImpl->GetParaChanged() && 
m_pImpl->GetParaSectpr()
 && !bSingleParagraphAfterRedline
 && !bIsColumnBreak
+&& !m_pImpl->GetIsLastSectionGroup() // 
testContSectionPageBreak
 && !m_pImpl->GetParaHadField()
 && 

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

2023-11-16 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/layout.cxx  |3 +
 sw/qa/extras/rtfexport/data/page-break-emptyparas-spltpgpar.rtf |   13 +
 sw/qa/extras/rtfexport/data/page-break-emptyparas.rtf   |   12 
 sw/qa/extras/rtfexport/rtfexport5.cxx   |4 -
 sw/qa/extras/rtfexport/rtfexport6.cxx   |7 ++
 sw/qa/extras/rtfexport/rtfexport7.cxx   |   25 
++
 sw/qa/extras/rtfimport/rtfimport.cxx|5 +-
 writerfilter/source/dmapper/DomainMapper.cxx|4 +
 writerfilter/source/rtftok/rtfdispatchflag.cxx  |7 ++
 writerfilter/source/rtftok/rtfdispatchsymbol.cxx|   25 
+-
 writerfilter/source/rtftok/rtfdocumentimpl.cxx  |   16 +-
 11 files changed, 99 insertions(+), 22 deletions(-)

New commits:
commit 15b886f460919ea3dce425a621dc017c2992a96b
Author: Michael Stahl 
AuthorDate: Fri Nov 10 17:04:27 2023 +0100
Commit: Michael Stahl 
CommitDate: Thu Nov 16 10:19:49 2023 +0100

tdf#153194 writerfilter: RTF import: \spltpgpar

 1. Some experimenting with the bugdoc (saving it to DOCX in Word
changes the layout in Word to exactly what Writer imports from RTF!)
leads to DOCX w:splitPgBreakAndParaMark setting.

 2. the RTF implementation of \spltpgpar was missing; apparently if the
flag is present the "new" behavior is in effect, which is the
opposite of how it's specified in RTF Spec 1.9.1.

 3. the DomainMapper code that uses this attribute is not in the text()
function to which RTFDocumentImpl sends paragraph breaks, but in the
utext() function, so send the break there instead, rather than
creating even more copypasta.

 4. now some filters-text crashes with nullptr pContext in
DomainMapper::lcl_utext(), avoid that.

 5. dispatchSymbol(m_nResetBreakOnSectBreak) doesn't do anything because
these are handled by dispatchFlag().

 6. Test name: testFdo81892::Load_Verify_Reload_Verify
equality assertion failed
- Expected: Performance
- Actual  :

Fails because additional paragraph break inserted after \page; in
dispatchSymbol() for \sect, remove the parBreak() as already hinted at
in commit 3c610336a58f644525d5e4d2566c35eee6f7a618

 7. rtfimport.cxx:868:Assertion
Test name: testContSectionPageBreak::TestBody
equality assertion failed
- Expected:
- Actual  : THIRD

It has no paragraph between SECOND and THIRD, whereas Word
definitely shows a paragraph there.  In dispatchSymbol() for \sect,
sectBreak() is not called (which may create a paragraph break); in
m_bIgnoreNextContSectBreak case this needs to be done manually for
cont-section-pagebreak.rtf to get the empty paragraph between SECOND
and THIRD.

 8. testFdo52052 fails; in dispatchSymbol() for \sect, if the document
ends with \sect (e.g. fdo52052.rtf) a paragraph break must be
inserted after this (because DomainMapper unconditionally removes
the last paragraph break), but not via m_bNeedCr as that creates
unwanted page break in testNestedTable (m_bNeedCr =>
dispatchSymbol(\par) => m_bNeedSect => sectBreak()); handle it in
RTFDocumentImpl::popState() for the end of the document by
dispatching \par.

 9. rtfimport.cxx:1519:Assertion

testTdf108947 now has 1 empty paragraph in the header instead of 2;
Word also shows only 1 so it's an improvement.

10. Test name: testFdo49893_2::Load_Verify_Reload_Verify
equality assertion failed
- Expected: 1
- Actual  : 0
- xpath should match exactly 1 node

This was reduced to only 2 pages, while Word shows 5; in
dispatchSymbol() for \page, for the consecutive \page send an empty
string to DomainMapper's utext() which causes a paragraph break to
be created if \spltpgpar isn't set (this was not at all obvious!).

11. testTdf133437 fails with some numbers of flys changing, but it had
those values before commit 3c610336a58f644525d5e4d2566c35eee6f7a618
which says "the exact number isn't that interesting".

12. testTdf153613_anchoredAfterPgBreak4 fails, but it now looks as in
Word, so this is a bugfix.

13. Jenkins build on WNT (only) crashes in testForcepoint93 in sw
layout code - disable test for now, debug asap.

Change-Id: Ia1063693d96adff900ece943020a5bf69bdeb7a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159471
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 47f2eddbc42d..83cbf0757c96 100644
--- 

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

2023-11-10 Thread Oliver Specht (via logerrit)
 sw/qa/extras/rtfimport/data/tdf158044.rtf  |   20 +
 sw/qa/extras/rtfimport/rtfimport.cxx   |   47 +
 writerfilter/source/dmapper/DomainMapper.cxx   |   89 +
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |1 
 writerfilter/source/rtftok/rtfsprm.cxx |9 +-
 5 files changed, 163 insertions(+), 3 deletions(-)

New commits:
commit fce18155052821756466ea043c638f4ed72f41d6
Author: Oliver Specht 
AuthorDate: Thu Nov 2 16:34:50 2023 +0100
Commit: Thorsten Behrens 
CommitDate: Fri Nov 10 22:29:40 2023 +0100

tdf#158044 handling of paragraph attributes in RTF import

style attributes need to be repeated at the paragraph
if not repeated then defaults have to be applied

Change-Id: I4ee567e8006c240c046b7e7bb75eae92e5563776
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158839
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

diff --git a/sw/qa/extras/rtfimport/data/tdf158044.rtf 
b/sw/qa/extras/rtfimport/data/tdf158044.rtf
new file mode 100755
index ..65e687f25d39
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf158044.rtf
@@ -0,0 +1,20 @@
+{\rtf1\ansi
+{\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;\red0\green0\blue0;\red0\green0\blue0;}
+
+{\stylesheet
+{\fs24\sa3200 Normal;}
+{\s97\tx1701\tx2835 StyleTabstops;}
+{\s98\cbpat6  StyleRed;}
+{\s99\qc SyleCentered;}
+}
+
+
+{\s97 Paragraph without tabstops\par}
+{\s98 Pargraph without color \par}
+{\s99 Paragraph without center\par}
+{\s97\tx1701\tx2835 Paragraph with tabstops\par}
+{\s98\cbpat6  Pargraph with color \par}
+{\s99\qc Paragraph with center\par}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx 
b/sw/qa/extras/rtfimport/rtfimport.cxx
index 78409762e827..b1b00cf2b1b4 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1712,6 +1712,53 @@ CPPUNIT_TEST_FIXTURE(Test, testParaStyleBottomMargin)
  getProperty(xPara, 
"ParaLineSpacing").Height);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, test158044Tdf)
+{
+createSwDoc("tdf158044.rtf");
+
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xParaEnumAccess(xTextDocument->getText(),
+  
uno::UNO_QUERY);
+uno::Reference xParaEnum = 
xParaEnumAccess->createEnumeration();
+int paraIndex = 0;
+while (xParaEnum->hasMoreElements())
+{
+uno::Reference 
xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
+sal_Int16 adjust = getProperty(xPropertySet, "ParaAdjust");
+Color fillColor = getProperty(xPropertySet, "FillColor");
+drawing::FillStyle fillStyle = 
getProperty(xPropertySet, "FillStyle");
+uno::Sequence tabStops
+= getProperty>(xPropertySet, 
"ParaTabStops");
+switch (paraIndex)
+{
+case 0:
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), tabStops.getLength());
+break;
+case 1:
+CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, fillStyle);
+CPPUNIT_ASSERT(0xff == fillColor);
+break;
+case 2:
+CPPUNIT_ASSERT_EQUAL(sal_Int16(0), adjust);
+break;
+case 3:
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabStops.getLength());
+break;
+case 4:
+CPPUNIT_ASSERT(tabStops.getLength() < 2);
+CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, fillStyle);
+CPPUNIT_ASSERT(0xff == fillColor);
+break;
+case 5:
+CPPUNIT_ASSERT(tabStops.getLength() < 2);
+CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, fillStyle);
+break;
+default:
+break;
+}
+++paraIndex;
+}
+}
 // tests should only be added to rtfIMPORT *if* they fail round-tripping in 
rtfEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index f015b79520bf..a2399e44bf37 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3845,6 +3846,35 @@ void DomainMapper::lcl_endCharacterGroup()
 m_pImpl->PopProperties(CONTEXT_CHARACTER);
 }
 
+//copied from rtfsprm
+/// Is it problematic to deduplicate this SPRM?
+static bool isSPRMDeduplicateDenylist(PropertyIds nId, PropertyMapPtr pContext)
+{
+switch 

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

2023-11-10 Thread Michael Stahl (via logerrit)
 sw/qa/extras/rtfexport/data/tdf153178.rtf  |7 +++
 sw/qa/extras/rtfexport/rtfexport7.cxx  |   10 ++
 writerfilter/source/rtftok/rtfdispatchflag.cxx |   20 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |6 +++---
 4 files changed, 40 insertions(+), 3 deletions(-)

New commits:
commit 4e2f2489c4c7436f8b3a21a530bc625cbef4e365
Author: Michael Stahl 
AuthorDate: Thu Nov 9 19:54:19 2023 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 10 10:33:54 2023 +0100

tdf#153178 writerfilter: do not create text frame spuriously

There are different RTF keywords that end up in RTFFrame, and some of
them cause Word to create a frame, while others don't.

Getting this right requires implementing support for all the missing
wrapping keywords, as most of them create a frame in Word but
\wrapdefault does not.

Change-Id: I1e55d15180564f3d66a5ee7d98274ae18f032872
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159228
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/rtfexport/data/tdf153178.rtf 
b/sw/qa/extras/rtfexport/data/tdf153178.rtf
new file mode 100644
index ..e1d74f4010ea
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf153178.rtf
@@ -0,0 +1,7 @@
+{\rtf1
+\tqr\tlul\tx2025\dxfrtext142\dfrmtxtx142\dfrmtxty142\wrapdefault\faauto\adjustright\rin0\lin57\itap0
 \rtlch\fcs1 \afs26\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079
+
+\par
+\pard
+\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport7.cxx 
b/sw/qa/extras/rtfexport/rtfexport7.cxx
index ad9249bedeb8..4d1550af4fdd 100644
--- a/sw/qa/extras/rtfexport/rtfexport7.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport7.cxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -659,6 +660,15 @@ DECLARE_RTFEXPORT_TEST(testWatermark, "watermark.rtf")
 CPPUNIT_ASSERT_EQUAL(float(66), nFontSize);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf153178, "tdf153178.rtf")
+{
+// the problem was that a frame was created
+uno::Reference xTextFramesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xIndexAccess(xTextFramesSupplier->getTextFrames(),
+ uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf109790, "tdf109790.rtf")
 {
 uno::Reference xTable(getParagraphOrTable(2), 
uno::UNO_QUERY);
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx 
b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index de7b91e26fae..699698aa8df8 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -1242,6 +1242,26 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword 
nKeyword)
 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_wrap,

NS_ooxml::LN_Value_doc_ST_Wrap_notBeside);
 break;
+case RTFKeyword::OVERLAY:
+m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_wrap,
+   
NS_ooxml::LN_Value_doc_ST_Wrap_none);
+break;
+case RTFKeyword::WRAPAROUND:
+m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_wrap,
+   
NS_ooxml::LN_Value_doc_ST_Wrap_around);
+break;
+case RTFKeyword::WRAPTHROUGH:
+m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_wrap,
+   
NS_ooxml::LN_Value_doc_ST_Wrap_through);
+break;
+case RTFKeyword::WRAPTIGHT:
+m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_wrap,
+   
NS_ooxml::LN_Value_doc_ST_Wrap_tight);
+break;
+case RTFKeyword::WRAPDEFAULT:
+m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_wrap,
+   
NS_ooxml::LN_Value_doc_ST_Wrap_auto);
+break;
 case RTFKeyword::MNOR:
 m_bMathNor = true;
 break;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 568ad4a8f31f..11e251b0828a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3995,9 +3995,9 @@ RTFSprms RTFFrame::getSprms()
 
 bool RTFFrame::hasProperties() const
 {
-return m_nX != 0 || m_nY != 0 || m_nW != 0 || m_nH != 0 || m_nHoriPadding 
!= 0
-   || m_nVertPadding != 0 || m_nHoriAlign != 0 || m_nHoriAnchor != 0 
|| m_nVertAlign != 0
-   || m_nVertAnchor != 0;
+// tdf#153178 \dxfrtext \dfrmtxtx \dfrmtxty \wrapdefault do *not* create 
frame
+return m_nX != 0 || m_nY != 0 || m_nW != 0 || m_nH != 0
+   || (m_oWrap && *m_oWrap 

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

2023-10-05 Thread Justin Luth (via logerrit)
 dev/null  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   15 ---
 writerfilter/source/dmapper/DomainMapper.cxx  |5 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   13 -
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |3 ---
 5 files changed, 1 insertion(+), 35 deletions(-)

New commits:
commit 32102e559eed6eadf2ea146e212a330a3bc897ca
Author: Justin Luth 
AuthorDate: Thu Oct 5 07:24:56 2023 -0400
Commit: Justin Luth 
CommitDate: Thu Oct 5 16:26:13 2023 +0200

tdf#157574 Revert "tdf#153613 tdf#146984 split para after anchors"

This reverts 7.6 commit 828fde37632a5bb0542b6925454690a5287d6490.

and also reverts the dependent parts of the follow-up test from
commit 828fde37632a5bb0542b6925454690a5287d6490
(although the patch itself is fine to remain in place)

and also reverts followup "cid#1522030 Uninitialized scalar field"
commit 9a123a6e63600ba3998d22bbc300ac4b65b3da2c.

The commit in general is fine. However, it fails in case
of an empty paragraph (with only anchors).
Unfortunately, there is no way of knowing ahead of time,
so either everything needs to be processed after a delay,
or else the paragraph needs to be split and then re-joined
in case it is not an empty paragraph.
Both options are extremely non-trivial - I don't know how
to do either of them.

Change-Id: I9e98d825ad0008e822172b6797116ad16e90b871
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157593
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak3.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak3.docx
deleted file mode 100644
index a282deaa0ad7..
Binary files 
a/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak3.docx and 
/dev/null differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 066eb3647cb5..bbcc40dde073 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -193,11 +193,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf146984_anchorInShape, 
"tdf146984_anchorInShape.d
 {
 // This was only one page b/c the page break was missing.
 CPPUNIT_ASSERT_EQUAL(2, getPages());
-
-const auto& pLayout = parseLayoutDump();
-// There are shapes on both pages - these should be non-zero numbers
-assertXPath(pLayout, "//page[1]//anchored", 3);
-assertXPath(pLayout, "//page[2]//anchored", 2);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf127622_framePr, "tdf127622_framePr.docx")
@@ -379,16 +374,6 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak2, "tdf153613_textboxA
 assertXPathContent(pLayout, "//page[2]/body/txt", "There should be no 
prior carriage return.");
 }
 
-DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak3, 
"tdf153613_textboxAfterPgBreak3.docx")
-{
-// All anchored TO-character shapes stay on the first page, before the 
page break.
-CPPUNIT_ASSERT_EQUAL(2, getPages());
-CPPUNIT_ASSERT_EQUAL(3, getParagraphs());
-
-const auto& pLayout = parseLayoutDump();
-assertXPath(pLayout, "//page[2]//anchored", 0);
-}
-
 DECLARE_OOXMLEXPORT_TEST(testTdf153613_sdtAfterPgBreak, 
"tdf153613_sdtAfterPgBreak.docx")
 {
 CPPUNIT_ASSERT_EQUAL(2, getPages());
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 5b5647be8bae..726730ad3076 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3741,7 +3741,7 @@ void 
DomainMapper::lcl_startShape(uno::Reference const& xShape)
 {
 // If there is a deferred page break, handle it now, so that the
 // started shape will be on the correct page.
-if (m_pImpl->isBreakDeferred(PAGE_BREAK) && 
!m_pImpl->IsBreakDeferredByAnchor())
+if (m_pImpl->isBreakDeferred(PAGE_BREAK))
 {
 // RTF doesn't properly report IsFirstRun, so in order to prevent 
regressions
 // always split the paragraph for RTF since that is the way it has 
been done lately.
@@ -3751,9 +3751,6 @@ void 
DomainMapper::lcl_startShape(uno::Reference const& xShape)
 finishParagraph();
 lcl_startParagraphGroup();
 }
-else
-m_pImpl->SetIsBreakDeferredByAnchor();
-
 }
 m_pImpl->PushShapeContext( xShape );
 lcl_startParagraphGroup();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 36a0f6c178f9..4d91790ade4c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -334,7 +334,6 @@ DomainMapper_Impl::DomainMapper_Impl(
 m_bIsColumnBreakDeferred( false ),
 

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

2023-10-04 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf157572_defaultVAnchor.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx   |   11 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx   |   16 ++--
 3 files changed, 20 insertions(+), 7 deletions(-)

New commits:
commit 4dd491bc50801d10bb2f1004fff6ebcdb5da9f59
Author: Justin Luth 
AuthorDate: Tue Oct 3 13:44:15 2023 -0400
Commit: Justin Luth 
CommitDate: Wed Oct 4 16:36:14 2023 +0200

tdf#157572 tdf#112287 tdf#154129 writerfilter framePr: fix vAnchor default

Fixes LO 7.6 regression commit 630732bfd8ed531e9d412a36a083f33763def054

See bug 157572 for the documentation.

To test this, I used ooxmlexport5's tdf112287B.docx with Word 2010:
-changed vertical relative to Paragraph - exported w:vAnchor="text"
-changed vertical relative to Page - exported w:vAnchor="page"
-changed vertical relative to Margin - did not export w:vAnchor

So, obviously the default is "margin"

Note that it always exports w:y=1

For importing, the default vAnchor changed depending on whether
w:y=0 (text) or w:y=1 (margin)
* an exception is when w:y=0 and vAlign is defined - then 'margin'

make CppunitTest_sw_ooxmlexport5 \
CPPUNIT_TEST_NAME=testTdf157572_defaultVAnchor

Change-Id: I126094eafc43a83e3a4efdd1ebc8d9cab9d49759
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157527
Reviewed-by: Justin Luth 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf157572_defaultVAnchor.docx 
b/sw/qa/extras/ooxmlexport/data/tdf157572_defaultVAnchor.docx
new file mode 100644
index ..9f63950693f7
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf157572_defaultVAnchor.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index ceb6bdff9c06..71cea9fa2964 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1429,6 +1429,17 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf112287)
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","yAlign","bottom");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf157572_defaultVAnchor)
+{
+loadAndSave("tdf157572_defaultVAnchor.docx");
+xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
+
+// vAnchor wasn't defined on import. It should default to 'margin' when 
w:y=non-zero
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","margin");
+// yAlign=something is not compatible with w:y=non-zero" - don't write 
anything out
+// assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr", "yAlign");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf112287B)
 {
 loadAndSave("tdf112287B.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 13836906c53e..9c1b32a54927 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1873,13 +1873,15 @@ DomainMapper_Impl::MakeFrameProperties(const 
ParagraphProperties& rProps)
 aFrameProperties.push_back(
 comphelper::makePropertyValue(getPropertyName(PROP_VERT_ORIENT), 
nVertOrient));
 
-//Default the anchor in case FramePr_vAnchor is missing ECMA 17.3.1.11
-sal_Int16 nVAnchor = text::RelOrientation::FRAME; // 'text'
-// vAlign is ignored if vAnchor is set to 'text'. So, if w:y is not 
defined,
-// but there is a defined vAlign, then a missing vAnchor should become 
'margin'.
-if (!bValidY && nVertOrient)
-{
-nVAnchor = text::RelOrientation::PAGE_PRINT_AREA; // 'margin'
+// Default the anchor in case FramePr_vAnchor is missing.
+// ECMA 17.3.1.11 says "page",
+// but errata documentation MS-OE376 2.1.48 Section 2.3.1.11 says 
"text"
+// while actual testing usually indicates "margin" tdf#157572 
tdf#112287
+sal_Int16 nVAnchor = text::RelOrientation::PAGE_PRINT_AREA; // 'margin'
+if (!nY && (bValidY || nVertOrient == text::VertOrientation::NONE))
+{
+// special cases? "auto" position defaults to "paragraph" based on 
testing when w:y=0
+nVAnchor = text::RelOrientation::FRAME; // 'text'
 }
 for (const auto pProp : vProps)
 {


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

2023-09-07 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf157136_TwoContentControls.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx  |   57 
++
 writerfilter/source/dmapper/SdtHelper.cxx   |5 
 3 files changed, 61 insertions(+), 1 deletion(-)

New commits:
commit b7a5c2502434d3da92d1fbcad528cabeb61a2719
Author: Mike Kaganski 
AuthorDate: Thu Sep 7 19:32:54 2023 +0300
Commit: Mike Kaganski 
CommitDate: Thu Sep 7 21:15:45 2023 +0200

tdf#157136: apply top context properties to the text input field

Change-Id: Ie3877811e482c1ec395a00ec6bf67155220b2b64
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156675
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf157136_TwoContentControls.docx 
b/sw/qa/extras/ooxmlexport/data/tdf157136_TwoContentControls.docx
new file mode 100644
index ..f4e898cb057f
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf157136_TwoContentControls.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 961bbdfb6def..275891d4f58b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -1096,6 +1098,61 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156548)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf157136)
+{
+// Given a document with two content controls - one block, one inline
+createSwDoc("tdf157136_TwoContentControls.docx");
+
+// Both of them must import with the correct character style
+
+{
+// 1st paragraph - block content control
+auto xRun = getRun(getParagraph(1), 1);
+CPPUNIT_ASSERT_EQUAL(OUString("Click or tap here to enter text.\r"), 
xRun->getString());
+// Without the fix in place, this would fail with
+// - Expected: Placeholder Text
+// - Actual  :
+CPPUNIT_ASSERT_EQUAL(OUString("Placeholder Text"),
+ getProperty(xRun, "CharStyleName"));
+}
+
+{
+// 2nd paragraph - inline content control
+auto xRun = getRun(getParagraph(2), 1);
+auto xContentControl
+= getProperty>(xRun, 
"ContentControl");
+CPPUNIT_ASSERT_EQUAL(OUString("Click or tap here to enter text."),
+ xContentControl->getString());
+CPPUNIT_ASSERT_EQUAL(OUString("Placeholder Text"),
+ getProperty(xRun, "CharStyleName"));
+}
+
+// Test the same after round-trip
+saveAndReload("Office Open XML Text");
+
+{
+// 1st paragraph - becomes inline content control after roundtrip
+auto xRun = getRun(getParagraph(1), 1);
+auto xContentControl
+= getProperty>(xRun, 
"ContentControl");
+CPPUNIT_ASSERT_EQUAL(OUString("Click or tap here to enter text."),
+ xContentControl->getString());
+CPPUNIT_ASSERT_EQUAL(OUString("Placeholder Text"),
+ getProperty(xRun, "CharStyleName"));
+}
+
+{
+// 2nd paragraph - inline content control
+auto xRun = getRun(getParagraph(2), 1);
+auto xContentControl
+= getProperty>(xRun, 
"ContentControl");
+CPPUNIT_ASSERT_EQUAL(OUString("Click or tap here to enter text."),
+ xContentControl->getString());
+CPPUNIT_ASSERT_EQUAL(OUString("Placeholder Text"),
+ getProperty(xRun, "CharStyleName"));
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index 4f94c46f2f55..041802147605 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -350,8 +350,11 @@ void SdtHelper::createPlainTextControl()
 
 xPropertySet->setPropertyValue("Content", uno::Any(aDefaultText));
 
+PropertyMap aMap;
+aMap.InsertProps(m_rDM_Impl.GetTopContext());
+
 // add it into document
-m_rDM_Impl.appendTextContent(xControlModel, 
uno::Sequence());
+m_rDM_Impl.appendTextContent(xControlModel, aMap.GetPropertyValues());
 
 // Store all unused sdt parameters from grabbag
 xPropertySet->setPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG,


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

2023-08-24 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx   |6 ++
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   12 ++--
 writerfilter/source/dmapper/DomainMapperTableHandler.hxx |5 -
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|1 -
 4 files changed, 8 insertions(+), 16 deletions(-)

New commits:
commit 178421a6c719dac9c16f220b76292fec16a53f60
Author: Miklos Vajna 
AuthorDate: Thu Aug 24 08:34:38 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Aug 24 10:19:07 2023 +0200

tdf#77760 sw floattable: add support for footnotes, DOCX import

This was originally added in commit
2fe248f2b36d541c0d243a620c217058a50a9d5d (tdf#87460 DOCX import: fix
missing endnote in floattable, 2015-06-23), because Writer core only
allows footnotes in floating tables since commit
56da1d30afe48cc4acd79567052a575e81f8c7a0 (tdf#77760 sw floattable: add
support for footnotes, doc model, 2023-08-22).

The DOCX export works already.

The ODT filter also works: there is a mechanism to try to not insert
footnotes in text frames, but the way XMLTextImportHelper::IsInFrame()
is implemented means that it only rejects footnotes directly in text
frames, not in tables-in-textframes, which is the interesting case for
us.

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

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 69a3fc137acb..961bbdfb6def 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -286,6 +286,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf87460, "tdf87460.docx")
 uno::Reference xEndnotes = 
xEndnotesSupplier->getEndnotes();
 // This was 0: endnote was lost on import.
 CPPUNIT_ASSERT_EQUAL(static_cast(1), xEndnotes->getCount());
+
+// Also make sure that  is mapped to a text frame (hosting the 
table):
+uno::Reference xTextFramesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xTextFrames = 
xTextFramesSupplier->getTextFrames();
+// Without the fix in place, this test would have failed, the table was 
inline.
+CPPUNIT_ASSERT(xTextFrames->hasByName("Frame1"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf90611, "tdf90611.docx")
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 5b0971eee20f..a942e303cae9 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -88,8 +88,7 @@ DomainMapperTableHandler::DomainMapperTableHandler(
 css::uno::Reference xText,
 DomainMapper_Impl& rDMapper_Impl)
 : m_xText(std::move(xText)),
-m_rDMapper_Impl( rDMapper_Impl ),
-m_bHadFootOrEndnote(false)
+m_rDMapper_Impl( rDMapper_Impl )
 {
 }
 
@@ -1546,8 +1545,7 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
 }
 
 // If we have a table with a start and an end position, we should make 
it a floating one.
-// Unless the table had a foot or endnote, as Writer doesn't support 
those in TextFrames.
-if (xTable.is() && xStart.is() && xEnd.is() && !m_bHadFootOrEndnote)
+if (xTable.is() && xStart.is() && xEnd.is())
 {
 uno::Reference xTableProperties(xTable, 
uno::UNO_QUERY);
 bool bIsRelative = false;
@@ -1675,7 +1673,6 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
 m_aTableProperties.clear();
 m_aCellProperties.clear();
 m_aRowProperties.clear();
-m_bHadFootOrEndnote = false;
 
 #ifdef DBG_UTIL
 TagLogger::getInstance().endElement();
@@ -1752,11 +1749,6 @@ void DomainMapperTableHandler::endCell(const 
css::uno::Reference< css::text::XTe
 m_aRowRanges.push_back(comphelper::containerToSequence(m_aCellRange));
 }
 
-void DomainMapperTableHandler::setHadFootOrEndnote(bool bHadFootOrEndnote)
-{
-m_bHadFootOrEndnote = bHadFootOrEndnote;
-}
-
 DomainMapper_Impl& DomainMapperTableHandler::getDomainMapperImpl()
 {
 return m_rDMapper_Impl;
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
index f05fc1e474f1..d67c4d26bb7c 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
@@ -67,9 +67,6 @@ class DomainMapperTableHandler final : public virtual 
SvRefBase
 PropertyMapVector1  m_aRowProperties;
 TablePropertyMapPtr m_aTableProperties;
 
-/// Did we have a foot or endnote in this table?
-bool m_bHadFootOrEndnote;
-
 TableStyleSheetEntry * endTableGetTableStyle(TableInfo & rInfo,
 std::vector& 

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

2023-07-21 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/data/tdf149498.docx |binary
 sw/qa/extras/uiwriter/uiwriter5.cxx   |   18 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |5 +++--
 3 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 818f8f13128ba78769b4f542ed1efef658de38d9
Author: László Németh 
AuthorDate: Fri Jul 21 17:35:12 2023 +0200
Commit: László Németh 
CommitDate: Sat Jul 22 01:14:19 2023 +0200

tdf#149498 sw: fix Undo crash at bookmark over cells

Importing DOCX files with bookmarks between w:p paragraph
elements resulted bookmark ranges over cell boundaries
within text tables, causing crash with Undo.

Partial revert of commit 9e1e88ad5cf2dc0e9b188c60930445652a6c7519
to avoid bookmark ranges over cell boundaries, creating
only collapsed bookmarks here, as before.

Regression from commit 9e1e88ad5cf2dc0e9b188c60930445652a6c7519
"tdf#145720 DOCX export: fix loss of tracked moving".

Note: to avoid of another assertion, skip testing with
debug builds.

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

diff --git a/sw/qa/extras/uiwriter/data/tdf149498.docx 
b/sw/qa/extras/uiwriter/data/tdf149498.docx
new file mode 100644
index ..b310e88aa735
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf149498.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 88868f8086c2..dfe0cc80f7ec 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2589,6 +2589,24 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747)
 assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1);
 }
 
+#ifndef DBG_UTIL
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498)
+{
+// load a table, and delete the first column with enabled change tracking:
+// now the column is not deleted silently, but keeps the deleted cell 
content,
+// and only accepting it will result the deletion of the table column.
+createSwDoc("tdf149498.docx");
+
+// select table, copy, paste and Undo
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+dispatchCommand(mxComponent, ".uno:Copy", {});
+dispatchCommand(mxComponent, ".uno:Paste", {});
+
+// this would crash due to bookmark over cell boundary
+dispatchCommand(mxComponent, ".uno:Undo", {});
+}
+#endif
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, 
testTdf150673_RedlineTableColumnDeletionWithExport)
 {
 // load a table, and delete the first column with enabled change tracking:
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index ec1766f9e750..a9522e53db2c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -8454,10 +8454,11 @@ void DomainMapper_Impl::StartOrEndBookmark( const 
OUString& rId )
 // then  move the bookmark-End to the earlier paragraph
 if (IsOutsideAParagraph())
 {
-// keep bookmark range
+// keep bookmark range, if it doesn't exceed cell boundary
 uno::Reference< text::XTextRange > xStart = 
xCursor->getStart();
 xCursor->goLeft( 1, false );
-xCursor->gotoRange(xStart, true );
+if (m_nTableDepth == 0 || !m_bFirstParagraphInCell)
+xCursor->gotoRange(xStart, true );
 }
 uno::Reference< container::XNamed > xBkmNamed( xBookmark, 
uno::UNO_QUERY_THROW );
 SAL_WARN_IF(aBookmarkIter->second.m_sBookmarkName.isEmpty(), 
"writerfilter.dmapper", "anonymous bookmark");


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

2023-07-17 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf156030.rtf |   11 ++
 sw/qa/extras/rtfexport/rtfexport7.cxx |   38 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   30 -
 3 files changed, 78 insertions(+), 1 deletion(-)

New commits:
commit da2e7b1e0b58aed20d44b7c588ee86d922d614a8
Author: Vasily Melenchuk 
AuthorDate: Thu Jul 6 12:45:11 2023 +0300
Commit: Thorsten Behrens 
CommitDate: Mon Jul 17 15:56:14 2023 +0200

tdf#156030: sw: better import of IF field for RTF and DOCX

Since long time IF field was converted to ConditionalText, but no
parameters were given. So condition, then text and else text were
lost during import.

Change-Id: I9b45e8ab394f3c53bb34370bf3ea15a939a400fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154101
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

diff --git a/sw/qa/extras/rtfexport/data/tdf156030.rtf 
b/sw/qa/extras/rtfexport/data/tdf156030.rtf
new file mode 100644
index ..db501d5bffac
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf156030.rtf
@@ -0,0 +1,11 @@
+{\rtf1
+{\field{\*\fldinst IF 1 = 2 "true value 1" "false value 1"}}\par
+{\field{\*\fldinst IF 1 == 2 "true value 2" "false value 2"}}\par
+{\field{\*\fldinst IF 1 != 2 "true value 3" "false value 3"}}\par
+{\field{\*\fldinst IF 1 <> 2 "true value 4" "false value 4"}}\par
+{\field{\*\fldinst IF 1 > 2 "true value 5" "false value 5"}}\par
+{\field{\*\fldinst IF 1 < 2 "true value 6" "false value 6"}}\par
+{\field{\*\fldinst IF 1 1 = 1 2 1 true value 7 false value 7}}\par
+{\field{\*\fldinst IF 1 1 = "1 2 1 true value 8 fal"se "value 8}}\par
+{\field{\*\fldinst IF a}}\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport7.cxx 
b/sw/qa/extras/rtfexport/rtfexport7.cxx
index 11eaadee6a88..ad9249bedeb8 100644
--- a/sw/qa/extras/rtfexport/rtfexport7.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport7.cxx
@@ -683,6 +683,44 @@ DECLARE_RTFEXPORT_TEST(testTdf113202, "tdf113202.rtf")
 CPPUNIT_ASSERT(getProperty(getParagraph(4), "ParaContextMargin"));
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf156030, "tdf156030.rtf")
+{
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xFieldsAccess(
+xTextFieldsSupplier->getTextFields());
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+
+// As usual, fields given by FieldsAccess are not in same order as in the 
document
+std::vector> aExpectedValues = {
+{ "1 FORMULA 2", "true value 1", "false value 1" }, // #1, condition 
should be 1 = 2
+{ "", "", "" }, // #9, not enough field params
+{ "1 1 FORMULA 1 2 1 true value 8 fal", "se", "value 8" }, // #8, 
nonsense in field params
+{ "1 1 FORMULA 1 2 1 true value 7 false", "value", "7" }, // #7, 
another parse error
+{ "1 < 2", "true value 6", "false value 6" }, // #6
+{ "1 > 2", "true value 5", "false value 5" }, // #5
+{ "1 <> 2", "true value 4", "false value 4" }, // #4
+{ "1 != 2", "true value 3", "false value 3" }, // #3
+{ "1 FORMULA FORMULA 2", "true value 2", "false value 2" }, // #2, 
condition expected 1 == 2
+};
+uno::Reference xPropertySet;
+OUString sValue;
+
+for (const auto& aValues : aExpectedValues)
+{
+xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT(xPropertySet.is());
+CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Condition") >>= sValue);
+CPPUNIT_ASSERT_EQUAL(aValues[0], sValue);
+CPPUNIT_ASSERT(xPropertySet->getPropertyValue("TrueContent") >>= 
sValue);
+CPPUNIT_ASSERT_EQUAL(aValues[1], sValue);
+CPPUNIT_ASSERT(xPropertySet->getPropertyValue("FalseContent") >>= 
sValue);
+CPPUNIT_ASSERT_EQUAL(aValues[2], sValue);
+}
+
+// No more fields
+CPPUNIT_ASSERT(!xFields->hasMoreElements());
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf153195, "tdf153195.rtf")
 {
 uno::Reference xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 491c755206b7..bf433e2b8d33 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -7447,7 +7447,35 @@ void DomainMapper_Impl::CloseFieldCommand()
 pContext->SetHyperlinkTarget(sTarget);
 }
 break;
-case FIELD_IF   : break;
+case FIELD_IF:
+{
+if (vArguments.size() < 3)
+{
+SAL_WARN("writerfilter.dmapper", "IF field requires at 
lest 3 parameters!");
+break;
+}
+
+if (xFieldProperties.is())
+{
+// Following code assumes that last argument in field 
is false value
+

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

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

New commits:
commit b915dd9e1559870045481403806dd073f4fb5818
Author: Mike Kaganski 
AuthorDate: Mon Jul 10 21:16:32 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Jul 11 05:03:30 2023 +0200

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

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

testTdf154319 is updated to test this.

Change-Id: I561995a8e96882e1f17ee9982e3fc640e621cda2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154281
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

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

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

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

New commits:
commit 6d153fa9f5277b7324885e18b0a63e1af830b6c5
Author: László Németh 
AuthorDate: Thu Jul 6 17:31:20 2023 +0200
Commit: László Németh 
CommitDate: Sun Jul 9 14:31:26 2023 +0200

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

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

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

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

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


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

2023-07-06 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |9 -
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   26 +++
 2 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit 9ac864159b241d2093e86f664ab6f4b76c69196d
Author: Miklos Vajna 
AuthorDate: Thu Jul 6 08:13:40 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Jul 6 09:19:37 2023 +0200

tdf#156059 sw floattable: fix lost 0 bottom margin of anchor in ftn from 
DOCX

The bottom margin of floating table anchor paragraph in the footnotes
was non-zero, which meant that the document had 2 pages in Writer, but
only 1 in Word.

What happened here is that commit
d1ac8df139a2a65db45d1970ccc0b80e17d827f6 (tdf#146346 DOCX import: fix
table margins in footnotes, 2022-05-03) fixed this, but only for the
case when the floating table conversion was delayed and not in the
instant conversion case. Then later commit
c50bf5a5daaae3d40f89ea0784a75a8a571c208d (sw floattable: remove no
longer needed DOCX import heuristics, 2023-04-12) made all floating
table conversions instant, so the problem was re-introduced.

Fix the problem by now fixing the problem in
DomainMapperTableHandler::endTable(), restoring code that was removed
from SectionPropertyMap::CloseSectionGroup().

There was a disabled testcase for this, so just enable that.

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

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 5edb4dcdcd11..4718837981cc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1366,8 +1366,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx")
 assertXPath(pXmlDoc, "/root/page[1]//anchored/fly", 8);
 assertXPath(pXmlDoc, "/root/page[1]//anchored/fly/tab", 8);
 
-// FIXME no second page (regression since multi-page floating tables?)
-//assertXPath(pXmlDoc, "/root/page[2]", 0);
+// No second page.
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 0
+// - Actual  : 1
+// i.e. unwanted lower margin in the floating table's anchor paragraph in 
the footnote created a
+// second page.
+assertXPath(pXmlDoc, "/root/page[2]", 0);
 }
 #endif
 
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 2bd77f3f13ea..370a89c0442f 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1617,6 +1617,32 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
 uno::Reference xContent = 
xTextAppendAndConvert->convertToTextFrame(xStart, xEnd, 
comphelper::containerToSequence(aFrameProperties));
 xFrameAnchor.set(xContent->getAnchor(), uno::UNO_QUERY);
 
+bool bConvertToFloatingInFootnote = false;
+if (xContent.is() && xContent->getAnchor().is())
+{
+uno::Reference 
xText(xContent->getAnchor()->getText(), uno::UNO_QUERY);
+if (xText.is())
+{
+bConvertToFloatingInFootnote = 
xText->supportsService("com.sun.star.text.Footnote");
+}
+}
+
+// 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 ( bConvertToFloatingInFootnote && xContent.is() )
+{
+uno::Reference xParagraph(
+xContent->getAnchor(), uno::UNO_QUERY);
+if ( xParagraph.is() )
+{
+xParagraph->setPropertyValue("ParaTopMargin",
+uno::Any(static_cast(0)));
+xParagraph->setPropertyValue("ParaBottomMargin",
+uno::Any(static_cast(0)));
+}
+}
+
 AfterConvertToTextFrame(m_rDMapper_Impl, aFramedRedlines, 
redPos, redLen, redCell, redTable);
 }
 


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

2023-06-15 Thread Satya (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf155736_PageNumbers_footer.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx  |   14 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx   |   21 
+++---
 writerfilter/source/dmapper/DomainMapper_Impl.hxx   |2 
 4 files changed, 30 insertions(+), 7 deletions(-)

New commits:
commit d7dd39e124f8a1fa199dd8322b642e8be04ed360
Author: Satya 
AuthorDate: Wed Jun 14 18:15:35 2023 +0530
Commit: Justin Luth 
CommitDate: Thu Jun 15 23:39:33 2023 +0200

tdf#155736 Modified IsInTOC() to handle IsInHeaderFooter() case.

This fixes a problem of page numbers missing in the footer.
The importer might start processing the footer before the
TOC has finished - m_bStartTOC might be true.
In this case we are not actually IsInTOC,and m_bStartTOC
should be ignored and make use of IsInHeaderFooter() and 
m_bStartTOCHeaderFooter to confirm if the footer/header itself
has TOC.

Change-Id: Ieede9f8e2120556630ba57b9c748935788f3cc9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153052
Reviewed-by: Justin Luth 
Tested-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf155736_PageNumbers_footer.docx 
b/sw/qa/extras/ooxmlexport/data/tdf155736_PageNumbers_footer.docx
new file mode 100644
index ..58e36988002a
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf155736_PageNumbers_footer.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index fbb87915369e..9183863c8af7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -850,6 +850,20 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135786, "tdf135786.docx")
 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf155736, "tdf155736_PageNumbers_footer.docx")
+{
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/footer");
+assertXPath(pXmlDoc, "/root/page[2]/footer");
+//Without the fix in place, it would have failed with
+//- Expected: Page * of *
+//- Actual  : Page of
+CPPUNIT_ASSERT_EQUAL(OUString("Page * of *"), 
parseDump("/root/page[1]/footer/txt/text()"));
+CPPUNIT_ASSERT_EQUAL(OUString("Page * of *"), 
parseDump("/root/page[2]/footer/txt/text()"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f75fbf529c96..8b5cf8b6e049 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2959,7 +2959,7 @@ void DomainMapper_Impl::appendTextPortion( const 
OUString& rString, const Proper
 // If we are in comments, then disable CharGrabBag, comment text 
doesn't support that.
 uno::Sequence< beans::PropertyValue > aValues = 
pPropertyMap->GetPropertyValues(/*bCharGrabBag=*/!m_bIsInComments);
 
-if (m_bStartTOC || m_bStartIndex || m_bStartBibliography)
+if (IsInTOC() || m_bStartIndex || m_bStartBibliography)
 for( auto& rValue : asNonConstRange(aValues) )
 {
 if (rValue.Name == "CharHidden")
@@ -3372,6 +3372,14 @@ void 
DomainMapper_Impl::fillEmptyFrameProperties(std::vector(0)));
 }
 
+bool DomainMapper_Impl::IsInTOC() const
+{
+if (IsInHeaderFooter())
+return m_bStartTOCHeaderFooter;
+else
+return m_bStartTOC;
+}
+
 void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, 
bool bDynamicHeightBottom)
 {
 while (!m_aHeaderFooterTextAppendStack.empty())
@@ -7063,7 +7071,7 @@ void DomainMapper_Impl::CloseFieldCommand()
 break;
 }
 }
-if (m_bStartTOC && (aIt->second.eFieldId == FIELD_PAGEREF) )
+if (IsInTOC() && (aIt->second.eFieldId == FIELD_PAGEREF))
 {
 bCreateField = false;
 }
@@ -7451,7 +7459,7 @@ void DomainMapper_Impl::CloseFieldCommand()
 break;
 case FIELD_PAGEREF:
 case FIELD_REF:
-if (xFieldProperties.is() && !m_bStartTOC)
+if (xFieldProperties.is() && !IsInTOC())
 {
 bool bPageRef = aIt->second.eFieldId == FIELD_PAGEREF;
 
@@ -8133,9 +8141,9 @@ void DomainMapper_Impl::PopFieldContext()
 else
 {
 xToInsert.set(pContext->GetTC(), uno::UNO_QUERY);
-if( !xToInsert.is() && !m_bStartTOC && !m_bStartIndex && 
!m_bStartBibliography )
+if (!xToInsert.is() && !IsInTOC() && !m_bStartIndex && 
!m_bStartBibliography)
 xToInsert = pContext->GetTextField();
-if( 

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

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

New commits:
commit 142aa77265361492e74707b08c5bcd366e7205ad
Author: Michael Stahl 
AuthorDate: Wed Jun 14 15:35:24 2023 +0200
Commit: Michael Stahl 
CommitDate: Wed Jun 14 16:54:26 2023 +0200

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

... at start of section.

(regression from commit 2e8aad6d45c53d554ccaf26de998ede708cfc289)

Change-Id: I1e0e720758b607b69645b29c46f4092264289f9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153053
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

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


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

2023-06-12 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx   |5 
 writerfilter/source/dmapper/StyleSheetTable.cxx |   29 +++-
 2 files changed, 24 insertions(+), 10 deletions(-)

New commits:
commit db9d42f8ac4cb4669b79cf5f718f4013a1e81c31
Author: Justin Luth 
AuthorDate: Thu Jun 1 22:13:12 2023 -0400
Commit: Miklos Vajna 
CommitDate: Mon Jun 12 11:27:56 2023 +0200

tdf#154371 writerfilter outineNumbering: copy inherited listId

LO has a unique heading numbering/chapter numbering/outline numbering
that has no counterpart in DOCX world.
One big gotcha is that styles do not inherit numbering that is
defined by the chapter numbering. So any DOCX paragraph styles
that inherit outlineLvl, listLvl, listId from a style that
is assigned to chapter numbering needs to explicitly assign the value.

One thing I am puzzled about is how the listLvl is being set.
(Perhaps that is one setting that Chapter Numbering allows to inherit?
But really hard to test because changing ANYTHING triggers all the code
that ensures that no inheritance occurs/resets listLvl.)

make CppunitTest_sw_ooxmlexport4 CPPUNIT_TEST_NAME=test_ClosingBrace

Change-Id: Ia744b076a86291b06af474934b2f4f705744b8b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152515
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 04e438d64dfb..aa1433f07ac0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -892,6 +892,11 @@ CPPUNIT_TEST_FIXTURE(Test, test_ClosingBrace)
 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
 // Checking for ClosingBrace tag
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/m:oMath[1]/m:d[2]/m:dPr[1]/m:endChr[1]","val","");
+
+// tdf#154371 paragraph style Подзаголовок ур3 inherits from Heading 3 
(includes list level and list id)
+uno::Reference 
xParaStyle(getStyles("ParagraphStyles")->getByName(u"Подзаголовок ур3"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(static_cast(2), 
getProperty(xParaStyle, "NumberingLevel"));
+CPPUNIT_ASSERT(!getProperty(xParaStyle, 
"NumberingStyleName").isEmpty());
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testlvlPicBulletId)
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx 
b/writerfilter/source/dmapper/StyleSheetTable.cxx
index a78ac4fda2db..b0282e981374 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -969,26 +969,35 @@ void 
StyleSheetTable::ReApplyInheritedOutlineLevelFromChapterNumbering()
 if (pEntry->m_nStyleTypeCode != STYLE_TYPE_PARA || 
pEntry->m_sBaseStyleIdentifier.isEmpty())
 continue;
 
-sal_Int16 nOutlineLevel = pEntry->m_pProperties->GetOutlineLevel();
-if (nOutlineLevel != -1)
-continue;
-
 StyleSheetEntryPtr pParent = 
FindStyleSheetByISTD(pEntry->m_sBaseStyleIdentifier);
 if (!pParent || !pParent->m_bAssignedAsChapterNumbering)
 continue;
 
+uno::Reference< style::XStyle > xStyle;
+xParaStyles->getByName(pEntry->m_sConvertedStyleName) >>= xStyle;
+if (!xStyle.is())
+continue;
+
+uno::Reference xPropertySet(xStyle, 
uno::UNO_QUERY_THROW);
+const sal_Int16 nListId = 
pEntry->m_pProperties->props().GetListId();
+const OUString& sParentNumberingStyleName
+= 
m_pImpl->m_rDMapper.GetListStyleName(pParent->m_pProperties->props().GetListId());
+if (nListId == -1 && !sParentNumberingStyleName.isEmpty())
+{
+
xPropertySet->setPropertyValue(getPropertyName(PROP_NUMBERING_STYLE_NAME),
+   
uno::Any(sParentNumberingStyleName));
+}
+
+sal_Int16 nOutlineLevel = pEntry->m_pProperties->GetOutlineLevel();
+if (nOutlineLevel != -1)
+continue;
+
 nOutlineLevel = pParent->m_pProperties->GetOutlineLevel();
 assert(nOutlineLevel >= WW_OUTLINE_MIN && nOutlineLevel < 
WW_OUTLINE_MAX);
 
 // convert MS level to LO equivalent outline level
 ++nOutlineLevel;
 
-uno::Reference< style::XStyle > xStyle;
-xParaStyles->getByName(pEntry->m_sConvertedStyleName) >>= xStyle;
-if ( !xStyle.is() )
-break;
-
-uno::Reference xPropertySet( xStyle, 
uno::UNO_QUERY_THROW );
 
xPropertySet->setPropertyValue(getPropertyName(PROP_OUTLINE_LEVEL), 
uno::Any(nOutlineLevel));
 }
 }


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

2023-06-03 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf134114_allowOverlap.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|7 +++
 writerfilter/source/dmapper/GraphicImport.cxx |3 +++
 writerfilter/source/dmapper/PropertyIds.cxx   |1 +
 writerfilter/source/dmapper/PropertyIds.hxx   |1 +
 5 files changed, 12 insertions(+)

New commits:
commit 3eb90b3370ca0284fdbf09f37d7dc63e5d158be7
Author: Justin Luth 
AuthorDate: Sat Jun 3 08:13:00 2023 -0400
Commit: Justin Luth 
CommitDate: Sat Jun 3 18:37:54 2023 +0200

tdf#134114 writerfilter: pass on AllowOverlap to graphics

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf134114_allowOverlap

The unit test has terrible layout after a round-trip...

Change-Id: I448af1c6b0c5135eb6d41dd6aa0c4bf00506ebbd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152572
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf134114_allowOverlap.docx 
b/sw/qa/extras/ooxmlexport/data/tdf134114_allowOverlap.docx
new file mode 100644
index ..637d4b6b9435
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf134114_allowOverlap.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 63f5b419df7f..50a058d19c9d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -529,6 +529,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf76022_textboxWrap)
 CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf134114_allowOverlap, 
"tdf134114_allowOverlap.docx")
+{
+// CPPUNIT_ASSERT_EQUAL(1, getPages());
+CPPUNIT_ASSERT(!getProperty(getShape(1), "AllowOverlap"));
+CPPUNIT_ASSERT(getProperty(getShape(2), "AllowOverlap"));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
 // Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx 
b/writerfilter/source/dmapper/GraphicImport.cxx
index 2351100f06bb..c6dd379e9481 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1854,6 +1854,9 @@ uno::Reference 
GraphicImport::createGraphicObject(uno::Refer
 
xGraphicObjectProperties->setPropertyValue(getPropertyName( 
PROP_FOLLOW_TEXT_FLOW ),
 uno::Any(m_pImpl->m_bLayoutInCell));
 
+
xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_ALLOW_OVERLAP),
+   
uno::Any(m_pImpl->m_bAllowOverlap));
+
 xGraphicObjectProperties->setPropertyValue(getPropertyName( 
PROP_SURROUND_CONTOUR ),
 uno::Any(m_pImpl->m_bContour));
 xGraphicObjectProperties->setPropertyValue(getPropertyName( 
PROP_CONTOUR_OUTSIDE ),
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx 
b/writerfilter/source/dmapper/PropertyIds.cxx
index 935e9dfd2075..e945dc2609b2 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -161,6 +161,7 @@ const OUString & getPropertyName( PropertyIds eId )
 { PROP_PAGE_TOGGLE, u"PageToggle"},
 { PROP_BACK_COLOR, u"BackColor"},
 { PROP_BACK_COLOR_TRANSPARENCY, u"BackColorTransparency"},
+{ PROP_ALLOW_OVERLAP, u"AllowOverlap"},
 { PROP_ALTERNATIVE_TEXT, u"AlternativeText"},
 { PROP_HEADER_TEXT_LEFT, u"HeaderTextLeft"},
 { PROP_HEADER_TEXT, u"HeaderText"},
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx 
b/writerfilter/source/dmapper/PropertyIds.hxx
index d708e566fcd9..083051f8d9e7 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -35,6 +35,7 @@ enum PropertyIds
 ,PROP_ADJUST
 ,PROP_ADJUST_CONTRAST
 ,PROP_ADJUST_LUMINANCE
+,PROP_ALLOW_OVERLAP
 ,PROP_ALTERNATIVE_TEXT
 ,PROP_ANCHOR_TYPE
 ,PROP_AUTOMATIC_DISTANCE


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

2023-06-01 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf154751_dualStrikethrough.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx |7 
 writerfilter/source/dmapper/DomainMapper.cxx   |   16 
+++---
 3 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 3e6f4bbefaa4f4f83210970210aa7796aab7cf03
Author: Justin Luth 
AuthorDate: Thu Jun 1 20:18:46 2023 -0400
Commit: Justin Luth 
CommitDate: Fri Jun 2 04:27:44 2023 +0200

tdf#154751 writerfilter: last enabled strikethrough wins

The problem is that multiple strikeout character properties can
be defined for DOCX, but it is implemented using a single property
in LO. If the last definition was "not *strike" then all strikeouts
were disabled.

Instead, if any strikeout is enabled, the last one overrides the others,
but cancelling doesn't negate a previously defined strikeout.

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf154751_dualStrikethrough

Change-Id: Iaf17380061a0b37db4bc7a87c703e81f0181bcc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152514
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf154751_dualStrikethrough.docx 
b/sw/qa/extras/ooxmlexport/data/tdf154751_dualStrikethrough.docx
new file mode 100644
index ..4669be366a68
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf154751_dualStrikethrough.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 0b66396d556e..63f5b419df7f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -11,6 +11,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -151,6 +152,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153042_noTab, 
"tdf153042_noTab.docx")
 assertXPath(pLayout, "//SwFixPortion", "width", "10");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf154751_dualStrikethrough, 
"tdf154751_dualStrikethrough.docx")
+{
+auto nStrike = getProperty(getRun(getParagraph(1), 1), 
"CharStrikeout");
+CPPUNIT_ASSERT_EQUAL(awt::FontStrikeout::SINGLE, nStrike);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf154478)
 {
 loadAndSave("tdf154478.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 06bd0dd10ed1..fb3113273079 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1921,12 +1921,20 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
 }
 break;
 case NS_ooxml::LN_EG_RPrBase_strike:
-rContext->Insert(ePropertyId,
- uno::Any( nIntValue ? 
awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) );
+{
+const auto eStrike
+= nIntValue ? awt::FontStrikeout::SINGLE : 
awt::FontStrikeout::NONE;
+const bool bOverwrite(nIntValue);
+rContext->Insert(ePropertyId, uno::Any(eStrike), 
bOverwrite);
+}
 break;
 case NS_ooxml::LN_EG_RPrBase_dstrike:
-rContext->Insert(ePropertyId,
- uno::Any( nIntValue ? 
awt::FontStrikeout::DOUBLE : awt::FontStrikeout::NONE ) );
+{
+const auto eStrike
+= nIntValue ? awt::FontStrikeout::DOUBLE : 
awt::FontStrikeout::NONE;
+const bool bOverwrite(nIntValue);
+rContext->Insert(ePropertyId, uno::Any(eStrike), 
bOverwrite);
+}
 break;
 case NS_ooxml::LN_EG_RPrBase_outline:
 case NS_ooxml::LN_EG_RPrBase_shadow:


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

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

New commits:
commit fd79c5ed9b13516bdb0f2a29806296698ddda7b2
Author: Czeber László Ádám 
AuthorDate: Thu Apr 27 09:48:50 2023 +0200
Commit: László Németh 
CommitDate: Thu Apr 27 18:47:48 2023 +0200

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

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

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

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

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf131722.docx 
b/sw/qa/extras/ooxmlexport/data/tdf131722.docx
new file mode 100644
index ..8b72ad4b86a7
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf131722.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 729fd09724a9..059d652d0a33 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -949,6 +949,63 @@ DECLARE_OOXMLEXPORT_TEST(testTdf138093, "tdf138093.docx")
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf131722, "tdf131722.docx")
+{
+if (isExported())
+{
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+assertXPath(pXmlDoc, "//w:sdt", 4);
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+uno::Reference xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+uno::Reference xCell = xTable->getCellByName("A1");
+uno::Reference xParagraphsAccess(xCell, 
uno::UNO_QUERY);
+uno::Reference xParagraphs
+= xParagraphsAccess->createEnumeration();
+uno::Reference 
xParagraph(xParagraphs->nextElement(),
+ 
uno::UNO_QUERY);
+uno::Reference xPortions = 
xParagraph->createEnumeration();
+uno::Reference 
xTextPortion(xPortions->nextElement(), uno::UNO_QUERY);
+
+OUString aPortionType;
+xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType;
+CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType);
+
+uno::Reference xContentControl;
+xTextPortion->getPropertyValue("ContentControl") >>= xContentControl;
+uno::Reference 
xContentControlProps(xContentControl, uno::UNO_QUERY);
+bool bDate{};
+xContentControlProps->getPropertyValue("Date") >>= bDate;
+CPPUNIT_ASSERT(bDate);
+uno::Reference 
xContentControlEnumAccess(xContentControl,
+   
 uno::UNO_QUERY);
+uno::Reference xContentControlEnum
+= xContentControlEnumAccess->createEnumeration();
+uno::Reference 
xTextPortionRange(xContentControlEnum->nextElement(),
+   uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("Enter a date here!"), 
xTextPortionRange->getString());
+}
+else
+{
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMarkAccess->getFieldmarksCount());
+
+for (auto aIter = pMarkAccess->getFieldmarksBegin();
+ aIter != pMarkAccess->getFieldmarksEnd(); ++aIter)
+{
+::sw::mark::IDateFieldmark* pFieldmark
+= dynamic_cast<::sw::mark::IDateFieldmark*>(*aIter);
+CPPUNIT_ASSERT(pFieldmark);
+CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), 
pFieldmark->GetFieldname());
+CPPUNIT_ASSERT_EQUAL(OUString("Enter a date here!"), 
pFieldmark->GetContent());
+}
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index f9cedcbf19eb..4f94c46f2f55 100644
--- 

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

2023-04-26 Thread Czeber László Ádám (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf138093.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx   |   55 +++
 writerfilter/source/dmapper/SdtHelper.cxx|4 +
 3 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit e898f95bfab16ddd9b04e516293cb6eb7e0a3847
Author: Czeber László Ádám 
AuthorDate: Tue Apr 18 15:01:14 2023 +0200
Commit: László Németh 
CommitDate: Wed Apr 26 10:55:29 2023 +0200

tdf#138093 DOCX import: fix broken date selector control in table

In tables, first character of the text value of the date selector
control left outside of the control during the import, resulting
broken date selector, e.g. 2[023] instead of [2023]. (Clicking on
the broken control, according to the year *023*, the selector listed
the lowest possible value, year 1900, and selecting that, the result
became 2[1900].)

Note: the fix works well with nested tables, too, so likely the
condition with tables is obsolete.

Perhaps regression from commit b36ef83ea59eeaca239e58b95aa0b1acdcb99efc
"tdf126701: MSForms: Fix import of date field at the end of the
paragraph." and commit 68e1be4ccbb90ee9a788962219a88312c4ffbea2
"MSForms: Rework text-based date form field's representation".

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf138093.docx 
b/sw/qa/extras/ooxmlexport/data/tdf138093.docx
new file mode 100644
index ..097fbb1351cc
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf138093.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 9e01ca72ca17..729fd09724a9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -33,6 +33,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 class Test : public SwModelTestBase
 {
@@ -894,6 +896,59 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf133363)
 "0");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf138093, "tdf138093.docx")
+{
+if (isExported())
+{
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+assertXPath(pXmlDoc, "//w:sdt", 3);
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+uno::Reference xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+uno::Reference xCell = xTable->getCellByName("B1");
+uno::Reference xParagraphsAccess(xCell, 
uno::UNO_QUERY);
+uno::Reference xParagraphs
+= xParagraphsAccess->createEnumeration();
+uno::Reference 
xParagraph(xParagraphs->nextElement(),
+ 
uno::UNO_QUERY);
+uno::Reference xPortions = 
xParagraph->createEnumeration();
+uno::Reference 
xTextPortion(xPortions->nextElement(), uno::UNO_QUERY);
+
+OUString aPortionType;
+xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType;
+CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType);
+
+uno::Reference xContentControl;
+xTextPortion->getPropertyValue("ContentControl") >>= xContentControl;
+uno::Reference 
xContentControlProps(xContentControl, uno::UNO_QUERY);
+bool bDate{};
+xContentControlProps->getPropertyValue("Date") >>= bDate;
+CPPUNIT_ASSERT(bDate);
+uno::Reference 
xContentControlEnumAccess(xContentControl,
+   
 uno::UNO_QUERY);
+uno::Reference xContentControlEnum
+= xContentControlEnumAccess->createEnumeration();
+uno::Reference 
xTextPortionRange(xContentControlEnum->nextElement(),
+   uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("2017"), xTextPortionRange->getString());
+}
+else
+{
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMarkAccess->getAllMarksCount());
+
+::sw::mark::IDateFieldmark* pFieldmark
+= 
dynamic_cast<::sw::mark::IDateFieldmark*>(*pMarkAccess->getAllMarksBegin());
+CPPUNIT_ASSERT(pFieldmark);
+CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), 
pFieldmark->GetFieldname());
+CPPUNIT_ASSERT_EQUAL(OUString("2017"), pFieldmark->GetContent());
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git 

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

2023-04-21 Thread Czeber László Ádám (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf133363.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx|   11 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |5 -
 3 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit e6a08aa351815b7be3bd094320c589026582454b
Author: Czeber László Ádám 
AuthorDate: Thu Apr 13 08:48:05 2023 +0200
Commit: László Németh 
CommitDate: Fri Apr 21 10:53:04 2023 +0200

tdf#133363 sw DOCX import: remove extra auto space in mixed list

Remove extra auto space even for mixed list styles. For mixed
style lists, it has not removed all the extra space needed.

See also commit 9cca15204af9cc44a8a9528ccf2f36616fb70e69
"tdf#133052: DOCX import: fix top auto margin of subitems".

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf133363.docx 
b/sw/qa/extras/ooxmlexport/data/tdf133363.docx
new file mode 100644
index ..937554facde6
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf133363.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 94a2c57c00ea..9e01ca72ca17 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -883,6 +883,17 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf105875_VmlShapeRotationWithFlip,
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf133363)
+{
+loadAndSave("tdf133363.docx");
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// tdf#133363: remove extra auto space between first and second list 
elements
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p[2]/w:pPr/w:spacing", "before",
+"0");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p[3]/w:pPr/w:spacing", "after",
+"0");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3bca3186ca82..6cb0c1d90d28 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2498,7 +2498,10 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
 
m_xPreviousParagraph->getPropertyValue("NumberingStyleName") >>= 
aPreviousNumberingName;
 }
 
-if (!aPreviousNumberingName.isEmpty() && 
aCurrentNumberingName == aPreviousNumberingName)
+// tdf#133363: remove extra auto space even for mixed 
list styles
+if (!aPreviousNumberingName.isEmpty()
+&& (aCurrentNumberingName == aPreviousNumberingName
+|| !isNumberingViaRule))
 {
 uno::Sequence 
aPrevPropertiesSeq;
 
m_xPreviousParagraph->getPropertyValue("ParaInteropGrabBag") >>= 
aPrevPropertiesSeq;


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

2023-04-21 Thread Czeber László Ádám (via logerrit)
 sw/qa/extras/rtfexport/data/tdf153195.rtf   |  319 
 sw/qa/extras/rtfexport/rtfexport7.cxx   |   13 
 writerfilter/source/rtftok/rtfdispatchvalue.cxx |   31 +-
 3 files changed, 357 insertions(+), 6 deletions(-)

New commits:
commit 5c98966b8318d526bdfbefc77831c051e946231f
Author: Czeber László Ádám 
AuthorDate: Tue Apr 4 15:07:47 2023 +0200
Commit: László Németh 
CommitDate: Fri Apr 21 09:52:02 2023 +0200

tdf#153195 sw RTF import: fix negative indent of table in footer

Fix missing processing of TBLIND keyword, which puts the table in
the footer in the correct orientation, applying also the following
conversion between RTF and OpenDocument/Writer to avoid regression:

Left spacing of the table has different meaning in MSO and Writer.
In MSO, left spacing means the indent of the text content of the
cells, i.e. if table spacing is 0, the text content of the cells
is vertically adjusted to the text content of the table, not to
the table border. In Writer, if left table spacing is 0, the table
border is vertically adjusted to the page text content. So for
the correct conversion, left spacing of the table decreased
with the left padding of the table text content during the RTF
import. (See table padding on the Borders pane of Table Properties.)

Reported and created unit test document by Gábor Kelemen.

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

diff --git a/sw/qa/extras/rtfexport/data/tdf153195.rtf 
b/sw/qa/extras/rtfexport/data/tdf153195.rtf
new file mode 100644
index ..995bd6dbc7e4
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf153195.rtf
@@ -0,0 +1,319 @@
+{\rtf1\adeflang1025\ansi\ansicpg1250\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1038\deflangfe1038\themelang1038\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi
 \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt 
Times New Roman};}
+{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New 
Roman{\*\falt Times New Roman};}{\f39\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020f0502020204030204}Calibri;}
+{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman{\*\falt Times New 
Roman};}{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman{\*\falt Times New Roman};}
+{\fhimajor\f31502\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020f0302020204030204}Calibri Light;}{\fbimajor\f31503\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt 
Times New Roman};}
+{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman{\*\falt Times New 
Roman};}{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman{\*\falt Times New Roman};}
+{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020f0502020204030204}Calibri;}{\fbiminor\f31507\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt 
Times New Roman};}
+{\f364\fbidi \froman\fcharset238\fprq2 Times New Roman CE{\*\falt Times New 
Roman};}{\f365\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt 
Times New Roman};}
+{\f367\fbidi \froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Times New 
Roman};}{\f368\fbidi \froman\fcharset162\fprq2 Times New Roman Tur{\*\falt 
Times New Roman};}
+{\f369\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Times 
New Roman};}{\f370\fbidi \froman\fcharset178\fprq2 Times New Roman 
(Arabic){\*\falt Times New Roman};}
+{\f371\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Times 
New Roman};}{\f372\fbidi \froman\fcharset163\fprq2 Times New Roman 
(Vietnamese){\*\falt Times New Roman};}
+{\f364\fbidi \froman\fcharset238\fprq2 Times New Roman CE{\*\falt Times New 
Roman};}{\f365\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt 
Times New Roman};}
+{\f367\fbidi \froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Times New 
Roman};}{\f368\fbidi \froman\fcharset162\fprq2 Times New Roman Tur{\*\falt 
Times New Roman};}
+{\f369\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Times 
New Roman};}{\f370\fbidi \froman\fcharset178\fprq2 Times New Roman 
(Arabic){\*\falt Times New Roman};}
+{\f371\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Times 
New Roman};}{\f372\fbidi \froman\fcharset163\fprq2 Times New Roman 
(Vietnamese){\*\falt Times New Roman};}{\f754\fbidi \fswiss\fcharset238\fprq2 
Calibri CE;}
+{\f755\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\f757\fbidi 
\fswiss\fcharset161\fprq2 Calibri Greek;}{\f758\fbidi \fswiss\fcharset162\fprq2 
Calibri Tur;}{\f759\fbidi \fswiss\fcharset177\fprq2 Calibri (Hebrew);}
+{\f760\fbidi 

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

2023-04-14 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   11 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   10 ++
 2 files changed, 17 insertions(+), 4 deletions(-)

New commits:
commit a24d461d736de0a29bb8ef2a20b57db4836cda3e
Author: Justin Luth 
AuthorDate: Thu Apr 13 10:04:24 2023 -0400
Commit: Justin Luth 
CommitDate: Fri Apr 14 16:55:05 2023 +0200

tdf#154703 writerfilter framePr: RTF != INVERT_BORDER_SPACING

Change-Id: I839b187f8e5822fb162255595aeeeac36427cb5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150356
Reviewed-by: Justin Luth 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 37008720247f..171826175e0b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -205,6 +205,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePr2, 
"tdf154703_framePr2.rtf")
 // framePr frames are always imported as fully transparent
 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty(getShape(1), 
"FillTransparence"));
 
+// as opposed to testLibreOfficeHang (RTF != INVERT_BORDER_SPACING) do not 
duplicate left/right
+uno::Reference xTextRange(getShape(1), uno::UNO_QUERY);
+uno::Reference xText = xTextRange->getText();
+CPPUNIT_ASSERT_EQUAL(OUString("framePr"), getParagraphOfText(1, 
xText)->getString());
+sal_Int32 nFrame = getProperty(getShape(1), 
"LeftBorderDistance");
+sal_Int32 nPara = getProperty(getParagraphOfText(1, xText), 
"LeftBorderDistance");
+if (!isExported()) // RTF
+CPPUNIT_ASSERT_EQUAL(sal_Int32(529), nFrame + nPara);
+else // DOCX
+CPPUNIT_ASSERT_EQUAL(sal_Int32(529*2), nFrame + nPara);
+
 if (!isExported())
 {
 // Fill the frame with a red background. It should be transferred on 
export to the paragraph
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 07a475485eca..068347f52347 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1528,7 +1528,8 @@ bool DomainMapper_Impl::isParaSdtEndDeferred() const
 
 static void lcl_MoveBorderPropertiesToFrame(std::vector& 
rFrameProperties,
 uno::Reference const& xStartTextRange,
-uno::Reference const& xEndTextRange )
+uno::Reference const& xEndTextRange,
+bool bIsRTFImport)
 {
 try
 {
@@ -1561,10 +1562,10 @@ static void 
lcl_MoveBorderPropertiesToFrame(std::vector& r
 aValue.Value = 
xTextRangeProperties->getPropertyValue(sPropertyName);
 if( nProperty < 4 )
 xTextRangeProperties->setPropertyValue( sPropertyName, 
uno::Any(table::BorderLine2()));
-else if (nProperty > 5)
+else if (nProperty > 5 || bIsRTFImport)
 {
+// left4/right5 need to be duplicated because of 
INVERT_BORDER_SPACING (DOCX only)
 // Do not duplicate the top6/bottom7 border spacing.
-// left4/right5 need to be duplicated because of 
INVERT_BORDER_SPACING
 aValue.Value <<= sal_Int32(0);
 }
 if (aValue.Value.hasValue())
@@ -1841,7 +1842,8 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion(bool bPreventOverlap)
 
 lcl_MoveBorderPropertiesToFrame(aFrameProperties,
 
rAppendContext.pLastParagraphProperties->GetStartingRange(),
-
rAppendContext.pLastParagraphProperties->GetEndingRange());
+
rAppendContext.pLastParagraphProperties->GetEndingRange(),
+IsRTFImport());
 
 //frame conversion has to be executed after table conversion, not now
 
RegisterFrameConversion(rAppendContext.pLastParagraphProperties->GetStartingRange(),


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

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

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

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

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

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

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

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


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

2023-04-13 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf105035_framePrB.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf105035_framePrC.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   29 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |  106 +++---
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |2 
 5 files changed, 121 insertions(+), 16 deletions(-)

New commits:
commit cbdd54e41a78e6a567d7ff97935721b07461cce5
Author: Justin Luth 
AuthorDate: Wed Apr 5 08:19:11 2023 -0400
Commit: Miklos Vajna 
CommitDate: Thu Apr 13 08:19:09 2023 +0200

tdf#105035 writerfilter framePr: don't allow overlap in extreme case

I NEED to do something about preventing overlap
because in certain cases MS Word (2010/2016 tested) does
not overlap frames even though their vertical placement
is identical.

The previous commit just fixed mis-combining separate frames into one,
but now those frames might overlap each other - which is worse
than being combined into one IMHO.

Unfortunately, Microsoft's decision to not overlap seems arbirary.
In most cases it needs to be allowed,
so I have developed a minimal set of specifications
that prevent overlap for bug 105035's specific document,
and it should be flexible enough to allow other cases to be added.
I tested a number of cases when designing my formula.
It doesn't seem to prevent overlap for page or margin position.
It doesn't seem to prevent overlap when set to top/middle/bottom.
It doesn't seem to prevent overlap if the frames are below the
first line of text.

I still have a problem: the order of the frames might
layout wrong - as in this unit test. Sigh.

Too bad this code is so ugly and long,
but it should be relatively performant.

make CppunitTest_sw_ooxmlexport18 CPPUNIT_TEST_NAME=testTdf105035_framePrB

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf105035_framePrB.docx 
b/sw/qa/extras/ooxmlexport/data/tdf105035_framePrB.docx
new file mode 100644
index ..fe813609fbac
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf105035_framePrB.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf105035_framePrC.docx 
b/sw/qa/extras/ooxmlexport/data/tdf105035_framePrC.docx
new file mode 100644
index ..4954f8cc6294
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf105035_framePrC.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index caf312ba9198..b485a8ea2e1c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -152,6 +152,35 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127622_framePr, 
"tdf127622_framePr.docx")
 CPPUNIT_ASSERT_EQUAL(1, getShapes());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf105035_framePrB, "tdf105035_framePrB.docx")
+{
+// The paragraphs have different frame definitions, so they must be in 
separate frames,
+// and the frames must not overlap - even though their vertical positions 
are identical.
+const auto& pLayout = parseLayoutDump();
+sal_Int32 n1stFlyBottom
+= getXPath(pLayout, "//page[1]//anchored/fly[1]/infos/bounds", 
"bottom").toInt32();
+sal_Int32 n2ndFlyTop
+= getXPath(pLayout, "//page[1]//anchored/fly[2]/infos/bounds", 
"top").toInt32();
+CPPUNIT_ASSERT_GREATER(n1stFlyBottom, n2ndFlyTop); //Top is greater than 
bottom
+
+// Impossible layout TODO: the textboxes are in the wrong order.
+OUString sTextBox1("Preparation of Papers for IEEE TRANSACTIONS and 
JOURNALS (November 2012)");
+CPPUNIT_ASSERT_MESSAGE("DID YOU FIX ME? Wow - I didn't think this would be 
possible!",
+!getXPathContent(pLayout, 
"//page[1]//anchored/fly[1]/txt").startsWith(sTextBox1));
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf105035_framePrC, "tdf105035_framePrC.docx")
+{
+// The paragraphs have different frame definitions, so they must be in 
separate frames,
+// and the frames DO overlap this time.
+const auto& pLayout = parseLayoutDump();
+sal_Int32 n1stFlyTop
+= getXPath(pLayout, "//page[1]//anchored/fly[1]/infos/bounds", 
"top").toInt32();
+sal_Int32 n2ndFlyTop
+= getXPath(pLayout, "//page[1]//anchored/fly[2]/infos/bounds", 
"top").toInt32();
+CPPUNIT_ASSERT_EQUAL(n1stFlyTop, n2ndFlyTop); //both frames start at the 
same position
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf154129_framePr1, "tdf154129_framePr1.docx")
 {
 for (size_t i = 1; i < 4; ++i)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 11247cbf6b77..6a7e9a405ee1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ 

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

2023-04-12 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf127622_framePr.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |6 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|  126 ++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx|1 
 writerfilter/source/dmapper/PropertyMap.cxx  |   21 ---
 writerfilter/source/dmapper/PropertyMap.hxx  |3 
 6 files changed, 75 insertions(+), 82 deletions(-)

New commits:
commit e0e33aa622968bc2e182099670a024a1d00b8e5c
Author: Justin Luth 
AuthorDate: Tue Apr 4 14:20:45 2023 -0400
Commit: Miklos Vajna 
CommitDate: Wed Apr 12 09:14:33 2023 +0200

tdf#105035 tdf#127622 writerfilter framePr: compare using style info

Prior to this patch, we were only comparing frame definitions
based on direct formatting properties.

Well, the definition can be spread throughout the paragraph styles,
and only if the end result matches will they all be part of one frame.

This patch fixes bug 127622 where three different styles all had
the same framePr settings.

It partially fixes bug 105035 - the frame is split in two - but
now the frames overlap. There is no "overlap" tick box in MSO,
although they do allow overlap - just not from other framePr text.
So this could end up giving me a lot of grief, where two frames
joined look OK, but split they will almost inevitably be stuck
overtop of each other - like we previously saw in bug 127622.

make CppunitTest_sw_ooxmlexport18 CPPUNIT_TEST_NAME=testTdf127622_framePr

Change-Id: Ie9ce9076d06029b8789a95b46f4ed49190ab09f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150036
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf127622_framePr.docx 
b/sw/qa/extras/ooxmlexport/data/tdf127622_framePr.docx
new file mode 100644
index ..5440a81985fc
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf127622_framePr.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 6f84d9784250..caf312ba9198 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -146,6 +146,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf146984_anchorInShape, 
"tdf146984_anchorInShape.d
 assertXPath(pLayout, "//page[2]//anchored", 2);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf127622_framePr, "tdf127622_framePr.docx")
+{
+// All the paragraphs end up with the same frame definition, so put them 
all in one frame
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf154129_framePr1, "tdf154129_framePr1.docx")
 {
 for (size_t i = 1; i < 4; ++i)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8511417e852c..11247cbf6b77 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1578,10 +1578,9 @@ static void 
lcl_MoveBorderPropertiesToFrame(std::vector& r
 }
 
 
-static void lcl_AddRangeAndStyle(
+static void lcl_AddRange(
 ParagraphPropertiesPtr const & pToBeSavedProperties,
 uno::Reference< text::XTextAppend > const& xTextAppend,
-const PropertyMapPtr& pPropertyMap,
 TextAppendContext const & rAppendContext)
 {
 uno::Reference xParaCursor(
@@ -1590,16 +1589,6 @@ static void lcl_AddRangeAndStyle(
 xParaCursor->gotoStartOfParagraph( false );
 
 pToBeSavedProperties->SetStartingRange(xParaCursor->getStart());
-if(pPropertyMap)
-{
-std::optional aParaStyle = 
pPropertyMap->getProperty(PROP_PARA_STYLE_NAME);
-if( aParaStyle )
-{
-OUString sName;
-aParaStyle->second >>= sName;
-pToBeSavedProperties->SetParaStyleName(sName);
-}
-}
 }
 
 
@@ -1608,28 +1597,19 @@ constexpr sal_Int32 DEFAULT_FRAME_MIN_WIDTH = 0;
 constexpr sal_Int32 DEFAULT_FRAME_MIN_HEIGHT = 0;
 constexpr sal_Int32 DEFAULT_VALUE = 0;
 
-void DomainMapper_Impl::CheckUnregisteredFrameConversion( )
+std::vector
+DomainMapper_Impl::MakeFrameProperties(const ParagraphProperties& rProps)
 {
-if (m_aTextAppendStack.empty())
-return;
-TextAppendContext& rAppendContext = m_aTextAppendStack.top();
-// n#779642: ignore fly frame inside table as it could lead to messy 
situations
-if (!rAppendContext.pLastParagraphProperties)
-return;
-if (!rAppendContext.pLastParagraphProperties->IsFrameMode())
-return;
-if (!hasTableManager())
-return;
-if (getTableManager().isInTable())
-return;
+std::vector aFrameProperties;
+
 try
 {
 // A paragraph's properties come from direct formatting or somewhere 
in the style hierarchy
 std::vector vProps;
-vProps.emplace_back(rAppendContext.pLastParagraphProperties.get());
+vProps.emplace_back();

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

2023-04-08 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|   14 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |7 +++
 2 files changed, 21 insertions(+)

New commits:
commit e4b1be58db73f5a3c483b40b5615c1c764bbe1d3
Author: Justin Luth 
AuthorDate: Fri Apr 7 20:42:18 2023 -0400
Commit: Justin Luth 
CommitDate: Sun Apr 9 03:39:57 2023 +0200

tdf#154703 writerfilter framePr: don't duplicate top/bot spacing

With framePr, all of the background/border settings
are really just paragraph properties.

BETTER would be to zero out the frame spacing
and leave it on the paragraph.
After all, there could be multiple paragraphs
and each could have their own spacing.

However, in this case we are getting the whole range as
one propertySet, so that basically means it is treated as one.
I presume.

But the biggest reason for zeroing out the paragraph instead of the frame
is because on export only the frame borders are being written out.
So that really needs to be fixed first.

make CppunitTest_sw_ooxmlexport10 CPPUNIT_TEST_NAME=testLibreOfficeHang

Change-Id: I1faeef6bf12668fb28e2b3710053ff545a4c36e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150157
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 60f7eb57b711..c4464f9d5cfb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -548,6 +548,20 @@ DECLARE_OOXMLEXPORT_TEST(testLibreOfficeHang, 
"frame-wrap-auto.docx")
 // fdo#72775
 // This was text::WrapTextMode_NONE.
 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_DYNAMIC, 
getProperty(getShape(1), "Surround"));
+
+// tdf#154703 top/bottom margins should not be duplicated from paragraph(s)
+uno::Reference xTextRange(getShape(1), uno::UNO_QUERY);
+uno::Reference xText = xTextRange->getText();
+CPPUNIT_ASSERT_EQUAL(OUString("test"), getParagraphOfText(1, 
xText)->getString());
+
+sal_Int32 nFrame = getProperty(getShape(1), 
"TopBorderDistance");
+sal_Int32 nPara = getProperty(getParagraphOfText(1, xText), 
"TopBorderDistance");
+CPPUNIT_ASSERT_EQUAL(sal_Int32(143), nFrame + nPara);
+// NOTE: left/right are different because of compat flag 
INVERT_BORDER_SPACING]
+nFrame = getProperty(getShape(1), "LeftBorderDistance");
+nPara = getProperty(getParagraphOfText(1, xText), 
"LeftBorderDistance");
+CPPUNIT_ASSERT_EQUAL(nFrame, nPara);
+CPPUNIT_ASSERT(nPara);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testI124106, "i124106.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 5e8d2712a13c..f559060704b6 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1561,6 +1561,13 @@ static void 
lcl_MoveBorderPropertiesToFrame(std::vector& r
 aValue.Value = 
xTextRangeProperties->getPropertyValue(sPropertyName);
 if( nProperty < 4 )
 xTextRangeProperties->setPropertyValue( sPropertyName, 
uno::Any(table::BorderLine2()));
+else if (nProperty > 5)
+{
+// Do not duplicate the top/bottom border spacing.
+// [NOTE: left/right need to be duplicated because of 
INVERT_BORDER_SPACING]
+// Hack: a minimal distance is given so left/right shading 
extends to the edge.
+xTextRangeProperties->setPropertyValue( sPropertyName, 
uno::Any(sal_Int32(1)));
+}
 if (aValue.Value.hasValue())
 rFrameProperties.push_back(aValue);
 }


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

2023-04-08 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf154703_framePr.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |6 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|3 ++-
 3 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 31ea6305b6a763ee48f639562313d9bd109a2923
Author: Justin Luth 
AuthorDate: Sat Apr 8 08:22:45 2023 -0400
Commit: Justin Luth 
CommitDate: Sat Apr 8 20:10:09 2023 +0200

tdf#154703 writerfilter framePr: avoid exception with hasValue

I'm assuming that because the range has multiple border definitions
in the various paragraphs that the left border was considered
undefined. Whatever the reason, a (void) uno::Any as a border
was causing the conversion to fail.

No matching existing unit tests found.
make CppunitTest_sw_ooxmlexport18 CPPUNIT_TEST_NAME=testTdf154703_framePr

Change-Id: I02fabfd035cad0f2094b023936ff1d33ed7f3fb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150156
Reviewed-by: Justin Luth 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf154703_framePr.docx 
b/sw/qa/extras/ooxmlexport/data/tdf154703_framePr.docx
new file mode 100644
index ..2ec5b493ecd3
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf154703_framePr.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index b871961406c3..6f84d9784250 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -159,6 +159,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf154129_framePr1, 
"tdf154129_framePr1.docx")
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePr, "tdf154703_framePr.docx")
+{
+// the frame conversion had been failing, so it imported as plain text 
only.
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, 
"tdf153613_anchoredAfterPgBreak.docx")
 {
 const auto& pLayout = parseLayoutDump();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 775b2194bd2d..5e8d2712a13c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1559,9 +1559,10 @@ static void 
lcl_MoveBorderPropertiesToFrame(std::vector& r
 beans::PropertyValue aValue;
 aValue.Name = sPropertyName;
 aValue.Value = 
xTextRangeProperties->getPropertyValue(sPropertyName);
-rFrameProperties.push_back(aValue);
 if( nProperty < 4 )
 xTextRangeProperties->setPropertyValue( sPropertyName, 
uno::Any(table::BorderLine2()));
+if (aValue.Value.hasValue())
+rFrameProperties.push_back(aValue);
 }
 }
 catch( const uno::Exception& )


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

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

New commits:
commit b6a5f16a9bf3227867bf46b88d012440138b6f24
Author: Mike Kaganski 
AuthorDate: Sat Apr 8 00:03:31 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sat Apr 8 00:46:51 2023 +0200

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

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

Change-Id: I0be5d61a5d2cbbf778ee88a11129a6e7655593ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150133
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

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

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

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

New commits:
commit 992d86b1b67a6bd28bbf5e63b2d2406881f476b7
Author: Vasily Melenchuk 
AuthorDate: Tue Mar 28 13:15:09 2023 +0300
Commit: Thorsten Behrens 
CommitDate: Fri Mar 31 12:57:59 2023 +

tdf#150542: DOCX import: support for document varibles

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

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

Change-Id: I7103c90eef59ab18f8a25e616dcf8a8b1c6dcb08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149646
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

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

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

2023-03-29 Thread Czeber László Ádám (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf124472.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   12 ++
 sw/qa/extras/ww8export/ww8export4.cxx |1 
 writerfilter/source/dmapper/DomainMapper.cxx  |   11 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   11 +-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |   13 ++-
 writerfilter/source/ooxml/model.xml   |   39 --
 7 files changed, 79 insertions(+), 8 deletions(-)

New commits:
commit 8bf897186de81b39064340c44a54db344d6878f6
Author: Czeber László Ádám 
AuthorDate: Thu Mar 9 10:35:10 2023 +0100
Commit: László Németh 
CommitDate: Wed Mar 29 14:58:04 2023 +

tdf#124472 DOCX import: fix broken field command by skipping delInstrText

Process only inserted and not tracked parts of the (partially)
tracked field commands to avoid of broken fields, e.g. hyperlinks
with bad URLs.

For example, instead of the previous bad URL
'https://www.libreoffice.org/"HYPERLINK https://bugs.libreoffice.org/',
now the hypertext field of the test document imported with the
correct URL 'https://www.libreoffice.org/'.

Field commands have change tracking in OOXML, but not in ODF/Writer.
OOXML delInstrText, i.e. deleted part of the field commands was imported
as part of the actual command, resulting broken fields, e.g. hyperlinks.

FieldCommand was splitted into two parts, deleted and non-deleted
elements. This way the commands do not get mixed up if the order
is changed and no fragmentation of deleted items occurs (otherwise
it could fail on the test of tdf#150086).

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf124472.docx 
b/sw/qa/extras/ooxmlexport/data/tdf124472.docx
new file mode 100644
index ..7d7f275be7b9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf124472.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 90e9cf2e6543..b871961406c3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -658,6 +658,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153664)
 assertXPath(pXmlStyles, 
"/w:styles/w:style[@w:styleId='TableofFigures']/w:name", "val", "Table of 
Figures");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf124472_hyperlink, "tdf124472.docx")
+{
+CPPUNIT_ASSERT_EQUAL(OUString("https://www.libreoffice.org/;),
+ getProperty(getRun(getParagraph(1), 1), 
"HyperLinkURL"));
+CPPUNIT_ASSERT_EQUAL(OUString("mailto:i...@libreoffice.org;),
+ getProperty(getRun(getParagraph(2), 1), 
"HyperLinkURL"));
+CPPUNIT_ASSERT_EQUAL(OUString(""),
+ getProperty(getRun(getParagraph(3), 1), 
"HyperLinkURL"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf135786, "tdf135786.docx")
 {
 // Empty first line remain, if the section's initial dummy paragraph is 
not deleted:
@@ -666,6 +676,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135786, "tdf135786.docx")
 CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
 }
 
-CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ww8export/ww8export4.cxx 
b/sw/qa/extras/ww8export/ww8export4.cxx
index 2fbe6911a2df..b620a0672958 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -75,7 +75,6 @@ DECLARE_WW8EXPORT_TEST(testTdf141649_conditionalText, 
"tdf141649_conditionalText
 getParagraph(1, "trueResult");
 }
 
-
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 1438ba4fee2e..b0030e781ab7 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3428,6 +3428,17 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
 pProperties->resolve(*this);
 }
 break;
+case NS_ooxml::LN_EG_RunInnerContent_instrText:
+{
+m_pImpl->SetIsTextDeleted(false);
+}
+break;
+case NS_ooxml::LN_EG_RunInnerContent_delText:
+case NS_ooxml::LN_EG_RunInnerContent_delInstrText:
+{
+m_pImpl->SetIsTextDeleted(true);
+}
+break;
 default:
 {
 #ifdef DBG_UTIL
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3f402c50b3ee..45128e43565c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -349,6 +349,7 @@ DomainMapper_Impl::DomainMapper_Impl(
 

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

2023-03-27 Thread Czeber László Ádám (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf135786.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   10 +-
 writerfilter/source/dmapper/DomainMapper.cxx  |5 +++--
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |1 +
 4 files changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 5f138e23f61b58857b0e90dc09642ee832af29d4
Author: Czeber László Ádám 
AuthorDate: Mon Mar 27 09:59:28 2023 +0200
Commit: László Németh 
CommitDate: Mon Mar 27 13:50:44 2023 +

tdf#135786: DOCX import: remove dummy paragraph before tables with comment

Section-starting tables were imported with a section-starting dummy
paragraph, when the tables contain comments. Remove dummy paragraph
by postponing the call of RemoveDummyParaForTableInSection() after
the annotations are processed.

Regression from commit 2e8aad6d45c53d554ccaf26de998ede708cfc289
"fdo#39056 fdo#75431 Section Properties if section starts with table".

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf135786.docx 
b/sw/qa/extras/ooxmlexport/data/tdf135786.docx
new file mode 100644
index ..b766b1905aaf
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135786.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 9d7a81304588..90e9cf2e6543 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -658,6 +658,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153664)
 assertXPath(pXmlStyles, 
"/w:styles/w:style[@w:styleId='TableofFigures']/w:name", "val", "Table of 
Figures");
 }
 
-CPPUNIT_PLUGIN_IMPLEMENT();
+DECLARE_OOXMLEXPORT_TEST(testTdf135786, "tdf135786.docx")
+{
+// Empty first line remain, if the section's initial dummy paragraph is 
not deleted:
+// - Expected: 2
+// - Actual  : 3
+CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 9db58e721a1b..1438ba4fee2e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3531,8 +3531,9 @@ void DomainMapper::lcl_endSectionGroup()
 pSectionContext->CloseSectionGroup( *m_pImpl );
 // Remove the dummy paragraph if added for
 // handling the section properties if section starts with a table
-if (m_pImpl->GetIsDummyParaAddedForTableInSection())
-m_pImpl->RemoveDummyParaForTableInSection();
+// tdf#135786: Added annotation condition
+if (m_pImpl->GetIsDummyParaAddedForTableInSection() && 
(m_pImpl->GetAnnotationId() < 0))
+ m_pImpl->RemoveDummyParaForTableInSection();
 }
 m_pImpl->SetIsTextFrameInserted( false );
 m_pImpl->PopProperties(CONTEXT_SECTION);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 050a510353a8..3150a890f88d 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -906,6 +906,7 @@ public:
 
 void PushAnnotation();
 void PopAnnotation();
+sal_Int32 GetAnnotationId() { return m_nAnnotationId; }
 
 /// A field context starts with a cFieldStart.
 void PushFieldContext();


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

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

New commits:
commit 7eedd76d93ef04d11ae2e1bfb1e7d264aab88f40
Author: Mike Kaganski 
AuthorDate: Fri Mar 24 11:01:56 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 24 16:38:51 2023 +

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

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

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

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

2023-03-22 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx|   17 ++-
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |7 +++---
 2 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit a1b935ca1bb6d48241e73e7206a367fe2b51f948
Author: Miklos Vajna 
AuthorDate: Wed Mar 22 08:28:34 2023 +0100
Commit: Miklos Vajna 
CommitDate: Wed Mar 22 08:35:05 2023 +

sw floattable: fix inner floating table inside normal outer table from DOCX

The problem was that CppunitTest_sw_ooxmlexport9's testTdf79329 has a
normal outer table and a floating inner table; the inner table was
already not floating (so that's not a new problem), but
SW_FORCE_FLY_SPLIT=1 even failed the text-to-table conversion for the
outer table, so we just had 1 table, not 2 tables.

The problem seems to be that the start/end positions for the outer table
cell get invalidated by the inner table-to-frame conversion, so the
outer table conversion will fail as well.

Fix the problem by limiting the table-to-frame conversion for toplevel
tables: this avoids the failing text-to-table conversion in the
SW_FORCE_FLY_SPLIT=1 case.

At some stage I should revisit this, since the DOC import has working
floating tables for the inner case, for now just make sure that the DOCX
import result has two tables, as before.

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

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index c821953f1160..50c07f693c25 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -848,12 +848,19 @@ DECLARE_OOXMLEXPORT_TEST(testBnc519228OddBreaks, 
"bnc519228_odd-breaksB.docx")
 getParagraphOfText( 1, getProperty< uno::Reference 
>(page5Style, "HeaderText"), "This is the header for odd pages");
 }
 
-DECLARE_OOXMLEXPORT_TEST(testTdf79329, "tdf79329.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf79329)
 {
-uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
-uno::Reference 
xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
-// This was 1: only the inner, not the outer table was created.
-CPPUNIT_ASSERT_EQUAL(static_cast(2), xTables->getCount());
+SwModelTestBase::FlySplitGuard aGuard;
+auto verify = [this]() {
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+// This was 1: only the inner, not the outer table was created.
+CPPUNIT_ASSERT_EQUAL(static_cast(2), xTables->getCount());
+};
+createSwDoc("tdf79329.docx");
+verify();
+reload(mpFilter, "tdf79329.docx");
+verify();
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf103982)
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 97b9e3c64991..70fdcae061de 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1618,9 +1618,10 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
 // Only execute the conversion if the table is not anchored at
 // the start of an outer table cell, that's not yet
 // implemented.
-// Tables starting at cell start are not a problem if we don't 
delay via
-// m_aPendingFloatingTables.
-if (xTextAppendAndConvert.is() && (!bTableStartsAtCellStart || 
IsFlySplitAllowed()))
+// Multi-page floating tables works if an outer/toplevel table 
is floating, but not
+// when an inner table would float.
+bool bToplevelSplitFly = IsFlySplitAllowed() && 
nestedTableLevel <= 1;
+if (xTextAppendAndConvert.is() && (!bTableStartsAtCellStart || 
bToplevelSplitFly))
 {
 std::deque aFramedRedlines = 
m_rDMapper_Impl.m_aStoredRedlines[StoredRedlines::FRAME];
 std::vector redPos, redLen;


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

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

New commits:
commit ed0372bac123b402fe3cd694a455e8328117752d
Author: László Németh 
AuthorDate: Mon Mar 20 17:27:32 2023 +0100
Commit: László Németh 
CommitDate: Tue Mar 21 15:57:27 2023 +

tdf#153255 DOCX import: fix footnote order

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

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

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

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

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

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

2023-03-17 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |1 
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   10 
 writerfilter/source/dmapper/PropertyMap.cxx  |  175 +++
 writerfilter/source/dmapper/PropertyMap.hxx  |5 
 4 files changed, 108 insertions(+), 83 deletions(-)

New commits:
commit 9a9ee21ec237eda5df6ea70bfa3bec07b44b4d21
Author: Miklos Vajna 
AuthorDate: Fri Mar 17 15:14:37 2023 +0100
Commit: Miklos Vajna 
CommitDate: Fri Mar 17 19:24:40 2023 +

sw floattable: fix redline import from DOCX

The problem was that sw/qa/extras/ooxmlexport/data/tdf149388.docx
contained redlines but those were not imported for split flys.

This happened because split flys get imported directly in
DomainMapperTableHandler::endTable(), and the redling handling for
floating tables was only implemented in
SectionPropertyMap::CloseSectionGroup() (where delayed floating tables
are imported).

Fix this by extracting the redline import code for floating tables into
2 functions and then calling those also from
DomainMapperTableHandler::endTable().

Note that the !isExported() branch of the testcase looks like dead code,
since we always run this code after an export.

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

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index b3c2bceef5bb..d5ca8435b82b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1509,6 +1509,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf149388)
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf132271)
 {
+SwModelTestBase::FlySplitGuard aGuard;
 // see also testTdf149388
 loadAndSave("tdf149388.docx");
 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 968e3c0835a7..bd81fb9df941 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1619,7 +1619,17 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
 // the start of an outer table cell, that's not yet
 // implemented.
 if (xTextAppendAndConvert.is() && !bTableStartsAtCellStart)
+{
+std::deque aFramedRedlines = 
m_rDMapper_Impl.m_aStoredRedlines[StoredRedlines::FRAME];
+std::vector redPos, redLen;
+std::vector redCell;
+std::vector redTable;
+BeforeConvertToTextFrame(aFramedRedlines, redPos, redLen, 
redCell, redTable);
+
 xTextAppendAndConvert->convertToTextFrame(xStart, xEnd, 
comphelper::containerToSequence(aFrameProperties));
+
+AfterConvertToTextFrame(m_rDMapper_Impl, aFramedRedlines, 
redPos, redLen, redCell, redTable);
+}
 }
 }
 
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index 2c917873c455..40d9eec86b7f 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1354,6 +1354,96 @@ void 
SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl&
 rAnchoredObjectAnchors.clear();
 }
 
+void BeforeConvertToTextFrame(std::deque& rFramedRedlines, 
std::vector& redPos, std::vector& redLen, 
std::vector& redCell, std::vector& redTable)
+{
+// convert redline ranges to cursor movement and character length
+for( size_t i = 0; i < rFramedRedlines.size(); i+=3)
+{
+uno::Reference xCell;
+uno::Reference< text::XTextRange > xRange;
+rFramedRedlines[i] >>= xRange;
+uno::Reference< beans::XPropertySet > xRangeProperties;
+if ( xRange.is() )
+{
+OUString sTableName;
+OUString sCellName;
+xRangeProperties.set( xRange, uno::UNO_QUERY_THROW );
+if 
(xRangeProperties->getPropertySetInfo()->hasPropertyByName("TextTable"))
+{
+uno::Any aTable = 
xRangeProperties->getPropertyValue("TextTable");
+if ( aTable != uno::Any() )
+{
+uno::Reference xTable;
+aTable >>= xTable;
+uno::Reference 
xTableProperties(xTable, uno::UNO_QUERY);
+xTableProperties->getPropertyValue("TableName") >>= 
sTableName;
+}
+if 
(xRangeProperties->getPropertySetInfo()->hasPropertyByName("Cell"))
+{
+uno::Any aCell = 

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

2023-03-15 Thread Justin Luth (via logerrit)
 sw/qa/extras/rtfexport/data/tdf154129_transparentFrame.rtf |3 +++
 sw/qa/extras/rtfexport/rtfexport3.cxx  |6 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |   10 ++
 3 files changed, 15 insertions(+), 4 deletions(-)

New commits:
commit b1194e42dde6e3749631a6510d9e7b969e5eae8e
Author: Justin Luth 
AuthorDate: Mon Mar 13 12:57:35 2023 -0400
Commit: Justin Luth 
CommitDate: Wed Mar 15 16:16:24 2023 +

tdf#154129 writerfilter framePr: deduplicate BackColorTransparency

Well, not really deduplicate, because it only existed once.

Added long ago with commit 4ac48167662c592c21025b89fe8f6925c680c6e0
Author: Miklos Vajna on Mon Feb 20 15:46:08 2012 +0100
n#695479 fix rtf/docx import of transparent frames

However, it didn't handle the situation where
{\stylesheet{\fs19\lang1033 \snext0 Normal;}}
was missing. In that case there is no "Normal"
paragraph style to inherit from, and thus his fix is also
needed in the no-style case.

make CppunitTest_sw_rtfexport3 \
CPPUNIT_TEST_NAME=testTdf154129_transparentFrame

Change-Id: Iaa5b92cd626192d44d11c1365b9b483bd46dff9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148815
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/rtfexport/data/tdf154129_transparentFrame.rtf 
b/sw/qa/extras/rtfexport/data/tdf154129_transparentFrame.rtf
new file mode 100644
index ..29cece2af5c8
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf154129_transparentFrame.rtf
@@ -0,0 +1,3 @@
+{\rtf1\ansi\ansicpg1252\deff0\deflang1033
+\paperw7920\paperh6120\margl360\margr360\margt360\margb302\gutter0 
\windowctrl\ftnbj\viewkind1\viewscale100 \sectd \linex0
+{\pard \pvpg\phcol\posx2204\posy3791\absw1772\absh-230\overlay {\pard \cf1 \f0 
\b \pvpg\phcol\posx2204\posy3791\absw1772\absh-220\overlay 
VISIBLE\par}\par}\sect }
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx 
b/sw/qa/extras/rtfexport/rtfexport3.cxx
index e47212c82f86..83d1743e05d2 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -109,6 +109,12 @@ DECLARE_RTFEXPORT_TEST(testTdf130817, "tdf130817.rtf")
 CPPUNIT_ASSERT_EQUAL(OUString("$"), xEndnote1->getAnchor()->getString());
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf154129_transparentFrame, 
"tdf154129_transparentFrame.rtf")
+{
+// Without the fix, this was zero, and the text frame with "Visible" just 
looks white.
+CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty(getShape(1), 
"FillTransparence"));
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf137683_charHighlightNone, 
"tdf137683_charHighlightNone.rtf")
 {
 uno::Reference xRun(getRun(getParagraph(1), 1), 
uno::UNO_QUERY_THROW);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0f8991819b3b..2324fa78c2b5 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1811,12 +1811,14 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion( )
 
comphelper::makePropertyValue(getPropertyName(PROP_FRM_DIRECTION), 
*nDirection));
 }
 
+// If there is no fill, the Word default is 100% transparency.
+// Otherwise CellColorHandler has priority, and this setting
+// will be ignored.
+aFrameProperties.push_back(comphelper::makePropertyValue(
+getPropertyName(PROP_BACK_COLOR_TRANSPARENCY), sal_Int32(100)));
+
 if (vProps.size() > 1)
 {
-// If there is no fill, the Word default is 100% transparency.
-// Otherwise CellColorHandler has priority, and this setting
-// will be ignored.
-
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_BACK_COLOR_TRANSPARENCY),
 sal_Int32(100)));
 
 uno::Sequence aGrabBag( 
comphelper::InitPropertySequence({
 { "ParaFrameProperties", 
uno::Any(rAppendContext.pLastParagraphProperties->IsFrameMode()) }


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

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

New commits:
commit 949b2bbbaaa9bd21b6882dab49ea2018a08d2362
Author: Justin Luth 
AuthorDate: Wed Mar 15 07:54:53 2023 -0400
Commit: Justin Luth 
CommitDate: Wed Mar 15 13:54:37 2023 +

tdf#146984 writerfilter inline_inline: no break in shape

Change-Id: I94efea80df1fee9ecd338bfec3430edfdf418e3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148918
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf146984_anchorInShape.docx 
b/sw/qa/extras/ooxmlexport/data/tdf146984_anchorInShape.docx
new file mode 100644
index ..38fcaf9abeb9
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf146984_anchorInShape.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index c30e555ae15e..b19c196016b2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -135,6 +135,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104394_lostTextbox, 
"tdf104394_lostTextbox.docx"
 CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf146984_anchorInShape, 
"tdf146984_anchorInShape.docx")
+{
+// This was only one page b/c the page break was missing.
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+
+const auto& pLayout = parseLayoutDump();
+// There are shapes on both pages - these should be non-zero numbers
+assertXPath(pLayout, "//page[1]//anchored", 3);
+assertXPath(pLayout, "//page[2]//anchored", 2);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf154129_framePr1, "tdf154129_framePr1.docx")
 {
 for (size_t i = 1; i < 4; ++i)
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 800ae2525060..9db58e721a1b 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2569,7 +2569,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
 break;
 //tdf112342: Break before images as well, if there are page break
 if (m_pImpl->isBreakDeferred(BreakType::PAGE_BREAK)
-&& nSprmId == NS_ooxml::LN_inline_inline)
+&& nSprmId == NS_ooxml::LN_inline_inline && !m_pImpl->IsInShape())
 {
 if (m_pImpl->GetIsFirstParagraphInSection() || 
!m_pImpl->IsFirstRun())
 {


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

2023-03-14 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak3.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   10 

 writerfilter/source/dmapper/DomainMapper.cxx  |5 +++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   12 
++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |3 ++
 5 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit 828fde37632a5bb0542b6925454690a5287d6490
Author: Justin Luth 
AuthorDate: Tue Mar 14 14:20:58 2023 -0400
Commit: Justin Luth 
CommitDate: Wed Mar 15 01:38:29 2023 +

tdf#153613 tdf#146984 writerfilter: split para after anchors

Even though the w:br occurs in the paragraph before the anchors,
the anchors stay on the first page, and don't move to the second page
(unless it is the last paragraph in the section/document,
which is not yet handled.)

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf153613_textboxAfterPgBreak3

Change-Id: Icfc7e2a5d7657f1eb8f94263a4bfc8dcca7e52de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148897
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak3.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak3.docx
new file mode 100644
index ..a282deaa0ad7
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak3.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 460f4098e837..c30e555ae15e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -217,6 +217,16 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak2, "tdf153613_textboxA
 assertXPathContent(pLayout, "//page[2]/body/txt", "There should be no 
prior carriage return.");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak3, 
"tdf153613_textboxAfterPgBreak3.docx")
+{
+// All anchored TO-character shapes stay on the first page, before the 
page break.
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+CPPUNIT_ASSERT_EQUAL(3, getParagraphs());
+
+const auto& pLayout = parseLayoutDump();
+assertXPath(pLayout, "//page[2]//anchored", 0);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf153613_sdtAfterPgBreak, 
"tdf153613_sdtAfterPgBreak.docx")
 {
 CPPUNIT_ASSERT_EQUAL(2, getPages());
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index c526968fc8c0..800ae2525060 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3635,7 +3635,7 @@ void 
DomainMapper::lcl_startShape(uno::Reference const& xShape)
 {
 // If there is a deferred page break, handle it now, so that the
 // started shape will be on the correct page.
-if (m_pImpl->isBreakDeferred(PAGE_BREAK))
+if (m_pImpl->isBreakDeferred(PAGE_BREAK) && 
!m_pImpl->IsBreakDeferredByAnchor())
 {
 // RTF doesn't properly report IsFirstRun, so in order to prevent 
regressions
 // always split the paragraph for RTF since that is the way it has 
been done lately.
@@ -3645,6 +3645,9 @@ void 
DomainMapper::lcl_startShape(uno::Reference const& xShape)
 finishParagraph();
 lcl_startParagraphGroup();
 }
+else
+m_pImpl->SetIsBreakDeferredByAnchor();
+
 }
 m_pImpl->PushShapeContext( xShape );
 lcl_startParagraphGroup();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 62dda7d02ac2..f33d3c390afb 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1477,6 +1477,7 @@ void DomainMapper_Impl::clearDeferredBreak(BreakType 
deferredBreakType)
 break;
 case PAGE_BREAK:
 m_bIsPageBreakDeferred = false;
+m_bIsBreakDeferredByAnchor = false;
 break;
 default:
 break;
@@ -1488,6 +1489,17 @@ void DomainMapper_Impl::clearDeferredBreaks()
 m_nLineBreaksDeferred = 0;
 m_bIsColumnBreakDeferred = false;
 m_bIsPageBreakDeferred = false;
+m_bIsBreakDeferredByAnchor = false;
+}
+
+bool DomainMapper_Impl::IsBreakDeferredByAnchor()
+{
+return m_bIsBreakDeferredByAnchor;
+}
+
+void DomainMapper_Impl::SetIsBreakDeferredByAnchor()
+{
+m_bIsBreakDeferredByAnchor = true;
 }
 
 void DomainMapper_Impl::setSdtEndDeferred(bool bSdtEndDeferred)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 234ae9416eb1..050a510353a8 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -487,6 +487,7 @@ 

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

2023-03-14 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf112287.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |1 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   29 +++---
 3 files changed, 21 insertions(+), 9 deletions(-)

New commits:
commit 1bc004f67feb51beb00113cedd5f98a1e6e2bcdd
Author: Justin Luth 
AuthorDate: Sat Mar 11 16:00:27 2023 -0500
Commit: Justin Luth 
CommitDate: Tue Mar 14 12:03:06 2023 +

tdf#154129 writerfilter framePr: check whole style inheritance: X/XAlign

This patch depends on HAnchor, which created vProps.

XAlign is not like YAlign - which is invalid with a text anchor.
XAlign is still valid with a text anchor,
and so doesn't need to copy YAlign's special vAnchor default.
A unit test was added just to pre-emptively assert that.

There were no existing unit tests where the old and new method
produced different values.

Change-Id: Ib3066f3d67c01a1bca972c6a114bb726bccac5af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148714
Reviewed-by: Justin Luth 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf112287.docx 
b/sw/qa/extras/ooxmlexport/data/tdf112287.docx
index 3464e28985da..ca22693186e0 100644
Binary files a/sw/qa/extras/ooxmlexport/data/tdf112287.docx and 
b/sw/qa/extras/ooxmlexport/data/tdf112287.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index adfaca7aaf0f..84d8b45cddf0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1416,6 +1416,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf112287)
 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
 
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","margin");
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","hAnchor","text");
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf112287B)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3fcabf1ccb37..bc1f7f8452ed 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1667,18 +1667,29 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion( )
 
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_FRM_DIRECTION),
 *nDirection));
 }
 
-sal_Int16 nHoriOrient = sal_Int16(
-rAppendContext.pLastParagraphProperties->GetxAlign() >= 0 ?
-rAppendContext.pLastParagraphProperties->GetxAlign() :
-pStyleProperties->props().GetxAlign() >= 0 ? 
pStyleProperties->props().GetxAlign() : text::HoriOrientation::NONE );
+sal_Int16 nHoriOrient = text::HoriOrientation::NONE;
+for (const auto pProp : vProps)
+{
+if (pProp->GetxAlign() < 0)
+continue;
+nHoriOrient = pProp->GetxAlign();
+break;
+}
 
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_HORI_ORIENT),
 nHoriOrient));
 
 //set a non negative default value
-
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_HORI_ORIENT_POSITION),
-rAppendContext.pLastParagraphProperties->IsxValid() ?
-rAppendContext.pLastParagraphProperties->Getx() :
-pStyleProperties->props().IsxValid()
-? pStyleProperties->props().Getx() : DEFAULT_VALUE));
+bool bValidX = false;
+sal_Int32 nX = DEFAULT_VALUE;
+for (const auto pProp : vProps)
+{
+bValidX = pProp->IsxValid();
+if (!bValidX)
+continue;
+nX = pProp->Getx();
+break;
+}
+aFrameProperties.push_back(
+
comphelper::makePropertyValue(getPropertyName(PROP_HORI_ORIENT_POSITION), nX));
 
 //Default the anchor in case FramePr_hAnchor is missing ECMA 
17.3.1.11
 sal_Int16 nHAnchor = text::RelOrientation::FRAME;


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

2023-03-14 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf112287B.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |9 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |5 +++--
 3 files changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 630732bfd8ed531e9d412a36a083f33763def054
Author: Justin Luth 
AuthorDate: Sat Mar 11 13:16:56 2023 -0500
Commit: Justin Luth 
CommitDate: Tue Mar 14 12:02:24 2023 +

tdf#112287 tdf#154129 writerfilter framePr: fix vAnchor default

This patch depends on previous patches for tdf#154129.

yAlign takes precedence over w:y. HOWEVER, there is a clause
in the documentation that complicates everything.

"If [yAlign is] specified, the position for this attribute
supersedes any value which is specified in the y attribute,
and that value is ignored, UNLESS the vAnchor is set to 'text',
in which case any relative positioning is not allowed,
and [yAlign] is itself ignored"

So if vAnchor is not defined, it defaults to text (FRAME),
but if yAlign is defined then it should mean margin
(or else yAlign has no meaning), unless of course w:y
is also defined, in which case "text" anchor has meaning again
and this unit test shows that w:y wins out in this case.

The anchor is not affected by wrapping.

[P.S. This was already set correctly in the code, but worth noting:
 "The standard states that the default value for the vAnchor attribute is 
page.
 Word uses a default value of 'text' for this attribute."]

make CppunitTest_sw_ooxmlexport5 CPPUNIT_TEST_NAME=testTdf112287
make CppunitTest_sw_ooxmlexport5 CPPUNIT_TEST_NAME=testTdf112287B

Change-Id: I953afa89e3c0974a16d43500ce590e1a481c2251
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148691
Reviewed-by: Justin Luth 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf112287B.docx 
b/sw/qa/extras/ooxmlexport/data/tdf112287B.docx
new file mode 100644
index ..945d3d026b19
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf112287B.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index f33013413a1c..adfaca7aaf0f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1418,6 +1418,15 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf112287)
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","margin");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf112287B)
+{
+loadAndSave("tdf112287B.docx");
+xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
+
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","text");
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","hAnchor","text");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testZOrderInHeader)
 {
 loadAndSave("tdf120760_ZOrderInHeader.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index fad1efd9ead3..3fcabf1ccb37 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1718,8 +1718,9 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( 
)
 
 //Default the anchor in case FramePr_vAnchor is missing ECMA 
17.3.1.11
 sal_Int16 nVAnchor = text::RelOrientation::FRAME; // 'text'
-if (rAppendContext.pLastParagraphProperties->GetWrap() != 
text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE ||
-pStyleProperties->props().GetWrap() != 
text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE)
+// vAlign is ignored if vAnchor is set to 'text'. So, if w:y is 
not defined,
+// but there is a defined vAlign, then a missing vAnchor should 
become 'margin'.
+if (!bValidY && nVertOrient)
 {
 nVAnchor = text::RelOrientation::PAGE_PRINT_AREA; // 'margin'
 }


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

2023-03-13 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|4 +--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   23 ++
 2 files changed, 13 insertions(+), 14 deletions(-)

New commits:
commit c253fc3877fd91f4345feb60dacb6565f9a2509b
Author: Justin Luth 
AuthorDate: Sat Mar 11 12:25:18 2023 -0500
Commit: Justin Luth 
CommitDate: Tue Mar 14 00:18:12 2023 +

tdf#154129 writerfilter framePr: check whole style inheritance: VAnchor

This patch depends on HAnchor, which created vProps.

A style can inherit its properties from another style,
but the code was naively just checking the first paragraph style,
and not any of the parents.

make CppunitTest_sw_ooxmlexport18 CPPUNIT_TEST_NAME=testTdf154129_framePr1

Change-Id: I72159321485aca18bc4bb8384221ff59cb685fe0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148689
Reviewed-by: Justin Luth 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 3c8950162648..460f4098e837 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -143,8 +143,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf154129_framePr1, 
"tdf154129_framePr1.docx")
 // The anchor is defined in the style, and only the first style was 
checked, not the parents
 auto nAnchor = getProperty(xTextFrame, 
"HoriOrientRelation");
 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, nAnchor);
-//nAnchor = getProperty(xTextFrame, "VertOrientRelation");
-//CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, nAnchor);
+nAnchor = getProperty(xTextFrame, "VertOrientRelation");
+CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, nAnchor);
 }
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index a63c172caf0c..e6f9f8f6a3ab 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1706,22 +1706,21 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion( )
 ? pStyleProperties->props().Gety() : DEFAULT_VALUE));
 
 //Default the anchor in case FramePr_vAnchor is missing ECMA 
17.3.1.11
-if (rAppendContext.pLastParagraphProperties->GetWrap() == 
text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE &&
-pStyleProperties->props().GetWrap()
-== text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE)
+sal_Int16 nVAnchor = text::RelOrientation::FRAME; // 'text'
+if (rAppendContext.pLastParagraphProperties->GetWrap() != 
text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE ||
+pStyleProperties->props().GetWrap() != 
text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE)
 {
-
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_VERT_ORIENT_RELATION),
 sal_Int16(
-rAppendContext.pLastParagraphProperties->GetvAnchor() >= 0 
?
-rAppendContext.pLastParagraphProperties->GetvAnchor() :
-pStyleProperties->props().GetvAnchor() >= 0 ? 
pStyleProperties->props().GetvAnchor() : text::RelOrientation::FRAME)));
+nVAnchor = text::RelOrientation::PAGE_PRINT_AREA; // 'margin'
 }
-else
+for (const auto pProp : vProps)
 {
-
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_VERT_ORIENT_RELATION),
 sal_Int16(
-rAppendContext.pLastParagraphProperties->GetvAnchor() >= 0 
?
-rAppendContext.pLastParagraphProperties->GetvAnchor() :
-pStyleProperties->props().GetvAnchor() >= 0 ? 
pStyleProperties->props().GetvAnchor() : 
text::RelOrientation::PAGE_PRINT_AREA)));
+if (pProp->GetvAnchor() < 0)
+continue;
+nVAnchor = pProp->GetvAnchor();
+break;
 }
+aFrameProperties.push_back(comphelper::makePropertyValue(
+getPropertyName(PROP_VERT_ORIENT_RELATION), nVAnchor));
 
 
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_SURROUND),
 rAppendContext.pLastParagraphProperties->GetWrap() != 
text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE


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

2023-03-13 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf154129_framePr1.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   14 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   29 +++---
 3 files changed, 39 insertions(+), 4 deletions(-)

New commits:
commit 1519ae101abf32187db983c8a08f7bf1899d5d22
Author: Justin Luth 
AuthorDate: Sat Mar 11 11:36:59 2023 -0500
Commit: Miklos Vajna 
CommitDate: Mon Mar 13 07:43:12 2023 +

tdf#154129 writerfilter framePr: check whole style inheritance: HAnchor

A style can inherit its properties from another style,
but the code was naively just checking the first paragraph style,
and not any of the parents.

I'm going to onboard these one at a time.

make CppunitTest_sw_ooxmlexport18 CPPUNIT_TEST_NAME=testTdf154129_framePr1

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf154129_framePr1.docx 
b/sw/qa/extras/ooxmlexport/data/tdf154129_framePr1.docx
new file mode 100644
index ..27ba6055c287
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf154129_framePr1.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 9e637fb937e7..3c8950162648 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -134,6 +135,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104394_lostTextbox, 
"tdf104394_lostTextbox.docx"
 CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf154129_framePr1, "tdf154129_framePr1.docx")
+{
+for (size_t i = 1; i < 4; ++i)
+{
+uno::Reference xTextFrame = getShape(i);
+// The anchor is defined in the style, and only the first style was 
checked, not the parents
+auto nAnchor = getProperty(xTextFrame, 
"HoriOrientRelation");
+CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, nAnchor);
+//nAnchor = getProperty(xTextFrame, "VertOrientRelation");
+//CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, nAnchor);
+}
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, 
"tdf153613_anchoredAfterPgBreak.docx")
 {
 const auto& pLayout = parseLayoutDump();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 68f2511358b8..f8cbc3c7f3f5 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1603,6 +1603,21 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion( )
 StyleSheetEntryPtr pParaStyle =
 
GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(rAppendContext.pLastParagraphProperties->GetParaStyleName());
 
+// A paragraph's properties come from direct formatting or somewhere 
in the style hierarchy
+std::vector vProps;
+vProps.emplace_back(rAppendContext.pLastParagraphProperties.get());
+sal_Int8 nSafetyLimit = 16;
+StyleSheetEntryPtr pStyle = 
GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(
+rAppendContext.pLastParagraphProperties->GetParaStyleName());
+while (--nSafetyLimit && pStyle && pStyle->m_pProperties)
+{
+vProps.emplace_back(>m_pProperties->props());
+assert(pStyle->m_sBaseStyleIdentifier != pStyle->m_sStyleName);
+if (pStyle->m_sBaseStyleIdentifier.isEmpty())
+break;
+pStyle = 
GetStyleSheetTable()->FindStyleSheetByISTD(pStyle->m_sBaseStyleIdentifier);
+}
+
 std::vector aFrameProperties;
 
 if ( pParaStyle )
@@ -1665,10 +1680,16 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion( )
 ? pStyleProperties->props().Getx() : DEFAULT_VALUE));
 
 //Default the anchor in case FramePr_hAnchor is missing ECMA 
17.3.1.11
-
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_HORI_ORIENT_RELATION),
 sal_Int16(
-rAppendContext.pLastParagraphProperties->GethAnchor() >= 0 ?
-rAppendContext.pLastParagraphProperties->GethAnchor() :
-pStyleProperties->props().GethAnchor() >=0 ? 
pStyleProperties->props().GethAnchor() : text::RelOrientation::FRAME )));
+sal_Int16 nHAnchor = text::RelOrientation::FRAME;
+for (const auto pProp : vProps)
+{
+if (pProp->GethAnchor() < 0)
+continue;
+nHAnchor = pProp->GethAnchor();
+break;
+}
+aFrameProperties.push_back(comphelper::makePropertyValue(
+   

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

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

New commits:
commit f4f91c9e7ad9ad669f03fc9a09cd20fdfb53805b
Author: Justin Luth 
AuthorDate: Fri Mar 10 12:45:35 2023 -0500
Commit: Justin Luth 
CommitDate: Fri Mar 10 20:40:36 2023 +

tdf#104394 writerfilter: no addDummyParaForTable when PrevFramed

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

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

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

Change-Id: I7fb2c6189ddbff5d46828b27d68667c9d4a31122
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148656
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf104394_lostTextbox.docx 
b/sw/qa/extras/ooxmlexport/data/tdf104394_lostTextbox.docx
new file mode 100644
index ..472d0723a9ac
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf104394_lostTextbox.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index b9432a32a47b..9e637fb937e7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -128,6 +128,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153592_columnBreaks)
 assertXPath(pXmlDoc, "//w:br", 2);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf104394_lostTextbox, 
"tdf104394_lostTextbox.docx")
+{
+// This was only one page b/c the textbox was missing.
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, 
"tdf153613_anchoredAfterPgBreak.docx")
 {
 const auto& pLayout = parseLayoutDump();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index b7e94ff50e84..c526968fc8c0 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3173,7 +3173,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
  */
 if(m_pImpl->m_nTableDepth == 0 && 
m_pImpl->GetIsFirstParagraphInSection()
 && !m_pImpl->GetIsDummyParaAddedForTableInSection() && 
!m_pImpl->GetIsTextFrameInserted()
-&& !IsInHeaderFooter())
+&& !m_pImpl->GetIsPreviousParagraphFramed() && 
!IsInHeaderFooter())
 {
 m_pImpl->AddDummyParaForTableInSection();
 }


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

2023-03-08 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153964_firstIndentAfterBreak14.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf153964_numberingAfterBreak14.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |   42 
+-
 writerfilter/source/dmapper/DomainMapper.cxx |3 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|   15 +++
 5 files changed, 56 insertions(+), 4 deletions(-)

New commits:
commit 80e8763036f36afd482a06fbf0f3ffe1ebbe2b46
Author: Justin Luth 
AuthorDate: Tue Mar 7 20:26:22 2023 -0500
Commit: Justin Luth 
CommitDate: Thu Mar 9 00:33:26 2023 +

tdf#153964 writerfilter: column break split should inherit most properties

When a column break or page break split occurs,
the split off paragraph should keep (most of) the properties
of the original paragraph. This already happened for page breaks.

Exceptions are first line indents, and numbering
if there was a run to apply them to already.

This commit:
-tells lcl_startParagraph when column breaks are m_bIsParaSplit,
 resulting in the paragraph properties being copied over
-clears the para properties that shouldn't apply twice.

[Top Margin was more complicated and handled separately.]

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf153964_firstIndentAfterBreak14

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf153964_numberingAfterBreak14

Change-Id: I5ecd25da831894536044c6dbffbb0a262f8b6828
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148452
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf153964_firstIndentAfterBreak14.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153964_firstIndentAfterBreak14.docx
new file mode 100644
index ..696c4b4278c9
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153964_firstIndentAfterBreak14.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153964_numberingAfterBreak14.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153964_numberingAfterBreak14.docx
new file mode 100644
index ..a94a3c9736d7
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153964_numberingAfterBreak14.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 1e87210d90f8..770ea9a89dec 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -216,7 +216,7 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf153964_topMarginAfterBreak14, "tdf153964_topMarg
 // The top margin was applied to paragraph 3, so it shouldn't apply here
 xPara.set(getParagraph(4, u"column break1"), uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara, 
"ParaTopMargin"));
-//CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty(xPara, 
"ParaBackColor"));
+CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty(xPara, 
"ParaBackColor"));
 
 xPara.set(getParagraph(5, u"60 pt followed by page break"), 
uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty(xPara, 
"ParaTopMargin"));
@@ -240,7 +240,7 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf153964_topMarginAfterBreak14, "tdf153964_topMarg
 // The top margin was not applied before the column break, so with 
compat14 it should apply here
 xPara.set(getParagraph(10, u""), uno::UNO_QUERY); // after column break
 CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty(xPara, 
"ParaTopMargin"));
-//CPPUNIT_ASSERT_EQUAL(Color(0xfff2cc), getProperty(xPara, 
"ParaBackColor"));
+CPPUNIT_ASSERT_EQUAL(Color(0xfff2cc), getProperty(xPara, 
"ParaBackColor"));
 
 // In an odd twist, the w:br was actually at the end of the previous w:p, 
so in that case
 // we ignore the top margin definition this time.
@@ -262,7 +262,7 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf153964_topMarginAfterBreak15, "tdf153964_topMarg
 // The top margin was applied to paragraph 3, so it shouldn't apply here
 xPara.set(getParagraph(4, u"column break1"), uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara, 
"ParaTopMargin"));
-//CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty(xPara, 
"ParaBackColor"));
+CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty(xPara, 
"ParaBackColor"));
 
 xPara.set(getParagraph(5, u"60 pt followed by page break"), 
uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty(xPara, 
"ParaTopMargin"));
@@ -285,13 +285,47 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf153964_topMarginAfterBreak15, "tdf153964_topMarg
 // The top margin was not applied to paragraph 9, and with compat15 it 
shouldn't apply here.
 xPara.set(getParagraph(10, u""), uno::UNO_QUERY); // after column break
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara, 
"ParaTopMargin"));
-//CPPUNIT_ASSERT_EQUAL(Color(0xfff2cc), getProperty(xPara, 

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

2023-03-08 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak14.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak15.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx |   90 
++
 writerfilter/source/dmapper/DomainMapper.cxx   |   62 
++
 4 files changed, 151 insertions(+), 1 deletion(-)

New commits:
commit 96a502b3756a1c100b40235f50ef2122d5b543f9
Author: Justin Luth 
AuthorDate: Tue Mar 7 07:43:14 2023 -0500
Commit: Justin Luth 
CommitDate: Wed Mar 8 12:25:57 2023 +

tdf#153964 writerfilter compat15: top margin after break split

The problem was that the top margin was being applied
to the new paragraph after the split.

This is absolutely attrocious in MS Word before 2013.
If I am going to be in error, I want to error on the side
of being compliant with compat15, since all other versions
of MS Word are now unsupported.

I think I have the logic of it mostly figured out.
In compat15, the top margin never applies after the break.

In compat14, if the paragraph properties are not applied
to a run before the break, then they can be applied after the break.

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf153964_topMarginAfterBreak14

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf153964_topMarginAfterBreak15

Change-Id: I8816b391e898cfea58c2e0dbf01c881f87bbc4c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148451
Tested-by: Justin Luth 
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak14.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak14.docx
new file mode 100644
index ..6c57bcfdc8ef
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak14.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak15.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak15.docx
new file mode 100644
index ..e4d5c45ed034
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak15.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 67c15685d7a3..1e87210d90f8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -202,6 +202,96 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153613_sdtAfterPgBreak, 
"tdf153613_sdtAfterPgBre
 CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153964_topMarginAfterBreak14, 
"tdf153964_topMarginAfterBreak14.docx")
+{
+//The top margin should only apply once in a split paragraph.
+//In this compat14 (Windows 2010) version, it applies after the break if 
no prior visible run.
+uno::Reference xPara(getParagraph(2, "a w:br at the 
start of the document. Does it use 60 point top margin?"), uno::UNO_QUERY);
+//CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty(xPara, 
"ParaTopMargin"));
+
+xPara.set(getParagraph(3, u"60 pt spacing before"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty(xPara, 
"ParaTopMargin"));
+CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty(xPara, 
"ParaBackColor"));
+
+// The top margin was applied to paragraph 3, so it shouldn't apply here
+xPara.set(getParagraph(4, u"column break1"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara, 
"ParaTopMargin"));
+//CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty(xPara, 
"ParaBackColor"));
+
+xPara.set(getParagraph(5, u"60 pt followed by page break"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty(xPara, 
"ParaTopMargin"));
+CPPUNIT_ASSERT_EQUAL(Color(0xdeeaf6), getProperty(xPara, 
"ParaBackColor"));
+
+// The top margin was applied to paragraph 5, so it shouldn't apply here
+xPara.set(getParagraph(6, u"page break1"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara, 
"ParaTopMargin"));
+CPPUNIT_ASSERT_EQUAL(Color(0xdeeaf6), getProperty(xPara, 
"ParaBackColor"));
+
+// The top margin was not applied yet, so with compat14 it should apply 
here.
+xPara.set(getParagraph(7, u"column break2"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty(xPara, 
"ParaTopMargin"));
+CPPUNIT_ASSERT_EQUAL(Color(0xe2efd9), getProperty(xPara, 
"ParaBackColor"));
+
+// In an odd twist, the w:br was actually at the end of the previous w:p, 
so in that case
+// we ignore the top margin definition this time.
+xPara.set(getParagraph(9, u"page break2"), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara, 
"ParaTopMargin"));
+
+// The top margin was not applied before the column break, so with 
compat14 it should apply here
+xPara.set(getParagraph(10, u""), uno::UNO_QUERY); 

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

2023-03-03 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153613_sdtAfterPgBreak.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |5 +
 writerfilter/source/dmapper/DomainMapper.cxx |   31 +++
 3 files changed, 36 insertions(+)

New commits:
commit 620d1dc63b652db97b05eb21685dad70e6b2ab0d
Author: Justin Luth 
AuthorDate: Thu Mar 2 19:32:27 2023 -0500
Commit: Justin Luth 
CommitDate: Fri Mar 3 15:30:54 2023 +

tdf#153613 writerfilter: handle defered break before SDT start

If there are deferred column or page breaks before an SDT,
then before starting the SDT we need to determine if the
existing run needs to split - same as everywhere else.

There was only one existing unit test that had any defered
page or column breaks, so only two example documents to work from.
That was tdf125778_lostPageBreakTOX.docx.

Change-Id: I02d71577af13399d8aaf3ba0ce40fc6bed5e6e3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148148
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_sdtAfterPgBreak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_sdtAfterPgBreak.docx
new file mode 100644
index ..fa62b475cfaa
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_sdtAfterPgBreak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 2e71b5bcc7fe..67c15685d7a3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -197,6 +197,11 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak2, "tdf153613_textboxA
 assertXPathContent(pLayout, "//page[2]/body/txt", "There should be no 
prior carriage return.");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_sdtAfterPgBreak, 
"tdf153613_sdtAfterPgBreak.docx")
+{
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
 // Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 573a1b41f4a5..d816aad4a9af 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1075,7 +1075,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
 break;
 case NS_ooxml::LN_CT_SdtBlock_sdtContent:
 case NS_ooxml::LN_CT_SdtRun_sdtContent:
+{
 m_pImpl->m_pSdtHelper->SetSdtType(nName);
+
 if (m_pImpl->m_pSdtHelper->getControlType() == 
SdtControlType::unknown)
 {
 // Still not determined content type? and it is even not 
unsupported? Then it is plain text field
@@ -1093,11 +1095,40 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
 }
 }
 
+PropertyMapPtr pContext = 
m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
+if (pContext && m_pImpl->isBreakDeferred(PAGE_BREAK))
+{
+if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape()
+&& !m_pImpl->IsInComments())
+{
+if (m_pImpl->GetIsFirstParagraphInSection() || 
!m_pImpl->IsFirstRun())
+{
+m_pImpl->m_bIsSplitPara = true;
+finishParagraph();
+lcl_startParagraphGroup();
+}
+pContext->Insert(PROP_BREAK_TYPE, 
uno::Any(style::BreakType_PAGE_BEFORE));
+m_pImpl->clearDeferredBreaks();
+}
+}
+else if (pContext && m_pImpl->isBreakDeferred(COLUMN_BREAK))
+{
+if (m_pImpl->GetIsFirstParagraphInSection() || 
!m_pImpl->IsFirstRun())
+{
+mbIsSplitPara = true;
+finishParagraph();
+lcl_startParagraphGroup();
+}
+pContext->Insert(PROP_BREAK_TYPE, 
uno::Any(style::BreakType_COLUMN_BEFORE));
+m_pImpl->clearDeferredBreaks();
+}
+
 
m_pImpl->m_pSdtHelper->setControlType(SdtControlType::richText);
 m_pImpl->PushSdt();
 break;
 }
 m_pImpl->SetSdt(true);
+}
 break;
 case NS_ooxml::LN_CT_SdtBlock_sdtEndContent:
 case NS_ooxml::LN_CT_SdtRun_sdtEndContent:


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

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

New commits:
commit e34074feeb1b918ab9f26a18c5fdb0b1f2e35f94
Author: László Németh 
AuthorDate: Wed Mar 1 14:11:30 2023 +0100
Commit: László Németh 
CommitDate: Thu Mar 2 21:51:39 2023 +

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

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

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

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

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


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

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

New commits:
commit d4355f14d1483a57fa08579b143a762f0aad4631
Author: Michael Stahl 
AuthorDate: Tue Feb 28 18:36:26 2023 +0100
Commit: Michael Stahl 
CommitDate: Tue Feb 28 19:43:00 2023 +

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

Change-Id: I9704d35a8286b92169dffd8de7e57e286884f607
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148016
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 9eb7eabd2434..0394c03495a6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -830,6 +830,9 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153874, 
"image_through_shape.docx")
 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, 
xShape1->getPropertyValue("AnchorType").get());
 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, 
xShape2->getPropertyValue("AnchorType").get());
 CPPUNIT_ASSERT_LESS(xShape2->getPropertyValue("ZOrder").get(), 
xShape1->getPropertyValue("ZOrder").get());
+CPPUNIT_ASSERT(xShape1->getPropertyValue("Decorative").get());
+// not implemented on shape yet
+//CPPUNIT_ASSERT(xShape2->getPropertyValue("Decorative").get());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTextBoxZOrder, "testTextBoxZOrder.docx")
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx 
b/writerfilter/source/dmapper/GraphicImport.cxx
index c8c1e392f2c0..2351100f06bb 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1795,10 +1795,10 @@ uno::Reference 
GraphicImport::createGraphicObject(uno::Refer
 xGraphicObjectProperties->setPropertyValue(getPropertyName( 
PROP_SIZE_PROTECTED ),
 uno::Any(true));
 
+
xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_DECORATIVE), 
uno::Any(m_pImpl->m_bDecorative));
 sal_Int32 nWidth = - m_pImpl->m_nLeftPosition;
 if (m_pImpl->m_rGraphicImportType == IMPORT_AS_DETECTED_ANCHOR)
 {
-
xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_DECORATIVE), 
uno::Any(m_pImpl->m_bDecorative));
 //adjust margins
 if( (m_pImpl->m_nHoriOrient == text::HoriOrientation::LEFT &&
 (m_pImpl->m_nHoriRelation == 
text::RelOrientation::PAGE_PRINT_AREA ||


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

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

New commits:
commit dbbfcb7e098c1c16f932785ef62ef7d3d819ad1a
Author: Justin Luth 
AuthorDate: Wed Feb 22 11:19:40 2023 -0500
Commit: Justin Luth 
CommitDate: Wed Feb 22 22:35:06 2023 +

tdf#153526 writerfilter: catch exception from no NumberingRules

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

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

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

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx
new file mode 100644
index ..f26240092c10
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 8b6795b726c5..2e71b5bcc7fe 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -80,6 +80,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf147646, 
"tdf147646_mergedCellNumbering.docx")
 
CPPUNIT_ASSERT_EQUAL(OUString("2."),parseDump("/root/page/body/tab/row[4]/cell/txt/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']","expand"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153526_commentInNumbering, 
"tdf153526_commentInNumbering.docx")
+{
+// an exception was prematurely ending finishParagraph, losing numbering 
and CRs
+// so before the patch, this was 6.
+CPPUNIT_ASSERT_EQUAL(13, getParagraphs());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf153042_largeTab, "tdf153042_largeTab.docx")
 {
 // This is not the greatest test because it is slightly weird, and has a 
different layout
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index efc83477f818..558d71f90fe7 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2332,11 +2332,14 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
 uno::Reference 
xCurrentNumberingRules(itNumberingRules->Value, uno::UNO_QUERY);
 if (xCurrentNumberingRules.is())
 aCurrentNumberingName = 
xCurrentNumberingRules->getName();
-if (m_xPreviousParagraph.is())
+try
+{
+uno::Reference 
xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"),
 uno::UNO_QUERY_THROW);
+aPreviousNumberingName = 
xPreviousNumberingRules->getName();
+}
+catch (const uno::Exception&)
 {
-uno::Reference 
xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"),
 uno::UNO_QUERY);
-if (xPreviousNumberingRules.is())
-aPreviousNumberingName = 
xPreviousNumberingRules->getName();
+TOOLS_WARN_EXCEPTION("writerfilter", 
"DomainMapper_Impl::finishParagraph NumberingRules");
 }
 }
 else if ( 
m_xPreviousParagraph->getPropertySetInfo()->hasPropertyByName("NumberingStyleName")
 &&


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

2023-02-16 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak2.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |   12 
 sw/qa/extras/rtfexport/data/tdf153613_inlineAfterPgBreak2.rtf|  265 
++
 sw/qa/extras/rtfexport/rtfexport5.cxx|   12 
 writerfilter/source/dmapper/DomainMapper.cxx |   16 
 5 files changed, 302 insertions(+), 3 deletions(-)

New commits:
commit 5884a122dc2a2c73865efdbdd861c281475a681e
Author: Justin Luth 
AuthorDate: Thu Feb 16 09:16:39 2023 -0500
Commit: Justin Luth 
CommitDate: Thu Feb 16 20:41:22 2023 +

tdf#153613 writerfilter: split para for inline too if not FirstRun

If we have some stuff in a character run (i.e some text usually)
and then a page break
and then an inline image,
then the inline image should start a new paragraph
and move to the following page.
Only anchored images don't necessarily move to the next page.

make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_inlineAfterPgBreak2
make CppunitTest_sw_rtfexport5 
CPPUNIT_TEST_NAME=testTdf153613_inlineAfterPgBreak2

Change-Id: I756f756d836b29eedc776a35b7667ba33e6cdebd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147170
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak2.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak2.docx
new file mode 100644
index ..c8fe50ea3fa2
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak2.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 7afaa31b1889..b10a05986425 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -149,6 +149,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153613_inlineAfterPgBreak, 
"tdf153613_inlineAfte
 assertXPath(pLayout, "//page[2]//anchored", 1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_inlineAfterPgBreak2, 
"tdf153613_inlineAfterPgBreak2.docx")
+{
+// An inline AS character image moves to the following page when after the 
page break.
+// The difference from the previous test is that it is not the first 
character run
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+CPPUNIT_ASSERT_EQUAL(4, getParagraphs());
+
+const auto& pLayout = parseLayoutDump();
+CPPUNIT_ASSERT_EQUAL(OUString("x"), getXPathContent(pLayout, 
"//page[1]/body/txt[2]"));
+assertXPath(pLayout, "//page[2]//anchored", 1);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak, 
"tdf153613_textboxAfterPgBreak.docx")
 {
 CPPUNIT_ASSERT_EQUAL(3, getParagraphs());
diff --git a/sw/qa/extras/rtfexport/data/tdf153613_inlineAfterPgBreak2.rtf 
b/sw/qa/extras/rtfexport/data/tdf153613_inlineAfterPgBreak2.rtf
new file mode 100644
index ..43e43377f86b
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf153613_inlineAfterPgBreak2.rtf
@@ -0,0 +1,265 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang2057\deflangfe2057\themelang1038\themelangfe0\themelangcs1025{\fonttbl{\f1\fbidi
 \fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}{\f34\fbidi 
\froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria Math;}
+{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020f0502020204030204}Calibri;}{\f38\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020b0604030504040204}Tahoma;}{\flomajor\f31500\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
+{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi 
\fswiss\fcharset0\fprq2{\*\panose 020f0302020204030204}Calibri Light{\*\falt 
Calibri};}
+{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman;}{\flominor\f31504\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
+{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman;}{\fhiminor\f31506\fbidi 
\fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}
+{\fbiminor\f31507\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020b0604020202020204}Arial;}{\f240\fbidi \fswiss\fcharset238\fprq2 Arial 
CE;}{\f241\fbidi \fswiss\fcharset204\fprq2 Arial Cyr;}{\f243\fbidi 
\fswiss\fcharset161\fprq2 Arial Greek;}
+{\f244\fbidi \fswiss\fcharset162\fprq2 Arial Tur;}{\f245\fbidi 
\fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f246\fbidi 
\fswiss\fcharset178\fprq2 Arial (Arabic);}{\f247\fbidi 
\fswiss\fcharset186\fprq2 Arial Baltic;}
+{\f248\fbidi \fswiss\fcharset163\fprq2 Arial (Vietnamese);}{\f570\fbidi 
\froman\fcharset238\fprq2 Cambria Math CE;}{\f571\fbidi 
\froman\fcharset204\fprq2 Cambria Math Cyr;}{\f573\fbidi 
\froman\fcharset161\fprq2 Cambria Math Greek;}
+{\f574\fbidi 

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

2023-02-16 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak.docx  |binary
 sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak2.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   17 ++
 sw/qa/extras/rtfexport/data/n818997B.rtf  |   77 
++
 sw/qa/extras/rtfexport/rtfexport5.cxx |6 
 writerfilter/source/dmapper/DomainMapper.cxx  |   16 +-
 6 files changed, 108 insertions(+), 8 deletions(-)

New commits:
commit a9bc19c2d4a35606668aa2dcc53355651b71ee78
Author: Justin Luth 
AuthorDate: Wed Feb 15 13:54:31 2023 -0500
Commit: Justin Luth 
CommitDate: Thu Feb 16 20:39:40 2023 +

tdf#153613 writerfilter: don't always split para for shape w/ pagebreak

The problem was that an extra paragraph was added,
and the shape was anchored to the wrong page.

There are lots of places that handle deferred breaks,
and they typically do this only for FirstParagraph or non-first
character properties run.

This is needed here too.
make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_textboxAfterPgBreak
make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_textboxAfterPgBreak2

Of course, RTF is goofy, so handle that as an exception
to just leave it alone as it has been.
To solve it properly is likely very tricky - as are all things RTF,
because we can't trust IsFirstRun in general and especially not for RTF.
make CppunitTest_sw_rtfexport5 CPPUNIT_TEST_NAME=testN818997B

Change-Id: Iad06f3ea9684a2860ae6ba724887bdf0b5850f94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147169
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak.docx
new file mode 100644
index ..4ad4dfba8110
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak2.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak2.docx
new file mode 100644
index ..26006abd2fe3
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak2.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 81267209e7bc..7afaa31b1889 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -149,6 +149,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153613_inlineAfterPgBreak, 
"tdf153613_inlineAfte
 assertXPath(pLayout, "//page[2]//anchored", 1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak, 
"tdf153613_textboxAfterPgBreak.docx")
+{
+CPPUNIT_ASSERT_EQUAL(3, getParagraphs());
+
+const auto& pLayout = parseLayoutDump();
+assertXPathContent(pLayout, "//page[2]/body/txt", "There should be no 
prior carriage return.");
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak2, 
"tdf153613_textboxAfterPgBreak2.docx")
+{
+// same as previous example, except that it is the first paragraph in the 
section.
+CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
+
+const auto& pLayout = parseLayoutDump();
+assertXPathContent(pLayout, "//page[2]/body/txt", "There should be no 
prior carriage return.");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
 // Given a docx document with a shape with vert="mongolianVert".
diff --git a/sw/qa/extras/rtfexport/data/n818997B.rtf 
b/sw/qa/extras/rtfexport/data/n818997B.rtf
new file mode 100644
index ..94c0324f42e8
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/n818997B.rtf
@@ -0,0 +1,77 @@
+{\rtf 
+{\par\par\shp 
+{\*\shpinst\shpleft2310\shpright6060\shptop8685\shpbottom8985\shpbxpage
+\shpbypage\shpwr3\shpz2 
+{\sp 
+{\sn shapeType}
+{\sv 202}
+}
+{\sp 
+{\sn dxTextLeft}
+{\sv 
+0}
+}
+{\sp 
+{\sn dxTextRight}
+{\sv 0}
+}
+{\sp 
+{\sn dyTextTop}
+{\sv 0}
+}
+{\sp 
+{\sn 
+dyTextBottom}
+{\sv 0}
+}
+{\sp 
+{\sn fLine}
+{\sv 0}
+}
+{\shptxt\plain\pard\f29\fs24 
+On first page.\par}
+{\sp 
+{\sn fFilled}
+{\sv 0}
+}
+}
+}
+\page
+{\shp 
+{\*\shpinst\shpleft4800\shpright8025\shptop780\shpbottom1080\shpbxpage
+\shpbypage\shpwr3\shpz2 
+{\sp 
+{\sn shapeType}
+{\sv 202}
+}
+{\sp 
+{\sn dxTextLeft}
+{\sv 
+0}
+}
+{\sp 
+{\sn dxTextRight}
+{\sv 0}
+}
+{\sp 
+{\sn dyTextTop}
+{\sv 0}
+}
+{\sp 
+{\sn 
+dyTextBottom}
+{\sv 0}
+}
+{\sp 
+{\sn fLine}
+{\sv 0}
+}
+{\shptxt\plain\pard\f29\fs24\b 
+On second page.\par}
+{\sp 
+{\sn fFilled}
+{\sv 0}
+}
+}
+}
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx 
b/sw/qa/extras/rtfexport/rtfexport5.cxx
index e49960930297..376608ba22b3 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -86,6 +86,12 @@ 

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

2023-02-16 Thread Paris Oplopoios (via logerrit)
 sw/qa/extras/ooxmlexport/data/CommentReply.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx|2 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

New commits:
commit f2428c21c635b142b27adf020518d9b13b3baf0e
Author: Paris Oplopoios 
AuthorDate: Wed Feb 15 03:23:07 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Feb 16 08:44:42 2023 +

Fix issue where comment replies would not get a para id on roundtrip

Also adjusted the test file to account for this

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

diff --git a/sw/qa/extras/ooxmlexport/data/CommentReply.docx 
b/sw/qa/extras/ooxmlexport/data/CommentReply.docx
index 4a78d84d55e6..e3a648aa4326 100644
Binary files a/sw/qa/extras/ooxmlexport/data/CommentReply.docx and 
b/sw/qa/extras/ooxmlexport/data/CommentReply.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 30ef1735c73f..99c0b2c9ffe7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -885,6 +885,8 @@ CPPUNIT_TEST_FIXTURE(Test, testCommentReply)
 loadAndSave("CommentReply.docx");
 xmlDocUniquePtr pXmlComm = parseExport("word/comments.xml");
 xmlDocUniquePtr pXmlCommExt = parseExport("word/commentsExtended.xml");
+CPPUNIT_ASSERT(pXmlComm);
+CPPUNIT_ASSERT(pXmlCommExt);
 OUString sParentId = getXPath(pXmlComm, "/w:comments/w:comment[1]/w:p[1]", 
"paraId");
 OUString sChildId = getXPath(pXmlComm, "/w:comments/w:comment[2]/w:p[1]", 
"paraId");
 OUString sChildIdEx = getXPath(pXmlCommExt, 
"/w15:commentsEx/w15:commentEx", "paraId");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f5f8f70d732c..b282742e7311 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2696,8 +2696,8 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
 {
 m_bAnnotationResolved = item->second.bDone;
 m_sAnnotationParent = item->second.sParaIdParent;
-m_sAnnotationImportedParaId = sParaId;
 }
+m_sAnnotationImportedParaId = sParaId;
 }
 }
 


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

2023-02-15 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak.docx  |binary
 sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak2.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak3.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak.docx|binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx |   28 
++
 writerfilter/source/dmapper/DomainMapper.cxx   |3 -
 6 files changed, 30 insertions(+), 1 deletion(-)

New commits:
commit 02444789bb5e59e2582fdb92a5852db9c6471eac
Author: Justin Luth 
AuthorDate: Tue Feb 14 19:06:12 2023 -0500
Commit: Justin Luth 
CommitDate: Wed Feb 15 19:19:39 2023 +

tdf#153613 writerfilter: anchors ignore prior run with page break

Although an image that is INLINE with the text DOES move
to the following page when it is preceded by a w:br,
an anchored image does not (when it is the last property
in the paragraph).

make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_anchoredAfterPgBreak
make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_inlineAfterPgBreak

I also tested with x< following the anchor
and it already works correctly.
make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_anchoredAfterPgBreak2

I also tested with 
and it already works correctly.
make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_anchoredAfterPgBreak3

Change-Id: Ibf9c0d38c4dfe56db4e05416a40e3b7881693b17
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147032
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak.docx
new file mode 100644
index ..45010820867d
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak2.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak2.docx
new file mode 100644
index ..c29f8a49516b
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak2.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak3.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak3.docx
new file mode 100644
index ..5dd61ec7f409
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak3.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak.docx
new file mode 100644
index ..6b25d6c70c1e
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 8c2aa0c8a845..81267209e7bc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -121,6 +121,34 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153592_columnBreaks)
 assertXPath(pXmlDoc, "//w:br", 2);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, 
"tdf153613_anchoredAfterPgBreak.docx")
+{
+const auto& pLayout = parseLayoutDump();
+// An anchored TO character image anchors before the page break.
+assertXPath(pLayout, "//page[1]//anchored", 1);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak2, 
"tdf153613_anchoredAfterPgBreak2.docx")
+{
+const auto& pLayout = parseLayoutDump();
+// An anchored TO character image, followed by more characters moves to 
the following page
+assertXPath(pLayout, "//page[2]//anchored", 1);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak3, 
"tdf153613_anchoredAfterPgBreak3.docx")
+{
+const auto& pLayout = parseLayoutDump();
+// An anchored TO character image, with setting splitPgBreakAndParaMark 
moves to the following page
+assertXPath(pLayout, "//page[2]//anchored", 1);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_inlineAfterPgBreak, 
"tdf153613_inlineAfterPgBreak.docx")
+{
+const auto& pLayout = parseLayoutDump();
+// An inline AS character image moves to the following page when after the 
page break.
+assertXPath(pLayout, "//page[2]//anchored", 1);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
 // Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 35dd9940a652..85d91fd454fe 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2519,7 +2519,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
 if ( 

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

2023-02-14 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx|3 +++
 writerfilter/source/dmapper/DomainMapper.cxx |   10 ++
 2 files changed, 13 insertions(+)

New commits:
commit ce0b9f3eb3f57f57a2315e099a0093c33987e6ca
Author: Justin Luth 
AuthorDate: Mon Feb 13 17:47:36 2023 -0500
Commit: Justin Luth 
CommitDate: Tue Feb 14 14:21:42 2023 +

tdf#153602 writerfilter: clear isDummyPara after processing table.

Once the table is processed, the fact that we had a dummy paragraph
is no longer relevant to the section. So, after carefully figuring
out that we have had some other paragraph in the main text body,
clear the dummy status used to control bRemove.

This fixes the problem of adding an empty paragraph each round-trip.

Unfortunately, this would still fail if for example there was only
another table following the first one. Well, it wouldn't fail that
badly because the first save would add an empty paragraph,
and then following saves would use that single empty paragraph
as the one that resets things. So we always have at least one CR
following a table, but at least they aren't multiplying.

Unfortunately this isn't at all clean, because as soon as
the table starts, we no longer know that it is the first
paragraph in the section. (The other table paragraphs
and potentially header, comment, footnote, shape etc
can all set IsFirstParagraphInSection to off.
Basically, most flags are completely useless since
they are not stacked in any way. So we are left with
a multitude of conditions to check for everything.

Change-Id: Ic6a9795a6c529f8b5dd4f5d189db01b03d28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146955
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index bccfbddb7eb0..5bd2c3164fc8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -789,6 +789,9 @@ DECLARE_OOXMLEXPORT_TEST(testFdo53985, "fdo53985.docx")
 CPPUNIT_ASSERT_EQUAL_MESSAGE("TextSection is protected", true, 
getProperty(xSect, "IsProtected"));
 xSect.set(xSections->getByIndex(3), uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section3 is protected", false, 
getProperty(xSect, "IsProtected"));
+
+// This was increasing by 3 every round-trip - an extra paragraph after 
each table in sections
+CPPUNIT_ASSERT_EQUAL(9, getParagraphs());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testFdo59638, "fdo59638.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index c6fd96eb7407..62f2ad548e64 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -4131,6 +4131,16 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
 finishParagraph(bRemove, bNoNumbering);
 if (bRemove)
 m_pImpl->RemoveLastParagraph();
+
+// When the table is closed and the section's initial dummy 
paragraph has been processed
+// then any following sectPr paragraph in the section must be 
eligible for removal.
+if (!bRemove && 
m_pImpl->GetIsDummyParaAddedForTableInSectionPage() && !IsInTable()
+&& !m_pImpl->GetFootnoteContext() && !m_pImpl->IsInComments() 
&& !IsInHeaderFooter()
+&& !IsInShape())
+{
+   m_pImpl->SetIsDummyParaAddedForTableInSectionPage(false);
+}
+
 m_pImpl->SetParaSectpr(false);
 }
 else


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

2023-02-13 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf153592_columnBreaks.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|9 +
 writerfilter/source/dmapper/DomainMapper.cxx  |6 +++---
 3 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 80f9ad23282e0d8c4ba3441797d4899b9555eee3
Author: Justin Luth 
AuthorDate: Mon Feb 13 13:35:47 2023 -0500
Commit: Justin Luth 
CommitDate: Tue Feb 14 02:06:28 2023 +

tdf#153592 writerfilter: don't defer breaks into shapes/comments

When starting a pargraph, we already had a clause to avoid
deferring page and column breaks when we were in a shape
or a comment. These clauses are also necessary
in the other sections of the code where we defer these breaks.

The provided test proves the two shape cases in lcl_utext.
I just took IsInComments along for the ride,
as it certainly would apply in that case as well.

make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153592_columnBreaks

ooxmlexport4's testTdf81345_045Original proves that it is
also needed in lcl_text. However, it is such a complex document
that I wasn't confident that a unit test would be stable enough.

Change-Id: I2de15341d3e756bf47fcd85b868a849c8a2419cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146939
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153592_columnBreaks.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153592_columnBreaks.docx
new file mode 100644
index ..ea6acac29b5b
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153592_columnBreaks.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 8de09d6d3c7c..8c2aa0c8a845 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -112,6 +112,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153042_noTab, 
"tdf153042_noTab.docx")
 assertXPath(pLayout, "//SwFixPortion", "width", "10");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf153592_columnBreaks)
+{
+loadAndSave("tdf153592_columnBreaks.docx");
+
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// The two column breaks were lost on import. (I wouldn't complain if they 
were at 3,5)
+assertXPath(pXmlDoc, "//w:br", 2);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
 // Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index c2e84cf1534a..c6fd96eb7407 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3739,7 +3739,7 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, 
size_t len)
 m_pImpl->appendTextPortion("\n", pContext);
 }
 
-if (!m_pImpl->GetFootnoteContext())
+if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape() && 
!m_pImpl->IsInComments())
 {
 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, 
uno::Any(style::BreakType_PAGE_BEFORE));
@@ -4061,7 +4061,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
 const bool bSingleParagraphAfterRedline = 
m_pImpl->GetIsFirstParagraphInSection(/*bAfterRedline=*/true) &&
 m_pImpl->GetIsLastParagraphInSection();
 PropertyMapPtr pContext = 
m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
-if (!m_pImpl->GetFootnoteContext())
+if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape() && 
!m_pImpl->IsInComments())
 {
 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
 {
@@ -4137,7 +4137,7 @@ void DomainMapper::lcl_utext(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();
-if (!m_pImpl->GetFootnoteContext())
+if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape() && 
!m_pImpl->IsInComments())
 {
 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
 {


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

2023-01-31 Thread Michael Stahl (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|8 -
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   55 +-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |2 
 writerfilter/source/dmapper/StyleSheetTable.cxx   |  120 --
 writerfilter/source/dmapper/StyleSheetTable.hxx   |5 
 5 files changed, 153 insertions(+), 37 deletions(-)

New commits:
commit ca71482237d31703454062b8b2f544a8bacd2831
Author: Michael Stahl 
AuthorDate: Tue Jan 31 15:05:44 2023 +0100
Commit: Michael Stahl 
CommitDate: Tue Jan 31 17:02:51 2023 +

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

There was a problem with commit ecbad22fdf81c6f072b6c9f9c16dbba47fe4748c
while it now worked in Writer, the roundtripped DOCX with the en-US
built-in style name in the TOC field no longer worked in Word in the
original locale (but started to work in en-US locale).

Let's try a slightly different approach: use the same style name as-is
from the TOC field, and if it doesn't exist as a style, then clone the
en-US built-in style with that name, and at the end of the import,
iterate all paragraphs in the document and replace any application of the
en-US style with the localised style.

So both the en-US style and the localised style exist, and for
references that aren't fields (e.g. basedOn in other styles) it should
hopefully not matter which one is referenced.

The DOCX exported from Writer now has a TOC field that works in Word in
the original locale.

Change-Id: Ibcc3c5899e31295b5704ebefb548f40b67eda9bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146414
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index bfc09d934343..fbfe633fd55e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -725,8 +725,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153082_semicolon, 
"custom-styles-TOC-semicolon.d
 xParaStyles->getByIndex(1) >>= styles;
 CPPUNIT_ASSERT_EQUAL(uno::Sequence{}, styles);
 xParaStyles->getByIndex(2) >>= styles;
-// the first one is built-in Word style that was localised DE "Intensives 
Zitat" in the file
-CPPUNIT_ASSERT_EQUAL((uno::Sequence{"Intense Quote", "Custom1", 
"_MyStyle0"}), styles);
+// the first one is built-in Word style "Intense Quote" that was localised 
DE "Intensives Zitat" in the file
+CPPUNIT_ASSERT_EQUAL((uno::Sequence{"Intensives Zitat", 
"Custom1", "_MyStyle0"}), styles);
 xTOC->update();
 OUString const tocContent(xTOC->getAnchor()->getString());
 CPPUNIT_ASSERT(tocContent.startsWith("Table of Contents"));
@@ -749,8 +749,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153082_comma, 
"custom-styles-TOC-comma.docx")
 xParaStyles->getByIndex(1) >>= styles;
 CPPUNIT_ASSERT_EQUAL(uno::Sequence{"Custom1"}, styles);
 xParaStyles->getByIndex(2) >>= styles;
-// the first one is built-in Word style that was localised DE "Intensives 
Zitat" in the file
-CPPUNIT_ASSERT_EQUAL(uno::Sequence{"Intense Quote"}, styles);
+// the first one is built-in Word style "Intense Quote" that was localised 
DE "Intensives Zitat" in the file
+CPPUNIT_ASSERT_EQUAL(uno::Sequence{"Intensives Zitat"}, styles);
 xTOC->update();
 OUString const tocContent(xTOC->getAnchor()->getString());
 CPPUNIT_ASSERT(tocContent.startsWith("Table of Contents"));
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 604e067aab8e..d25e3463d7f5 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -89,6 +89,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -449,7 +450,10 @@ DomainMapper_Impl::~DomainMapper_Impl()
 ChainTextFrames();
 // Don't remove last paragraph when pasting, sw expects that empty 
paragraph.
 if (m_bIsNewDoc)
+{
 RemoveLastParagraph();
+GetStyleSheetTable()->ApplyClonedTOCStyles();
+}
 if (hasTableManager())
 {
 getTableManager().endLevel();
@@ -6107,6 +6111,51 @@ DomainMapper_Impl::StartIndexSectionChecked(const 
OUString& sServiceName)
 return xRet;
 }
 
+/**
+ This is a heuristic to find Word's w:styleId value from localised style name.
+ It's not clear how exactly it works, but apparently Word stores into
+ w:styleId some filtered representation of the localised style name.
+ Tragically there are references to the localised style name itself in TOC
+ fields.
+ Hopefully this works and a complete map of >100 built-in style names
+ localised to all languages isn't needed.
+*/
+static auto FilterChars(OUString const& rStyleName) -> OUString
+{
+OUStringBuffer ret;
+sal_Int32 index(0);
+while (index < 

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

2023-01-20 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf125038_conditionalText3.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |   10 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |7 ---
 3 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit c6cf80af60d23fc52502f88f24dc23ad85462e77
Author: Justin Luth 
AuthorDate: Thu Jan 19 15:28:14 2023 -0500
Commit: Justin Luth 
CommitDate: Fri Jan 20 20:22:13 2023 +

related tdf#125038 FORMTEXT/REF:fix spurious text outside IF field

This builds on top of commit d09336fbdceaafd9320466b660a2b32a07dcc16a
(tdf#125038 DOCX import: fix lost MERGEFIELD result inside an IF field,
2019-10-31), and extends it for FORMTEXT and REF.

With this, all unexpected content is gone from the paragraph.

Actually this is all somewhat irrelevant since DOCX doesn't import
IF fields at all anyway - they are just left blank.
So AFAICS, we should ALWAYS return false at this point.

I also took the opportunity to be able to remove multiple
spaces from the front of the command.

Change-Id: Ib7e7971bce86bdda545166e398fbb620ca515b91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145832
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf125038_conditionalText3.docx 
b/sw/qa/extras/ooxmlexport/data/tdf125038_conditionalText3.docx
new file mode 100644
index ..ec5698eeae1c
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf125038_conditionalText3.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 11ddc54f1717..e0c471824193 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -829,6 +829,16 @@ CPPUNIT_TEST_FIXTURE(Test, testConditionalText2)
 getParagraph(1, "test1");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testConditionalText3)
+{
+loadAndReload("tdf125038_conditionalText3.docx");
+// It is unclear what the purpose of all the conditional IF statements is,
+// but the end result should not produce any output.
+// Previously, the fields were being displayed as text
+// instead of as building blocks for the IF field condition.
+CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), 
getParagraph(1)->getString().indexOf('2'));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf142464_ampm, "tdf142464_ampm.docx")
 {
 css::uno::Reference xTextFieldsSupplier(
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0b73640fd57f..b849f453034c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -264,10 +264,8 @@ static bool IsFieldNestingAllowed(const FieldContextPtr& 
pOuter, const FieldCont
 OUString aCommand = pOuter->GetCommand();
 
 // Ignore leading space before the field name, but don't accept IFF 
when we check for IF.
-if (!aCommand.isEmpty() && aCommand[0] == ' ')
-{
+while (aCommand.getLength() > 3 && aCommand[0] == ' ')
 aCommand = aCommand.subView(1);
-}
 
 if (aCommand.startsWith("IF "))
 {
@@ -288,10 +286,13 @@ static bool IsFieldNestingAllowed(const FieldContextPtr& 
pOuter, const FieldCont
 switch (*pInner->GetFieldId())
 {
 case FIELD_DOCVARIABLE:
+case FIELD_FORMTEXT:
 case FIELD_FORMULA:
 case FIELD_IF:
 case FIELD_MERGEFIELD:
+case FIELD_REF:
 {
+// LO does not currently know how to evaluate these as 
conditions or results
 return false;
 }
 default:


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

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

New commits:
commit ecbad22fdf81c6f072b6c9f9c16dbba47fe4748c
Author: Michael Stahl 
AuthorDate: Wed Jan 18 15:41:57 2023 +0100
Commit: Michael Stahl 
CommitDate: Wed Jan 18 18:41:25 2023 +

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

The bugdoc contains this style:

  




...

which is referred to by:

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

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

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

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

Change-Id: I2050f7cf7f8d80bee1f667ee53b7f9981bbf7b49
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145745
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

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

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

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

New commits:
commit 26d74a57d54327b9fd562065d04d867852ce8e8a
Author: Vasily Melenchuk 
AuthorDate: Fri Jan 6 17:31:16 2023 +0300
Commit: Vasily Melenchuk 
CommitDate: Tue Jan 10 08:05:43 2023 +

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

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

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

Change-Id: I640228ed117f1d65dde9753a00b8403dda45dd40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145148
Tested-by: Jenkins
Reviewed-by: Vasily Melenchuk 

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

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

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

New commits:
commit 788cc6ff3b186ceb8f265e53b5482f808f6536f4
Author: Vasily Melenchuk 
AuthorDate: Thu Jan 5 18:17:12 2023 +0300
Commit: Thorsten Behrens 
CommitDate: Mon Jan 9 07:54:51 2023 +

tdf#148578: Do not apply table shift for RTF

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

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

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

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


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

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

New commits:
commit e8d18b471ea5063bc0b2c94afc1b94017e8e66bc
Author: Vasily Melenchuk 
AuthorDate: Tue Dec 27 15:31:37 2022 +0300
Commit: Miklos Vajna 
CommitDate: Fri Jan 6 14:47:23 2023 +

tdf#152784: RTF import: more default paragraph params

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

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

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


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

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

New commits:
commit e17b4df3fe5441ca66e4203c725a578eb1797eb2
Author: László Németh 
AuthorDate: Thu Jan 5 10:21:10 2023 +0100
Commit: László Németh 
CommitDate: Thu Jan 5 14:39:34 2023 +

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

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

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

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

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

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

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


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

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

New commits:
commit d5a9722874871576b864feb7bd815f9f8bfaac48
Author: Vasily Melenchuk 
AuthorDate: Wed Dec 28 23:52:10 2022 +0300
Commit: Thorsten Behrens 
CommitDate: Thu Dec 29 22:39:55 2022 +

ms format import: better handling for invalid styles

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

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

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

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


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

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

New commits:
commit 96a856f87f16cca2e039c973c18d57c8b9dca362
Author: László Németh 
AuthorDate: Fri Dec 16 13:20:25 2022 +0100
Commit: László Németh 
CommitDate: Mon Dec 19 07:34:36 2022 +

tdf#152206 DOCX import: fix mixed first footnote

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

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

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

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

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

2022-11-24 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/ooxmlimport/data/tdf152200-bad_fldChar_end.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx|6 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|   39 ++-
 3 files changed, 29 insertions(+), 16 deletions(-)

New commits:
commit 9a7945f36ce95a48e0d525bc444e722b9ec5c452
Author: Mike Kaganski 
AuthorDate: Thu Nov 24 15:05:43 2022 +0300
Commit: Mike Kaganski 
CommitDate: Thu Nov 24 22:01:13 2022 +0100

tdf#152200: tolerate begin/end fldChar context mismatch

We generate such files currently. Fixing that will be another commit.

Change-Id: I788501e346cba63c08a767c0e05e063bc1172089
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143223
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf152200-bad_fldChar_end.docx 
b/sw/qa/extras/ooxmlimport/data/tdf152200-bad_fldChar_end.docx
new file mode 100644
index ..7f77c8d66b2b
Binary files /dev/null and 
b/sw/qa/extras/ooxmlimport/data/tdf152200-bad_fldChar_end.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 1c79dbecf75f..a1110d0d287e 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -941,6 +941,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf119039)
 // Should not crash/hang because of problematic embedded compound
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf152200)
+{
+createSwDoc("tdf152200-bad_fldChar_end.docx");
+// Should not crash/hang because of wrong placement of ending fldChar
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3e17187b40fa..4c20cdc1bfb5 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -7535,7 +7535,6 @@ void DomainMapper_Impl::PopFieldContext()
 {
 try
 {
-uno::Reference< text::XTextCursor > xCrsr = 
xTextAppend->createTextCursorByRange(pContext->GetStartRange());
 uno::Reference< text::XTextContent > xToInsert( 
pContext->GetTOC(), uno::UNO_QUERY );
 if( xToInsert.is() )
 {
@@ -7597,30 +7596,38 @@ void DomainMapper_Impl::PopFieldContext()
 }
 else
 {
+uno::Reference< text::XTextCursor > xCrsr = 
xTextAppend->createTextCursorByRange(pContext->GetStartRange());
 FormControlHelper::Pointer_t 
pFormControlHelper(pContext->getFormControlHelper());
 if (pFormControlHelper)
 {
-uno::Reference< text::XFormField > xFormField( 
pContext->GetFormField() );
-assert(xCrsr.is());
-if (pFormControlHelper->hasFFDataHandler())
+// xCrsr may be empty e.g. when 
pContext->GetStartRange() is outside of
+// xTextAppend, like when a field started in a 
parent paragraph is being
+// closed inside an anchored text box. It could be 
possible to throw an
+// exception here, and abort import, but Word 
tolerates such invalid
+// input, so it makes sense to do the same 
(tdf#152200)
+if (xCrsr.is())
 {
-xToInsert.set(xFormField, uno::UNO_QUERY);
-if (xFormField.is() && xToInsert.is())
+uno::Reference< text::XFormField > 
xFormField(pContext->GetFormField());
+if (pFormControlHelper->hasFFDataHandler())
 {
-PopFieldmark(m_aTextAppendStack, xCrsr,
-pContext->GetFieldId());
-pFormControlHelper->processField( 
xFormField );
+xToInsert.set(xFormField, uno::UNO_QUERY);
+if (xFormField.is() && xToInsert.is())
+{
+PopFieldmark(m_aTextAppendStack, xCrsr,
+ pContext->GetFieldId());
+
pFormControlHelper->processField(xFormField);
+}
+else
+{
+
pFormControlHelper->insertControl(xCrsr);
+}
 }
  

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

2022-11-24 Thread László Németh (via logerrit)
 sw/qa/extras/layout/data/tdf151954.docx   |binary
 sw/qa/extras/layout/layout2.cxx   |   18 ++
 writerfilter/source/dmapper/DomainMapper.cxx  |4 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   14 +-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |3 +++
 writerfilter/source/ooxml/model.xml   |2 ++
 6 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 386402ded6db4614c943c94f6e68bc1de1a38fe6
Author: László Németh 
AuthorDate: Thu Nov 24 13:28:34 2022 +0100
Commit: László Németh 
CommitDate: Thu Nov 24 16:57:54 2022 +0100

tdf#151954 DOCX import: fix text moving before paragraph end

Tracked text moving before paragraph end was extended
to the paragraph end, too.

Follow-up to commit 11071d95f4f3cbe578c3393729c42b7cce011b45
"tdf#149711 sw_redlinenum DOCX: import moveTo paragraph mark"
and commit d32d9a2b3c5e3963f4a18f6c7bbf50fab2e9b2be
"tdf#123460 DOCX track changes: moveFrom completely".

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

diff --git a/sw/qa/extras/layout/data/tdf151954.docx 
b/sw/qa/extras/layout/data/tdf151954.docx
new file mode 100644
index ..64e4782f7ab9
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf151954.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 14a03999b091..259a6ea66292 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -635,6 +635,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testTdf149711_importDOCXMoveToParagraphMar
 assertXPath(pXmlDoc, "/root/page[1]/body/txt", 5);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf151954)
+{
+createSwDoc("tdf151954.docx");
+SwDoc* pDoc = getSwDoc();
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2);
+
+// accept tracked insertion (moveTo)
+SwEditShell* const pEditShell(pDoc->GetEditShell());
+CPPUNIT_ASSERT_EQUAL(static_cast(3), 
pEditShell->GetRedlineCount());
+pEditShell->AcceptRedline(0);
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+// This was 1 (moveFrom was extended to the paragraph mark)
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInFootnote)
 {
 createSwDoc("tdf85610.fodt");
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 3521f705fdf8..93cb36cb8e55 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2604,6 +2604,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
  if (m_pImpl->hasTableManager())
 m_pImpl->getTableManager().setMoved( OUString() );
 break;
+case NS_ooxml::LN_CT_ParaRPr_moveFrom:
+case NS_ooxml::LN_CT_ParaRPr_moveTo:
+ m_pImpl->StartParaMarkerMove( );
+break;
 case NS_ooxml::LN_paratrackchange:
 m_pImpl->StartParaMarkerChange( );
 [[fallthrough]];
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index ec0861caa4e3..3e17187b40fa 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -359,6 +359,7 @@ DomainMapper_Impl::DomainMapper_Impl(
 m_bLineNumberingSet( false ),
 m_bIsInFootnoteProperties( false ),
 m_bIsParaMarkerChange( false ),
+m_bIsParaMarkerMove( false ),
 m_bRedlineImageInPreviousRun( false ),
 m_bParaChanged( false ),
 m_bIsFirstParaInSection( true ),
@@ -3439,7 +3440,7 @@ void DomainMapper_Impl::CheckParaMarkerRedline( 
uno::Reference< text::XTextRange
 m_currentRedline.clear();
 }
 }
-else if ( m_pParaMarkerRedlineMove )
+else if ( m_pParaMarkerRedlineMove && m_bIsParaMarkerMove )
 {
 // terminating moveFrom/moveTo redline removes also the paragraph mark
 CreateRedline( xRange, m_pParaMarkerRedlineMove );
@@ -3447,6 +3448,7 @@ void DomainMapper_Impl::CheckParaMarkerRedline( 
uno::Reference< text::XTextRange
 if ( m_pParaMarkerRedlineMove )
 {
 m_pParaMarkerRedlineMove.clear();
+EndParaMarkerMove();
 }
 }
 
@@ -3493,6 +3495,16 @@ void DomainMapper_Impl::EndParaMarkerChange( )
 m_currentRedline.clear();
 }
 
+void DomainMapper_Impl::StartParaMarkerMove( )
+{
+m_bIsParaMarkerMove = true;
+}
+
+void DomainMapper_Impl::EndParaMarkerMove( )
+{
+m_bIsParaMarkerMove = false;
+}
+
 void DomainMapper_Impl::StartCustomFootnote(const PropertyMapPtr pContext)
 {
 if (pContext == m_pFootnoteContext)
diff --git 

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

2022-11-14 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/data/tdf151993.docx |binary
 sw/qa/extras/uiwriter/uiwriter8.cxx   |   31 +-
 writerfilter/source/dmapper/DomainMapper.cxx  |   10 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |7 +++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |3 ++
 5 files changed, 48 insertions(+), 3 deletions(-)

New commits:
commit c6688def010fcb6854c6d896efe7186ff6c63475
Author: László Németh 
AuthorDate: Sat Nov 12 11:37:23 2022 +0100
Commit: László Németh 
CommitDate: Mon Nov 14 09:30:14 2022 +0100

tdf#151993 DOCX import: convert decimal comma only if needed

E.g. convert en_US document with decimal comma, but not
de_DE document with decimal comma.

Regression from commit 94bf4908a6661101c270ef647e33dde09f16ac08
"tdf#148799 DOCX import: fix invalid formulas with comma".

DOCX allows to set decimal symbol independently from the locale
of the document, so if the DOCX document uses comma, but
its locale ("language") has got a default decimal point in Writer,
Writer formulas must contain decimal points instead of commas,
otherwise automatic update of the formulas, e.g. moving text
cursor in the table, results ** Expression is faulty ** instead
of the recalculated value. The only way to get standard
Writer formulas is to replace the commas with points in numbers
in writerfilter, if document language has a default
decimal point in Writer.

Note: not only document language, but area setting of
LibreOffice installation modifies formula handling. I.e.
plain numbers recognized with comma only if area setting
is modified to a language, which uses decimal comma
(but formulas still need decimal points, if the language
of the document is a locale with default decimal point).
E.g. an en_US DOCX document with decimal comma, or a
de_DE document with decimal comma loaded correctly now,
but recognizing cell content with a single number with comma
needs to set also the correct area setting.

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

diff --git a/sw/qa/extras/uiwriter/data/tdf151993.docx 
b/sw/qa/extras/uiwriter/data/tdf151993.docx
new file mode 100644
index ..462feb0a61e4
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf151993.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 83698fa36a18..e6b5d0dad60c 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1400,7 +1400,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146573)
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148799)
 {
-// load a document with table formulas with comma delimiter
+// load a document with table formulas with comma delimiter,
+// but with a document language with default point delimiter
 createSwDoc("tdf148799.docx");
 SwDoc* pDoc = getSwDoc();
 SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
@@ -1430,6 +1431,34 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148799)
 CPPUNIT_ASSERT_EQUAL(OUString("23684.5"), xCellA4->getString());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf151993)
+{
+// load a document with table formulas with comma delimiter
+// (with a document language with default comma delimiter)
+createSwDoc("tdf151993.docx");
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+// check formula update
+
+// put cursor in the first table row
+pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1);
+
+uno::Reference xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTextTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+uno::Reference xTextTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getRows()->getCount());
+
+// This was 0
+uno::Reference xCellA1(xTextTable->getCellByName("A2"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("30"), xCellA1->getString());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148849)
 {
 // load a document with a table and an empty paragraph before the table
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 95694c270a8e..b5e45b7c2734 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -75,6 +75,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "TextEffectsHandler.hxx"
@@ -658,6 +659,15 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
 case 

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

2022-11-14 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf151912.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |5 +++
 writerfilter/source/dmapper/SdtHelper.cxx|   36 ---
 3 files changed, 32 insertions(+), 9 deletions(-)

New commits:
commit b15c82e02c0a97d3523b6e46cb4ba4c958ea38d0
Author: Vasily Melenchuk 
AuthorDate: Tue Nov 8 14:55:40 2022 +0300
Commit: Vasily Melenchuk 
CommitDate: Mon Nov 14 09:20:42 2022 +0100

tdf#151912: sw: suppress exceptions during SDT evluation

Failure in XPath processing during retrieving fresh value from
data source is not a critical problem and should not cancel
document loading.

Just put warning in log and continue to eval further.

Change-Id: I76ecf0e0e227f46a270db3e77d86c19f7e9ad21a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142428
Tested-by: Jenkins
Reviewed-by: Vasily Melenchuk 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf151912.docx 
b/sw/qa/extras/ooxmlexport/data/tdf151912.docx
new file mode 100644
index ..65e8d5a93f87
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf151912.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 1ce78f262eef..6f76391d75dd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -101,6 +101,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 assertXPath(pXmlDoc, "//wps:bodyPr", "vert", "mongolianVert");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf151912, "tdf151912.docx")
+{
+// For now just ensure roundtrip is successful
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf147724, "tdf147724.docx")
 {
 const auto& pLayout = parseLayoutDump();
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index d8f48ef7ffe2..cf86a629219b 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace writerfilter::dmapper
@@ -225,25 +226,42 @@ std::optional 
SdtHelper::getValueFromDataBinding()
 const auto& aSourceIt = m_xPropertiesXMLs.find(m_sDataBindingStoreItemID);
 if (aSourceIt != m_xPropertiesXMLs.end())
 {
-uno::Reference xResult
-= xXpathAPI->eval(aSourceIt->second, m_sDataBindingXPath);
+try
+{
+uno::Reference xResult
+= xXpathAPI->eval(aSourceIt->second, m_sDataBindingXPath);
 
-if (xResult.is() && xResult->getNodeList() && 
xResult->getNodeList()->getLength()
-&& xResult->getString().getLength())
+if (xResult.is() && xResult->getNodeList() && 
xResult->getNodeList()->getLength()
+&& xResult->getString().getLength())
+{
+return xResult->getString();
+}
+}
+catch (const XPathException& e)
 {
-return xResult->getString();
+// XPath failed? Log and continue with next data document
+SAL_WARN("writerfilter", "SdtHelper::failed running XPath: " << 
e.Message);
 }
 }
 
 // Nothing found? Try to iterate storages and eval xpath
 for (const auto& aSource : m_xPropertiesXMLs)
 {
-uno::Reference xResult = xXpathAPI->eval(aSource.second, 
m_sDataBindingXPath);
+try
+{
+uno::Reference xResult
+= xXpathAPI->eval(aSource.second, m_sDataBindingXPath);
 
-if (xResult.is() && xResult->getNodeList() && 
xResult->getNodeList()->getLength()
-&& xResult->getString().getLength())
+if (xResult.is() && xResult->getNodeList() && 
xResult->getNodeList()->getLength()
+&& xResult->getString().getLength())
+{
+return xResult->getString();
+}
+}
+catch (const XPathException& e)
 {
-return xResult->getString();
+// XPath failed? Log and continue with next data document
+SAL_WARN("writerfilter", "SdtHelper::failed running XPath: " << 
e.Message);
 }
 }
 


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

2022-11-09 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/data/tdf148799.docx |binary
 sw/qa/extras/uiwriter/uiwriter8.cxx   |   31 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |7 
 3 files changed, 38 insertions(+)

New commits:
commit 94bf4908a6661101c270ef647e33dde09f16ac08
Author: László Németh 
AuthorDate: Wed Nov 9 13:35:11 2022 +0100
Commit: László Németh 
CommitDate: Wed Nov 9 16:34:48 2022 +0100

tdf#148799 DOCX import: fix invalid formulas with comma

Writer formulas must contain decimal points instead of commas,
otherwise automatic update of the formulas, e.g. moving text
cursor in the table, results ** Expression is faulty ** instead
of the recalculated value. The only way to get standard
Writer formulas is to replace the commas with points in numbers
in writerfilter.

Note: only formula cells support comma localization,
but not formula fields yet, so the recalculated values show
decimal point instead of decimal comma.

Follow-up to commit 1abf4e6d07ca0ac31bc54f812df84efc82d2af1b
"DOCX import: don't throw away cached value of SwHiddenTextField ...",
see also tdf#136106.

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

diff --git a/sw/qa/extras/uiwriter/data/tdf148799.docx 
b/sw/qa/extras/uiwriter/data/tdf148799.docx
new file mode 100644
index ..280fa18c15b5
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf148799.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index dbb1d4fda678..674747b6c0d7 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1382,6 +1382,37 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146573)
 CPPUNIT_ASSERT_EQUAL(OUString("204"), xCellA4->getString());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148799)
+{
+// load a document with table formulas with comman delimiter
+SwDoc* pDoc = createSwDoc("tdf148799.docx");
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+// check formula update
+
+// put cursor in the first table row
+pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1);
+
+uno::Reference xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTextTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+uno::Reference xTextTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTextTable->getRows()->getCount());
+
+// These were "** Expression is faulty **"
+
+uno::Reference xCellA1(xTextTable->getCellByName("D3"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("2.3"), xCellA1->getString());
+uno::Reference xCellA3(xTextTable->getCellByName("D4"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("2345"), xCellA3->getString());
+uno::Reference xCellA4(xTextTable->getCellByName("D5"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("23684.5"), xCellA4->getString());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148849)
 {
 // load a document with a table and an empty paragraph before the table
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index b5afddc7a494..0e436fe165b9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5552,6 +5552,13 @@ OUString DomainMapper_Impl::convertFieldFormula(const 
OUString& input) {
 icu::RegexMatcher rmatch6("\\b(ABOVE|BELOW|LEFT|RIGHT)\\b", usInput, 
rMatcherFlags, status);
 usInput = rmatch6.replaceAll(icu::UnicodeString(" $1 "), status);
 
+/* fix decimal separator */
+if ( m_pSettingsTable->GetDecimalSymbol() == "," )
+{
+icu::RegexMatcher rmatch7("\\b([0-9]+),([0-9]+([eE][-]?[0-9]+)?)\\b", 
usInput, rMatcherFlags, status);
+usInput = rmatch7.replaceAll(icu::UnicodeString("$1.$2"), status);
+}
+
 return OUString(usInput.getTerminatedBuffer());
 }
 


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

2022-10-07 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf136617.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |   12 
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   12 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|2 +-
 writerfilter/source/dmapper/PropertyMap.hxx  |1 -
 5 files changed, 17 insertions(+), 10 deletions(-)

New commits:
commit 2a3e528bb9df4a1a2564ca5236be62dfdaba77e6
Author: László Németh 
AuthorDate: Fri Oct 7 12:37:53 2022 +0200
Commit: László Németh 
CommitDate: Fri Oct 7 16:59:44 2022 +0200

tdf#136617 DOCX import: fix empty table paragraphs with direct formatting

Table paragraph styles applied on paragraphs without runs, i.e.
on empty paragraphs, despite their direct formatting, resulting
e.g. different font size, and after that different paragraph
i.e. cell height, breaking the original table layout.

Regression from commit bf3124cdf61b40c94ba117a76f1b63dabdfd528e
"tdf#135187 DOCX import: fix table style at character formatting".

Also clean-up commit 498d2b82187ec3ff58f076e0d15741e64c0505ba
"tdf#131546 DOCX import: fix performance regression at tables".

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf136617.docx 
b/sw/qa/extras/ooxmlexport/data/tdf136617.docx
new file mode 100644
index ..e7b35aa295cb
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf136617.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 586f36ed0c82..7bead3a2bb1f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1874,6 +1874,18 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf135187)
 "false");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf136617)
+{
+loadAndSave("tdf136617.docx");
+
+// This was 2
+CPPUNIT_ASSERT_EQUAL(1, getPages());
+
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:p[2]/w:pPr/w:rPr/w:sz", "val",
+"16");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf121597TrackedDeletionOfMultipleParagraphs)
 {
 loadAndSave("tdf121597.odt");
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index cc9f9ada017b..2e962260c79c 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1112,14 +1112,6 @@ void 
DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag
 
 OUString sPropertyName = getPropertyName(eId);
 
-if ( bIsParaLevel && ( 
rParaProp.m_aParaOverrideApplied.find(sPropertyName) != 
rParaProp.m_aParaOverrideApplied.end() ||
-sPropertyName.startsWith("CharFontName") ) )
-{
-// don't apply table style, if this character property was 
applied on paragraph level
-// (or in the case of paragraph level font name settings to 
avoid regressions)
-continue;
-}
-
 auto pCellProp = std::find_if(rCellProperties.begin(), 
rCellProperties.end(),
 [&](const beans::PropertyValue& rProp) { return rProp.Name == 
sPropertyName; });
 // this cell applies the table style property
@@ -1179,6 +1171,10 @@ void 
DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag
 uno::Reference< beans::XPropertyState > xParaProperties( 
xParagraph, uno::UNO_QUERY_THROW );
 if ( xParaProperties->getPropertyState(sPropertyName) == 
css::beans::PropertyState_DEFAULT_VALUE )
 {
+// don't overwrite empty paragraph with table style, 
if it has a direct paragraph formatting
+if ( bIsParaLevel && 
xParagraph->getString().getLength() == 0 )
+continue;
+
 if ( eId != PROP_FILL_COLOR )
 {
 // apply style setting when the paragraph doesn't 
modify it
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 191b7fec353c..dc42f0198cdf 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2462,7 +2462,7 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
 xParaCursor->gotoStartOfParagraph(false);
 if (m_nTableDepth > 0)
 {
-TableParagraph aPending{xParaCursor, xCur, 
pParaContext, 

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

2022-10-07 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf151370.rtf  |3 +++
 sw/qa/extras/rtfexport/rtfexport5.cxx  |   18 ++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |2 +-
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |2 +-
 4 files changed, 23 insertions(+), 2 deletions(-)

New commits:
commit 0d545f1f0afc93bd568f8172a134ab9196529809
Author: Vasily Melenchuk 
AuthorDate: Thu Oct 6 12:37:31 2022 +0300
Commit: Vasily Melenchuk 
CommitDate: Fri Oct 7 11:06:48 2022 +0200

tdf#151370: RTF import: docvar name/value can have several sequences

In case of unicode used there can be tokens, replacements, etc.
So it is better to collect and join all received strings, not
overwrite with just last received.

Change-Id: I2b6ce465d87db4ee30987cbe0ecce1470386242f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141007
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/rtfexport/data/tdf151370.rtf 
b/sw/qa/extras/rtfexport/data/tdf151370.rtf
new file mode 100644
index ..e555d5c58cd2
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf151370.rtf
@@ -0,0 +1,3 @@
+{\rtf1\adeflang1025\ansi\ansicpg1250
+{\*\docvar 
{LocalChars\'c1rv\'edzturoT\'fck\'f6rf\'far\'f3g\'e9p}{\'e1rv\'edzturot\'fck\'f6rf\'far\'f3g\'e9p}}
+}
\ No newline at end of file
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx 
b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 1dbacde70bea..6c3d6c6c8471 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -848,6 +848,24 @@ DECLARE_RTFEXPORT_TEST(testTdf150267, "tdf150267.rtf")
 CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), 
getProperty(xFieldMaster, "Content"));
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf151370, "tdf151370.rtf")
+{
+uno::Reference xModel(mxComponent, uno::UNO_QUERY);
+uno::Reference xSupplier(xModel, 
uno::UNO_QUERY);
+uno::Reference xTextFieldMasters = 
xSupplier->getTextFieldMasters();
+// Here we try to read/write docvar having non-ascii name and value. So it 
is encoded in Unicode
+OUString sFieldName(u"com.sun.star.text.fieldmaster.User."
+
"LocalChars\u00c1\u0072\u0076\u00ed\u007a\u0074\u0075\u0072\u006f\u0054"
+
"\u00fc\u006b\u00f6\u0072\u0066\u00fa\u0072\u00f3\u0067\u00e9\u0070");
+CPPUNIT_ASSERT_EQUAL(sal_True, xTextFieldMasters->hasByName(sFieldName));
+
+auto xFieldMaster = xTextFieldMasters->getByName(sFieldName);
+CPPUNIT_ASSERT_EQUAL(
+
OUString(u"\u00e1\u0072\u0076\u00ed\u007a\u0074\u0075\u0072\u006f\u0074\u00fc"
+ 
"\u006b\u00f6\u0072\u0066\u00fa\u0072\u00f3\u0067\u00e9\u0070"),
+getProperty(xFieldMaster, "Content"));
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf108416, "tdf108416.rtf")
 {
 uno::Reference 
xCharacterStyles(getStyles("CharacterStyles"));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7fa664ea26b1..8a888d8348f6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1503,7 +1503,7 @@ void RTFDocumentImpl::text(OUString& rString)
 break;
 case Destination::DOCVAR:
 {
-m_aStates.top().setDocVar(rString);
+m_aStates.top().appendDocVar(rString);
 }
 break;
 case Destination::FONTTABLE:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 208812fd4237..ac1263a41531 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -524,7 +524,7 @@ public:
 RTFInternalState getInternalState() const { return m_nInternalState; }
 RTFDocumentImpl* getDocumentImpl() { return m_pDocumentImpl; }
 OUString getDocVar() { return m_aDocVar; }
-void setDocVar(OUString& aDocVar) { m_aDocVar = aDocVar; };
+void appendDocVar(OUString& aDocVar) { m_aDocVar += aDocVar; };
 OUString getDocVarName() { return m_aDocVarName; }
 void setDocVarName(OUString& aDocVarName) { m_aDocVarName = aDocVarName; }
 void clearDocVarName() { m_aDocVarName = ""; }


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

2022-09-28 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf147724.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |   13 +
 writerfilter/source/dmapper/SdtHelper.cxx|   64 ++-
 writerfilter/source/dmapper/SdtHelper.hxx|3 -
 4 files changed, 69 insertions(+), 11 deletions(-)

New commits:
commit da100343e5416e1040f8f6d83fd73d8d0577112e
Author: Vasily Melenchuk 
AuthorDate: Sun Sep 11 15:46:09 2022 +0300
Commit: Vasily Melenchuk 
CommitDate: Wed Sep 28 09:58:00 2022 +0200

tdf#147724: DOCX STD import: use storeid to indetify custom XML

We need to identify XML document to use by storeid in sdt block
and in properties of external XML file. Otherwise are possible
content collisions when same xpath can evaluate successfully
absolutely unrelated custom XML.

Change-Id: I6d201a539130b110046deb1818340513cc47a061
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139771
Tested-by: Jenkins
Reviewed-by: Vasily Melenchuk 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf147724.docx 
b/sw/qa/extras/ooxmlexport/data/tdf147724.docx
new file mode 100644
index ..97f05c921b89
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf147724.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 6c4eaa09fa34..b9932f7c199d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -104,6 +104,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 assertXPath(pXmlDoc, "//wps:bodyPr", "vert", "mongolianVert");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf147724, "tdf147724.docx")
+{
+const auto& pLayout = parseLayoutDump();
+
+// Ensure we load field value from external XML correctly (it was 
"HERUNTERLADEN")
+assertXPathContent(pLayout, "/root/page[1]/body/txt[1]", "Placeholder -> 
*ABC*");
+
+// This SDT has no storage id, it is not an error, but content can be 
taken from any suitable XML
+// There 2 variants possible, both are acceptable
+OUString sFieldResult = getXPathContent(pLayout, 
"/root/page[1]/body/txt[2]");
+CPPUNIT_ASSERT(sFieldResult == "Placeholder -> *HERUNTERLADEN*" || 
sFieldResult == "Placeholder -> *ABC*");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index 50ddf4b99b21..8225a6a04bca 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -104,13 +104,13 @@ void SdtHelper::loadPropertiesXMLs()
 if (!xDomBuilder.is())
 return;
 
-std::vector> aPropDocs;
-
 // Load core properties
 try
 {
 auto xCorePropsStream = 
xImporter->getCorePropertiesStream(m_rDM_Impl.m_xDocumentStorage);
-aPropDocs.push_back(xDomBuilder->parse(xCorePropsStream));
+m_xPropertiesXMLs.insert(
+{ OUString("{6C3C8BC8-F283-45AE-878A-BAB7291924A1}"), // hardcoded 
id for core props
+  xDomBuilder->parse(xCorePropsStream) });
 }
 catch (const uno::Exception&)
 {
@@ -123,7 +123,9 @@ void SdtHelper::loadPropertiesXMLs()
 {
 auto xExtPropsStream
 = 
xImporter->getExtendedPropertiesStream(m_rDM_Impl.m_xDocumentStorage);
-aPropDocs.push_back(xDomBuilder->parse(xExtPropsStream));
+m_xPropertiesXMLs.insert(
+{ OUString("{6668398D-A668-4E3E-A5EB-62B293D839F1}"), // hardcoded 
id for extended props
+  xDomBuilder->parse(xExtPropsStream) });
 }
 catch (const uno::Exception&)
 {
@@ -136,12 +138,40 @@ void SdtHelper::loadPropertiesXMLs()
 // Add custom XMLs
 uno::Sequence> aCustomXmls
 = m_rDM_Impl.getDocumentReference()->getCustomXmlDomList();
-for (const auto& xDoc : aCustomXmls)
+uno::Sequence> aCustomXmlProps
+= m_rDM_Impl.getDocumentReference()->getCustomXmlDomPropsList();
+if (aCustomXmls.getLength())
 {
-aPropDocs.push_back(xDoc);
+uno::Reference xXpathAPI = 
XPathAPI::create(m_xComponentContext);
+xXpathAPI->registerNS("ds",
+  
"http://schemas.openxmlformats.org/officeDocument/2006/customXml;);
+sal_Int32 nItem = 0;
+// Hereby we assume that items from getCustomXmlDomList() and 
getCustomXmlDomPropsList()
+// are matching each other:
+// item1.xml -> itemProps1.xml, item2.xml -> itemProps2.xml
+// This does works practically, but is it true in general?
+for (const auto& xDoc : aCustomXmls)
+{
+// Retrieve storeid from properties xml
+OUString aStoreId;
+uno::Reference xResult
+= xXpathAPI->eval(aCustomXmlProps[nItem], 
"string(/ds:datastoreItem/@ds:itemID)");
+
+if (xResult.is() && xResult->getString().getLength())
+{
+

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

2022-09-12 Thread Samuel Mehrbrodt (via logerrit)
 sw/qa/extras/rtfexport/rtfexport5.cxx  |   16 +---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   12 
 2 files changed, 13 insertions(+), 15 deletions(-)

New commits:
commit 5eff45749464739706c9f25cca6c1edff3187f1d
Author: Samuel Mehrbrodt 
AuthorDate: Mon Sep 12 13:39:40 2022 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Mon Sep 12 15:14:54 2022 +0200

tdf#150267 Import docvar value correctly

Change-Id: I388923e3f7bea35c1247f47812c158f5ab92fc0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139793
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx 
b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 511c749a5aec..1dbacde70bea 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -840,18 +841,11 @@ DECLARE_RTFEXPORT_TEST(testTdf150267, "tdf150267.rtf")
 uno::Reference xModel(mxComponent, uno::UNO_QUERY);
 uno::Reference xSupplier(xModel, 
uno::UNO_QUERY);
 uno::Reference xTextFieldMasters = 
xSupplier->getTextFieldMasters();
-uno::Sequence aMasterNames = 
xTextFieldMasters->getElementNames();
-bool bHasUnusedField = false;
-for (const auto& rMasterName : std::as_const(aMasterNames))
-{
-if (rMasterName == "com.sun.star.text.fieldmaster.User.Unused")
-{
-bHasUnusedField = true;
-break;
-}
-}
+CPPUNIT_ASSERT_EQUAL(sal_True,
+ 
xTextFieldMasters->hasByName("com.sun.star.text.fieldmaster.User.Unused"));
 
-CPPUNIT_ASSERT_EQUAL(true, bHasUnusedField);
+auto xFieldMaster = 
xTextFieldMasters->getByName("com.sun.star.text.fieldmaster.User.Unused");
+CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), 
getProperty(xFieldMaster, "Content"));
 }
 
 DECLARE_RTFEXPORT_TEST(testTdf108416, "tdf108416.rtf")
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 02d5f7ca5069..5eb29f07510a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3489,12 +3490,15 @@ void RTFDocumentImpl::afterPopState(RTFParserState& 
rState)
 }
 else
 {
-uno::Reference xMasterProperties(
+uno::Reference xMaster(
 
m_xModelFactory->createInstance("com.sun.star.text.FieldMaster.User"),
 uno::UNO_QUERY_THROW);
-xMasterProperties->setPropertyValue("Name",
-
uno::Any(m_aStates.top().getDocVarName()));
-xMasterProperties->setPropertyValue("Value", 
uno::Any(docvar));
+xMaster->setPropertyValue("Name", 
uno::Any(m_aStates.top().getDocVarName()));
+uno::Reference xField(
+
m_xModelFactory->createInstance("com.sun.star.text.TextField.User"),
+uno::UNO_QUERY);
+xField->attachTextFieldMaster(xMaster);
+xField->getTextFieldMaster()->setPropertyValue("Content", 
uno::Any(docvar));
 
 m_aStates.top().clearDocVarName();
 }


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

2022-09-06 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/data/cell-sdt-redline.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx  |7 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx   |6 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit cfc851da557214286685cde26baaac6be70d8624
Author: Miklos Vajna 
AuthorDate: Tue Sep 6 09:31:07 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue Sep 6 10:05:24 2022 +0200

crashtesting: fix DOCX export of forum-mso-en-11199.docx

This went wrong in a4432eb0946c0bc775b3d30b634bef5d66544f8d (tdf#104823:
support for sdt plain text fields, 2021-11-24), when we started to turn
cell SDTs into a field containing the cell text, which now needs to work
with redlining, even if the original DOCX file had no fields.

The root cause was introduced earlier, in
0c84c60f48cf681daf467c0678a768711f22e5c3 (tdf#77419 DOCX table import:
ignore right white space, 2020-01-21), which assumed that goRight(2,
select=false) is the opposite of goLeft(1, false) + goLeft(1, true),
which is not true for input fields where an input field with 2 chars
will select 5 chars (not 1) when you do goLeft(1, true) with a cursor at
the right edge of the field (2 chars of content +
CH_TXT_ATR_INPUTFIELDSTART + CH_TXT_ATR_INPUTFIELDEND + the field's
dummy character itself), as "going left" selects the entire field, not
just 1 character.

Fix the problem by replacing goRight() with re-positioning the cursor
the way it was positioned before trimming whitespace a few lines above.

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

diff --git a/sw/qa/extras/ooxmlexport/data/cell-sdt-redline.docx 
b/sw/qa/extras/ooxmlexport/data/cell-sdt-redline.docx
new file mode 100644
index ..41d722299070
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/cell-sdt-redline.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index a2d5f2cca2b2..1bf487a1f3bc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -63,6 +63,13 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineSdtHeader)
 loadAndSave("inline-sdt-header.docx");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testCellSdtRedline)
+{
+// Without the accompanying fix in place, this test would have failed with 
an assertion failure,
+// we produced not-well-formed XML on save.
+loadAndSave("cell-sdt-redline.docx");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index a93f435fca49..8966e096dd59 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2408,7 +2408,11 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
 else
 break;
 }
-xCur->goRight(2, false);
+
+if (rAppendContext.xInsertPosition.is())
+xCur->gotoRange(rAppendContext.xInsertPosition, 
false);
+else
+xCur->gotoEnd(false);
 }
 
 xCur->goLeft( 1 , true );


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

2022-09-01 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/rtfexport/data/tdf127806.rtf  |   86 +
 sw/qa/extras/rtfexport/rtfexport3.cxx  |   23 ++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   23 --
 writerfilter/source/rtftok/rtfsdrimport.cxx|   38 +--
 4 files changed, 144 insertions(+), 26 deletions(-)

New commits:
commit 57d9cc81b058757421cd082e5dbe32a919716807
Author: Vasily Melenchuk 
AuthorDate: Tue Aug 30 15:42:44 2022 +0300
Commit: Miklos Vajna 
CommitDate: Thu Sep 1 20:35:28 2022 +0200

tdf#127806: RTF import: use shape dimensions for pib picture

If RTF shape contains pib (embedded picture) we should override
any picture sizes by values from shape. Values provided inside
\pict are ignored by MS Word; only shape values matter.

To achieve this we need to know shape dimensions so it's
calculation is moved to earlier step before internal picture
eval.

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

diff --git a/sw/qa/extras/rtfexport/data/tdf127806.rtf 
b/sw/qa/extras/rtfexport/data/tdf127806.rtf
new file mode 100644
index ..2cc165f4110a
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf127806.rtf
@@ -0,0 +1,86 @@
+{\rtf1\ansi\ansicpg1252
+{\shpgrp{\*\shpinst
+\shplid67
+\shpleft0\shptop21\shpright11906\shpbottom16137\shpfhdr0
+\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt1\shpz0
+\shpwr3\shpfblwtxt1
+{\sp{\sn groupLeft}{\sv 0}}
+{\sp{\sn groupTop}{\sv 21}}
+{\sp{\sn groupRight}{\sv 11906}}
+{\sp{\sn groupBottom}{\sv 16137}}
+{\sp{\sn fFlipH}{\sv 0}}
+{\sp{\sn fFlipV}{\sv 0}}
+{\sp{\sn posrelh}{\sv 1}}
+{\sp{\sn posrelv}{\sv 1}}
+{\sp{\sn fBehindDocument}{\sv 1}}
+
+{\shp{\*\shpinst\shplid70
+{\sp{\sn relLeft}{\sv 979}}
+{\sp{\sn relTop}{\sv 14827}}
+{\sp{\sn relRight}{\sv 10918}}
+{\sp{\sn relBottom}{\sv 15176}}
+{\sp{\sn fRelFlipH}{\sv 0}}
+{\sp{\sn fRelFlipV}{\sv 0}}
+{\sp{\sn shapeType}{\sv 0}}
+{\sp{\sn rotation}{\sv 0}}
+{\sp{\sn geoRight}{\sv 9939}}
+{\sp{\sn geoBottom}{\sv 349}}
+{\sp{\sn shapePath}{\sv 4}}
+{\sp{\sn pVerticies}{\sv 8;5;(9938,0);(0,0);(0,348);(9938,348);(9938,0)}}
+{\sp{\sn pSegmentInfo}{\sv 
2;12;16384;45824;1;45824;1;45824;1;45824;1;45824;24577;32768}}
+{\sp{\sn fFillOK}{\sv 1}}
+{\sp{\sn fFilled}{\sv 1}}
+{\sp{\sn fillColor}{\sv 5987168}}
+{\sp{\sn fLine}{\sv 0}}{\sp{\sn lineType}{\sv 0}}
+{\sp{\sn posrelh}{\sv 1}}
+{\sp{\sn posrelv}{\sv 1}}
+{\sp{\sn fArrowheadsOK}{\sv 1}}
+{\sp{\sn fBehindDocument}{\sv 1}}
+}}
+
+{\shp{\*\shpinst\shplid72
+{\sp{\sn relLeft}{\sv 830}}
+{\sp{\sn relTop}{\sv 816}}
+{\sp{\sn relRight}{\sv 1190}}
+{\sp{\sn relBottom}{\sv 1156}}
+{\sp{\sn 
pib}{\sv{\pict\picscalex500\picscaley9\piccropl0\piccropr0\piccropt0\piccropb0\picw1270\pich1243\picwgoal720\pichgoal705
+\pngblip{\*\blipuid c0d486c26efd24459c14592d8249a32b}
+89504e470d0a1a0a000d494844520030002f080600a58249
+c90006624b474400ff00ff00ffa0bda7930009704859730ec400
+000ec401952b0e1b041e494441546881cd984d6c1b4514c7ff33ebf5b7e3
+943a6da2a290402528a5520f9168f9101c00b5a71e2ace9c7be28022242e1542
+e28038708023070e1c901007041c8a904088b6082808921450212d4e9438561c
+3bb1d7ebddd9791ce275b7eeaee38f59dbbfd3ee7b3b6fe6bff366e6ed322282
+8bf5fb4b5764f9eb17110276310ae3a72c00a62c66e4686a87bb37246d5deefe
+f0b4b2e81e9c3d0dc6af1350397800489fbbbc785740f5e7054823a9b40700d2
+62307ec902821ffc700fe8c7260bb113af7cd88a2acbdf3da7b407002401e346
+16d288a80e8df4f9b75f0580bb022adf3eafb20322a0be9481538aaa0c0b00d0
+e7a6f2d1e3173f019a028875fe5bb713b0d7122a43b6489f7ff7927bbd2f
+c0f8f33138d5b4aa0eecad28cc9bcac2dd83968bef461f3af7a57bbf2fa0b6f4
+84aa0e9c5a383b8e4bfcd40b5f78ef3900c8da1fa754042702cc9534e0a8dd71
+5a3042e2cc1b97bda6e60ca811200a3188624c45285ff4071fd8d4b28fdcf2da
+94092001d457c2c97b97f8e98b1fb7db3889bd0c356ecf0d1abc712b0532b541
+c304a311e20b8b6fb59b3999ff3e3c686ca7aaa1b1aafc10bf87c8e15499c726
+2bed764ed6fab141021301f5e50c40e1ec3a2e9199f9bffdec9c1a8309b03762
+70b6d59fb6ede8b367bff7b3730c300324586807563bd1e3173ef5b30f3403d6
+5a1cd40871e1366131483eb5f0a39faf6f01448075279c5aa79d486eb2c83927
+3f1f27bb38d54f50a7a443d6d497c97ef0c9231b813ec87a5fafb131a4b70f00
+3c91dd09f4f523409a1ca2105ec9d00e4b1e2a05f938f521c0cac743dff7bdf0
+646e2bd0d7eb0c9004acfcf0d2070078eae866a00f4e6f02c45634dc9ac7079e
+9e590ff4811a3d25b37527dc9ac70f96c815837c1c2c6a751b886c06b1adab19
+550f50a37c28c8c7c1e366b781444947589f8a9d90b5c274908f8327eadd0612
+3bc37ffb004046f148908fb31e66208c7f3cdd20ebdb81d542d7294402702ac3
+291deeebdb281d0ef27168a95a37419cb23ed4c3cb8b344ab9201f67d1e9c043
+c28b1851fa008028aecd07f938d3bb1430a2050c004ea9d22185623381a5aa0b
+49c019a10032c19dd2ca493f5f5733e05422801c4dfebb58ab5f5df0b377b506
+a431dcdac70f91bff6ac9f9db3f8fcea418dc90ae95f670fd8ebcba7fdec9c25
+1ffdeba0c6648f8380d2b4acd9cb9996ae2236fb5fa7c6648d36ff010092
+c1bcf1deebed660e003c79e266c7b663904200602e7dfe72bb8d03003b40c038

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

2022-08-16 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/data/content-control-grab-bag.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx   |   12 
 writerfilter/source/dmapper/DomainMapper.cxx|3 ++-
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 7ad44f3dd271a591529b048212c4391d8b38ed9d
Author: Miklos Vajna 
AuthorDate: Tue Aug 16 11:37:27 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue Aug 16 15:06:13 2022 +0200

crashtesting: fix DOCX export of forum-mso-de-99522.docx

Export of this document to DOCX wrote not-well-formed XML output,
resulting in an assertion failure in debug builds.

writerfilter/ maps a selection of  tags to Writer content
controls (a safe subset), and leaves the rest unchanged, which means we
continue to map those to grab-bags. The trouble is that a combination of
content controls and grab-bags leads to bad output on export, as we
start the  element twice, but only close it once.

Fix the problem by extending writerfilter/ code to not do any grab-bags
for the richText type, we already did that in the past for dropDowns.

In the long run, we should never do grab-bagging for any 
elements that we map to Writer content controls.

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

diff --git a/sw/qa/extras/ooxmlexport/data/content-control-grab-bag.docx 
b/sw/qa/extras/ooxmlexport/data/content-control-grab-bag.docx
new file mode 100644
index ..33c01f08fd25
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/content-control-grab-bag.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 43a7c2a67ce4..688b393a2d29 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -871,6 +871,18 @@ DECLARE_OOXMLEXPORT_TEST( testSdtDatePicker, 
"test_sdt_datepicker.docx" )
 CPPUNIT_ASSERT_EQUAL(OUString("008000"), sColor);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testContentControlGrabBag)
+{
+// Given a document with a  tag:
+OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"content-control-grab-bag.docx";
+loadURL(aURL, nullptr);
+
+// When exporting that document back to DOCX:
+// Then make sure that completes without an assertion failure, which would 
mean not-well-formed
+// output was produced:
+save("Office Open XML Text", maTempFile);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf104823)
 {
 // Test how we can roundtrip sdt plain text with databindings support
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 27621bec27bb..51aab4ce5364 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3813,7 +3813,8 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
 else
 {
 uno::Sequence aGrabBag = 
m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear();
-if (m_pImpl->GetSdtStarts().empty() || 
m_pImpl->m_pSdtHelper->getControlType() != SdtControlType::dropDown)
+if (m_pImpl->GetSdtStarts().empty()
+|| (m_pImpl->m_pSdtHelper->getControlType() != 
SdtControlType::dropDown && m_pImpl->m_pSdtHelper->getControlType() != 
SdtControlType::richText))
 {
 
m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->Insert(PROP_SDTPR,
 uno::Any(aGrabBag), true, PARA_GRAB_BAG);


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

2022-08-15 Thread Michael Stahl (via logerrit)
 sw/qa/extras/rtfexport/data/para-border.rtf |   27 
 sw/qa/extras/rtfexport/rtfexport4.cxx   |   62 
 writerfilter/source/rtftok/rtfsprm.cxx  |   16 +++
 3 files changed, 105 insertions(+)

New commits:
commit 6f42a2c8631bace1caa4fac0b3ea554942f1fca3
Author: Michael Stahl 
AuthorDate: Fri Aug 12 14:10:31 2022 +0200
Commit: Michael Stahl 
CommitDate: Mon Aug 15 11:14:38 2022 +0200

tdf#150382 writerfilter,sw: RTF import of paragraph border override

The style (default unnamed \s0, applied via \pard) defines green
borders, which are overridden at the 2nd paragraph and cleared.

Of course there isn't a single border control word to be found on the
2nd paragraph, the override happens by omitting the borders of the
implicitly applied style.

Hence handle LN_CT_PrBase_pBdr in getDefaultSPRM().

The export of the override relies on changes from commit
967a03eb8760fb498c5ea6c32d03d1eea486bbe2.

Change-Id: I081eb2908d76123e7828cab6c31ceb7b11760183
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138193
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/rtfexport/data/para-border.rtf 
b/sw/qa/extras/rtfexport/data/para-border.rtf
new file mode 100644
index ..d7f55c746757
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/para-border.rtf
@@ -0,0 +1,27 @@
+{\rtf1\adeflang1025\ansi\ansicpg1250\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1038\deflangfe1038\themelang1038\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi
 \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt 
Times New Roman};}
+{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New 
Roman{\*\falt Times New Roman};}
+{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020f0502020204030204}Calibri;}{\fbiminor\f31507\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt 
Times New Roman};}
+}{\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;\caccentsix\ctint255\cshade255\red112\green173\blue71;}{\*\defchp
 \f31506\fs22\lang1038\langfe1033\langfenp1033 }{\*\defpap \ql 
\li0\ri0\sa160\sl259\slmult1
+\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 
}\noqfpromote {\stylesheet{\ql 
\li0\ri0\sa160\sl259\slmult1\widctlpar\brdrt\brdrs\brdrw20\brsp20\brdrcf17 
\brdrl\brdrs\brdrw20\brsp80\brdrcf17 \brdrb\brdrs\brdrw20\brsp20\brdrcf17 
+\brdrr\brdrs\brdrw20\brsp80\brdrcf17 
\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 
\af31507\afs22\alang1025 \ltrch\fcs0 
\f31506\fs22\lang1038\langfe1033\cgrid\langnp1038\langfenp1033 
+\snext0 \sqformat \spriority0 \styrsid3957916 Normal,Bordered;}{\*\cs10 
\additive \ssemihidden \sunhideused \spriority1 Default Paragraph Font;}{\*
+\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
 \ql \li0\ri0\sa160\sl259\slmult1
+\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 
\rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 
\f31506\fs22\lang1038\langfe1033\cgrid\langnp1038\langfenp1033 \snext11 
\ssemihidden \sunhideused Normal Table;}}
+{\*\rsidtbl 
\rsid3957916\rsid7626595\rsid14618113}{\mmathPr\mmathFont34\mbrkBin0\mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0\mrMargin0\mdefJc1\mwrapIndent1440\mintLim0\mnaryLim1}{\info{\author
 G\'e1bor Kelemen2010}{\operator G\'e1bor Kelemen2010}
+{\creatim\yr2022\mo8\dy12\hr12\min9}{\revtim\yr2022\mo8\dy12\hr12\min38}{\version3}{\edmins27}{\nofpages1}{\nofwords9}{\nofchars63}{\nofcharsws71}{\vern49169}}{\*\xmlnstbl
 {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}
+\paperw11906\paperh16838\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect
 
+\deftab708\widowctrl\ftnbj\aenddoc\hyphhotz425\trackmoves0\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0
+\showxmlerrors1\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1440\dgvorigin1440\dghshow1\dgvshow1
+\jexpand\viewkind1\viewscale162\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct

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

2022-07-15 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf139759_commentHighlightBackground.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx  |   12 
++
 writerfilter/source/dmapper/DomainMapper.cxx|4 
+++
 3 files changed, 16 insertions(+)

New commits:
commit 386a9fadffa446caf40fd4f40b865c8c9432fa27
Author: Justin Luth 
AuthorDate: Thu Jul 14 10:02:35 2022 -0400
Commit: Justin Luth 
CommitDate: Fri Jul 15 13:41:34 2022 +0200

tdf#139759 writerfilter: avoid exception importing w:shd in comments

The unit test depends on the two previous fixes in this bug report.
-initial load tests highlight import
-export tests saving the character background
-reload tests this shade import

Change-Id: Iceb405841efc6814654061659e5551ac89f3c7b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137091
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf139759_commentHighlightBackground.docx 
b/sw/qa/extras/ooxmlexport/data/tdf139759_commentHighlightBackground.docx
new file mode 100644
index ..487439a5cff8
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf139759_commentHighlightBackground.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 93ad3abf2da6..038dca7cc92b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -191,6 +191,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf114734_commentFormating, 
"tdf114734_commentForma
  getProperty(xParagraph, 
"ParaAdjust"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf139759_commentHighlightBackground, 
"tdf139759_commentHighlightBackground.docx")
+{
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+uno::Reference xField(xFields->nextElement(), 
uno::UNO_QUERY);
+
+uno::Reference xText = 
getProperty>(xField, "TextRange");
+uno::Reference xParagraph = getParagraphOfText(1, xText);
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getProperty(getRun(xParagraph, 2), 
"CharBackColor"));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf135906)
 {
 loadAndReload("tdf135906.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 969578a4e73c..c3742cdbaa47 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1988,6 +1988,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
 pProperties->resolve(*pCellColorHandler);
 
rContext->InsertProps(pCellColorHandler->getProperties().get());
 m_pImpl->GetTopContext()->Insert(PROP_CHAR_SHADING_MARKER, 
uno::Any(true), true, CHAR_GRAB_BAG );
+
+// EditEng doesn't have a corresponding property for Shading 
Value, so eliminate it.
+if (m_pImpl->IsInComments())
+rContext->Erase(PROP_CHAR_SHADING_VALUE);
 }
 break;
 }


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

2022-07-12 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf149313.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |2 ++
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   13 +
 writerfilter/source/dmapper/DomainMapper.cxx |   14 --
 4 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit a4ab155ae15e9e6d4deb157634f8b86c87fcbde4
Author: Vasily Melenchuk 
AuthorDate: Thu Jun 16 12:16:33 2022 +0300
Commit: Thorsten Behrens 
CommitDate: Tue Jul 12 21:16:48 2022 +0200

tdf#149313: DOCX import: improved conditions for removeparagraph

Quite complex conditions to define if current paragraph can be
removed for document were forcing to keep paragraphs after page
break with only section definition. Usually these pars are removed,
but since tdf#103975 fix they were kept.

It looks like to resolve that problem will be enough to ensure
current break is a column break: they are bit different and
processed in a different way unlike other break types.

So this condition part instead of "do not remove par with section
info after any break" it is right now "do not remove par after
column break".

Change-Id: Ib6290dc6254430883a598bef3ecd1f7ab7063922
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135969
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf149313.docx 
b/sw/qa/extras/ooxmlexport/data/tdf149313.docx
new file mode 100644
index ..4c0c454b42a6
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf149313.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 5573a1b1adf2..d027706de65d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -689,6 +689,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112202, 
"090716_Studentische_Arbeit_VWS.docx")
 assertXPath(pXmlDoc, "/root/page[3]/header/tab", 1);
 assertXPath(pXmlDoc, "/root/page[3]/header/tab/row/cell/txt/Text", 0);
 assertXPath(pXmlDoc, "/root/page[3]/header//anchored", 0);
+// tdf#149313: ensure 3rd page does not have extra empty paragraph at top
+assertXPathContent(pXmlDoc, "/root/page[3]/body//txt", "AUFGABENSTELLUNG");
 
 // page 4 header: 1 table, 1 paragraph, with text
 assertXPath(pXmlDoc, "/root/page[4]/header/txt", 1);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 496a7cfaed02..93ad3abf2da6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -1018,6 +1018,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf149200)
 CPPUNIT_ASSERT_EQUAL(OUString("dark1"), getXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:color", "themeColor"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf149313, "tdf149313.docx")
+{
+// only 2, but not 3 pages in document
+CPPUNIT_ASSERT_EQUAL(2, getPages());
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+// And ensure that pages are with correct sections (have correct 
dimensions)
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4989), getXPath(pXmlDoc, 
"/root/page[1]/infos/bounds", "height").toInt32());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4989), getXPath(pXmlDoc, 
"/root/page[1]/infos/bounds", "width").toInt32());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4989), getXPath(pXmlDoc, 
"/root/page[2]/infos/bounds", "height").toInt32());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(8000), getXPath(pXmlDoc, 
"/root/page[2]/infos/bounds", "width").toInt32());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf135923, "tdf135923-min.docx")
 {
 uno::Reference xShape(getShape(1), uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 713412ccfa94..d940d09ffd34 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3892,13 +3892,23 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
 
 // If the paragraph contains only the section properties and it has
 // no runs, we should not create a paragraph for it in Writer, 
unless that would remove the whole section.
-SectionPropertyMap* pSectionContext = m_pImpl->GetSectionContext();
+// Also do not remove here column breaks: they are treated in a 
different way and place.
+bool bIsColumnBreak = false;
+if (pContext->isSet(PROP_BREAK_TYPE))
+{
+const uno::Any aBreakType = 
pContext->getProperty(PROP_BREAK_TYPE)->second;
+bIsColumnBreak =
+aBreakType == style::BreakType_COLUMN_BEFORE ||
+aBreakType == style::BreakType_COLUMN_AFTER ||
+aBreakType == style::BreakType_COLUMN_BOTH;
+}
+
 bool bRemove = (!m_pImpl->GetParaChanged() && 
m_pImpl->GetRemoveThisPara()) 

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

2022-07-11 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf114734_commentFormating.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   23 ++
 writerfilter/source/dmapper/DomainMapper.cxx  |6 +-
 3 files changed, 26 insertions(+), 3 deletions(-)

New commits:
commit cf02b94bc513ee1b742b4c5d7174632b568e8b72
Author: Justin Luth 
AuthorDate: Thu Jun 30 15:45:02 2022 -0400
Commit: Justin Luth 
CommitDate: Mon Jul 11 22:10:40 2022 +0200

tdf#114734 writerfilter: avoid PostIt exception

Comments (aka AnnotationMarks) cannot contain
a paragraph style. The exception was causing
all properties to be dropped.

This fixes the right-to-left text direction issue.

Additionally, I need to cancel code
when dealing with justify. There is no
underlying style to deal with,
and also MS Word seems to treat justify
literally when dealing with comments.

IIRC, LO interally always refers to justify literally,
while DOCX normally depends on the RtL context,
treating LEFT as START and RIGHT as END.

Hmm - I bet that complicates things for export,
since exporting comments needs to be handled uniquely.

Change-Id: I4f604f90aaad36ea56b8a9157a8a8458f39877c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136690
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf114734_commentFormating.docx 
b/sw/qa/extras/ooxmlexport/data/tdf114734_commentFormating.docx
new file mode 100644
index ..5c8edb168991
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf114734_commentFormating.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index c264342fdb77..07441a5d9196 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -12,6 +12,8 @@
 #include 
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -170,6 +172,27 @@ DECLARE_OOXMLEXPORT_TEST(testTdf132475_printField, 
"tdf132475_printField.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Last printed"), 
xField->getPresentation(true));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf114734_commentFormating, 
"tdf114734_commentFormating.docx")
+{
+if (mbExported)
+return;
+// Get the PostIt/Comment/Annotation
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+uno::Reference xField(xFields->nextElement(), 
uno::UNO_QUERY);
+
+uno::Reference xText = 
getProperty>(xField, "TextRange");
+uno::Reference xParagraph = getParagraphOfText(1, xText);
+// Paragraph formatting was lost: should be right to left, and thus 
right-justified
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Right to Left comment",
+ text::WritingMode2::RL_TB,
+ getProperty(xParagraph, 
"WritingMode"));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("literal right justified",
+ sal_Int16(style::ParagraphAdjust_RIGHT),
+ getProperty(xParagraph, 
"ParaAdjust"));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf135906)
 {
 loadAndReload("tdf135906.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 224f8c2aa902..713412ccfa94 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1369,7 +1369,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
 {
 case NS_ooxml::LN_CT_PPrBase_jc:
 {
-bool bExchangeLeftRight = !IsRTFImport() && 
ExchangeLeftRight(rContext, *m_pImpl);
+bool bExchangeLeftRight = !IsRTFImport() && !m_pImpl->IsInComments() 
&& ExchangeLeftRight(rContext, *m_pImpl);
 handleParaJustification(nIntValue, rContext, bExchangeLeftRight);
 break;
 }
@@ -1667,7 +1667,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
 m_pImpl->GetPropertyFromParaStyleSheet(PROP_WRITING_MODE) >>= 
nParentBidi;
 // Paragraph justification reverses its meaning in an RTL context.
 // 1. Only make adjustments if the BiDi changes.
-if ( nParentBidi != nWritingMode && !IsRTFImport() )
+if (nParentBidi != nWritingMode && !IsRTFImport() && 
!m_pImpl->IsInComments())
 {
 style::ParagraphAdjust eAdjust = style::ParagraphAdjust(-1);
 // 2. no adjust property exists yet
@@ -3318,7 +3318,7 @@ void DomainMapper::lcl_startParagraphGroup()
 
 if (m_pImpl->GetTopContext())
 {
-if (!m_pImpl->IsInShape())
+if (!m_pImpl->IsInShape() && !m_pImpl->IsInComments())
 {
 const OUString& 

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

2022-07-08 Thread László Németh (via logerrit)
 sw/qa/extras/layout/data/tdf149711.docx   |binary
 sw/qa/extras/layout/layout2.cxx   |   17 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   19 ++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |4 ++--
 4 files changed, 29 insertions(+), 11 deletions(-)

New commits:
commit 11071d95f4f3cbe578c3393729c42b7cce011b45
Author: László Németh 
AuthorDate: Thu Jul 7 13:04:45 2022 +0200
Commit: László Németh 
CommitDate: Fri Jul 8 09:31:49 2022 +0200

tdf#149711 sw_redlinenum DOCX: import moveTo paragraph mark

It was imported as an old paragraph with new content,
resulting that e.g. rejecting a moved list item left
an empty list item instead of removing the moved list
item completely.

Follow-up to commit 80694a8fcfeb86ed69425ab6954b353b9a0ae854
"tdf#149708 sw_redlinenum DOCX export: track inserted list items"
and commit d32d9a2b3c5e3963f4a18f6c7bbf50fab2e9b2be
"tdf#123460 DOCX track changes: moveFrom completely".

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

diff --git a/sw/qa/extras/layout/data/tdf149711.docx 
b/sw/qa/extras/layout/data/tdf149711.docx
new file mode 100644
index ..d90efa7c1f88
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf149711.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index c755bd62514f..cb36569fbc8f 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -566,6 +566,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testTdf149709_RedlineNumberingLevel)
 assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[8]/text", 
"2.");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testTdf149711_importDOCXMoveToParagraphMark)
+{
+SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf149711.docx");
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 6);
+
+// reject tracked insertion (moveTo)
+SwEditShell* const pEditShell(pDoc->GetEditShell());
+CPPUNIT_ASSERT_EQUAL(static_cast(2), 
pEditShell->GetRedlineCount());
+pEditShell->RejectRedline(1);
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+// This was 6 (not tracked paragraph mark of the moveTo list item)
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 5);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInFootnote)
 {
 SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf85610.fodt");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index bbd22d199c2b..17f0e03cb6db 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2734,10 +2734,10 @@ void DomainMapper_Impl::appendTextPortion( const 
OUString& rString, const Proper
 }
 }
 
-// reset moveFrom data of non-terminating runs of the paragraph
-if ( m_pParaMarkerRedlineMoveFrom )
+// reset moveFrom/moveTo data of non-terminating runs of the paragraph
+if ( m_pParaMarkerRedlineMove )
 {
-m_pParaMarkerRedlineMoveFrom.clear();
+m_pParaMarkerRedlineMove.clear();
 }
 CheckRedline( xTextRange );
 m_bParaChanged = true;
@@ -3297,13 +3297,14 @@ void 
DomainMapper_Impl::CreateRedline(uno::Reference const& xR
 break;
 case XML_moveTo:
 bRedlineMoved = true;
+m_pParaMarkerRedlineMove = pRedline.get();
 [[fallthrough]];
 case XML_ins:
 sType = getPropertyName( PROP_INSERT );
 break;
 case XML_moveFrom:
 bRedlineMoved = true;
-m_pParaMarkerRedlineMoveFrom = pRedline.get();
+m_pParaMarkerRedlineMove = pRedline.get();
 [[fallthrough]];
 case XML_del:
 sType = getPropertyName( PROP_DELETE );
@@ -3372,14 +3373,14 @@ void DomainMapper_Impl::CheckParaMarkerRedline( 
uno::Reference< text::XTextRange
 m_currentRedline.clear();
 }
 }
-else if ( m_pParaMarkerRedlineMoveFrom )
+else if ( m_pParaMarkerRedlineMove )
 {
-// terminating moveFrom redline removes also the paragraph mark
-CreateRedline( xRange, m_pParaMarkerRedlineMoveFrom );
+// terminating moveFrom/moveTo redline removes also the paragraph mark
+CreateRedline( xRange, m_pParaMarkerRedlineMove );
 }
-if ( m_pParaMarkerRedlineMoveFrom )
+if ( m_pParaMarkerRedlineMove )
 {
-m_pParaMarkerRedlineMoveFrom.clear();
+m_pParaMarkerRedlineMove.clear();
 }
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index c0a41b0328cf..4072a646840b 100644
--- 

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

2022-07-07 Thread Mark Hung (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf149089.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   10 ++
 writerfilter/source/dmapper/PropertyMap.cxx  |   13 ++---
 3 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit 23f80b26098bcf9a8ae870e8ded878cca6e0c541
Author: Mark Hung 
AuthorDate: Wed Jun 29 21:03:35 2022 +0800
Commit: Mark Hung 
CommitDate: Thu Jul 7 15:18:19 2022 +0200

tdf#149089 fallback GridMode.

If line pitch is not defined -> fallback to none.
Otherwise if charSpace is not defined -> fallback to lines.

Change-Id: I1df027f2e74baf0215567fb9a70c879522558346
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136622
Tested-by: Jenkins
Reviewed-by: Mark Hung 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf149089.docx 
b/sw/qa/extras/ooxmlexport/data/tdf149089.docx
new file mode 100644
index ..2390476841e3
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf149089.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 75d7b8feb4ba..c264342fdb77 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1021,6 +1022,15 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf148273_sectionBulletFormatLeak, "tdf148273_secti
 CPPUNIT_ASSERT_EQUAL(false, aValue.hasValue());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf149089, "tdf149089.docx")
+{
+uno::Reference xPageStyles = 
getStyles("PageStyles");
+uno::Reference 
xPageStyle(xPageStyles->getByName("Standard"), uno::UNO_QUERY);
+sal_Int16 nGridMode;
+xPageStyle->getPropertyValue("GridMode") >>= nGridMode;
+CPPUNIT_ASSERT_EQUAL( sal_Int16(text::TextGridMode::LINES), nGridMode);   
// was LINES_AND_CHARS
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index e1814a8ce1d5..1ae28759db33 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1759,16 +1759,23 @@ void SectionPropertyMap::CloseSectionGroup( 
DomainMapper_Impl& rDM_Impl )
 }
 
 const sal_Int32 nGridLines = nTextAreaHeight / nGridLinePitch;
+sal_Int16 nGridType = m_nGridType;
 if ( nGridLines >= 0 && nGridLines <= SAL_MAX_INT16 )
 Insert( PROP_GRID_LINES, uno::Any( sal_Int16(nGridLines) ) );
+else
+nGridType = text::TextGridMode::NONE;
 
 // PROP_GRID_MODE
-Insert( PROP_GRID_MODE, uno::Any( static_cast (m_nGridType) 
) );
-if ( m_nGridType == text::TextGridMode::LINES_AND_CHARS )
+if ( nGridType == text::TextGridMode::LINES_AND_CHARS )
 {
-Insert( PROP_GRID_SNAP_TO_CHARS, uno::Any( m_bGridSnapToChars ) );
+if (!m_nDxtCharSpace)
+nGridType = text::TextGridMode::LINES;
+else
+Insert( PROP_GRID_SNAP_TO_CHARS, uno::Any( m_bGridSnapToChars 
) );
 }
 
+Insert( PROP_GRID_MODE, uno::Any( nGridType ) );
+
 sal_Int32 nCharWidth = 423; //240 twip/ 12 pt
 const StyleSheetEntryPtr pEntry = 
rDM_Impl.GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( u"Standard" 
);
 if ( pEntry )


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

2022-05-26 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf146955.odt   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   12 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   12 +---
 3 files changed, 17 insertions(+), 7 deletions(-)

New commits:
commit 73696a01224a3758bde686f32ec7e6f4c90877fe
Author: László Németh 
AuthorDate: Wed May 25 11:57:13 2022 +0200
Commit: László Németh 
CommitDate: Thu May 26 20:26:13 2022 +0200

tdf#146955 DOCX import: fix SAX exception with footnotes

(Likely broken) DOCX documents exported by Writer raised a SAX
exception, when PopFootOrEndnote() tried to access to a
not-existent footnote, because PushFootOrEndnote() failed to
create that.

Note: the original ODT contains hundreds of frames, and
these and the text content of the document have been put
into the TOC section during Writer's DOCX export, resulting a
broken document.

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

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf146955.odt 
b/sw/qa/extras/ooxmlexport/data/tdf146955.odt
new file mode 100644
index ..c7a849f9b756
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf146955.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index d3804717e29c..fd6c560395b5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -813,6 +814,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf144563, "tdf144563.docx")
 }
 }
 
+// broken test document?
+#if !defined(_WIN32)
+DECLARE_OOXMLEXPORT_TEST(testTdf146955, "tdf146955.odt")
+{
+// import of a (broken?) DOCX export with dozens of frames raised a SAX 
exception,
+// when the code tried to access to a non-existent footnote
+uno::Reference xNotes(mxComponent, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xNotes->getFootnotes()->getCount());
+}
+#endif
+
 DECLARE_OOXMLEXPORT_TEST(testTdf144668, "tdf144668.odt")
 {
 uno::Reference xPara1(getParagraph(1, u"level1"), 
uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1371b7cc0e32..4e769e15b0cf 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3504,13 +3504,11 @@ void DomainMapper_Impl::PopFootOrEndnote()
 uno::Reference< text::XFootnote > xFootnoteFirst, xFootnoteLast;
 auto xFootnotes = xFootnotesSupplier->getFootnotes();
 auto xEndnotes = xEndnotesSupplier->getEndnotes();
-if (IsInFootnote())
-xFootnotes->getByIndex(xFootnotes->getCount()-1) >>= xFootnoteLast;
-else
-xEndnotes->getByIndex(xEndnotes->getCount()-1) >>= xFootnoteLast;
-if ( ( ( IsInFootnote() && xFootnotes->getCount() > 1 ) ||
- ( !IsInFootnote() && xEndnotes->getCount() > 1 ) ) &&
-xFootnoteLast->getLabel().isEmpty() )
+if ( ( ( IsInFootnote() && xFootnotes->getCount() > 1 &&
+   ( xFootnotes->getByIndex(xFootnotes->getCount()-1) >>= 
xFootnoteLast ) ) ||
+   ( !IsInFootnote() && xEndnotes->getCount() > 1 &&
+   ( xEndnotes->getByIndex(xEndnotes->getCount()-1) >>= 
xFootnoteLast ) )
+ ) && xFootnoteLast->getLabel().isEmpty() )
 {
 // copy content of the first remaining temporary footnote
 if ( IsInFootnote() )


[Libreoffice-commits] core.git: 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 02f53bd61222d7999b847a22fd24d65195f129e5
Author: Vasily Melenchuk 
AuthorDate: Wed May 11 09:44:22 2022 +0300
Commit: Miklos Vajna 
CommitDate: Thu May 19 11:58:24 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

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 5c25a3b5d369..8146e942ce5d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -15,8 +15,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -824,6 +827,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(testTdf135923, "tdf135923-min.docx")
 {
 uno::Reference xShape(getShape(1), uno::UNO_QUERY);
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 ;}
 \listid1421871093}
 }
 {\*\listoverridetable
 {\listoverride\listid1421871093\listoverridecount0\ls30}
 }
-\pard\plain Before.\par
-\pard\plain \ls30\f40\fs18 

[Libreoffice-commits] core.git: 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 d1ac8df139a2a65db45d1970ccc0b80e17d827f6
Author: László Németh 
AuthorDate: Tue May 3 11:06:59 2022 +0200
Commit: László Németh 
CommitDate: Wed May 4 12:22:41 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 

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 c6c545b24e54..8d7068e4faa2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1253,6 +1253,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 7b29266f38f4..80c30a527949 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: sw/qa writerfilter/source

2022-04-29 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf148380_usernameField.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |   13 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |6 --
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit f56f8be65b26cb3c8e83af05f10ba9f717ff76b2
Author: Justin Luth 
AuthorDate: Fri Apr 22 19:46:16 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri Apr 29 12:25:01 2022 +0200

tdf#126636 writerfilter: import USERNAME field as fixed

This depends on and mimics some of the fixes for tdf#148380.

Microsoft Word doesn't immediately/automatically update field contents
like LO does. Instead, the user needs to press F9 on each field.
So, these USERNAME or USERINITIALS fields just show the
when-last-updated text that was saved in the document
instead of the actual current value of the field.

Although LO doesn't have that ability, we can flag them as FIXED
and achieve a very similar result. Doing so fixes this bug report
which might be quite common since USERNAME might be mistaken
for AUTHOR or LASTSAVEDBY by the user - since in practice
they tend to be the same thing.

We already did this for AUTHOR (which is extremely safe since
that can never change). I almost hate to do it with this one
because even this bug shows it is too often a case of mis-use,
but that is the way it is, and this seems to be the best solution.

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148380_usernameField.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148380_usernameField.docx
new file mode 100644
index ..241632bc80e9
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf148380_usernameField.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index f03901f5180d..bbbc8e7cfb73 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -104,6 +104,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148380_fldLocked, 
"tdf148380_fldLocked.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Last printed (fixed)"), 
xField->getPresentation(true));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148380_usernameField, 
"tdf148380_usernameField.docx")
+{
+// Verify that these are fields, and not just plain text
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+uno::Reference xField(xFields->nextElement(), 
uno::UNO_QUERY);
+// These should match the as-last-seen-in-the-text name, and not the 
application's user name
+CPPUNIT_ASSERT_EQUAL(OUString("Charlie Brown"), 
xField->getPresentation(false));
+xField.set(xFields->nextElement(), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("CB"), xField->getPresentation(false));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf148380_modifiedField, 
"tdf148380_modifiedField.docx")
 {
 getParagraph(2, "4/5/2022 3:29:00 PM"); // default (unspecified) date 
format
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 2d956b5ab09c..b59b9eac066f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5547,7 +5547,7 @@ void DomainMapper_Impl::handleAutoNum
 }
 
 void DomainMapper_Impl::handleAuthor
-(std::u16string_view rFirstParam,
+(std::u16string_view,
  uno::Reference< beans::XPropertySet > const& xFieldProperties,
  FieldId  eFieldId )
 {
@@ -,7 +,9 @@ void DomainMapper_Impl::handleAuthor
 xFieldProperties->setPropertyValue
 ( getPropertyName(PROP_FULL_NAME), uno::makeAny( true ));
 
-if (!rFirstParam.empty() || eFieldId == FIELD_AUTHOR)
+// Always set as FIXED b/c MS Word only updates these fields via user 
intervention (F9)
+// AUTHOR of course never changes and USERNAME is easily mis-used as an 
original author field.
+// Additionally, this was forced as fixed if any special case-formatting 
was provided.
 {
 xFieldProperties->setPropertyValue(
 getPropertyName( PROP_IS_FIXED ),


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

2022-04-26 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 3a05acb8f0d94728ea6cbfd7a69dac6ffa7ffc68
Author: Vasily Melenchuk 
AuthorDate: Thu Apr 21 10:04:50 2022 +0300
Commit: Thorsten Behrens 
CommitDate: Wed Apr 27 00:56:10 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 

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 276bdd963b26..65b8ac90954c 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -646,6 +646,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: sw/qa writerfilter/source

2022-04-25 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf148380_printField.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx  |   17 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx   |   64 +++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx   |1 
 4 files changed, 61 insertions(+), 21 deletions(-)

New commits:
commit 115599cc3478e37879cd2fa0b6c6c9dabde7dfd1
Author: Justin Luth 
AuthorDate: Sat Apr 9 18:06:24 2022 +0200
Commit: Justin Luth 
CommitDate: Mon Apr 25 18:57:45 2022 +0200

tdf#132475 writerfilter: use proper date-field defaults

When a field doesn't specify the format for a date,
the system is free to implement it as it chooses.
However, the user tends to disagree with that,
so lets try to create a MS-similar default for
these dates - since LO defaults to only displaying
a date without any time component.

For example: PRINTDATE \* MERGEFORMAT
doesn't tell us how to display the date.

MS Word uses different defaults depending on
the language of the document. And that only make sense.
For example, I noticed that of course en-GB's format
is dd/MM/ instead of en-US's M/d/.

As a documentation example: 17.16.5.47 PRINTDATE
Syntax: PRINTDATE [ switches ]
Description: Retrieves the date and time on which the
document was last printed, as recorded in the
LastPrinted element of the Core File Properties part.

Switches: Zero or one date-and-time-formatting-switch
and zero or one of the following field-specific-switches.

PRINTDATE (without any formatting switches)
   the results are:
1/6/2006 2:58:00 PM

Change-Id: I41f3bdc155bd8cdc74177e4626b31ece9b47e16b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133208
Tested-by: Justin Luth 
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148380_printField.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148380_printField.docx
new file mode 100644
index ..44145748c6ed
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf148380_printField.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 9347a8abfb54..464c0b22d6c4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -100,6 +100,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148380_modifiedField, 
"tdf148380_modifiedField.d
  OUString("Charles Brown"), 
xField->getPresentation(false));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148380_printField, "tdf148380_printField.docx")
+{
+// Verify that these are fields, and not just plain text
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+uno::Reference xField(xFields->nextElement(), 
uno::UNO_QUERY);
+// unspecified SAVEDATE gets default GB formatting because stylele.xml has 
w:lang w:val="en-GB"
+//CPPUNIT_ASSERT_EQUAL(OUString("08/04/2022 07:10:00 AM"), 
xField->getPresentation(false));
+//CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Modified"), 
xField->getPresentation(true));
+//xField.set(xFields->nextElement(), uno::UNO_QUERY);
+// MS Word actually shows "8 o'clock-ish" until the document is reprinted,
+// but it seems best to actually show the real last-printed date since it 
can't be FIXEDFLD
+CPPUNIT_ASSERT_EQUAL(OUString("08/04/2022 06:47:00 AM"), 
xField->getPresentation(false));
+CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Last printed"), 
xField->getPresentation(true));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf132475_printField, "tdf132475_printField.docx")
 {
 // The last printed date field: formatted two different ways
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6206a9386edb..d8327fa8d248 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -35,6 +35,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -1187,6 +1189,15 @@ uno::Any DomainMapper_Impl::GetAnyProperty(PropertyIds 
eId, const PropertyMapPtr
 return aProperty->second;
 }
 
+// then look whether it was directly applied as a paragraph property
+PropertyMapPtr pParaContext = GetTopContextOfType(CONTEXT_PARAGRAPH);
+if (pParaContext && rContext != pParaContext)
+{
+std::optional aProperty = 
pParaContext->getProperty(eId);
+if (aProperty)
+return aProperty->second;
+}
+
 // then look whether it was inherited from a directly applied character 
style
 if ( eId != PROP_CHAR_STYLE_NAME && isCharacterProperty(eId) )
 {
@@ -4429,23 +4440,6 @@ static OUString 

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

2022-04-22 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf132475_printField.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx  |   18 
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx   |2 -
 writerfilter/source/dmapper/DomainMapper_Impl.cxx   |2 +
 writerfilter/source/dmapper/FieldTypes.hxx  |1 
 5 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 58cd67e096ca14123a85f8542c728b07645df705
Author: Justin Luth 
AuthorDate: Fri Apr 1 21:03:08 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri Apr 22 13:32:35 2022 +0200

tdf#132475 writerfilter: connect PRINTDATE with DocInfo.PrintDateTime

NOTE: This patch depends on a follow-up patch to handle the case
where no date formating instructions are provided.

NOTE: The time part might be considered a regression by some since
Word displays as local time while LO seems to display GMT time.

Although the date was being imported as a generic field,
it wasn't associated with the last printed date.

PRINTDATE is about the only field that MS Word automatically
updates without the user having to press F9 on it,
so that shows we should NOT mark it as fixed on import.
On the other hand, it doesn't update very often, so if a
user hand-modifies the result, then (without marking it as fixed)
LO will display differently from MS Word.

Hey, its a last-printed-date field I say. Who cares what
it looks like on someone else's computer. It only matters
if it is accurate and visible on yours.

This caused a unit test failure with
make CppunitTest_sw_ooxmlfieldexport CPPUNIT_TESt_NAME=testGenericTextField
because contents.match(" PRINTDATE ")
NOTE: we are losing \* MERGEFORMAT on all of supported fields on export,
but that might be OK because we don't do MERGEFORMAT anyway.

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf132475_printField.docx 
b/sw/qa/extras/ooxmlexport/data/tdf132475_printField.docx
new file mode 100644
index ..032a58d238cc
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf132475_printField.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index dcfede6b43ee..8dbdd637a3b3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -100,6 +100,24 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148380_modifiedField, 
"tdf148380_modifiedField.d
  OUString("Charles Brown"), 
xField->getPresentation(false));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf132475_printField, "tdf132475_printField.docx")
+{
+// The last printed date field: formatted two diferent ways
+getParagraph(2, "Thursday, March 17, 2022");
+getParagraph(3, "17-Mar-22");
+// Time zone affects the displayed time in MS Word. LO shows GMT time. 
Word only updated by F9
+getParagraph(5, "12:49");
+getParagraph(6, "12:49:00 PM");
+
+// Verify that these are fields, and not just plain text
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+uno::Reference xField(xFields->nextElement(), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("Thursday, March 17, 2022"), 
xField->getPresentation(false));
+CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Last printed"), 
xField->getPresentation(true));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf135906)
 {
 loadAndReload("tdf135906.docx");
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index e3628f721ccd..b3f45fd9ce95 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -342,7 +342,7 @@ CPPUNIT_TEST_FIXTURE(Test, testGenericTextField)
 xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
 xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
 OUString contents = 
OUString::createFromAscii(reinterpret_cast((pXmlNode->children[0]).content));
-CPPUNIT_ASSERT(contents.match("PRINTDATE   \\* MERGEFORMAT"));
+CPPUNIT_ASSERT(contents.match(" PRINTDATE "));
 xmlXPathFreeObject(pXmlObj);
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 2aff26ad5ad4..6206a9386edb 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5165,6 +5165,7 @@ static const FieldConversionMap_t & 
lcl_GetFieldConversion()
 {"NEXTIF",  {"DatabaseNextSet", FIELD_NEXTIF}},
 {"PAGE", 

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

2022-04-11 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf148380_createField.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   15 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|4 ++--
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 431a0399bb050e65dedb2e9280e744699a724227
Author: Justin Luth 
AuthorDate: Tue Apr 5 14:10:21 2022 +0200
Commit: Miklos Vajna 
CommitDate: Mon Apr 11 12:23:14 2022 +0200

tdf#148380 writerfilter: Import AUTHOR as FIXEDFLD

This patch depends on patches for tdf#147861
and will require a follow-up export patch that handles exporting
this FIXEDFLD (instead of just dumping the name of the field).

This was being imported as plain text because of exception
writerfilter/source/dmapper/DomainMapper_Impl.cxx:6950:
Exception in CloseFieldCommand() com.sun.star.beans.UnknownPropertyException
message: "Unknown property: FullName at
/persistent/git/libreoffice2/sw/source/core/unocore/unofield.cxx:2156"

Additionally, similar to tdf#134592, the create author will always
be constant, so mark that as fixed. (This helps because in MS Word,
the user can modify the field contents to be anything he wants,
and it is only updated when F9 is pressed on the selected field.
Thus, we might NOT want to show the real DocInfo.CreateAuthor
as the unit test demonstrates.)

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148380_createField.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148380_createField.docx
new file mode 100644
index ..c31ed72141e4
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf148380_createField.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 00f54a17c561..77caab6f81ff 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -67,6 +67,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf147861_customField, 
"tdf147861_customField.docx"
 CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Title (fixed)"), 
xField->getPresentation(true));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148380_createField, 
"tdf148380_createField.docx")
+{
+// Verify that these are fields, and not just plain text
+uno::Reference xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+uno::Reference 
xFields(xFieldsAccess->createEnumeration());
+if (mbExported)
+return;
+uno::Reference xField(xFields->nextElement(), 
uno::UNO_QUERY);
+// This should NOT be "Lorenzo Chavez", or a real date since the user 
hand-modified the result.
+CPPUNIT_ASSERT_EQUAL(OUString("Myself - that's who"), 
xField->getPresentation(false));
+xField.set(xFields->nextElement(), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("yesterday at noon"), 
xField->getPresentation(false));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf135906)
 {
 loadAndReload("tdf135906.docx");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 597549475936..311a0ffd4384 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5451,11 +5451,11 @@ void DomainMapper_Impl::handleAuthor
  uno::Reference< beans::XPropertySet > const& xFieldProperties,
  FieldId  eFieldId )
 {
-if ( eFieldId != FIELD_USERINITIALS )
+if (eFieldId == FIELD_USERNAME)
 xFieldProperties->setPropertyValue
 ( getPropertyName(PROP_FULL_NAME), uno::makeAny( true ));
 
-if (!rFirstParam.empty())
+if (!rFirstParam.empty() || eFieldId == FIELD_AUTHOR)
 {
 xFieldProperties->setPropertyValue(
 getPropertyName( PROP_IS_FIXED ),


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

2022-04-08 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 844be7358f1eec00094a55fa1fb4fadadb8cd1bf
Author: Vasily Melenchuk 
AuthorDate: Thu Apr 7 20:59:08 2022 +0300
Commit: Miklos Vajna 
CommitDate: Fri Apr 8 11:22:54 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 

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 2d036538d6fe..c2af71a93f63 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -553,6 +553,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 b3c04bb0f1f1..ca092fb66a37 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 5a19ccebb20a..47349ac8aaba 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);
+aNameNoSuffix = aName.copy(0, nLastSpace);
+sal_Int32 nEncoding = RTL_TEXTENCODING_DONTKNOW;
+for (int i = 0; aRTFFontNameSuffixes[i].codepage != 

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

2022-04-07 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 965313b9efc761c70aacf6e3ebee60ffa2b1d5dd
Author: Vasily Melenchuk 
AuthorDate: Tue Apr 5 19:13:05 2022 +0300
Commit: Miklos Vajna 
CommitDate: Thu Apr 7 14:29:04 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 

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 8f81b1565695..2d036538d6fe 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -492,6 +492,67 @@ CPPUNIT_TEST_FIXTURE(Test, testClearingBreak)
 verify();
 }
 
+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"));
+
+uno::Reference xRun12
+= getRun(getParagraph(12), 1, u"\u0390\u0391\u0392\u0393\u0394");
+CPPUNIT_ASSERT_EQUAL(OUString("Arial"), 

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

2022-04-05 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 fafadd7aee8c384af210008f693b5007a9f5ea48
Author: Vasily Melenchuk 
AuthorDate: Mon Apr 4 18:05:18 2022 +0300
Commit: Vasily Melenchuk 
CommitDate: Tue Apr 5 16:50:21 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 

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 f199b1fa6671..00f54a17c561 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -232,6 +232,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 6d02a044dae6..0bda90d71e4f 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -262,8 +262,7 @@ void SdtHelper::createDropDownControl()
 }
 
 // clean up
-m_aDropDownItems.clear();
-setControlType(SdtControlType::unknown);
+clear();
 }
 
 void SdtHelper::createPlainTextControl()
@@ -294,8 +293,7 @@ void SdtHelper::createPlainTextControl()
uno::makeAny(getInteropGrabBagAndClear()));
 
 // clean up
-m_aDropDownItems.clear();
-setControlType(SdtControlType::unknown);
+clear();
 }
 
 void SdtHelper::createDateContentControl()
@@ -370,11 +368,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,
@@ -421,6 +419,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 fb458d8d8b94..54e083ee8df2 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: sw/qa writerfilter/source

2022-04-05 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 e3a996bf72a16f5b22e6ff021745af5cec70a632
Author: Vasily Melenchuk 
AuthorDate: Fri Apr 1 16:35:40 2022 +0300
Commit: Miklos Vajna 
CommitDate: Tue Apr 5 15:50:54 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 

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 69591c638fcc..f199b1fa6671 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -397,6 +397,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 123b3b31ae4d..8f81b1565695 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -528,6 +528,38 @@ DECLARE_RTFEXPORT_TEST(testTdf111851, "tdf111851.rtf")
 CPPUNIT_ASSERT_EQUAL(COL_BLACK, 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),
+getProperty(getParagraph(5, "No border"), 
"TopBorder").LineWidth);
+
+// And let's ensure that there are no other horizontal borders
+CPPUNIT_ASSERT_EQUAL(

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

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

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

tdf#73499 DOCX import: fix grouped linked textbox

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

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

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

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

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

2022-03-26 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 9d033508af5257aeebbd8c22a053db5e74a814d3
Author: Vasily Melenchuk 
AuthorDate: Fri Mar 25 11:14:10 2022 +0300
Commit: Thorsten Behrens 
CommitDate: Sat Mar 26 23:02:01 2022 +0100

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 

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 aff5fb3b336c..8162b8fbb414 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -319,6 +319,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 f4fa3ef69405..f05d1c68b049 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -195,7 +195,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();
 }


  1   2   3   4   5   6   7   8   9   >