22 #include <unicode/ubidi.h>
23 #include <unicode/uchar.h>
36 , mnMinCharPos(nMinCharPos)
37 , mnEndCharPos(nEndCharPos)
38 , m_pTextLayoutCache(pLayoutCache)
40 , mpAltNaturalDXArray(nullptr)
61 UErrorCode rcI18n = U_ZERO_ERROR;
63 UBiDi* pParaBidi = ubidi_openSized(nLength, 0, &rcI18n);
66 ubidi_setPara(pParaBidi, reinterpret_cast<const UChar*>(
mrStr.getStr()), nLength, nLevel,
69 UBiDi* pLineBidi = pParaBidi;
71 if (nSubLength != nLength)
73 pLineBidi = ubidi_openSized(nSubLength, 0, &rcI18n);
74 ubidi_setLine(pParaBidi, mnMinCharPos,
mnEndCharPos, pLineBidi, &rcI18n);
78 const int nRunCount = ubidi_countRuns(pLineBidi, &rcI18n);
80 for (
int i = 0;
i < nRunCount; ++
i)
82 int32_t nMinPos, nRunLength;
83 const UBiDiDirection nDir = ubidi_getVisualRun(pLineBidi,
i, &nMinPos, &nRunLength);
85 const int nPos1 = nPos0 + nRunLength;
87 const bool bRTL = (nDir == UBIDI_RTL);
88 AddRun(nPos0, nPos1, bRTL);
92 if (pLineBidi != pParaBidi)
93 ubidi_close(pLineBidi);
94 ubidi_close(pParaBidi);
129 if ((0x0001 <= cChar) && (cChar <= 0x001F))
132 if ((0x200E <= cChar) && (cChar <= 0x200F))
134 if ((0x2028 <= cChar) && (cChar <= 0x202E))
137 if ((0x206A <= cChar) && (cChar <= 0x206F))
142 if ((cChar == 0xFEFF) || (cChar == 0xFFFE) || (cChar == 0xFFFF))
153 SAL_WARN_IF(nCharPos0 > nCharPos1,
"vcl",
"ImplLayoutArgs::AddRun() nCharPos0>=nCharPos1");
158 for (
int i = nCharPos0;
i < nCharPos1; ++
i)
168 for (
int i = nCharPos1; --
i >= nCharPos0;)
184 if (pGlyphsImpl !=
nullptr)
189 for (
auto const& aGlyphItem : *pGlyphsImpl)
191 for (
int i = aGlyphItem.charPos();
i < aGlyphItem.charPos() + aGlyphItem.charCount();
211 std::vector<int> aPosVector;
212 aPosVector.reserve(
mrStr.getLength());
215 for (
int i = nMin;
i < nEnd; ++
i)
216 aPosVector.push_back(
i);
220 std::sort(aPosVector.begin(), aPosVector.end());
229 auto it = std::lower_bound(aPosVector.begin(), aPosVector.end(), nMin);
230 for (; (it != aPosVector.end()) && (*it < nEnd); ++it)
231 aNewRuns.AddPos(*it, bRTL);
235 auto it = std::upper_bound(aPosVector.begin(), aPosVector.end(), nEnd);
236 while ((it != aPosVector.begin()) && (*--it >= nMin))
237 aNewRuns.AddPos(*it, bRTL);
248 bool bValid =
maRuns.
GetRun(nMinRunPos, nEndRunPos, bRTL);
259 s <<
"ImplLayoutArgs{";
266 bool need_or =
false;
269 if (rArgs.mnFlags & SalLayoutFlags::x) \
290 s <<
",Length=" << nLength;
298 for (
int i = 0;
i < lim;
i++)
300 if (rArgs.
mrStr[
i] ==
'\n')
303 s <<
"\\0x" << std::hex << std::setw(2) << std::setfill(
'0')
304 <<
static_cast<int>(rArgs.
mrStr[
i]) << std::setfill(
' ') << std::setw(1) << std::dec;
305 else if (rArgs.
mrStr[
i] < 0x7F)
306 s << static_cast<char>(rArgs.
mrStr[
i]);
308 s <<
"\\u" << std::hex << std::setw(4) << std::setfill(
'0')
309 <<
static_cast<int>(rArgs.
mrStr[
i]) << std::setfill(
' ') << std::setw(1) << std::dec;
323 for (
int i = 0;
i < lim;
i++)
ImplLayoutArgs(OUString const &rStr, int nMinCharPos, int nEndCharPos, SalLayoutFlags nFlags, LanguageTag const &rLanguageTag, vcl::text::TextLayoutCache const *pLayoutCache)
ImplLayoutRuns maFallbackRuns
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, const Region &rRegion)
sal_Int32 DeviceCoordinate
bool GetNextRun(int *nMinRunPos, int *nEndRunPos, bool *bRTL)
void SetLayoutWidth(DeviceCoordinate nWidth)
bool PrepareFallback(const SalLayoutGlyphsImpl *pGlyphsImpl)
void SetOrientation(Degree10 nOrientation)
const DeviceCoordinate * mpDXArray
void AddPos(int nCharPos, bool bRTL)
bool HasFallbackRun() const
static bool IsControlChar(sal_UCS4 cChar)
bool GetNextPos(int *nCharPos, bool *bRTL)
const double * mpAltNaturalDXArray
bool GetRun(int *nMinRunPos, int *nEndRunPos, bool *bRTL) const
#define SAL_WARN_IF(condition, area, stream)
void AddRun(int nMinRunPos, int nEndRunPos, bool bRTL)
bool GetNextPos(int *nCharPos, bool *bRTL)
void SetAltNaturalDXArray(const double *pDXArray)
LanguageTag maLanguageTag
void AddFallbackRun(int nMinRunPos, int nEndRunPos, bool bRTL)
void SetDXArray(const DeviceCoordinate *pDXArray)
DeviceCoordinate mnLayoutWidth
void AddRun(int nMinCharPos, int nEndCharPos, bool bRTL)