24#include <oox/token/namespaces.hxx>
25#include <oox/token/tokens.hxx>
26#include <osl/diagnose.h>
33using ::oox::core::ContextHandler2;
34using ::oox::core::ContextHandler2Helper;
40 ContextHandler2( rParent ),
41 mrTextBox( rTextBox ),
42 maParagraph(
std::move( aParagraph )),
43 maFont(
std::move( aParentFont )),
44 mnInitialPortions( rTextBox.getPortionCount() )
54 OSL_ENSURE( !
maFont.
monUnderline,
"TextPortionContext::TextPortionContext - nested <u> elements" );
59 OSL_ENSURE( !
maFont.
monEscapement,
"TextPortionContext::TextPortionContext - nested <sub> or <sup> elements" );
63 OSL_ENSURE( !
maFont.
mobBold,
"TextPortionContext::TextPortionContext - nested <b> elements" );
67 OSL_ENSURE( !
maFont.
mobItalic,
"TextPortionContext::TextPortionContext - nested <i> elements" );
71 OSL_ENSURE( !
maFont.
mobStrikeout,
"TextPortionContext::TextPortionContext - nested <s> elements" );
74 case OOX_TOKEN(dml, blip):
76 std::optional<OUString> oRelId = rAttribs.
getString(R_TOKEN(embed));
77 if (oRelId.has_value())
81 case VML_TOKEN(imagedata):
83 std::optional<OUString> oRelId = rAttribs.
getString(R_TOKEN(
id));
84 if (oRelId.has_value())
92 OSL_ENSURE(
false,
"TextPortionContext::TextPortionContext - unknown element" );
98 OSL_ENSURE( nElement != XML_font,
"TextPortionContext::onCreateContext - nested <font> elements" );
99 if (getNamespace(getCurrentElement()) == NMSP_doc)
106 if (getNamespace(getCurrentElement()) == NMSP_doc && getCurrentElement() != W_TOKEN(
t))
109 switch( getCurrentElement() )
122 switch (getCurrentElement())
136 case W_TOKEN(spacing):
143 case W_TOKEN(rFonts):
150 SAL_INFO(
"oox",
"unhandled: 0x" << std::hex<< getCurrentElement());
157 if (getNamespace(getCurrentElement()) == NMSP_doc && getCurrentElement() != W_TOKEN(
t))
182 ContextHandler2( rParent ),
183 mrTextBox( rTextBox )
188 std::u16string_view
value;
189 std::u16string_view remainingStr;
193 value.empty() ?
u"0.1in" :
value, 0,
false,
false );
195 inset = remainingStr;
198 value.empty() ?
u"0.05in" :
value, 0,
false,
false );
200 inset = remainingStr;
203 value.empty() ?
u"0.1in" :
value, 0,
false,
false );
205 inset = remainingStr;
208 value.empty() ?
u"0.05in" :
value, 0,
false,
false );
217 std::u16string_view
aName, aValue;
221 else if (
aName ==
u"mso-fit-shape-to-text")
223 else if (
aName ==
u"mso-layout-flow-alt")
225 else if (
aName ==
u"mso-next-textbox")
228 SAL_WARN(
"oox",
"unhandled style property: " << OUString(
aName));
235 switch( getCurrentElement() )
237 case VML_TOKEN( textbox ):
238 if( nElement == XML_div )
return this;
239 else if (nElement == W_TOKEN(txbxContent))
return this;
244 case W_TOKEN(txbxContent):
245 if (nElement == W_TOKEN(
p))
return this;
248 case W_TOKEN(sdtContent):
249 case W_TOKEN(smartTag):
250 if (nElement == W_TOKEN(r))
258 SAL_INFO(
"oox",
"unhandled 0x" << std::hex << getCurrentElement());
266 switch (getCurrentElement())
271 case W_TOKEN(pStyle):
279 if (getCurrentElement() == W_TOKEN(
p))
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...
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.
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
OUString getFragmentPathFromRelId(const OUString &rRelId) const
Returns the full fragment path for the passed relation identifier.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
TextBoxContext(::oox::core::ContextHandler2Helper const &rParent, TextBox &rTextBox, const AttributeList &rAttribs, const GraphicHelper &graphicHelper)
TextParagraphModel maParagraph
virtual void onStartElement(const AttributeList &rAttribs) override
virtual void onEndElement() override
The textbox contains all text contents and properties.
void appendPortion(const TextParagraphModel &rParagraph, const TextFontModel &rFont, const OUString &rText)
Appends a new text portion to the textbox.
bool borderDistanceSet
Text distance from the border (inset attribute of v:textbox), valid only if set.
size_t getPortionCount() const
Returns the current number of text portions.
ShapeTypeModel & mrTypeModel
TextPortionContext(::oox::core::ContextHandler2Helper const &rParent, TextBox &rTextBox, TextParagraphModel aParagraph, TextFontModel aParentFont, sal_Int32 nElement, const AttributeList &rAttribs)
virtual void onStartElement(const AttributeList &rAttribs) override
virtual void onEndElement() override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void onCharacters(const OUString &rChars) override
TextParagraphModel maParagraph
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
::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 decodeMeasureToHmm(const GraphicHelper &rGraphicHelper, std::u16string_view rValue, sal_Int32 nRefValue, bool bPixelX, bool bDefaultAsPixel)
Converts the passed VML measure string to 1/100 mm.
std::optional< OUString > moGraphicPath
Path to a graphic for this shape.
bool mbAutoHeight
If true, the height value is a minimum value (mostly used for textboxes)
OUString maLayoutFlowAlt
Specifies the alternate layout flow for text in textboxes.
Font settings for a text portion in a textbox.
std::optional< sal_Int32 > monEscapement
Subscript or superscript.
std::optional< sal_Int32 > monSize
Font size in twips.
std::optional< sal_Int32 > monUnderline
Single or double underline.
std::optional< OUString > moNameAsian
Asian font name.
std::optional< OUString > moNameComplex
Complex font name.
std::optional< bool > mobBold
std::optional< bool > mobStrikeout
std::optional< OUString > moName
Font name.
std::optional< sal_Int32 > monSpacing
std::optional< bool > mobItalic
std::optional< OUString > moColor
Font color, HTML encoded, sort of.
A text paragraph in a textbox.
std::optional< OUString > moParaStyleName
std::optional< OUString > moParaAdjust
Paragraph adjust (left, center, right, etc.)