22#include <rtl/ustrbuf.hxx>
24#include <com/sun/star/awt/FontWeight.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
27#include <com/sun/star/drawing/XShape.hpp>
28#include <com/sun/star/text/XTextAppend.hpp>
29#include <com/sun/star/text/WritingMode.hpp>
30#include <com/sun/star/style/ParagraphAdjust.hpp>
44 maParagraph(
std::move( aParagraph )),
45 maFont(
std::move( aFont )),
51 : mrTypeModel(rTypeModel)
52 , borderDistanceSet( false )
53 , borderDistanceLeft(0)
54 , borderDistanceTop(0)
55 , borderDistanceRight(0)
56 , borderDistanceBottom(0)
62 maPortions.emplace_back( rParagraph, rFont, rText );
74 aBuffer.append( portion.maText );
75 return aBuffer.makeStringAndClear();
80 uno::Reference<text::XTextAppend> xTextAppend(xShape, uno::UNO_QUERY);
82 bool bAmbiguousStyle =
true;
86 beans::PropertyValue aPropertyValue;
87 std::vector<beans::PropertyValue> aPropVec;
90 if (rFont.
moName.has_value())
92 aPropertyValue.Name =
"CharFontName";
93 aPropertyValue.Value <<= rFont.
moName.value();
94 aPropVec.push_back(aPropertyValue);
96 aPropertyValue.Name =
"CharFontNameAsian";
97 aPropertyValue.Value <<= rFont.
moNameAsian.value_or(
"");
98 aPropVec.push_back(aPropertyValue);
100 aPropertyValue.Name =
"CharFontNameComplex";
102 aPropVec.push_back(aPropertyValue);
106 aPropertyValue.Name =
"CharWeight";
107 aPropertyValue.Value <<= rFont.
mobBold.value() ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL;
108 aPropVec.push_back(aPropertyValue);
112 aPropertyValue.Name =
"CharHeight";
113 aPropertyValue.Value <<= double(rFont.
monSize.value()) / 2.;
114 aPropVec.push_back(aPropertyValue);
118 aPropertyValue.Name =
"CharKerning";
122 aPropertyValue.Value <<= sal_Int16(rFont.
monSpacing.value());
123 aPropVec.push_back(aPropertyValue);
127 style::ParagraphAdjust eAdjust = style::ParagraphAdjust_LEFT;
129 eAdjust = style::ParagraphAdjust_CENTER;
131 eAdjust = style::ParagraphAdjust_RIGHT;
133 aPropertyValue.Name =
"ParaAdjust";
134 aPropertyValue.Value <<= eAdjust;
135 aPropVec.push_back(aPropertyValue);
140 if (sParaStyle.isEmpty() )
144 if ( bAmbiguousStyle )
145 bAmbiguousStyle =
false;
149 else if ( !bAmbiguousStyle )
152 bAmbiguousStyle =
true;
154 bAmbiguousStyle =
true;
158 aPropertyValue.Name =
"CharColor";
159 aPropertyValue.Value <<= rFont.
moColor.value().toUInt32(16);
160 aPropVec.push_back(aPropertyValue);
169 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY_THROW);
170 aGrabBag.
update( xPropertySet->getPropertyValue(
"CharInteropGrabBag") );
171 aGrabBag[
"mso-pStyle"] <<= sParaStyle;
174 catch (
const uno::Exception&)
180 uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor();
181 xCursor->gotoEnd(
false);
182 xCursor->goLeft(1,
true);
183 if (xCursor->getString() ==
"\n")
184 xCursor->setString(
"");
189 uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY);
198 xProperties->setPropertyValue(
"TextHorizontalAdjust",
uno::Any(drawing::TextHorizontalAdjust_RIGHT));
200 xProperties->setPropertyValue(
"TextWritingMode",
uno::Any( text::WritingMode_TB_RL ) );
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
void update(const SequenceAsHashMap &rSource)
void convert(const css::uno::Reference< css::drawing::XShape > &xShape) const
void appendPortion(const TextParagraphModel &rParagraph, const TextFontModel &rFont, const OUString &rText)
Appends a new text portion to the textbox.
const TextFontModel * getFirstFont() const
Returns the font settings of the first text portion.
OUString getText() const
Returns the entire text of all text portions.
TextBox(ShapeTypeModel &rTypeModel)
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
The shape model structure contains all properties shared by all types of shapes.
Font settings for a text portion in a textbox.
std::optional< sal_Int32 > monSize
Font size in twips.
std::optional< OUString > moNameAsian
Asian font name.
std::optional< OUString > moNameComplex
Complex font name.
std::optional< bool > mobBold
std::optional< OUString > moName
Font name.
std::optional< sal_Int32 > monSpacing
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.)
TextPortionModel(TextParagraphModel aParagraph, TextFontModel aFont, OUString aText)
std::unique_ptr< char[]> aBuffer