summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-09-06 15:57:03 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-09-06 19:39:21 +0200
commit975875c97b8617c883d3f02e48def960f2419695 (patch)
treed3e72c3f1680195f664948a2344e6118ed2f279c
parent38e209eee11fe921e3c3c172518b17eae2faea66 (diff)
bnc#779642 VML import: handle drawinglayer rectangle char spacing
Change-Id: I79fa72c9235682030d23a03fdb0c7c40370c4a8a (cherry picked from commit 4cbc41bc4eaa822829e68c1ee11eafe834bb7da7)
-rw-r--r--oox/inc/oox/vml/vmltextbox.hxx1
-rw-r--r--oox/source/vml/vmltextbox.cxx10
-rw-r--r--oox/source/vml/vmltextboxcontext.cxx10
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/groupshape-sdt.docxbin0 -> 10742 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx16
5 files changed, 37 insertions, 0 deletions
diff --git a/oox/inc/oox/vml/vmltextbox.hxx b/oox/inc/oox/vml/vmltextbox.hxx
index 4ffec0b86922..eea12d2cf727 100644
--- a/oox/inc/oox/vml/vmltextbox.hxx
+++ b/oox/inc/oox/vml/vmltextbox.hxx
@@ -54,6 +54,7 @@ struct OOX_DLLPUBLIC TextFontModel
OptValue< bool > mobBold;
OptValue< bool > mobItalic;
OptValue< bool > mobStrikeout;
+ OptValue<sal_Int32> monSpacing;
explicit TextFontModel();
};
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index 1fbed35da66a..7878505d0845 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -20,6 +20,7 @@
#include "oox/vml/vmltextbox.hxx"
#include <rtl/ustrbuf.hxx>
+#include <svx/unopage.hxx>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
@@ -90,6 +91,15 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const
aPropertyValue.Value = uno::makeAny(double(rFont.monSize.get()) / 2.);
aPropVec.push_back(aPropertyValue);
}
+ if (rFont.monSpacing.has())
+ {
+ aPropertyValue.Name = "CharKerning";
+ // Value is not converted to mm100: SvxKerningItem::PutValue() gets
+ // called with nMemberId = 0, so no mm100 -> twips conversion will
+ // be done there.
+ aPropertyValue.Value = uno::makeAny(sal_Int16(rFont.monSpacing.get()));
+ aPropVec.push_back(aPropertyValue);
+ }
if (rParagraph.moParaAdjust.has())
{
style::ParagraphAdjust eAdjust = style::ParagraphAdjust_LEFT;
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index e176db441abc..c37d904374cf 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -133,6 +133,16 @@ void TextPortionContext::onStartElement(const AttributeList& rAttribs)
case OOX_TOKEN(doc, color):
maFont.moColor = rAttribs.getString( OOX_TOKEN(doc, val) );
break;
+ case OOX_TOKEN(doc, spacing):
+ maFont.monSpacing = rAttribs.getInteger(OOX_TOKEN(doc, val));
+ break;
+ case OOX_TOKEN(doc, r):
+ case OOX_TOKEN(doc, rPr):
+ case OOX_TOKEN(doc, t):
+ break;
+ default:
+ SAL_INFO("oox", "unhandled: 0x" << std::hex<< getCurrentElement());
+ break;
}
}
diff --git a/sw/qa/extras/ooxmlimport/data/groupshape-sdt.docx b/sw/qa/extras/ooxmlimport/data/groupshape-sdt.docx
new file mode 100755
index 000000000000..072984779d72
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/groupshape-sdt.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 9a0e08f89306..648baba541a2 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -137,6 +137,7 @@ public:
void testTablePagebreak();
void testFdo68607();
void testVmlTextVerticalAdjust();
+ void testGroupshapeSdt();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -222,6 +223,7 @@ void Test::run()
{"table-pagebreak.docx", &Test::testTablePagebreak},
{"fdo68607.docx", &Test::testFdo68607},
{"vml-text-vertical-adjust.docx", &Test::testVmlTextVerticalAdjust},
+ {"groupshape-sdt.docx", &Test::testGroupshapeSdt},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
@@ -1382,6 +1384,20 @@ void Test::testVmlTextVerticalAdjust()
CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust"));
}
+void Test::testGroupshapeSdt()
+{
+ // All problems here are due to the groupshape: we have a drawinglayer rectangle, not a writer textframe.
+ uno::Reference<drawing::XShapes> xOuterGroupShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShapes> xInnerGroupShape(xOuterGroupShape->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xShape(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY);
+ // Border distances were not implemented, this was 0.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1905), getProperty<sal_Int32>(xShape, "TextUpperDistance"));
+ // Sdt field result wasn't imported, this was "".
+ CPPUNIT_ASSERT_EQUAL(OUString("placeholder text"), xShape->getString());
+ // w:spacing was ignored in oox, this was 0.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(20), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xShape->getText()), 1), "CharKerning"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();