// Sequentially replace as many spans as possible
SwPaM aPam(*pStart); while (bCheckEmpty && nListEntry < rList.size() && nCurrBaseTexts < nMaxBaseTexts)
{ if (pEnd != pStart)
{
aPam.SetMark();
*aPam.GetMark() = *pEnd;
}
SwRubyListEntry aCheckEntry; auto bSelected = SelectNextRubyChars(aPam, aCheckEntry);
if (bSelected)
{
++nCurrBaseTexts;
// Existing ruby text was located. Apply the new attributes. const SwRubyListEntry* pEntry = rList[nListEntry++].get(); if (aCheckEntry.GetRubyAttr() != pEntry->GetRubyAttr())
{ // set/reset the attribute if (!pEntry->GetRubyAttr().GetText().isEmpty())
{
getIDocumentContentOperations().InsertPoolItem(aPam, pEntry->GetRubyAttr());
} else
{
ResetAttrs(aPam, true, aDelArr);
}
}
if (aCheckEntry.GetText() != pEntry->GetText())
{ if (pEntry->GetText().isEmpty())
{
ResetAttrs(aPam, true, aDelArr);
}
// text is changed, so replace the original
getIDocumentContentOperations().ReplaceRange(aPam, pEntry->GetText(), false);
aPam.Exchange();
}
aPam.DeleteMark();
} else
{ // No existing ruby text located. Advance to next paragraph.
aPam.DeleteMark();
aPam.Move(fnMoveForward, GoInNode);
}
// Stop substituting when the cursor advances to the end of the selection. if (*aPam.GetPoint() >= *pEnd)
{ break;
}
}
// Delete any spans past the end of the ruby list while (nListEntry == rList.size() && nCurrBaseTexts < nMaxBaseTexts && *aPam.GetPoint() < *pEnd)
{ if (pEnd != pStart)
{
aPam.SetMark();
*aPam.GetMark() = *pEnd;
}
SwRubyListEntry aCheckEntry; auto bSelected = SelectNextRubyChars(aPam, aCheckEntry);
aPam.DeleteMark();
} else
{ // No existing ruby text located. Advance to next paragraph.
aPam.DeleteMark();
aPam.Move(fnMoveForward, GoInNode);
}
}
// Insert any spans past the end of the base text list
sal_Int32 nTotalContentGrowth = 0; while (nListEntry < rList.size())
{ const SwRubyListEntry* pEntry = rList[nListEntry++].get();
if (!pEntry->GetText().isEmpty())
{
aPam.SetMark();
getIDocumentContentOperations().InsertString(aPam, pEntry->GetText());
aPam.GetMark()->AdjustContent(-pEntry->GetText().getLength());
if (!pEntry->GetRubyAttr().GetText().isEmpty())
{
getIDocumentContentOperations().InsertPoolItem(aPam, pEntry->GetRubyAttr());
}
bool SwDoc::SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rEntry )
{ // Point must be the startposition, Mark is optional the end position
SwPosition* pPos = rPam.GetPoint(); const SwTextNode* pTNd = pPos->GetNode().GetTextNode();
OUString const& rText = pTNd->GetText();
sal_Int32 nStart = pPos->GetContentIndex();
sal_Int32 nEnd = rText.getLength();
bool bHasMark = rPam.HasMark(); if( bHasMark )
{ // in the same node? if( rPam.GetMark()->GetNode() == pPos->GetNode() )
{ // then use that end const sal_Int32 nTEnd = rPam.GetMark()->GetContentIndex(); if( nTEnd < nEnd )
nEnd = nTEnd;
}
rPam.DeleteMark();
}
sal_Int32 nChType = rCC.getType(rText, nStart); bool bIgnoreChar = false, bIsAlphaNum = false, bChkNxtWrd = false; switch( nChType )
{ case UnicodeType::UPPERCASE_LETTER: case UnicodeType::LOWERCASE_LETTER: case UnicodeType::TITLECASE_LETTER: case UnicodeType::DECIMAL_DIGIT_NUMBER:
bChkNxtWrd = bIsAlphaNum = true; break;
case UnicodeType::SPACE_SEPARATOR: case UnicodeType::CONTROL: /*??*/ case UnicodeType::PRIVATE_USE: case UnicodeType::START_PUNCTUATION: case UnicodeType::END_PUNCTUATION:
bIgnoreChar = true; break;
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.