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

2023-11-30 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 bcbc024757b569e1c8999ac4f897bd7f0ee8781b
Author: Michael Stahl 
AuthorDate: Wed Nov 15 18:24:50 2023 +0100
Commit: Xisco Fauli 
CommitDate: Thu Nov 30 10:21:30 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 
(cherry picked from commit 454e5010aec9953f586fe8af671765358f6cafc4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159531
Reviewed-by: Xisco Fauli 

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 be75cee76577..203bce99df23 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -881,10 +881,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 0aeb3337f6f3..cdb2212a0a38 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -4409,6 +4409,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
(!m_pImpl->GetParaChanged() && 
m_pImpl->GetParaSectpr()
 && !bSingleParagraphAfterRedline
 && !bIsColumnBreak
+&& 

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

2023-11-28 Thread Michael Stahl (via logerrit)
 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 +-
 10 files changed, 96 insertions(+), 22 deletions(-)

New commits:
commit 022e12e9af6e92ac3db853e73b7b2577b3c0511e
Author: Michael Stahl 
AuthorDate: Fri Nov 10 17:04:27 2023 +0100
Commit: Thorsten Behrens 
CommitDate: Tue Nov 28 21:54:41 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 - strangely in the libreoffice-7-6 branch this happens
on Linux too and it was fixed with commit
191babee4f0ec643b80e96b0cd98c2d04ff96e4e)

Change-Id: Ia1063693d96adff900ece943020a5bf69bdeb7a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159471
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 15b886f460919ea3dce425a621dc017c2992a96b)
Reviewed-on: 

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

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

New commits:
commit d06bb71d19c29eaecdf499cb5e160f2ce08b58de
Author: Oliver Specht 
AuthorDate: Thu Nov 2 16:34:50 2023 +0100
Commit: Thorsten Behrens 
CommitDate: Sat Nov 11 20:54:24 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

This includes:
  Fix Windows 64-bit build using VS 2022

  Change-Id: Id976fe515287a4aa12d7ff8ca0ca09c31c65309f
  Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159316

and
  Make the unit test linear and more explicit

  Change-Id: Ic28d059ed41f88c9264743034a5ce5397fff0b2c
  Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159317

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

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 4ae5e90043f4..7dd9aa43877f 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1716,6 +1716,60 @@ CPPUNIT_TEST_FIXTURE(Test, testParaStyleBottomMargin)
  getProperty(xPara, 
"ParaLineSpacing").Height);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, test158044Tdf)
+{
+createSwDoc("tdf158044.rtf");
+
+{
+auto xPara(getParagraph(1));
+auto tabStops = getProperty>(xPara, 
"ParaTabStops");
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), tabStops.getLength());
+}
+
+{
+auto xPara(getParagraph(2));
+auto fillColor = getProperty(xPara, "FillColor");
+auto fillStyle = getProperty(xPara, "FillStyle");
+
+CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, fillStyle);
+CPPUNIT_ASSERT_EQUAL(Color(0xff), fillColor);
+}
+
+{
+auto xPara(getParagraph(3));
+auto adjust = getProperty(xPara, "ParaAdjust");
+
+CPPUNIT_ASSERT_EQUAL(sal_Int16(0), adjust);
+}
+
+{
+auto xPara(getParagraph(4));
+auto tabStops = getProperty>(xPara, 
"ParaTabStops");
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabStops.getLength());
+}
+
+{
+auto xPara(getParagraph(5));
+auto fillColor = getProperty(xPara, "FillColor");
+auto fillStyle = getProperty(xPara, "FillStyle");
+auto tabStops = getProperty>(xPara, 
"ParaTabStops");
+
+CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops.getLength());
+CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, fillStyle);
+CPPUNIT_ASSERT_EQUAL(Color(0xff), fillColor);
+}
+
+{
+auto xPara(getParagraph(6));
+auto fillStyle = getProperty(xPara, "FillStyle");
+auto tabStops = getProperty>(xPara, 
"ParaTabStops");
+
+CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops.getLength());
+CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, fillStyle);
+}
+}
 // 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 148bb98eaf42..adf956653071 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3843,6 +3844,35 @@ 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - 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 f24ad883b15a8112d7dfeb4de14afaf67da30a47
Author: Michael Stahl 
AuthorDate: Thu Nov 9 19:54:19 2023 +0100
Commit: Xisco Fauli 
CommitDate: Sat Nov 11 00:05:30 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 
(cherry picked from commit 4e2f2489c4c7436f8b3a21a530bc625cbef4e365)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159231
Reviewed-by: Xisco Fauli 

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 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - 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 06702d8474bdac71fa2a61723ea476e888fc91d6
Author: Justin Luth 
AuthorDate: Thu Oct 5 07:24:56 2023 -0400
Commit: Xisco Fauli 
CommitDate: Thu Oct 5 21:17:04 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 
(cherry picked from commit bd18618aae500d01e665d8af07067bb99a491850)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157615

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 62dc42dba5af..04c5789c19c6 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")
@@ -377,16 +372,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 e6a7e1dfde9e..148bb98eaf42 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3742,7 +3742,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.
@@ -3752,9 +3752,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 2bf742d3bf1c..1a8f44d8562c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ 

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

