[Libreoffice-commits] core.git: 3 commits - sw/qa sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Sun Oct 26 07:17:55 PDT 2014
sw/qa/extras/rtfimport/data/fdo82076.rtf | 13 +++++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 11 +++++++++++
sw/source/filter/ww8/docxexport.cxx | 2 +-
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 19 ++++++++++++++++++-
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 ++-
writerfilter/source/rtftok/rtfsdrimport.cxx | 12 +++++++-----
6 files changed, 52 insertions(+), 8 deletions(-)
New commits:
commit 8c6d3cd45e2183a19f91e9a30c1fdc699de393f8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sun Oct 26 14:42:19 2014 +0100
Avoid boost::optional<bool>
Change-Id: Idaacaf80098e59df47183741402c8664ba5ea631
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index f15a675..f2081b4 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -42,6 +42,8 @@
#include <oox/drawingml/shapepropertymap.hxx>
#include <oox/helper/propertyset.hxx>
+#include <boost/logic/tribool.hpp>
+
using namespace com::sun::star;
namespace writerfilter
@@ -147,7 +149,7 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> const& xShape,
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
sal_Int16 nHoriOrient = 0;
sal_Int16 nVertOrient = 0;
- boost::optional<bool> obFitShapeToText;
+ boost::logic::tribool obFitShapeToText(boost::logic::indeterminate);
bool bFilled = true;
if (aKey == "posh")
@@ -191,7 +193,7 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> const& xShape,
}
}
else if (aKey == "fFitShapeToText")
- obFitShapeToText.reset(aValue.toInt32() == 1);
+ obFitShapeToText = aValue.toInt32() == 1;
else if (aKey == "fFilled")
bFilled = aValue.toInt32() == 1;
else if (aKey == "rotation")
@@ -208,10 +210,10 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> const& xShape,
xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(nHoriOrient));
if (nVertOrient != 0 && xPropertySet.is())
xPropertySet->setPropertyValue("VertOrient", uno::makeAny(nVertOrient));
- if (obFitShapeToText && xPropertySet.is())
+ if (!boost::logic::indeterminate(obFitShapeToText) && xPropertySet.is())
{
- xPropertySet->setPropertyValue("SizeType", uno::makeAny(*obFitShapeToText ? text::SizeType::MIN : text::SizeType::FIX));
- xPropertySet->setPropertyValue("FrameIsAutomaticHeight", uno::makeAny(*obFitShapeToText));
+ xPropertySet->setPropertyValue("SizeType", uno::makeAny(obFitShapeToText ? text::SizeType::MIN : text::SizeType::FIX));
+ xPropertySet->setPropertyValue("FrameIsAutomaticHeight", uno::makeAny(static_cast<bool>(obFitShapeToText)));
}
if (!bFilled && xPropertySet.is())
{
commit cc926007e2471b9d7396a9724cae026e27e52ed2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sun Oct 26 14:32:37 2014 +0100
Let's have both switchHeaderFooter() calls in DocxExport::WriteHeaderFooter()
Change-Id: I051a2a74e0da44b8f13a21e052c35581159402f1
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index d15e4d2..67540eb 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -266,7 +266,6 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
// Turn OFF flag for 'Writing Headers \ Footers'
m_pAttrOutput->SetWritingHeaderFooter( false );
- m_pAttrOutput->switchHeaderFooter(false, -1);
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "DocxExport::WriteHeadersFooters() - nBreakCode introduced, but ignored\n" );
#endif
@@ -720,6 +719,7 @@ void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char*
m_pAttrOutput->switchHeaderFooter(true, m_nHeadersFootersInSection++);
// do the work
WriteHeaderFooterText( rFmt, bHeader );
+ m_pAttrOutput->switchHeaderFooter(false, -1);
m_pAttrOutput->EndParaSdtBlock();
//When the stream changes the cache which is maintained for the graphics in case of alternate content is not cleared.
commit 956c3ff3d43e1b181f7c91518edee1c7c4dc2a0a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sun Oct 26 12:53:05 2014 +0100
fdo#82076 RTF import: handle footnote in table cell
Change-Id: I69def7936c320e93db5d4504922d52346caaf9cf
diff --git a/sw/qa/extras/rtfimport/data/fdo82076.rtf b/sw/qa/extras/rtfimport/data/fdo82076.rtf
new file mode 100644
index 0000000..20b33e9
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo82076.rtf
@@ -0,0 +1,13 @@
+{\rtf1
+\pard\plain
+Before
+\par
+\trowd \cellx4000\cellx8000
+A1\cell
+B1
+{\chftn
+{\footnote Footnote}
+}
+\cell\row
+\pard After\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 6ecd7a3..90ae2ef 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1996,6 +1996,17 @@ DECLARE_RTFIMPORT_TEST(testFdo82859, "fdo82859.rtf")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getProperty<sal_Int32>(getShape(1), "BackColor"));
}
+DECLARE_RTFIMPORT_TEST(testFdo82076, "fdo82076.rtf")
+{
+ // Footnote position was wrong: should be at the end of the B1 cell.
+ 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);
+ uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
+ // This resulted in container::NoSuchElementException: the footnote was at the start of the A1 cell.
+ CPPUNIT_ASSERT_EQUAL(OUString("Footnote"), getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 2), "TextPortionType"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 8dbf3b0..cfba380 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1488,6 +1488,14 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
m_pSdrImport->resolve(boost::get<1>(aTuple)->getShape(), false, RTFSdrImport::SHAPE);
else if (boost::get<0>(aTuple) == BUFFER_ENDSHAPE)
m_pSdrImport->close();
+ else if (boost::get<0>(aTuple) == BUFFER_RESOLVESUBSTREAM)
+ {
+ RTFSprms& rAttributes = boost::get<1>(aTuple)->getAttributes();
+ sal_Size nPos = rAttributes.find(0)->getInt();
+ Id nId = rAttributes.find(1)->getInt();
+ OUString aCustomMark = rAttributes.find(2)->getString();
+ resolveSubstream(nPos, nId, aCustomMark);
+ }
else
assert(false);
}
@@ -1707,7 +1715,16 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
m_aStates.top().nDestinationState = DESTINATION_FOOTNOTE;
if (bCustomMark)
Mapper().startCharacterGroup();
- resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark);
+ if (!m_aStates.top().pCurrentBuffer)
+ resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark);
+ else
+ {
+ RTFSprms aAttributes;
+ aAttributes.set(Id(0), RTFValue::Pointer_t(new RTFValue(m_nGroupStartPos - 1)));
+ aAttributes.set(Id(1), RTFValue::Pointer_t(new RTFValue(nId)));
+ aAttributes.set(Id(2), RTFValue::Pointer_t(new RTFValue(aCustomMark)));
+ m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_RESOLVESUBSTREAM, RTFValue::Pointer_t(new RTFValue(aAttributes))));
+ }
if (bCustomMark)
{
m_aStates.top().aCharacterAttributes.clear();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 2f34299..85af01f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -56,7 +56,8 @@ enum RTFBufferTypes
BUFFER_ENDRUN,
BUFFER_PAR,
BUFFER_STARTSHAPE,
- BUFFER_ENDSHAPE
+ BUFFER_ENDSHAPE,
+ BUFFER_RESOLVESUBSTREAM
};
/// Form field types
More information about the Libreoffice-commits
mailing list