summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-07-05 08:33:06 +0200
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-07-06 14:51:31 +0200
commit47261441fc0fc3f0218cfbb43585b683c3fcc3af (patch)
tree500f60b8e5c18da8967ada5b06ef9a9db081d849 /sw
parent6aff11f36ecd02613c0613c9e89883c81656d9f6 (diff)
sw floattable: fix lost floating table right before a table from DOC
The bugdoc has a floating table, anchored in a paragraph that is hidden via character formatting. The bugdoc also has a normal table. This leads to 1 table in Writer, but 2 tables in Word. We already have code that tries to make sure floating tables have a suitable anchor, see the code in WW8TabDesc::CreateSwTable(), but that checks for the case when the next node after a floating table would be table (and not text), instead of the hidden character property. Fix the problem by not creating the hidden char attribute in the first place in SwWW8ImplReader::SetToggleAttr() in case the pool item would be inserted at the paragraph start and we just inserted a floating table, which makes the 2nd table visible in Writer as well. This is for DOC, interesting when Word converts this document to DOCX, then the hidden attribute is removed, so there this is not really needed. (cherry picked from commit 79ddca4def81198e3eee42eca8aca42fef964c80) Change-Id: I3a7411e6fcc318740bcbd4b0cde9f34134f384a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154090 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/layout/layout.cxx1
-rw-r--r--sw/qa/filter/ww8/data/floattable-hidden-anchor.docbin0 -> 39424 bytes
-rw-r--r--sw/qa/filter/ww8/ww8.cxx16
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx16
4 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 021114bd070e..cdca8e858d29 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3493,6 +3493,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109137)
{ "FilterName", uno::Any(OUString("writer8")) },
}));
xStorable->storeToURL(maTempFile.GetURL(), aDescriptor);
+ mxComponent->dispose();
mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// This was 0, the blue rectangle moved from the 1st to the 2nd page.
diff --git a/sw/qa/filter/ww8/data/floattable-hidden-anchor.doc b/sw/qa/filter/ww8/data/floattable-hidden-anchor.doc
new file mode 100644
index 000000000000..3e8feb876964
--- /dev/null
+++ b/sw/qa/filter/ww8/data/floattable-hidden-anchor.doc
Binary files differ
diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx
index 67d97c72ebe4..7d4c4c2f730a 100644
--- a/sw/qa/filter/ww8/ww8.cxx
+++ b/sw/qa/filter/ww8/ww8.cxx
@@ -317,6 +317,22 @@ CPPUNIT_TEST_FIXTURE(Test, testDOCfDontBreakWrappedTables)
// set.
CPPUNIT_ASSERT(bDontBreakWrappedTables);
}
+
+CPPUNIT_TEST_FIXTURE(Test, testDOCFloatingTableHiddenAnchor)
+{
+ // Given a document with a normal table and a floating table with a hidden anchor:
+ createSwDoc("floattable-hidden-anchor.doc");
+
+ // When laying out that document:
+ xmlDocUniquePtr pLayout = parseLayoutDump();
+
+ // Then make sure that both tables are visible:
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 2
+ // - Actual : 1
+ // i.e. the floating table was lost.
+ assertXPath(pLayout, "//tab", 2);
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 718df35b73a8..e2972105c560 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3351,6 +3351,22 @@ void SwWW8ImplReader::SetToggleAttr(sal_uInt8 nAttrId, bool bOn)
: SvxCaseMap::NotMapped, RES_CHRATR_CASEMAP ) );
break;
case 7:
+ if (m_pPaM->GetPoint()->GetContentIndex() == 0 && m_xFormatOfJustInsertedApo)
+ {
+ // We just inserted a frame and we're at the next paragraph start.
+ SwFrameFormat* pFormat = m_xFormatOfJustInsertedApo->GetFormat();
+ if (pFormat)
+ {
+ SwNode* pAnchorNode = pFormat->GetAnchor().GetAnchorNode();
+ if (pAnchorNode && *pAnchorNode == m_pPaM->GetPoint()->GetNode())
+ {
+ // The anchor paragraph would be hidden, leading to hiding the frame as
+ // well, prevent that.
+ break;
+ }
+ }
+ }
+
NewAttr(SvxCharHiddenItem(bOn, RES_CHRATR_HIDDEN));
break;
case 8: