summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-09-05 14:24:02 +0200
committerCaolán McNamara <caolanm@redhat.com>2013-09-09 08:38:47 +0000
commit8911e50765073d45778fa8c37d336c58490668e4 (patch)
tree661e8711b6e552fa547de5a90be05431106fafc3
parentf886f07a409b24a28edc4d39430f2b9e8682364b (diff)
bnc#779642 VML import: groupshape-related fixes
1) fix TextHorizontalAdjust when layout-flow is vertical The shape had no special properties about hori/vert text adjustment, so it should be hori left / vert top. Then it has vertical layout-flow, so vert should be top and hori should be right (vert was center). 2) import result of sdt fields We can't have e.g. placeholder fields on drawinglayer rectangles, but at least the result of the field is now imported. 3) handle drawinglayer rectangle inset 4) handle drawinglayer rectangle char spacing (cherry picked from commits b10afb26296e33c77e94a6eda3f2c36c4d34c2aa, 3847de4b724f4f435bb68bceef9a5e187c3f363c, 870a2394a87c77740daf41e1aa81b130113f8e00 and 4cbc41bc4eaa822829e68c1ee11eafe834bb7da7) Change-Id: I79fa72c9235682030d23a03fdb0c7c40370c4a8a Reviewed-on: https://gerrit.libreoffice.org/5847 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/oox/vml/vmltextbox.hxx1
-rw-r--r--oox/source/vml/vmlshape.cxx9
-rw-r--r--oox/source/vml/vmltextbox.cxx21
-rw-r--r--oox/source/vml/vmltextboxcontext.cxx15
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx9
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/groupshape-sdt.docxbin0 -> 10742 bytes
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docxbin0 -> 10578 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx27
8 files changed, 82 insertions, 0 deletions
diff --git a/include/oox/vml/vmltextbox.hxx b/include/oox/vml/vmltextbox.hxx
index fc97dc78413b..d31bb3b1f269 100644
--- a/include/oox/vml/vmltextbox.hxx
+++ b/include/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/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index d74a52675070..253fce6ba738 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -552,7 +552,16 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
PropertySet(xShape).setAnyProperty(PROP_TextVerticalAdjust, makeAny(eTextVerticalAdjust));
if (getTextBox())
+ {
getTextBox()->convert(xShape);
+ if (getTextBox()->borderDistanceSet)
+ {
+ PropertySet(xShape).setAnyProperty(PROP_TextLeftDistance, makeAny(sal_Int32(getTextBox()->borderDistanceLeft)));
+ PropertySet(xShape).setAnyProperty(PROP_TextUpperDistance, makeAny(sal_Int32(getTextBox()->borderDistanceTop)));
+ PropertySet(xShape).setAnyProperty(PROP_TextRightDistance, makeAny(sal_Int32(getTextBox()->borderDistanceRight)));
+ PropertySet(xShape).setAnyProperty(PROP_TextLowerDistance, makeAny(sal_Int32(getTextBox()->borderDistanceBottom)));
+ }
+ }
}
// Import Legacy Fragments (if any)
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index 6fe51b147f0d..4f03f7595ac0 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -20,8 +20,10 @@
#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>
#include <com/sun/star/text/XTextAppend.hpp>
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
@@ -91,6 +93,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;
@@ -126,6 +137,16 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const
if ( maLayoutFlow == "vertical" )
{
uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY);
+
+ // VML has the text horizontally aligned to left (all the time),
+ // v-text-anchor for vertical alignment, and vertical mode to swap the
+ // two. drawinglayer supports both horizontal and vertical alignment,
+ // but no vertical mode: we use T->B, R->L instead.
+ // As a result, we need to set horizontal adjustment here to 'right',
+ // that will result in vertical 'top' after writing mode is applied,
+ // which matches the VML behavior.
+ xProperties->setPropertyValue("TextHorizontalAdjust", uno::makeAny(drawing::TextHorizontalAdjust_RIGHT));
+
xProperties->setPropertyValue( "TextWritingMode", uno::makeAny( text::WritingMode_TB_RL ) );
}
}
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index d91c66ade821..3cd88a38ddec 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -132,6 +132,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;
}
}
@@ -217,14 +227,19 @@ ContextHandlerRef TextBoxContext::onCreateContext( sal_Int32 nElement, const Att
if (nElement == OOX_TOKEN(doc, p)) return this;
break;
case OOX_TOKEN(doc, p):
+ case OOX_TOKEN(doc, sdtContent):
if (nElement == OOX_TOKEN(doc, r))
return new TextPortionContext( *this, mrTextBox, maParagraph, TextFontModel(), nElement, rAttribs );
else
return this;
break;
case OOX_TOKEN(doc, pPr):
+ case OOX_TOKEN(doc, sdt):
return this;
break;
+ default:
+ SAL_INFO("oox", "unhandled 0x" << std::hex << getCurrentElement());
+ break;
}
return 0;
}
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 5963a1bed656..a9b2368830b0 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -257,6 +257,15 @@ protected:
return xCell;
}
+ /// Get shape (counted from 1)
+ uno::Reference<drawing::XShape> getShape(int number)
+ {
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(number - 1), uno::UNO_QUERY);
+ return xShape;
+ }
+
void header()
{
fprintf(stderr, "File tested,Execution Time (ms)\n");
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/data/vml-text-vertical-adjust.docx b/sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx
new file mode 100755
index 000000000000..1b05dbd6edab
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index af5a3f222c7e..913cc1626423 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -132,6 +132,8 @@ public:
void testTableStyleParprop();
void testTablePagebreak();
void testFdo68607();
+ void testVmlTextVerticalAdjust();
+ void testGroupshapeSdt();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -229,6 +231,8 @@ void Test::run()
{"table-style-parprop.docx", &Test::testTableStyleParprop},
{"table-pagebreak.docx", &Test::testTablePagebreak},
{"fdo68607.docx", &Test::testFdo68607},
+ {"vml-text-vertical-adjust.docx", &Test::testVmlTextVerticalAdjust},
+ {"groupshape-sdt.docx", &Test::testGroupshapeSdt},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1615,6 +1619,29 @@ void Test::testFdo68607()
CPPUNIT_ASSERT(getPages() > 1);
}
+void Test::testVmlTextVerticalAdjust()
+{
+ uno::Reference<drawing::XShapes> xOuterGroupShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShapes> xInnerGroupShape(xOuterGroupShape->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY);
+ // Was CENTER.
+ 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();