[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sw/qa writerfilter/CppunitTest_writerfilter_misc.mk writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Jul 3 12:51:12 PDT 2015
sw/qa/extras/ooxmlimport/data/tdf87460.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 9 +++++++++
writerfilter/CppunitTest_writerfilter_misc.mk | 1 +
writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 12 ++++++++++--
writerfilter/source/dmapper/DomainMapperTableHandler.hxx | 4 ++++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 8 ++++++++
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 ++-
7 files changed, 34 insertions(+), 3 deletions(-)
New commits:
commit b21ed9a42321dd4b22b70bfc66b7d401f2d22cd4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jun 23 09:03:10 2015 +0200
tdf#87460 DOCX import: fix missing endnote in floattable
Writer doesn't support foot or endnotes in TextFrames, so they are not
supported in OOXML floattables, either. In the past, floattables were
imported as normal tables, that's how this worked. Restore the old
situation till the core limitation is there, so we at least don't
regress.
(cherry picked from commit 2fe248f2b36d541c0d243a620c217058a50a9d5d)
Conflicts:
writerfilter/source/dmapper/DomainMapperTableHandler.hxx
writerfilter/source/dmapper/DomainMapper_Impl.hxx
Change-Id: I4eb62617e3131176f7371e9ca69f11bc9e948a0b
Reviewed-on: https://gerrit.libreoffice.org/16690
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/qa/extras/ooxmlimport/data/tdf87460.docx b/sw/qa/extras/ooxmlimport/data/tdf87460.docx
new file mode 100644
index 0000000..c443dbe
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf87460.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 4a7a8bc..99417ce 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2590,6 +2590,15 @@ DECLARE_OOXMLIMPORT_TEST(testTdf8255, "tdf8255.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
}
+DECLARE_OOXMLIMPORT_TEST(testTdf87460, "tdf87460.docx")
+{
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(xTextDocument, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xEndnotes = xEndnotesSupplier->getEndnotes();
+ // This was 0: endnote was lost on import.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xEndnotes->getCount());
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/CppunitTest_writerfilter_misc.mk b/writerfilter/CppunitTest_writerfilter_misc.mk
index 3f4fd80..f563c7a 100644
--- a/writerfilter/CppunitTest_writerfilter_misc.mk
+++ b/writerfilter/CppunitTest_writerfilter_misc.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_set_include,writerfilter_misc,\
$$(INCLUDE) \
-I$(SRCDIR)/writerfilter/inc \
-I$(SRCDIR)/writerfilter/source \
+ -I$(SRCDIR)/writerfilter/source/dmapper \
))
$(eval $(call gb_CppunitTest_use_external,writerfilter_misc,boost_headers))
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index c1487b4..468b38a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -55,7 +55,8 @@ DomainMapperTableHandler::DomainMapperTableHandler(TextReference_t const& xText,
: m_xText(xText),
m_rDMapper_Impl( rDMapper_Impl ),
m_nCellIndex(0),
- m_nRowIndex(0)
+ m_nRowIndex(0),
+ m_bHadFootOrEndnote(false)
{
}
@@ -1078,7 +1079,8 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
}
// If we have a table with a start and an end position, we should make it a floating one.
- if (xTable.is() && xStart.is() && xEnd.is())
+ // Unless the table had a foot or endnote, as Writer doesn't support those in TextFrames.
+ if (xTable.is() && xStart.is() && xEnd.is() && !m_bHadFootOrEndnote)
{
uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
bool bIsRelative = false;
@@ -1123,6 +1125,7 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
m_aTableProperties.reset();
m_aCellProperties.clear();
m_aRowProperties.clear();
+ m_bHadFootOrEndnote = false;
#ifdef DEBUG_WRITERFILTER
dmapper_logger->endElement();
@@ -1203,6 +1206,11 @@ void DomainMapperTableHandler::endCell(const Handle_t & end)
++m_nCellIndex;
}
+void DomainMapperTableHandler::setHadFootOrEndnote(bool bHadFootOrEndnote)
+{
+ m_bHadFootOrEndnote = bHadFootOrEndnote;
+}
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
index f1fe804..18eb49a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
@@ -84,6 +84,9 @@ class DomainMapperTableHandler : public TableDataHandler<Handle_t , TablePropert
sal_Int32 m_nCellIndex;
sal_Int32 m_nRowIndex;
+ /// Did we have a foot or endnote in this table?
+ bool m_bHadFootOrEndnote;
+
TableStyleSheetEntry * endTableGetTableStyle(TableInfo & rInfo, comphelper::SequenceAsVector<css::beans::PropertyValue>& rFrameProperties);
CellPropertyValuesSeq_t endTableGetCellProperties(TableInfo & rInfo, std::vector<HorizontallyMergedCell>& rMerges);
RowPropertyValuesSeq_t endTableGetRowProperties();
@@ -107,6 +110,7 @@ public:
{
return &m_xTableRange;
};
+ void setHadFootOrEndnote(bool bHadFootOrEndnote);
};
}}
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0f404af..2f96375 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5106,6 +5106,14 @@ void DomainMapper_Impl::substream(Id rName,
getTableManager().endLevel();
popTableManager();
+ switch(rName)
+ {
+ case NS_ooxml::LN_footnote:
+ case NS_ooxml::LN_endnote:
+ m_pTableHandler->setHadFootOrEndnote(true);
+ break;
+ }
+
// check that stacks are the same as before substream
assert(m_aContextStack.size() == contextSize);
for (int i = 0; i < NUMBER_OF_CONTEXTS; ++i) {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 8daf26e..d88df66 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -37,6 +37,7 @@
#include <dmapper/DomainMapper.hxx>
#include "DomainMapperTableManager.hxx"
+#include "DomainMapperTableHandler.hxx"
#include "PropertyMap.hxx"
#include "FontTable.hxx"
#include "NumberingManager.hxx"
@@ -360,7 +361,7 @@ private:
// TableManagers are stacked: one for each stream to avoid any confusion
std::stack< boost::shared_ptr< DomainMapperTableManager > > m_aTableManagers;
- TableDataHandler_t::Pointer_t m_pTableHandler;
+ boost::shared_ptr<DomainMapperTableHandler> m_pTableHandler;
//each context needs a stack of currently used attributes
PropertyStack m_aPropertyStacks[NUMBER_OF_CONTEXTS];
More information about the Libreoffice-commits
mailing list