summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-03-27 08:32:05 +0300
committerJustin Luth <justin_luth@sil.org>2020-03-28 20:17:19 +0100
commitcd868678583fa92833c37a63089131ba905dd3a6 (patch)
tree0f7644f3823e99fb86bd47abb6fe8a64fe000611 /sw
parentbefd6880873cc3f63a0566b76246d2ae54f8a3c5 (diff)
tdf#80635 ww8import:2 take float table RIGHT to inlined table
Since SW has problems with floating tables, any unnecessarily floated tables are converted to inline. However, the positioning of the tables is mostly lost. So the choice is either to refuse to inline a strangely positioned table or else to transfer the positioning onto the inlined table. Transferring is easier said than done. But for right-aligned tables, hopefully it is easy to copy that without causing trouble. I didn't find any real-world examples in existing unit tests or bug reports, so I made up my own complicated one using both right margin and BIDI. Change-Id: I855ae62531b5930cbc9a3272c3a7228dd7b0df53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91272 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ww8export/data/tdf80635_marginRightRTL.docbin0 -> 25088 bytes
-rw-r--r--sw/qa/extras/ww8export/data/tdf80635_pageRightRTL.docbin0 -> 25088 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export2.cxx22
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx8
4 files changed, 29 insertions, 1 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf80635_marginRightRTL.doc b/sw/qa/extras/ww8export/data/tdf80635_marginRightRTL.doc
new file mode 100644
index 000000000000..6e509a1907e5
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf80635_marginRightRTL.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/data/tdf80635_pageRightRTL.doc b/sw/qa/extras/ww8export/data/tdf80635_pageRightRTL.doc
new file mode 100644
index 000000000000..71f9adf4a8b5
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf80635_pageRightRTL.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index b477b03bbeaa..4672b750baa3 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -252,6 +252,28 @@ DECLARE_WW8EXPORT_TEST(testTdf116570_exportFootnote, "tdf116570_exportFootnote.o
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in first footnote", 2, getParagraphs(xFootnoteText) );
}
+DECLARE_WW8EXPORT_TEST(testTdf80635_pageRightRTL, "tdf80635_pageRightRTL.doc")
+{
+ // tdf#80635 - transfer the float orientation to the table.
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Horizontal Orientation", text::HoriOrientation::LEFT_AND_WIDTH, getProperty<sal_Int16>(xTable, "HoriOrient"));
+ //CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table Indent", long(3500), getProperty<long>(xTable, "LeftMargin"), 100);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Did you fix me? Text probably should wrap here", 2, getPages() );
+ // If so, replace test with the table set to a greater preferred width so that the text shouldn't wrap
+}
+
+DECLARE_WW8EXPORT_TEST(testTdf80635_marginRTL, "tdf80635_marginRightRTL.doc")
+{
+ // tdf#80635 - transfer the float orientation to the table.
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ if ( !mbExported )
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Horizontal Orientation", text::HoriOrientation::RIGHT, getProperty<sal_Int16>(xTable, "HoriOrient"));
+}
+
DECLARE_WW8EXPORT_TEST(testTdf107773, "tdf107773.doc")
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 3b1615793482..775dae384f6d 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -2428,7 +2428,13 @@ void WW8TabDesc::CreateSwTable()
if ( m_pIo->m_xSFlyPara && !m_pIo->m_xSFlyPara->pFlyFormat )
{
// Get the table orientation from the fly
- if ( m_pIo->m_xSFlyPara->eHAlign == text::HoriOrientation::CENTER )
+ // Do we also need to check m_pIo->m_xSFlyPara->bToggelPos/IsPosToggle()? [Probably not - layout-only concern]
+ const bool bAdjustMargin = m_pIo->m_xSFlyPara->eHRel == text::RelOrientation::PAGE_FRAME || m_pIo->m_xSFlyPara->nXPos;
+ const bool bIsInsideMargin = m_bIsBiDi ? m_pIo->m_xSFlyPara->eHAlign == text::HoriOrientation::RIGHT
+ : m_pIo->m_xSFlyPara->eHAlign == text::HoriOrientation::LEFT;
+ if ( bIsInsideMargin && bAdjustMargin )
+ m_eOri = text::HoriOrientation::LEFT_AND_WIDTH;
+ else if ( m_pIo->m_xSFlyPara->eHAlign != text::HoriOrientation::NONE )
m_eOri = m_pIo->m_xSFlyPara->eHAlign;
}