29#include <oox/token/namespaces.hxx>
30#include <oox/token/tokens.hxx>
36#include <osl/diagnose.h>
44using ::oox::core::ContextHandler2;
45using ::oox::core::ContextHandler2Helper;
52std::optional< bool > lclDecodeBool(
const AttributeList& rAttribs, sal_Int32 nToken )
54 std::optional< OUString > oValue = rAttribs.getString( nToken );
56 return std::optional< bool >();
62std::optional< double > lclDecodePercent(
const AttributeList& rAttribs, sal_Int32 nToken,
double fDefValue )
64 std::optional< OUString > oValue = rAttribs.getString( nToken );
66 return std::optional< double >();
72std::optional< double > lclDecodeOpacity(
const AttributeList& rAttribs, sal_Int32 nToken,
double fDefValue )
74 std::optional< OUString > oValue = rAttribs.getString( nToken );
75 double fRetval(fDefValue);
77 if( oValue.has_value() )
79 const OUString& aString(oValue.value());
80 const sal_Int32
nLength(aString.getLength());
84 if(aString.endsWith(
"f"))
86 fRetval = std::clamp(aString.toDouble() / 65536.0, 0.0, 1.0);
95 return std::optional< double >(fRetval);
100std::optional< Int32Pair > lclDecodeInt32Pair(
const AttributeList& rAttribs, sal_Int32 nToken )
102 std::optional< OUString > oValue = rAttribs.getString( nToken );
103 std::optional< Int32Pair > oRetValue;
104 if( oValue.has_value() )
106 std::u16string_view aValue1, aValue2;
115std::optional< DoublePair > lclDecodePercentPair(
const AttributeList& rAttribs, sal_Int32 nToken )
117 std::optional< OUString > oValue = rAttribs.getString( nToken );
118 std::optional< DoublePair > oRetValue;
119 if( oValue.has_value() )
121 std::u16string_view aValue1, aValue2;
134bool lclDecodeVmlxBool( std::u16string_view rValue,
bool bDefaultForEmpty )
136 if( rValue.empty() )
return bDefaultForEmpty;
139 return (nToken == XML_t) || (
nToken == XML_True);
145 ContextHandler2( rParent ),
146 mrDrawing( rDrawing )
154 case O_TOKEN( idmap ):
161 if( !aToken.empty() )
172 ContextHandler2( rParent ),
173 mrClientData( rClientData )
180 if( isRootElement() )
197 switch( getCurrentElement() )
231 ContextHandler2( rParent )
240 case O_TOKEN( shapelayout ):
243 case VML_TOKEN( shapetype ):
245 case VML_TOKEN(
group ):
247 case VML_TOKEN( shape ):
254 case VML_TOKEN( rect ):
256 case VML_TOKEN( roundrect ):
258 case VML_TOKEN( oval ):
260 case VML_TOKEN( polyline ):
262 case VML_TOKEN(
line ):
264 case VML_TOKEN( curve ):
268 case VML_TOKEN( arc ):
269 case VML_TOKEN( diagram ):
270 case VML_TOKEN( image ):
273 case W_TOKEN(control):
280 std::shared_ptr<ShapeType>
const& pShapeType,
283 , m_pShapeType(pShapeType)
284 , mrTypeModel( pShapeType->getTypeModel() )
287 bool bHasOspid = rAttribs.
hasAttribute( O_TOKEN( spid ) );
290 OSL_ENSURE( !
mrTypeModel.
maShapeId.isEmpty(),
"ShapeTypeContext::ShapeTypeContext - missing shape identifier" );
298 static constexpr OUStringLiteral sShapeTypePrefix =
u"shapetype_";
316 if( lclDecodeBool( rAttribs, O_TOKEN(
hr )).value_or(
false ))
321 OUString hrpct = rAttribs.
getString( O_TOKEN( hrpct ),
"1000" );
349 if( isRootElement() )
switch( nElement )
351 case VML_TOKEN( stroke ):
367 case VML_TOKEN( fill ):
371 bool bHasORelId = rAttribs.
hasAttribute( O_TOKEN(relid) );
386 case VML_TOKEN( imagedata ):
390 bool bHasORelId = rAttribs.
hasAttribute( O_TOKEN( relid ) );
401 std::optional<OUString> oGain = rAttribs.
getString(XML_gain);
402 sal_Int32 nGain = 0x10000;
403 if (oGain.has_value() && oGain.value().endsWith(
"f"))
405 nGain = oGain.value().toInt32();
416 std::optional<OUString> oBlacklevel = rAttribs.
getString(XML_blacklevel);
417 sal_Int16 nBlacklevel = 0;
418 if (oBlacklevel.has_value() && oBlacklevel.value().endsWith(
"f"))
420 nBlacklevel = oBlacklevel.value().toInt32();
422 if (nBlacklevel != 0)
429 case NMSP_vmlWord | XML_wrap:
435 case VML_TOKEN( shadow ):
444 case VML_TOKEN( textpath ):
455 std::optional< OUString > oFragmentPath;
457 if( oRelId.has_value() )
459 return oFragmentPath;
467 std::u16string_view
aName, aValue;
489 else if(
aName ==
u"visibility" )
502 const std::shared_ptr<ShapeBase>& pShape,
const AttributeList& rAttribs)
505 , mrShapeModel(pShape->getShapeModel())
508 mrShapeModel.maType = rAttribs.
getXString( XML_type, OUString() );
523 if( isRootElement() )
switch( nElement )
525 case VML_TOKEN( textbox ):
529 sal_Int32 nShapeType = 0;
533 if (!aType.isEmpty() && aType[0] ==
'#')
535 aType = aType.copy(1);
537 if (
const ShapeType* pShapeType = pShapeContainer->getShapeTypeById(aType))
539 nShapeType = pShapeType->getTypeModel().moShapeType.value();
563 case VMLPPT_TOKEN( textdata ):
567 "com.sun.star.drawing.RectangleShape");
570 case O_TOKEN( signatureline ):
582 rAttribs.
getString(XML_showsigndate,
"t"));
584 rAttribs.
getString(XML_allowcomments,
"f"));
586 case O_TOKEN(
lock ):
631 if (rPoint.X < fMinX)
633 else if (rPoint.X > fMaxX)
635 if (rPoint.Y < fMinY)
637 else if (rPoint.Y > fMaxY)
656 if (!rPoints.isEmpty())
662 if (!rPoints.isEmpty())
668 if (!rPoints.isEmpty())
674 if (!rPoints.isEmpty())
679 if (!rPath.isEmpty())
685 if (!rHyperlink.isEmpty())
690 const std::shared_ptr<GroupShape>& pShape,
693 , mrShapes(pShape->getChildren())
707 const std::shared_ptr<RectangleShape>& pShape)
static sal_Int32 decodeToken(std::u16string_view rValue)
Returns the XML token identifier from the passed string.
Provides access to attribute values of an element.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
std::optional< OUString > getXString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
OUString getFragmentPathFromRelId(const OUString &rRelId) const
Returns the full fragment path for the passed relation identifier.
GraphicHelper & getGraphicHelper() const
Returns a helper for the handling of graphics and graphic objects.
Bezier shape object that supports to, from, control1 and control2 attribute or path attribute specifi...
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void onCharacters(const OUString &rChars) override
ClientDataContext(::oox::core::ContextHandler2Helper const &rParent, ClientData &rClientData, const AttributeList &rAttribs)
virtual void onEndElement() override
ClientData & mrClientData
ControlShapeContext(::oox::core::ContextHandler2Helper const &rParent, ShapeContainer &rShapes, const AttributeList &rAttribs)
Represents the collection of VML shapes for a complete draw page.
::oox::core::XmlFilterBase & getFilter() const
Returns the filter object that imports/exports this VML drawing.
void registerControl(const ControlInfo &rControl)
Registers the passed embedded form control.
void registerBlockId(sal_Int32 nBlockId)
Registers a block of shape identifiers reserved by this drawing.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
GroupShapeContext(::oox::core::ContextHandler2Helper const &rParent, const std::shared_ptr< GroupShape > &pShape, const AttributeList &rAttribs)
ShapeContainer & mrShapes
A group shape that extends the basic shape by a container of child shapes.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
RectangleShapeContext(::oox::core::ContextHandler2Helper const &rParent, const AttributeList &rAttribs, const std::shared_ptr< RectangleShape > &pShape)
A rectangular shape object.
ShapeContainer * getContainer() const
Container that holds a list of shapes and shape templates.
Drawing & getDrawing()
Returns the drawing this shape container is part of.
std::shared_ptr< ShapeType > createShapeType()
Creates and returns a new shape template object.
std::shared_ptr< ShapeT > createShape()
Creates and returns a new shape object of the specified type.
ShapeContextBase(::oox::core::ContextHandler2Helper const &rParent)
::oox::core::ContextHandlerRef createShapeContext(::oox::core::ContextHandler2Helper const &rParent, ShapeContainer &rShapes, sal_Int32 nElement, const AttributeList &rAttribs)
void setVmlPath(const OUString &rPath)
Processes the 'path' attribute.
ShapeContext(::oox::core::ContextHandler2Helper const &rParent, const std::shared_ptr< ShapeBase > &pShape, const AttributeList &rAttribs)
void setTo(const OUString &rPoints)
Processes the 'to' attribute.
void setControl1(const OUString &rPoints)
Processes the 'control1' attribute.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
void setHyperlink(const OUString &rHyperlink)
Processes the 'href' attribute.
ShapeModel & mrShapeModel
void setControl2(const OUString &rPoints)
Processes the 'control2' attribute.
void setPoints(std::u16string_view rPoints)
Processes the 'points' attribute.
void setFrom(const OUString &rPoints)
Processes the 'from' attribute.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
ShapeLayoutContext(::oox::core::ContextHandler2Helper const &rParent, Drawing &rDrawing)
void setStyle(std::u16string_view rStyle)
Processes the 'style' attribute.
ShapeTypeModel & mrTypeModel
ShapeTypeContext(::oox::core::ContextHandler2Helper const &rParent, std::shared_ptr< ShapeType > const &pShapeType, const AttributeList &rAttribs)
std::optional< OUString > decodeFragmentPath(const AttributeList &rAttribs, sal_Int32 nToken) const
Resolve a relation identifier to a fragment path.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
A shape template contains all formatting properties of shapes and can serve as templates for several ...
const Drawing & getDrawing() const
ShapeTypeModel & getTypeModel()
Returns read/write access to the shape template model structure.
A simple shape object based on a specific UNO shape service.
#define ESCHER_ShpInst_TextBox
B2IRange fround(const B2DRange &rRange)
std::shared_ptr< osl::Mutex > const & lock()
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
::rtl::Reference< ContextHandler > ContextHandlerRef
OOX_DLLPUBLIC bool separatePair(std::u16string_view &orValue1, std::u16string_view &orValue2, std::u16string_view rValue, sal_Unicode cSep)
Returns two values contained in rValue separated by cSep.
OOX_DLLPUBLIC sal_Int32 decodeMeasureToTwip(const GraphicHelper &rGraphicHelper, std::u16string_view rValue, sal_Int32 nRefValue, bool bPixelX, bool bDefaultAsPixel)
Converts the passed VML measure string to Twip.
OOX_DLLPUBLIC double decodePercent(std::u16string_view rValue, double fDefValue)
Converts the passed VML percentage measure string to a normalized floating-point value.
OOX_DLLPUBLIC bool decodeBool(std::u16string_view rValue)
Returns the boolean value from the passed string of a VML attribute.
::std::pair< sal_Int32, sal_Int32 > Int32Pair
::std::pair< double, double > DoublePair
void assignIfUsed(std::optional< Type > &rDestValue, const std::optional< Type > &rSourceValue)
Excel specific shape client data (such as cell anchor).
bool mbDde
True = object is linked through DDE.
sal_Int32 mnCol
Column index for spreadsheet cell note.
sal_Int32 mnInc
Small increment of spin buttons and scroll bars.
sal_Int32 mnDropStyle
Drop down box style (read-only or editable).
bool mbVisible
True = cell note is visible.
OUString maFmlaLink
Link to value cell associated to the control.
sal_Int32 mnObjType
Type of the shape.
bool mbVScroll
True = textbox has a vertical scrollbar.
bool mbNo3D2
True = flat style, false = 3D style (listboxes and dropdowns).
OUString maFmlaPict
Target cell range of picture links.
sal_Int32 mnSelType
Listbox selection type.
bool mbNo3D
True = flat style, false = 3D style.
bool mbPrintObject
True = print the object.
sal_Int32 mnTextHAlign
Horizontal text alignment.
bool mbMultiLine
True = textbox allows line breaks.
OUString maFmlaRange
Link to cell range used as data source for the control.
sal_Int32 mnVTEdit
Data type of the textbox.
sal_Int32 mnTextVAlign
Vertical text alignment.
sal_Int32 mnMax
Maximum value of spin buttons and scroll bars.
sal_Int32 mnPage
Large increment of spin buttons and scroll bars.
sal_Int32 mnDropLines
Number of lines in drop down box.
sal_Int32 mnRow
Row index for spreadsheet cell note.
OUString maAnchor
Cell anchor as comma-separated string.
sal_Int32 mnVal
Current value of spin buttons and scroll bars.
bool mbSecretEdit
True = textbox is a password edit field.
sal_Int32 mnMin
Minimum value of spin buttons and scroll bars.
OUString maFmlaGroup
Link to value cell associated to a group of option buttons.
OUString maFmlaMacro
Link to macro associated to the control.
sal_Int32 mnChecked
State for checkboxes and option buttons.
Contains information about a form control embedded in a draw page.
OUString maName
Programmatical name of the form control.
bool mbTextContentShape
Whether this control shape will be imported to Writer or not (has AnchorType property or not).
OUString maShapeId
Shape identifier for shape lookup.
OUString maFragmentPath
Path to the fragment describing the form control properties.
std::optional< DoublePair > moFocusSize
Rectangular gradient focus size of second color.
std::optional< double > moOpacity
Solid fill color opacity.
std::optional< OUString > moColor2
End color of gradient.
std::optional< bool > moRotate
True = rotate gradient/bitmap with shape.
std::optional< DoublePair > moFocusPos
Rectangular gradient focus position of second color.
std::optional< sal_Int32 > moType
Fill type.
std::optional< double > moFocus
Linear gradient focus of second color.
std::optional< bool > moFilled
Shape fill on/off.
std::optional< OUString > moBitmapPath
Path to fill bitmap fragment.
std::optional< double > moOpacity2
End color opacity of gradient.
std::optional< sal_Int32 > moAngle
Gradient rotation angle.
std::optional< OUString > moColor
Solid fill color.
bool mbHasShadow
Is a v:shadow element seen?
std::optional< double > moOpacity
Specifies the opacity of the shadow.
std::optional< OUString > moOffset
Specifies the shadow's offset from the shape's location.
std::optional< bool > moShadowOn
Is the element turned on?
std::optional< OUString > moColor
Specifies the color of the shadow.
OUString maSignatureLineSuggestedSignerTitle
TextBox & createTextBox(ShapeTypeModel &rModel)
Creates and returns a new shape textbox structure.
OUString maLegacyDiagramPath
Legacy Diagram Fragment Path.
OUString maSignatureLineSuggestedSignerName
PointVector maPoints
Points for the polyline shape.
OUString maHyperlink
The hyperlink assigned to the shape.
bool mbSignatureLineCanAddComment
OUString maControl2
Bezier control point 2.
OUString maVmlPath
VML path for this shape.
bool mbIsSignatureLine
Shape is a signature line.
OUString maType
Shape template with default properties.
bool mbSignatureLineShowSignDate
OUString maSignatureLineSuggestedSignerEmail
ClientData & createClientData()
Creates and returns a new shape client data structure.
OUString maControl1
Bezier control point 1.
OUString maTo
End point for line shape.
OUString maSignatureLineSigningInstructions
OUString maSignatureId
ID of the signature.
OUString maFrom
Start point for line shape.
OUString maHeightPercent
The height in percents of the HeightRelative.
OUString maWrapDistanceTop
Distance from the top of the shape to the text that wraps around it.
OUString maPosition
Position type of the shape.
OUString maShapeName
Name of the shape, if present.
OUString maFlip
Flip type of the shape (can be "x" or "y").
ShadowModel maShadowModel
Shape shadow formatting.
OUString maPositionVertical
The Y position orientation.
std::optional< Int32Pair > moCoordPos
Top-left position of coordinate system for children scaling.
OUString maHeightRelative
To what the height is relative.
std::optional< Int32Pair > moCoordSize
Size of coordinate system for children scaling.
FillModel maFillModel
Shape fill formatting.
OUString maTop
Y position of the shape bounding box (number with unit).
std::optional< OUString > moGraphicTitle
Title of the graphic.
OUString maWrapDistanceRight
Distance from the right side of the shape to the text that wraps around it.
bool mbVisible
Visible or Hidden.
OUString maEditAs
Edit As type (e.g. "canvas" etc)
OUString maWrapStyle
Wrapping mode for text.
std::optional< OUString > moGraphicPath
Path to a graphic for this shape.
std::optional< OUString > moCropLeft
Specifies how much to crop the image from the left in as a fraction of picture size.
std::optional< OUString > moCropTop
Specifies how much to crop the image from the top down as a fraction of picture size.
std::optional< OUString > moWrapAnchorY
The base object from which our vertical positioning should be calculated.
std::optional< OUString > moCropRight
Specifies how much to crop the image from the right in as a fraction of picture size.
OUString maRotation
Rotation of the shape, in degrees.
OUString maHeight
Height of the shape bounding box (number with unit).
OUString maAdjustments
Shape adjustment values.
sal_Int16 mnBlacklevel
The image brightness, on a 0..0x10000 scale.
bool mbAutoHeight
If true, the height value is a minimum value (mostly used for textboxes)
std::optional< OUString > moWrapType
How to wrap the text around the object.
OUString maShapeId
Unique identifier of the shape.
OUString maWidthPercent
The width in percents of the WidthRelative.
StrokeModel maStrokeModel
Border line formatting.
std::optional< OUString > moWrapAnchorX
The base object from which our horizontal positioning should be calculated.
OUString maPositionVerticalRelative
The Y position is relative to this.
OUString maWidth
Width of the shape bounding box (number with unit).
OUString maLeft
X position of the shape bounding box (number with unit).
OUString maMarginTop
Y position of the shape bounding box to shape anchor (number with unit).
std::optional< OUString > moWrapSide
On which side to wrap the text around the object.
OUString maPositionHorizontalRelative
The X position is relative to this.
OUString maArcsize
round rectangles arc size
OUString maZIndex
ZIndex of the shape.
std::optional< OUString > moCropBottom
Specifies the how much to crop the image from the bottom up as a fraction of picture size.
OUString maWidthRelative
To what the width is relative.
OUString maVTextAnchor
How the text inside the shape is anchored vertically.
OUString maLegacyId
Plaintext identifier of the shape.
OUString maPositionHorizontal
The X position orientation (default: absolute).
OUString maWrapDistanceBottom
Distance from the bottom of the shape to the text that wraps around it.
std::optional< sal_Int32 > moShapeType
Builtin shape type identifier.
OUString maMarginLeft
X position of the shape bounding box to shape anchor (number with unit).
OUString maWrapDistanceLeft
Distance from the left side of the shape to the text that wraps around it.
TextpathModel maTextpathModel
Shape textpath formatting.
sal_Int32 mnGain
An adjustment for the intensity of all colors, i.e. contrast, on a 0..0x10000 scale.
std::optional< sal_Int32 > moArrowWidth
std::optional< sal_Int32 > moArrowType
std::optional< sal_Int32 > moArrowLength
StrokeArrowModel maStartArrow
Start line arrow style.
StrokeArrowModel maEndArrow
End line arrow style.
std::optional< sal_Int32 > moLineStyle
Line style (single, double, ...).
std::optional< sal_Int32 > moEndCap
Type of line end cap.
std::optional< OUString > moColor
Solid line color.
std::optional< bool > moStroked
Shape border line on/off.
std::optional< OUString > moDashStyle
Line dash (predefined or manually).
std::optional< sal_Int32 > moJoinStyle
Type of line join.
std::optional< double > moOpacity
Solid line color opacity.
std::optional< OUString > moWeight
Line width.
std::optional< OUString > moStyle
Specifies the style of the textpath.
std::optional< bool > moTrim
Specifies whether extra space is removed above and below the text.
std::optional< OUString > moString
Specifies the string of the textpath.