2023-10-05 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 e86d30e8bbabeb5e4a5a74d3fe439218a35cce8d
Author: Justin Luth 
AuthorDate: Tue Oct 3 13:44:15 2023 -0400
Commit: Miklos Vajna 
CommitDate: Thu Oct 5 08:42:04 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
(cherry picked from commit cfa744f49e9e18dfab6a0f5930304898dc98)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157544
Reviewed-by: Miklos Vajna 

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 1758f7662c49..2bf742d3bf1c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1874,13 +1874,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: Branch 'libreoffice-7-6' - sw/qa writerfilter/source

2023-08-01 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 d3cf473ceb2a0711ca723ed680034b9251dccbbd
Author: Satya 
AuthorDate: Wed Jun 14 18:15:35 2023 +0530
Commit: Justin Luth 
CommitDate: Tue Aug 1 13:18:12 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 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155120
Tested-by: Jenkins

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 c8dca64723a1..62dc42dba5af 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -856,6 +856,20 @@ DECLARE_OOXMLEXPORT_TEST(testTdf155903, "tdf155903.odt")
 // because the exported file was corrupted.
 }
 
+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 308768cc78eb..1758f7662c49 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2996,7 +2996,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")
@@ -3409,6 +3409,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())
@@ -7125,7 +7133,7 @@ void DomainMapper_Impl::CloseFieldCommand()
 break;
 }
 }
-if (m_bStartTOC && (aIt->second.eFieldId == FIELD_PAGEREF) )
+if (IsInTOC() && (aIt->second.eFieldId == FIELD_PAGEREF))
 {
 bCreateField = false;
 }
@@ -7541,7 +7549,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;
 
@@ -8223,9 +8231,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)
  

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

2023-07-26 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 5b9471ad3698aa7892985299b169a70b4e058443
Author: Mike Kaganski 
AuthorDate: Mon Jul 10 21:16:32 2023 +0300
Commit: Caolán McNamara 
CommitDate: Wed Jul 26 14:47:38 2023 +0200

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

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

testTdf154319 is updated to test this.

Change-Id: I561995a8e96882e1f17ee9982e3fc640e621cda2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154281
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit b915dd9e1559870045481403806dd073f4fb5818)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154259
Reviewed-by: Caolán McNamara 

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 77a68dd5a535..308768cc78eb 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -6314,7 +6314,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
 
@@ -6353,12 +6353,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) });
 }
 }
 
@@ -6733,7 +6733,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
@@ -6758,13 +6758,38 @@ void DomainMapper_Impl::handleToc
 xTOC->getPropertyValue("ParaStyleLevel" + 
OUString::number(nLevel)) >>= style;
 uno::Reference xStyle;
 if (xStyles->getByName(style) >>= xStyle)
-xStyle->getPropertyValue("ParaTabStops") >>= tabStops;
+{
+if (uno::Reference xPropState{ 
xStyle,
+  
uno::UNO_QUERY })
+{
+if (xPropState->getPropertyState("ParaTabStops")
+== beans::PropertyState_DIRECT_VALUE)
+{
+if (uno::Sequence tabStops;
+  

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

2023-07-24 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 3ec09683bcbf85e42940108fa2ec0c49ad7d3d8b
Author: László Németh 
AuthorDate: Fri Jul 21 17:35:12 2023 +0200
Commit: Michael Stahl 
CommitDate: Mon Jul 24 12:01:38 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 
(cherry picked from commit b081a818b1c3024d7ec5cc5b3a251109a1d9b08d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154708
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

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 4a32891f2503..77a68dd5a535 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -8420,10 +8420,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: Branch 'libreoffice-7-6' - sw/qa writerfilter/source

2023-07-18 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 8081bbcb2dd42508f8c306fe3b302392358fe892
Author: Vasily Melenchuk 
AuthorDate: Thu Jul 6 12:45:11 2023 +0300
Commit: Thorsten Behrens 
CommitDate: Tue Jul 18 22:14:40 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 
(cherry picked from commit d434104497fa1bea5744d5ce4e9447f75834ba55)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154530

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 f849a5246bf4..4a32891f2503 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -7414,7 +7414,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 

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

2023-07-10 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 6b93852a88140706561171dc75c0ebf6ddecf256
Author: Miklos Vajna 
AuthorDate: Thu Jul 6 08:13:40 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jul 10 10:18:17 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
(cherry picked from commit 9ac864159b241d2093e86f664ab6f4b76c69196d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154121
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index a8beca7e6b0e..67fba9e9b114 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1383,8 +1383,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 cd77182657c8..ab8e00e13731 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1619,6 +1619,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: Branch 'libreoffice-7-6' - 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 c93083d583e7b29a27bf8ff6e2664fe0613a6542
Author: László Németh 
AuthorDate: Thu Jul 6 17:31:20 2023 +0200
Commit: László Németh 
CommitDate: Sun Jul 9 21:42:53 2023 +0200

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

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

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

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153804.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153804.docx
new file mode 100644
index ..65a1fdfa8e17
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153804.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 5edb4dcdcd11..a8beca7e6b0e 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 4e410c0b0be9..f849a5246bf4 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4087,7 +4087,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 4668ebc8ac4c..55f3b671c836 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: Branch 'libreoffice-7-6' - sw/qa writerfilter/source

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

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

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

... at start of section.

(regression from commit 2e8aad6d45c53d554ccaf26de998ede708cfc289)

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

diff --git a/sw/qa/extras/ooxmlexport/data/tdf155690.docx 
b/sw/qa/extras/ooxmlexport/data/tdf155690.docx
new file mode 100644
index ..1839862688ee
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf155690.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 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);
 }