[Libreoffice-commits] core.git: 5 commits - include/oox oox/source sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Wed May 29 06:57:27 PDT 2013
include/oox/vml/vmlformatting.hxx | 12 ++++
include/oox/vml/vmlshape.hxx | 1
oox/source/vml/vmlformatting.cxx | 55 ++++++++++++++++++++++
oox/source/vml/vmlshape.cxx | 18 ++++++-
oox/source/vml/vmlshapecontext.cxx | 3 +
sw/qa/extras/ooxmlimport/data/watermark.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 26 ++++++++++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 5 +-
8 files changed, 117 insertions(+), 3 deletions(-)
New commits:
commit 8931c8f3c58afe35b5b7c98e136825aff04291e3
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed May 29 15:22:14 2013 +0200
bnc#817956 v:textpath VML import testcase
Change-Id: I4c4c3a84e8d9d048262e6570a8bed0106e8d184f
diff --git a/sw/qa/extras/ooxmlimport/data/watermark.docx b/sw/qa/extras/ooxmlimport/data/watermark.docx
new file mode 100755
index 0000000..8e279e3
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/watermark.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 3a765b7..36fc883 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -114,6 +114,7 @@ public:
void testN779630();
void testIndentation();
void testPageBackground();
+ void testWatermark();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -196,6 +197,7 @@ void Test::run()
{"n779630.docx", &Test::testN779630},
{"indentation.docx", &Test::testIndentation},
{"page-background.docx", &Test::testPageBackground},
+ {"watermark.docx", &Test::testWatermark},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1392,6 +1394,30 @@ void Test::testPageBackground()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
}
+void Test::testWatermark()
+{
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
+ // 1st problem: last character was missing
+ CPPUNIT_ASSERT_EQUAL(OUString("SAMPLE"), xShape->getString());
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xShape, "CustomShapeGeometry");
+ bool bFound = false;
+ for (int i = 0; i < aProps.getLength(); ++i)
+ if (aProps[i].Name == "TextPath")
+ bFound = true;
+ // 2nd problem: v:textpath wasn't imported
+ CPPUNIT_ASSERT_EQUAL(true, bFound);
+
+ // 3rd problem: rotation angle was 315, not 45.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(45 * 100), getProperty<sal_Int32>(xShape, "RotateAngle"));
+
+ // 4th problem: mso-position-vertical-relative:margin was ignored, VertOrientRelation was text::RelOrientation::FRAME.
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
commit f2720b87093968670e3fb47d24d4952f1631a654
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed May 29 14:47:54 2013 +0200
bnc#817956 VML import of mso-position-vertical-relative:margin
Change-Id: I86464c44022ef8c8a8037d4228bb2a6409fc77af
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index b4b3e9e..1ec5c24 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -457,6 +457,10 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
{
rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME);
}
+ else if ( rTypeModel.maPositionVerticalRelative == "margin" )
+ {
+ rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_PRINT_AREA);
+ }
else
{
// Vertical placement relative to margin, because parent style must not modify vertical position
commit b2c16f6c1b8bd3c96e0549eb3036c820094a795f
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed May 29 11:17:44 2013 +0200
bnc#817956 fix VML import of rotation
In VML, positive rotation angles are clockwise, we have them as
counter-clockwise. This wasn't noticed earlier, as the n751117.docx
testcase also had flip:x. (For example, rotation with angle 90 + flip:x
is presented as 270 by the UI.)
Fix this, and also mirror the angle when flip:x is present.
Change-Id: I591ec3369a5bdca53f9684006a459d11e37fbc33
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 8e5e2a9..b4b3e9e 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
+#include <svx/svdtrans.hxx>
#include "oox/drawingml/shapepropertymap.hxx"
#include "oox/helper/graphichelper.hxx"
#include "oox/helper/propertyset.hxx"
@@ -476,12 +477,17 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
{
awt::Rectangle aShapeRect(rShapeRect);
+ boost::optional<sal_Int32> oRotation;
+ if (!maTypeModel.maRotation.isEmpty())
+ oRotation.reset(maTypeModel.maRotation.toInt32());
if (!maTypeModel.maFlip.isEmpty())
{
if (maTypeModel.maFlip.equalsAscii("x"))
{
aShapeRect.X += aShapeRect.Width;
aShapeRect.Width *= -1;
+ if (oRotation)
+ oRotation.reset(360 - *oRotation);
}
else if (maTypeModel.maFlip.equalsAscii("y"))
{
@@ -548,9 +554,11 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
}
PropertySet aPropertySet(xShape);
- if (xShape.is() && !maTypeModel.maRotation.isEmpty())
+ if (xShape.is() && oRotation)
{
- aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny(maTypeModel.maRotation.toInt32() * 100));
+ // See DffPropertyReader::Fix16ToAngle(): in VML, positive rotation angles are clockwise, we have them as counter-clockwise.
+ // Additionally, VML type is 0..360, our is 0.36000.
+ aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny(sal_Int32(NormAngle360((*oRotation) * -100))));
// If rotation is used, simple setPosition() is not enough.
aPropertySet.setAnyProperty(PROP_HoriOrientPosition, makeAny( aShapeRect.X ) );
aPropertySet.setAnyProperty(PROP_VertOrientPosition, makeAny( aShapeRect.Y ) );
commit 290695c785ef831abb6e78cd3675bc071f05f643
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue May 28 17:44:25 2013 +0200
bnc#817956 VML import of v:textpath
Word exposes this as Watermark in its UI.
Change-Id: I23d9b2aab2dab60a98c7f456b0592c2b74bcaf81
diff --git a/include/oox/vml/vmlformatting.hxx b/include/oox/vml/vmlformatting.hxx
index 79fa380..81b83ee 100644
--- a/include/oox/vml/vmlformatting.hxx
+++ b/include/oox/vml/vmlformatting.hxx
@@ -24,6 +24,7 @@
#include "oox/dllapi.h"
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
#include <vector>
@@ -240,6 +241,17 @@ struct OOX_DLLPUBLIC ShadowModel
void pushToPropMap(oox::drawingml::ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const;
};
+/** The shadow model structure contains all shape textpath properties. */
+struct OOX_DLLPUBLIC TextpathModel
+{
+ OptValue<OUString> moString; ///< Specifies the string of the textpath.
+
+ TextpathModel();
+
+ /** Writes the properties to the passed property map. */
+ void pushToPropMap(oox::drawingml::ShapePropertyMap& rPropMap, com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape) const;
+};
+
} // namespace vml
} // namespace oox
diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx
index e16fe90..ca815ec 100644
--- a/include/oox/vml/vmlshape.hxx
+++ b/include/oox/vml/vmlshape.hxx
@@ -88,6 +88,7 @@ struct OOX_DLLPUBLIC ShapeTypeModel
StrokeModel maStrokeModel; ///< Border line formatting.
FillModel maFillModel; ///< Shape fill formatting.
ShadowModel maShadowModel; ///< Shape shadow formatting.
+ TextpathModel maTextpathModel; ///< Shape textpath formatting.
OptValue< OUString > moGraphicPath; ///< Path to a graphic for this shape.
OptValue< OUString > moGraphicTitle; ///< Title of the graphic.
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 7932acd..9be2c68 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -18,7 +18,11 @@
*/
#include "oox/vml/vmlformatting.hxx"
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
#include <rtl/strbuf.hxx>
#include "oox/drawingml/color.hxx"
#include "oox/drawingml/drawingmltypes.hxx"
@@ -828,6 +832,57 @@ void ShadowModel::pushToPropMap(ShapePropertyMap& rPropMap, const GraphicHelper&
rPropMap.setProperty(PROP_ShadowFormat, uno::makeAny(aFormat));
}
+TextpathModel::TextpathModel()
+{
+}
+
+beans::PropertyValue lcl_createTextpathProps()
+{
+ uno::Sequence<beans::PropertyValue> aTextpathPropSeq(4);
+ aTextpathPropSeq[0].Name = "TextPath";
+ aTextpathPropSeq[0].Value <<= sal_True;
+ aTextpathPropSeq[1].Name = "TextPathMode";
+ aTextpathPropSeq[1].Value <<= drawing::EnhancedCustomShapeTextPathMode_SHAPE;
+ aTextpathPropSeq[2].Name = "ScaleX";
+ aTextpathPropSeq[2].Value <<= sal_False;
+ aTextpathPropSeq[3].Name = "SameLetterHeights";
+ aTextpathPropSeq[3].Value <<= sal_False;
+
+ beans::PropertyValue aRet;
+ aRet.Name = "TextPath";
+ aRet.Value <<= aTextpathPropSeq;
+ return aRet;
+}
+
+void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, uno::Reference<drawing::XShape> xShape) const
+{
+ if (moString.has())
+ {
+ uno::Reference<text::XTextRange> xTextRange(xShape, uno::UNO_QUERY);
+ xTextRange->setString(moString.get());
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aGeomPropSeq = xPropertySet->getPropertyValue("CustomShapeGeometry").get< uno::Sequence<beans::PropertyValue> >();
+ bool bFound = false;
+ for (int i = 0; i < aGeomPropSeq.getLength(); ++i)
+ {
+ beans::PropertyValue& rProp = aGeomPropSeq[i];
+ if (rProp.Name == "TextPath")
+ {
+ bFound = true;
+ rProp = lcl_createTextpathProps();
+ }
+ }
+ if (!bFound)
+ {
+ sal_Int32 nSize = aGeomPropSeq.getLength();
+ aGeomPropSeq.realloc(nSize+1);
+ aGeomPropSeq[nSize] = lcl_createTextpathProps();
+ }
+ rPropMap.setAnyProperty(PROP_CustomShapeGeometry, uno::makeAny(aGeomPropSeq));
+ }
+}
+
} // namespace vml
} // namespace oox
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 2aa3bac..8e5e2a9 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -394,6 +394,8 @@ void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) con
aPropMap.erase(PROP_LineColor);
}
}
+ else if (xSInfo->supportsService("com.sun.star.drawing.CustomShape"))
+ maTypeModel.maTextpathModel.pushToPropMap(aPropMap, rxShape);
PropertySet( rxShape ).setProperties( aPropMap );
}
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 658215a..efa6e38 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -372,6 +372,9 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A
mrTypeModel.maShadowModel.moOpacity = lclDecodePercent(rAttribs, XML_opacity, 1.0);
}
break;
+ case VML_TOKEN( textpath ):
+ mrTypeModel.maTextpathModel.moString.assignIfUsed(rAttribs.getString(XML_string));
+ break;
}
return 0;
}
commit 4eaabc45f76aefe82558b283975ab9df3aea7fce
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue May 28 16:11:38 2013 +0200
bnc#817956 DOCX import: missing last character of shape text
Make sure writerfilter only removes the last character of the text if
it's a newline.
Change-Id: I96980e2d148ced93363b3147545afdd0dd070e5d
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index fa6b36d..adf5870 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -305,7 +305,10 @@ void DomainMapper_Impl::RemoveLastParagraph( )
else
{
xCursor->goLeft( 1, true );
- xCursor->setString(OUString());
+ // If this is a text on a shape, possibly the text has the trailing
+ // newline removed already.
+ if (xCursor->getString() == "\n")
+ xCursor->setString(OUString());
}
}
catch( const uno::Exception& )
More information about the Libreoffice-commits
mailing list