/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// do not bother to BiDi analyze strong LTR/RTL // TODO: can we assume these strings do not have unicode control chars? // if not remove the control characters from the runs bool bRTL(mnFlags & SalLayoutFlags::BiDiRtl);
AddRun(mnMinCharPos, mnEndCharPos, bRTL);
} else
{ // handle weak BiDi mode
UBiDiLevel nLevel = (mnFlags & SalLayoutFlags::BiDiRtl) ? 1 : 0;
staticbool IsControlChar(sal_UCS4 cChar)
{ // C0 control characters if ((0x0001 <= cChar) && (cChar <= 0x001F)) returntrue; // formatting characters if ((0x200E <= cChar) && (cChar <= 0x200F)) returntrue; if ((0x2028 <= cChar) && (cChar <= 0x202E)) returntrue; // deprecated formatting characters if ((0x206A <= cChar) && (cChar <= 0x206F)) returntrue; if (0x2060 == cChar) returntrue; // byte order markers and invalid unicode if ((cChar == 0xFEFF) || (cChar == 0xFFFE) || (cChar == 0xFFFF)) returntrue; // drop null character too, broken documents may contain it (ofz34898-1.doc) if (cChar == 0) returntrue; returnfalse;
}
// add a run after splitting it up to get rid of control chars void ImplLayoutArgs::AddRun(int nCharPos0, int nCharPos1, bool bRTL)
{
SAL_WARN_IF(nCharPos0 > nCharPos1, "vcl", "ImplLayoutArgs::AddRun() nCharPos0>=nCharPos1");
// remove control characters from runs by splitting them up if (!bRTL)
{ for (int i = nCharPos0; i < nCharPos1; ++i) if (IsControlChar(mrStr[i]))
{ // add run until control char
maRuns.AddRun(nCharPos0, i, bRTL);
nCharPos0 = i + 1;
}
} else
{ for (int i = nCharPos1; --i >= nCharPos0;) if (IsControlChar(mrStr[i]))
{ // add run until control char
maRuns.AddRun(i + 1, nCharPos1, bRTL);
nCharPos1 = i;
}
}
// add remainder of run
maRuns.AddRun(nCharPos0, nCharPos1, bRTL);
}
for (autoconst& aGlyphItem : *pGlyphsImpl)
{ for (int i = aGlyphItem.charPos(); i < aGlyphItem.charPos() + aGlyphItem.charCount();
++i)
maRuns.AddPos(i, aGlyphItem.IsRTLGlyph());
}
return !maRuns.IsEmpty();
}
// short circuit if no fallback is needed if (maFallbackRuns.IsEmpty())
{
maRuns.Clear(); returnfalse;
}
s << "Flags="; if (rArgs.mnFlags == SalLayoutFlags::NONE)
s << 0; else
{ bool need_or = false;
s << "{"; #define TEST(x) \ if (rArgs.mnFlags & SalLayoutFlags::x) \
{ \ if (need_or) \
s << "|"; \
s << #x; \
need_or = true; \
}
TEST(BiDiRtl);
TEST(BiDiStrong);
TEST(RightAlign);
TEST(DisableKerning);
TEST(KerningAsian);
TEST(Vertical);
TEST(DisableLigatures);
TEST(ForFallback); #undef TEST
s << "}";
}
constint nLength = rArgs.mrStr.getLength();
s << ",Length=" << nLength;
s << ",MinCharPos=" << rArgs.mnMinCharPos;
s << ",EndCharPos=" << rArgs.mnEndCharPos;
s << ",Str=\""; int lim = nLength; if (lim > 10)
lim = 7; for (int i = 0; i < lim; i++)
{ if (rArgs.mrStr[i] == '\n')
s << "\\n"; elseif (rArgs.mrStr[i] < ' ' || (rArgs.mrStr[i] >= 0x7F && rArgs.mrStr[i] <= 0xFF))
s << "\\0x" << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(rArgs.mrStr[i]) << std::setfill(' ') << std::setw(1) << std::dec; elseif (rArgs.mrStr[i] < 0x7F)
s << static_cast<char>(rArgs.mrStr[i]); else
s << "\\u" << std::hex << std::setw(4) << std::setfill('0')
<< static_cast<int>(rArgs.mrStr[i]) << std::setfill(' ') << std::setw(1) << std::dec;
} if (nLength > lim)
s << "...";
s << "\"";
s << ",DXArray="; if (!rArgs.mstJustification.empty())
{
s << "["; int count = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
lim = count; if (lim > 10)
lim = 7; for (int i = 0; i < lim; i++)
{
s << rArgs.mstJustification.GetTotalAdvance(rArgs.mnMinCharPos + i); if (i < lim - 1)
s << ",";
} if (count > lim)
{ if (count > lim + 1)
s << "...";
s << rArgs.mstJustification.GetTotalAdvance(rArgs.mnMinCharPos + count - 1);
}
s << "]";
} else
s << "NULL";
s << ",KashidaArray="; if (!rArgs.mstJustification.empty() && rArgs.mstJustification.ContainsKashidaPositions())
{
s << "["; int count = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
lim = count; if (lim > 10)
lim = 7; for (int i = 0; i < lim; i++)
{
s << rArgs.mstJustification.GetPositionHasKashida(rArgs.mnMinCharPos + i)
.value_or(false); if (i < lim - 1)
s << ",";
} if (count > lim)
{ if (count > lim + 1)
s << "...";
s << rArgs.mstJustification.GetPositionHasKashida(rArgs.mnMinCharPos + count - 1)
.value_or(false);
}
s << "]";
} else
s << "NULL";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.