diff options
author | umeshkadam <umesh.kadam@synerzip.com> | 2014-04-02 19:50:36 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-04-09 10:06:36 +0200 |
commit | 48dd43703914b9c756d2ecda1872512b47463902 (patch) | |
tree | 70c37fc3a192a9f9749d860fd7392fc5576f95cc | |
parent | a8b45a44c278a1aa9195cf30b759c12c1e4465e1 (diff) |
fdo#76583 DOCX import: Floating table information is not preserved in RT file.
- Earlier the table width was compared with the text area to decide if the
fly has to be created for the floating table.
- In most of the cases such floating tables were the ones which did not have
any text around them and not importing such tables as fly made sense.
- But there are some scenarios where in the floating tables have width
greater than the text area but are positioned in a way such that they begin
before left margin and end before the right margin moreover they appear to be
really floating (unlike in first scenario) as they have text around them since
there is still room for the text.
- Handled this scenario and added a UT.
Reviewed on:
https://gerrit.libreoffice.org/8840
Change-Id: I7ea25e04ed7c6315e4e4fe4b67badf451c30cd0c
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/fdo76583.docx | bin | 0 -> 14007 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 20 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 5 |
5 files changed, 30 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/fdo76583.docx b/sw/qa/extras/ooxmlimport/data/fdo76583.docx Binary files differnew file mode 100644 index 000000000000..9382e295f00c --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/fdo76583.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index da5472d68560..3c63f51f39c5 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1498,12 +1498,26 @@ DECLARE_OOXMLIMPORT_TEST(testChartProp, "chart-prop.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(8890), getProperty<sal_Int32>(xPropertySet, "Height")); } +void lcl_countTextFrames(com::sun::star::uno::Reference< lang::XComponent >& xComponent, + sal_Int32 nExpected ) +{ + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(xComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL( nExpected, xIndexAccess->getCount()); +} + DECLARE_OOXMLIMPORT_TEST(testBnc779620, "bnc779620.docx") { // The problem was that the floating table was imported as a non-floating one. - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + lcl_countTextFrames( mxComponent, 1 ); +} + +DECLARE_OOXMLIMPORT_TEST(testfdo76583, "fdo76583.docx") +{ + // The problem was that the floating table was imported as a non-floating one. + // floating tables are imported as text frames, therefore the document should + // exactly 1 text frame. + lcl_countTextFrames( mxComponent, 1 ); } DECLARE_OOXMLIMPORT_TEST(testFdo43093, "fdo43093.docx") diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 527a172dc38f..57261fc7adab 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -130,6 +130,14 @@ struct FieldConversion typedef ::std::map< OUString, FieldConversion> FieldConversionMap_t; +uno::Any FloatingTableInfo::getPropertyValue(OUString propertyName){ + + beans::PropertyValue* pFrameProperties = m_aFrameProperties.getArray(); + for( int i = 0 ; i < m_aFrameProperties.getLength(); i++ ) + if( pFrameProperties[i].Name == propertyName ) + return pFrameProperties[i].Value ; + return uno::Any() ; +} DomainMapper_Impl::DomainMapper_Impl( DomainMapper& rDMapper, diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 952e6e0c944b..acd2898d1ea9 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -286,6 +286,7 @@ struct FloatingTableInfo m_nTableWidth(nTableWidth) { } + uno::Any getPropertyValue(OUString propertyName); }; class DomainMapper; diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 19d8714168ae..141a338ee5b8 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -917,7 +917,10 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) // If the table is wider than the text area, then don't create a fly // for the table: no wrapping will be performed anyway, but multi-page // tables will be broken. - if (rInfo.m_nTableWidth < nTextAreaWidth) + // If the position is relative to the edge of the page, then we always + // create the fly. + if ( ( rInfo.getPropertyValue("HoriOrientRelation") == text::RelOrientation::PAGE_FRAME ) || + ( rInfo.m_nTableWidth < nTextAreaWidth ) ) xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd, rInfo.m_aFrameProperties); } rPendingFloatingTables.clear(); |