[Libreoffice-commits] core.git: sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jun 23 00:04:37 PDT 2015
sw/qa/extras/ooxmlimport/data/tdf87460.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 9 +++++++++
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 ++-
6 files changed, 33 insertions(+), 3 deletions(-)
New commits:
commit 2fe248f2b36d541c0d243a620c217058a50a9d5d
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.
Change-Id: I4eb62617e3131176f7371e9ca69f11bc9e948a0b
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 b16877d..5995027 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2716,6 +2716,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/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index f98e023..41daf91 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -56,7 +56,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)
{
}
@@ -1080,7 +1081,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;
@@ -1132,6 +1134,7 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
m_aTableProperties.reset();
m_aCellProperties.clear();
m_aRowProperties.clear();
+ m_bHadFootOrEndnote = false;
#ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().endElement();
@@ -1212,6 +1215,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 818f20f..d91b140 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
@@ -83,6 +83,9 @@ class DomainMapperTableHandler : public TableDataHandler
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, std::vector<css::beans::PropertyValue>& rFrameProperties);
CellPropertyValuesSeq_t endTableGetCellProperties(TableInfo & rInfo, std::vector<HorizontallyMergedCell>& rMerges);
RowPropertyValuesSeq_t endTableGetRowProperties();
@@ -103,6 +106,7 @@ public:
virtual void endCell(const Handle_t & end) SAL_OVERRIDE;
Handle_t& getTable() { return m_xTableRange; };
+ void setHadFootOrEndnote(bool bHadFootOrEndnote);
};
}}
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8394c95..42b5715 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5205,6 +5205,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 7884472..7d1aaf7 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -38,6 +38,7 @@
#include <DomainMapper.hxx>
#include "DomainMapperTableManager.hxx"
+#include "DomainMapperTableHandler.hxx"
#include "PropertyMap.hxx"
#include "FontTable.hxx"
#include "NumberingManager.hxx"
@@ -366,7 +367,7 @@ private:
// TableManagers are stacked: one for each stream to avoid any confusion
std::stack< std::shared_ptr< DomainMapperTableManager > > m_aTableManagers;
- TableDataHandler::Pointer_t m_pTableHandler;
+ std::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