summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-11-02 22:13:32 +0100
committerMichael Stahl <mstahl@redhat.com>2017-11-02 22:35:31 +0100
commitc79467ba954987f1d239c594c1e1b3af3f5515f6 (patch)
tree5138f2c58869a486619bdac51814c0093a5c655f /writerfilter
parent9a236714e539c772cad7b56caf21dc12b79e77df (diff)
sw: ODF import: default as-char shapes to vertical-pos="top"
The problem is that we don't render ShapesWithWrapping.odt the same as Word does: https://beta.opendocumentformat.org/rendercompare/upload/223/86/191/1 The first shape in the file is anchored "as-char" and has no style:vertical-rel or style:vertical-pos attribute affecting it. If Word would write either style:vertical-rel="baseline" or style:vertical-pos="top" explicitly, the rendering in LO would be the same. So the problem is that, for drawing shapes (note, text frames are images, embedded objects handled differently), LO's default vertical alignment is different, it is hard-coded in SwShapeDescriptor_Impl::GetVOrient() as SwFormatVertOrient(0, text::VertOrientation::NONE, text::RelOrientation::FRAME) This effectively positions as-char shapes *below* the baseline, which, while technically allowed, isn't really a good default. So fix this by making the default alignment dependent on the anchor type, so that as-char shapes sit on top of the baseline. The ODF filter sets the anchor type before inserting the shape in XMLTextShapeImportHelper::addShape(), however as it turns out the various MSO filters insert the shape before setting the anchor, which means the new default in SwXShape has an unwanted effect on them, as inserting the shape causes the default to be created. This requires changes to VML import to always set the VertOrient property, and to RTF import to set the anchor type before inserting. The DrawingML import is unaffected as it already sets VertOrient for every non-as-char shape. The testDmlTextshape "dml-textshape.docx" test still fails, but it turns out that the change in alignment for this test document is a bugfix, as it now has the same vertical alignment as in Word, so adapt the test. Change-Id: Ifcabd96a037515f7803f5474ec995f968b3b4de1
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdispatchdestination.cxx3
1 files changed, 3 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchdestination.cxx b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
index ed5748ab0c85..d6c1d1f5dc15 100644
--- a/writerfilter/source/rtftok/rtfdispatchdestination.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
@@ -11,6 +11,7 @@
#include <com/sun/star/document/DocumentProperties.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <filter/msfilter/escherex.hxx>
#include <rtl/character.hxx>
@@ -590,6 +591,8 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
if (xDrawSupplier.is())
{
uno::Reference<drawing::XShape> xShape(xGroupShape, uno::UNO_QUERY);
+ // set AnchorType before inserting
+ uno::Reference<beans::XPropertySet>(xShape, uno::UNO_QUERY)->setPropertyValue("AnchorType", uno::makeAny(text::TextContentAnchorType_AT_CHARACTER));
xDrawSupplier->getDrawPage()->add(xShape);
}
m_pSdrImport->pushParent(xGroupShape);