diff options
author | Justin Luth <justin.luth@collabora.com> | 2020-03-27 08:09:29 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-03-30 09:37:35 +0200 |
commit | ba989a99ea19ffd0aafeea01f9b737ea79fa952a (patch) | |
tree | 3860c07cdc4f28e97eb40d38c5b7c46c49e6e797 | |
parent | 79b578b7f8b5e3a80fcd0fd86e83d96d7c900bb1 (diff) |
tdf#80635 ww8import:3 take float table orient 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.
For absolutely positioned flies, which are LEFT_AND_WIDTH,
pass the X position to the left margin.
Change-Id: I996a06c753e8b9b1151f7deea8ad4caf5724dd0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91273
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf80635_marginLeft.doc | bin | 0 -> 47104 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf80635_pageLeft.doc | bin | 0 -> 36352 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export2.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par2.cxx | 17 |
4 files changed, 35 insertions, 4 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf80635_marginLeft.doc b/sw/qa/extras/ww8export/data/tdf80635_marginLeft.doc Binary files differnew file mode 100644 index 000000000000..ad70ff641076 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf80635_marginLeft.doc diff --git a/sw/qa/extras/ww8export/data/tdf80635_pageLeft.doc b/sw/qa/extras/ww8export/data/tdf80635_pageLeft.doc Binary files differnew file mode 100644 index 000000000000..16f32e3e3bca --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf80635_pageLeft.doc diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index 4672b750baa3..42cc8237b873 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -259,7 +259,7 @@ DECLARE_WW8EXPORT_TEST(testTdf80635_pageRightRTL, "tdf80635_pageRightRTL.doc") 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_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 } @@ -274,6 +274,26 @@ DECLARE_WW8EXPORT_TEST(testTdf80635_marginRTL, "tdf80635_marginRightRTL.doc") CPPUNIT_ASSERT_EQUAL_MESSAGE("Horizontal Orientation", text::HoriOrientation::RIGHT, getProperty<sal_Int16>(xTable, "HoriOrient")); } +DECLARE_WW8EXPORT_TEST(testTdf80635_marginLeft, "tdf80635_marginLeft.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); + // This was just the GetMinLeft of -199 + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table Indent", long(-2950), getProperty<long>(xTable, "LeftMargin"), 100); +} + +DECLARE_WW8EXPORT_TEST(testTdf80635_pageLeft, "tdf80635_pageLeft.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); + // This was just the GetMinLeft of -199 + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table Indent", long(-2750), getProperty<long>(xTable, "LeftMargin"), 100); +} + 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 775dae384f6d..3f3ff253a44e 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -2425,6 +2425,7 @@ void WW8TabDesc::CreateSwTable() // Because SW cannot handle multi-page floating frames, // _any unnecessary_ floating tables have been converted to inline. + long nLeft = 0; if ( m_pIo->m_xSFlyPara && !m_pIo->m_xSFlyPara->pFlyFormat ) { // Get the table orientation from the fly @@ -2436,6 +2437,17 @@ void WW8TabDesc::CreateSwTable() m_eOri = text::HoriOrientation::LEFT_AND_WIDTH; else if ( m_pIo->m_xSFlyPara->eHAlign != text::HoriOrientation::NONE ) m_eOri = m_pIo->m_xSFlyPara->eHAlign; + if ( m_eOri == text::HoriOrientation::LEFT_AND_WIDTH ) + { + nLeft = m_pIo->m_xSFlyPara->nXPos; + if ( m_pIo->m_xSFlyPara->eHRel == text::RelOrientation::PAGE_FRAME ) + { + if ( !m_bIsBiDi ) + nLeft -= m_pIo->m_aSectionManager.GetPageLeft(); + else + nLeft += m_pIo->m_aSectionManager.GetPageRight(); + } + } } // The table is small: The number of columns is the lowest count of @@ -2527,13 +2539,12 @@ void WW8TabDesc::CreateSwTable() //ability to set the margin. SvxLRSpaceItem aL( RES_LR_SPACE ); - long nLeft = 0; if (!m_bIsBiDi) - nLeft = GetMinLeft(); + nLeft += GetMinLeft(); else { const short nTableWidth = m_nPreferredWidth ? m_nPreferredWidth : m_nSwWidth; - nLeft = m_pIo->m_aSectionManager.GetTextAreaWidth(); + nLeft += m_pIo->m_aSectionManager.GetTextAreaWidth(); nLeft = nLeft - nTableWidth - GetMinLeft(); } aL.SetLeft(nLeft); |