summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-03-14 12:11:13 +0100
committerAndras Timar <andras.timar@collabora.com>2014-03-17 13:55:54 +0000
commite6006b5c91c8f6852a1b8b1b7ed1c5e7b4975a68 (patch)
tree108ece8d7055c6d66a98a26f46d142335807f037 /writerfilter
parentb85f07986dc005ea0a74baa3d14ee0fd1ec99609 (diff)
RTF import: 3 drawing-object fixes:
This bring back the fdo#fdo42407 bugdoc to the state where it was around 4.0. - fix dobxpage before dptxbx The problem was that dobxpage arrived first, set HoriOrientRelation to FRAME, then dptxbx tried to apply defaults, which overwrote the already set HoriOrientRelation. Fix this by only applying properties which are not set yet. (cherry picked from commit 7c53577f325e5260c538f9ca42cda54ca1a24b7a) - anchor drawing objects at-character by default (cherry picked from commit d05b67a7b9448c67c3a923ecb33dac74b52dd192) - fix ordering of old-style dhght in case of equal values Commit 1eaab77c718ffa254068ae6032862dfb5a03db67 (fdo#60722 import RTF_SHPZ, 2013-03-06) changed how we handle z-order, in case two shapes have the same value. Turns out for drawing-objects the order is the opposite in this situation. So fix this by adding a new mode, that keeps the original testcase happy without breaking older documents. (cherry picked from commit e4fe3610eb17c441217c80536f0acf4123abd683) Change-Id: Ib2d284cefc3c0dce40ac2e516ba260d6cd04ce43 Reviewed-on: https://gerrit.libreoffice.org/8621 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/GraphicHelpers.cxx10
-rw-r--r--writerfilter/source/dmapper/GraphicHelpers.hxx2
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx22
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx8
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.hxx2
5 files changed, 33 insertions, 11 deletions
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index d2e64d23e143..98afc6293f2c 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -268,14 +268,18 @@ void GraphicZOrderHelper::addItem( uno::Reference< beans::XPropertySet > props,
// The relativeHeight value in .docx is an arbitrary number, where only the relative ordering matters.
// But in Writer, the z-order is index in 0..(numitems-1) range, so whenever a new item needs to be
// added in the proper z-order, it is necessary to find the proper index.
-sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight )
+sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight, bool bOldStyle )
{
Items::const_iterator it = items.begin();
while( it != items.end())
{
// std::map is iterated sorted by key
- // if there is an item that has the same z-order, we belong under it
- if( it->first >= relativeHeight )
+
+ // Old-style ordering differs in what should happen when there is already an item with the same z-order:
+ // we belong under it in case of new-style, but we belong below it in case of old-style.
+ bool bCond = bOldStyle ? (it->first > relativeHeight) : (it->first >= relativeHeight);
+
+ if( bCond )
break; // this is the first one higher, we belong right before it
else
++it;
diff --git a/writerfilter/source/dmapper/GraphicHelpers.hxx b/writerfilter/source/dmapper/GraphicHelpers.hxx
index e3e4be66a2d6..e9774046b684 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.hxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.hxx
@@ -74,7 +74,7 @@ class WRITERFILTER_DLLPRIVATE GraphicZOrderHelper
{
public:
void addItem( uno::Reference< beans::XPropertySet > props, sal_Int32 relativeHeight );
- sal_Int32 findZOrder( sal_Int32 relativeHeight );
+ sal_Int32 findZOrder( sal_Int32 relativeHeight, bool bOldStyle = false );
private:
typedef std::map< sal_Int32, uno::Reference< beans::XPropertySet > > Items;
Items items;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 87071f01f1ee..54b692764d7c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -19,6 +19,7 @@
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <rtl/tencinfo.h>
#include <svl/lngmisc.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -2184,6 +2185,17 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
return 0;
}
+// Checks if rName is contained at least once in rProperties as a key.
+bool lcl_findPropertyName(const std::vector<beans::PropertyValue>& rProperties, const OUString& rName)
+{
+ for (std::vector<beans::PropertyValue>::const_iterator it = rProperties.begin(); it != rProperties.end(); ++it)
+ {
+ if (it->Name == rName)
+ return true;
+ }
+ return false;
+}
+
int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
{
setNeedSect();
@@ -2798,7 +2810,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.text.TextFrame"), uno::UNO_QUERY);
std::vector<beans::PropertyValue> aDefaults = m_pSdrImport->getTextFrameDefaults(false);
for (size_t i = 0; i < aDefaults.size(); ++i)
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aDefaults[i]);
+ {
+ if (!lcl_findPropertyName(m_aStates.top().aDrawingObject.aPendingProperties, aDefaults[i].Name))
+ m_aStates.top().aDrawingObject.aPendingProperties.push_back(aDefaults[i]);
+ }
checkFirstRun();
Mapper().startShape(m_aStates.top().aDrawingObject.xShape);
m_aStates.top().aDrawingObject.bHadShapeText = true;
@@ -2825,7 +2840,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
std::vector<beans::PropertyValue>& rPendingProperties = m_aStates.top().aDrawingObject.aPendingProperties;
for (std::vector<beans::PropertyValue>::iterator i = rPendingProperties.begin(); i != rPendingProperties.end(); ++i)
m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue(i->Name, i->Value);
- m_pSdrImport->resolveDhgt(m_aStates.top().aDrawingObject.xPropertySet, m_aStates.top().aDrawingObject.nDhgt);
+ m_pSdrImport->resolveDhgt(m_aStates.top().aDrawingObject.xPropertySet, m_aStates.top().aDrawingObject.nDhgt, /*bOldStyle=*/true);
}
break;
case RTF_DOBXMARGIN:
@@ -4467,6 +4482,9 @@ int RTFDocumentImpl::popState()
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY);
bool bTextFrame = xServiceInfo->supportsService("com.sun.star.text.TextFrame");
+ // The default is certainly not inline, but then what Word supports is just at-character.
+ xPropertySet->setPropertyValue("AnchorType", uno::makeAny(text::TextContentAnchorType_AT_CHARACTER));
+
if (bTextFrame)
{
xPropertySet->setPropertyValue("HoriOrientPosition", uno::makeAny((sal_Int32)rDrawing.nLeft));
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 14e2df2dfa56..fa147d77445c 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -119,12 +119,12 @@ void RTFSdrImport::popParent()
m_aParents.pop();
}
-void RTFSdrImport::resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder)
+void RTFSdrImport::resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder, bool bOldStyle)
{
writerfilter::dmapper::DomainMapper& rMapper =
dynamic_cast<writerfilter::dmapper::DomainMapper&>(m_rImport.Mapper());
writerfilter::dmapper::GraphicZOrderHelper* pHelper = rMapper.graphicZOrderHelper();
- xPropertySet->setPropertyValue("ZOrder", uno::makeAny(pHelper->findZOrder(nZOrder)));
+ xPropertySet->setPropertyValue("ZOrder", uno::makeAny(pHelper->findZOrder(nZOrder, bOldStyle)));
pHelper->addItem(xPropertySet, nZOrder);
}
@@ -455,7 +455,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
{
// dhgt is Word 2007, \shpz is Word 97-2003, the later has priority.
if (!rShape.oZ)
- resolveDhgt(xPropertySet, i->second.toInt32());
+ resolveDhgt(xPropertySet, i->second.toInt32(), /*bOldStyle=*/false);
}
// These are in EMU, convert to mm100.
else if (i->first == "dxTextLeft")
@@ -565,7 +565,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
}
}
if (rShape.oZ)
- resolveDhgt(xPropertySet, *rShape.oZ);
+ resolveDhgt(xPropertySet, *rShape.oZ, /*bOldStyle=*/false);
if (m_bTextFrame)
// Writer textframes implement text::WritingMode2, which is a different data type.
xPropertySet->setPropertyValue("WritingMode", uno::makeAny(sal_Int16(eWritingMode)));
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx
index 333927dd827c..31d08b4bba5b 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -28,7 +28,7 @@ namespace writerfilter {
void append(OUString aKey, OUString aValue);
/// Append property on the current parent.
void appendGroupProperty(OUString aKey, OUString aValue);
- void resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder);
+ void resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder, bool bOldStyle);
void resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nFLine);
/**
* These are the default in Word, but not in Writer.