Kaydet (Commit) 290695c7 authored tarafından Miklos Vajna's avatar Miklos Vajna

bnc#817956 VML import of v:textpath

Word exposes this as Watermark in its UI.

Change-Id: I23d9b2aab2dab60a98c7f456b0592c2b74bcaf81
üst 4eaabc45
......@@ -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
......
......@@ -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.
......
......@@ -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
......
......@@ -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 );
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment