24#include <com/sun/star/uno/XComponentContext.hpp>
29#include <osl/diagnose.h>
35#include <vcl/font.hxx>
59 :
comphelper::unique_disposing_ptr<ImpTimedRefDev>(
66class the_scoped_timed_RefDev :
public rtl::Static<scoped_timed_RefDev, the_scoped_timed_RefDev>
70class ImpTimedRefDev :
public Timer
77 explicit ImpTimedRefDev(scoped_timed_RefDev& rOwnerofMe);
78 virtual ~ImpTimedRefDev()
override;
79 virtual void Invoke()
override;
82 void releaseVirtualDevice();
85ImpTimedRefDev::ImpTimedRefDev(scoped_timed_RefDev& rOwnerOfMe)
86 :
Timer(
"drawinglayer ImpTimedRefDev destroy mpVirDev")
91 SetTimeout(3L * 60L * 1000L);
95ImpTimedRefDev::~ImpTimedRefDev()
97 OSL_ENSURE(0 ==
mnUseCount,
"destruction of a still used ImpTimedRefDev (!)");
102void ImpTimedRefDev::Invoke()
126void ImpTimedRefDev::releaseVirtualDevice()
128 OSL_ENSURE(
mnUseCount,
"mismatch call number to releaseVirtualDevice() (!)");
139 scoped_timed_RefDev& rStdRefDevice = the_scoped_timed_RefDev::get();
142 rStdRefDevice.reset(
new ImpTimedRefDev(rStdRefDevice));
144 return rStdRefDevice->acquireVirtualDevice();
147void releaseGlobalVirtualDevice()
149 scoped_timed_RefDev& rStdRefDevice = the_scoped_timed_RefDev::get();
151 OSL_ENSURE(rStdRefDevice,
152 "releaseGlobalVirtualDevice() without prior acquireGlobalVirtualDevice() call(!)");
153 rStdRefDevice->releaseVirtualDevice();
158TextLayouterDevice::TextLayouterDevice()
159 : mrDevice(acquireGlobalVirtualDevice())
168 double fFontScaleX,
double fFontScaleY,
169 const css::lang::Locale& rLocale)
177 double fRet = (rMetric.GetInternalLeading() / 2.0) - rMetric.
GetAscent();
191 double fRet = (rMetric.GetAscent() - rMetric.GetInternalLeading()) / 3.0;
212 sal_uInt32 nLength)
const
218 const OUString& rText, sal_uInt32 nIndex,
219 sal_uInt32 nLength,
const std::vector<double>& rDXArray,
220 const std::vector<sal_Bool>& rKashidaArray)
const
222 const sal_uInt32 nDXArrayCount(rDXArray.size());
223 sal_uInt32 nTextLength(
nLength);
224 const sal_uInt32 nStringLength(rText.getLength());
226 if (nTextLength +
nIndex > nStringLength)
228 nTextLength = nStringLength -
nIndex;
233 OSL_ENSURE(nDXArrayCount == nTextLength,
234 "DXArray size does not correspond to text portion size (!)");
237 aIntegerDXArray.
reserve(nDXArrayCount);
238 for (sal_uInt32
a(0);
a < nDXArrayCount;
a++)
242 aIntegerDXArray, rKashidaArray);
251 sal_uInt32 nLength)
const
253 sal_uInt32 nTextLength(
nLength);
254 const sal_uInt32 nStringLength(rText.getLength());
256 if (nTextLength +
nIndex > nStringLength)
258 nTextLength = nStringLength -
nIndex;
297 sal_uInt32 nLength,
bool bCaret)
const
299 std::vector<double> aRetval;
300 sal_uInt32 nTextLength(
nLength);
301 const sal_uInt32 nStringLength(rText.getLength());
303 if (nTextLength +
nIndex > nStringLength)
305 nTextLength = nStringLength -
nIndex;
312 aRetval.reserve(aArray.
size());
313 for (
size_t i = 0, nEnd = aArray.
size();
i < nEnd; ++
i)
314 aRetval.push_back(aArray[
i]);
323 double fFontScaleX,
double fFontScaleY,
double fFontRotation,
324 const css::lang::Locale& rLocale)
329 const bool bFontIsScaled(nHeight != nWidth);
344 Size(bFontIsScaled ? std::max<sal_uInt32>(nWidth, 1) : 0, nHeight));
349 : RTL_TEXTENCODING_UNICODE);
359 if (bFontIsScaled && nHeight > 0)
366 const double fScaleFactor(
static_cast<double>(nWidth) /
static_cast<double>(nHeight));
376 int aRotate10th(-basegfx::rad2deg<10>(fFontRotation));
413 const double fScaleFactor(
416 o_rSize.
setX(fScaleFactor * o_rSize.
getY());
static OutputDevice * GetDefaultDevice()
tools::Long GetDescent() const
tools::Long GetAscent() const
tools::Long GetInternalLeading() const
void reserve(size_t nCapacity)
void push_back(sal_Int32 nUnit)
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
void SetFont(const vcl::Font &rNewFont)
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void AddTextRectActions(const tools::Rectangle &rRect, const OUString &rOrigStr, DrawTextFlags nStyle, GDIMetaFile &rMtf)
tools::Long GetTextArray(const OUString &rStr, KernArray *pDXAry, sal_Int32 nIndex=0, sal_Int32 nLen=-1, bool bCaret=false, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
FontMetric GetFontMetric() const
tools::Long GetTextHeight() const
bool GetTextOutlines(PolyPolyVector &, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}) const
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
static VclPtr< reference_type > Create(Arg &&... arg)
const OUString & getStyleName() const
const OUString & getFamilyName() const
data read access
sal_uInt16 getWeight() const
bool getMonospaced() const
void addTextRectActions(const tools::Rectangle &rRectangle, const OUString &rText, DrawTextFlags nStyle, GDIMetaFile &rGDIMetaFile) const
void setFontAttribute(const attribute::FontAttribute &rFontAttribute, double fFontScaleX, double fFontScaleY, const css::lang::Locale &rLocale)
basegfx::B2DRange getTextBoundRect(const OUString &rText, sal_uInt32 nIndex, sal_uInt32 nLength) const
double getOverlineHeight() const
double getTextWidth(const OUString &rText, sal_uInt32 nIndex, sal_uInt32 nLength) const
double getUnderlineHeight() const
double getOverlineOffset() const
double getStrikeoutOffset() const
void getTextOutlines(basegfx::B2DPolyPolygonVector &, const OUString &rText, sal_uInt32 nIndex, sal_uInt32 nLength, const ::std::vector< double > &rDXArray, const ::std::vector< sal_Bool > &rKashidaArray) const
double getUnderlineOffset() const
~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE
void setFont(const vcl::Font &rFont)
tooling methods
double getTextHeight() const
double getFontDescent() const
::std::vector< double > getTextArray(const OUString &rText, sal_uInt32 nIndex, sal_uInt32 nLength, bool bCaret=false) const
double getFontAscent() const
void SetOrientation(Degree10 nLineOrientation)
void SetVertical(bool bVertical)
void SetOutline(bool bOutline)
void SetAverageFontWidth(tools::Long nWidth)
void SetPitch(FontPitch ePitch)
const OUString & GetStyleName() const
void SetItalic(FontItalic)
void SetWeight(FontWeight)
const OUString & GetFamilyName() const
void SetCharSet(rtl_TextEncoding)
const Size & GetFontSize() const
void SetAlignment(TextAlign)
rtl_TextEncoding GetCharSet() const
void SetLanguage(LanguageType)
tools::Long GetAverageFontWidth() const
::std::vector< B2DPolyPolygon > B2DPolyPolygonVector
B2IRange fround(const B2DRange &rRange)
Reference< XComponentContext > getProcessComponentContext()
vcl::Font getVclFontFromFontAttribute(const attribute::FontAttribute &rFontAttribute, double fFontScaleX, double fFontScaleY, double fFontRotation, const css::lang::Locale &rLocale)
Create a VCL-Font based on the definitions in FontAttribute and the given FontScaling.
attribute::FontAttribute getFontAttributeFromVclFont(basegfx::B2DVector &o_rSize, const vcl::Font &rFont, bool bRTL, bool bBiDiStrong)
Generate FontAttribute DataSet derived from the given VCL-Font.
VclPtr< VirtualDevice > mpVirDev
scoped_timed_RefDev & mrOwnerOfMe