/* -*- 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 .
*/
// tdf#115319 create alternative reference formats, if the user asked for it // (ReferenceFieldLanguage attribute of the reference field is not empty), and // language of the text and ReferenceFieldLanguage are the same. // Right now only HUNGARIAN seems to need this (as in the related issue, // the reversed caption order in autocaption, solved by #i61007#) staticvoid lcl_formatReferenceLanguage( OUString& rRefText, bool bClosingParenthesis, LanguageType eLang,
std::u16string_view rReferenceLanguage)
{ if (eLang != LANGUAGE_HUNGARIAN || (rReferenceLanguage != u"hu" && rReferenceLanguage != u"Hu")) return;
// Add Hungarian definitive article (a/az) before references, // similar to \aref, \apageref etc. of LaTeX Babel package. // // for example: // // "az 1. oldalon" ("on page 1"), but // "a 2. oldalon" ("on page 2") // "a fentebbi", "az alábbi" (above/below) // "a Lorem", "az Ipsum" // // Support following numberings of EU publications: // // 1., 1a., a), (1), (1a), iii., III., IA. // // (http://publications.europa.eu/code/hu/hu-120700.htm, // http://publications.europa.eu/code/hu/hu-4100600.htm)
CharClass aCharClass(( LanguageTag(eLang) ));
sal_Int32 nLen = rRefText.getLength();
sal_Int32 i; // substring of rRefText starting with letter or number
OUString sNumbering; // is article "az"? bool bArticleAz = false; // is numbering a number? bool bNum = false;
// search first member of the numbering (numbers or letters) for (i=0; i<nLen && (sNumbering.isEmpty() ||
((bNum && aCharClass.isDigit(rRefText, i)) ||
(!bNum && aCharClass.isLetter(rRefText, i)))); ++i)
{ // start of numbering within the field text if (sNumbering.isEmpty() && aCharClass.isLetterNumeric(rRefText, i)) {
sNumbering = rRefText.copy(i);
bNum = aCharClass.isDigit(rRefText, i);
}
}
// length of numbering
nLen = i - (rRefText.getLength() - sNumbering.getLength());
if (bNum)
{ // az 1, 1000, 1000000, 1000000000... // az 5, 50, 500... if ((sNumbering.startsWith("1") && (nLen == 1 || nLen == 4 || nLen == 7 || nLen == 10)) ||
sNumbering.startsWith("5"))
bArticleAz = true;
} elseif (nLen == 1 && sNumbering[0] < 128)
{ // ASCII 1-letter numbering // az a), e), f) ... x) // az i., v. (but, a x.) staticconst std::u16string_view sLettersStartingWithVowels = u"aefilmnorsuxyAEFILMNORSUXY"; if (sLettersStartingWithVowels.find(sNumbering[0]) != std::u16string_view::npos)
{ // x), X) are letters, but x. and X. etc. are Roman numbers if (bClosingParenthesis ||
(sNumbering[0] != 'x' && sNumbering[0] != 'X'))
bArticleAz = true;
} elseif ((sNumbering[0] == 'v' || sNumbering[0] == 'V') && !bClosingParenthesis) // v), V) are letters, but v. and V. are Roman numbers
bArticleAz = true;
} else
{ staticconst sal_Unicode sVowelsWithDiacritic[] = {
0x00E1, 0x00C1, 0x00E9, 0x00C9, 0x00ED, 0x00CD,
0x00F3, 0x00D3, 0x00F6, 0x00D6, 0x0151, 0x0150,
0x00FA, 0x00DA, 0x00FC, 0x00DC, 0x0171, 0x0170, 0 }; staticconst OUString sVowels = OUString::Concat(u"aAeEiIoOuU") + sVowelsWithDiacritic;
// handle more than 1-letter long Roman numbers and // their possible combinations with letters: // az IA, a IIB, a IIIC., az Ia, a IIb., a iiic), az LVIII. szonett bool bRomanNumber = false; if (nLen > 1 && (nLen + 1 >= sNumbering.getLength() || sNumbering[nLen] == '.'))
{
sal_Unicode last = sNumbering[nLen - 1];
OUString sNumberingTrim; if ((last >= 'A' && last < 'I') || (last >= 'a' && last < 'i'))
sNumberingTrim = sNumbering.copy(0, nLen - 1); else
sNumberingTrim = sNumbering.copy(0, nLen);
bRomanNumber =
sNumberingTrim.replaceAll("i", "").replaceAll("v", "").replaceAll("x", "").replaceAll("l", "").replaceAll("c", "").isEmpty() ||
sNumberingTrim.replaceAll("I", "").replaceAll("V", "").replaceAll("X", "").replaceAll("L", "").replaceAll("C", "").isEmpty();
}
if ( // Roman number and a letter optionally
( bRomanNumber && (
(sNumbering[0] == 'i' && sNumbering[1] != 'i' && sNumbering[1] != 'v' && sNumbering[1] != 'x') ||
(sNumbering[0] == 'I' && sNumbering[1] != 'I' && sNumbering[1] != 'V' && sNumbering[1] != 'X') ||
(sNumbering[0] == 'v' && sNumbering[1] != 'i') ||
(sNumbering[0] == 'V' && sNumbering[1] != 'I') ||
(sNumbering[0] == 'l' && sNumbering[1] != 'x') ||
(sNumbering[0] == 'L' && sNumbering[1] != 'X')) ) || // a word starting with vowel (not Roman number)
( !bRomanNumber && sVowels.indexOf(sNumbering[0]) != -1))
{
bArticleAz = true;
}
} // not a title text starting already with a definitive article if ( sNumbering.startsWith("A ") || sNumbering.startsWith("Az ") ||
sNumbering.startsWith("a ") || sNumbering.startsWith("az ") ) return;
// lowercase, if rReferenceLanguage == "hu", not "Hu"
OUString sArticle;
// show the referenced text without the deletions, but if the whole text was // deleted, show the original text for the sake of the comfortable reviewing, // but with Unicode strikethrough in the tooltip
OUString sRet = sw::GetExpandTextMerged(&rLayout, *pReferencedTextNode, true, false, ExpandMode::HideDeletions); if ( sRet.isEmpty() )
{ staticconst sal_Unicode cStrikethrough = u'\x0336';
sRet = sw::GetExpandTextMerged(&rLayout, *pReferencedTextNode, true, false, ExpandMode(0));
sRet = lcl_formatStringByCombiningCharacter( sRet, cStrikethrough );
}
staticvoid FilterText(OUString & rText, LanguageType const eLang,
std::u16string_view rSetReferenceLanguage)
{ // remove all special characters (replace them with blanks) if (rText.isEmpty()) return;
rText = rText.replaceAll(u"\u00ad", "");
OUStringBuffer aBuf(rText); const sal_Int32 l = aBuf.getLength(); for (sal_Int32 i = 0; i < l; ++i)
{ if (aBuf[i] < ' ')
{
aBuf[i] = ' ';
} elseif (aBuf[i] == 0x2011)
{
aBuf[i] = '-';
}
}
rText = aBuf.makeStringAndClear(); if (!rSetReferenceLanguage.empty())
{
lcl_formatReferenceLanguage(rText, false, eLang, rSetReferenceLanguage);
}
}
// where is the category name (e.g. "Illustration")? const OUString aText = pTextNd->GetText(); const sal_Int32 nCatStart = aText.indexOf(m_sSetRefName.toString()); constbool bHasCat = nCatStart>=0; const sal_Int32 nCatEnd = bHasCat ? nCatStart + m_sSetRefName.toString().getLength() : -1;
// length of the referenced text const sal_Int32 nLen = aText.getLength();
// which format? switch( GetFormat() )
{ case REF_CONTENT: case REF_ONLYNUMBER: case REF_ONLYCAPTION: case REF_ONLYSEQNO:
{ // needed part of Text
sal_Int32 nStart;
sal_Int32 nEnd;
case REF_BOOKMARK:
nStart = nNumStart; // text is spread across multiple nodes - get whole text or only until end of node?
nEnd = nNumEnd<0 ? nLen : nNumEnd; break;
case REF_OUTLINE: case REF_SETREFATTR:
nStart = nNumStart;
nEnd = nNumEnd; break;
case REF_FOOTNOTE: case REF_ENDNOTE: // get number or numString for( size_t i = 0; i < rDoc.GetFootnoteIdxs().size(); ++i )
{
SwTextFootnote* const pFootnoteIdx = rDoc.GetFootnoteIdxs()[i]; if( m_nSeqNo == pFootnoteIdx->GetSeqRefNo() )
{
rText = pFootnoteIdx->GetFootnote().GetViewNumStr(rDoc, pLayout); if (!m_sSetReferenceLanguage.isEmpty())
{
lcl_formatReferenceLanguage(rText, false, GetLanguage(), m_sSetReferenceLanguage);
} break;
}
} return;
case REF_STYLE:
nStart = 0;
nEnd = nLen; break;
default:
O3TL_UNREACHABLE;
}
if( nStart != nEnd ) // a section?
{ if (pLayout->IsHideRedlines())
{ if (m_nSubType == REF_OUTLINE
|| (m_nSubType == REF_SEQUENCEFLD && REF_CONTENT == GetFormat()))
{
rText = sw::GetExpandTextMerged(pLayout, *pTextNd, false, false,
ExpandMode(0));
} else
{
rText = pTextNd->GetExpandText(pLayout, nStart, nEnd - nStart, false, false, false, ExpandMode::HideDeletions);
}
} else
{
rText = pTextNd->GetExpandText(pLayout, nStart, nEnd - nStart, false, false, false, ExpandMode::HideDeletions); // show the referenced text without the deletions, but if the whole text was // deleted, show the original text for the sake of the comfortable reviewing // (with strikethrough in tooltip, see GetExpandedTextOfReferencedTextNode()) if (rText.isEmpty())
rText = pTextNd->GetExpandText(pLayout, nStart, nEnd - nStart, false, false, false, ExpandMode(0));
}
FilterText(rText, GetLanguage(), m_sSetReferenceLanguage);
}
} break;
case REF_PAGE: case REF_PAGE_PGDESC:
{
SwTextFrame const* pFrame = static_cast<SwTextFrame*>(pTextNd->getLayoutFrame(pLayout, nullptr, nullptr));
SwTextFrame const*const pSave = pFrame; if (pFrame)
{
TextFrameIndex const nNumStartIndex(pFrame->MapModelToView(pTextNd, nNumStart)); while (pFrame && !pFrame->IsInside(nNumStartIndex))
pFrame = pFrame->GetFollow();
}
// first a "short" test - in case both are in the same node if( pFieldTextAttr->GetpTextNode() == pTextNd )
{
rText = nNumStart < pFieldTextAttr->GetStart()
? aLocaleData.getAboveWord()
: aLocaleData.getBelowWord(); break;
}
if (!m_sSetReferenceLanguage.isEmpty())
lcl_formatReferenceLanguage(rText, false, GetLanguage(), m_sSetReferenceLanguage);
} break; // #i81002# case REF_NUMBER: case REF_NUMBER_NO_CONTEXT: case REF_NUMBER_FULL_CONTEXT:
{ if ( pFieldTextAttr && pFieldTextAttr->GetpTextNode() )
{ auto result =
MakeRefNumStr(pLayout, pFieldTextAttr->GetTextNode(), *pTextNd, m_nSubType, GetFormat(), GetFlags());
rText = result.first; // for differentiation of Roman numbers and letters in Hungarian article handling bool bClosingParenthesis = result.second; if (!m_sSetReferenceLanguage.isEmpty())
{
lcl_formatReferenceLanguage(rText, bClosingParenthesis, GetLanguage(), m_sSetReferenceLanguage);
}
}
}
// Determine, up to which level the superior list labels have to be // included - default is to include all superior list labels. int nRestrictInclToThisLevel( 0 ); // Determine for format REF_NUMBER the level, up to which the superior // list labels have to be restricted, if the text node of the reference // field and the text node of the referenced item are in the same // document context. if ( nRefNumFormat == REF_NUMBER &&
rTextNodeOfField.FindFlyStartNode()
== rTextNodeOfReferencedItem.FindFlyStartNode() &&
rTextNodeOfField.FindFootnoteStartNode()
== rTextNodeOfReferencedItem.FindFootnoteStartNode() &&
rTextNodeOfField.FindHeaderStartNode()
== rTextNodeOfReferencedItem.FindHeaderStartNode() &&
rTextNodeOfField.FindFooterStartNode()
== rTextNodeOfReferencedItem.FindFooterStartNode() )
{ const SwNodeNum* pNodeNumForTextNodeOfField( nullptr ); if ( rTextNodeOfField.HasNumber(pLayout) &&
rTextNodeOfField.GetNumRule() == rTextNodeOfReferencedItem.GetNumRule() )
{
pNodeNumForTextNodeOfField = rTextNodeOfField.GetNum(pLayout);
} else
{
pNodeNumForTextNodeOfField =
rTextNodeOfReferencedItem.GetNum(pLayout)->GetPrecedingNodeNumOf(rTextNodeOfField);
} if ( pNodeNumForTextNodeOfField )
{ const SwNumberTree::tNumberVector rFieldNumVec =
pNodeNumForTextNodeOfField->GetNumberVector(); const SwNumberTree::tNumberVector rRefItemNumVec =
rTextNodeOfReferencedItem.GetNum()->GetNumberVector();
std::size_t nLevel( 0 ); while ( nLevel < rFieldNumVec.size() && nLevel < rRefItemNumVec.size() )
{ if ( rRefItemNumVec[nLevel] == rFieldNumVec[nLevel] )
{
nRestrictInclToThisLevel = nLevel + 1;
} else
{ break;
}
++nLevel;
}
}
}
// Determine, if superior list labels have to be included constbool bInclSuperiorNumLabels(
( nRestrictInclToThisLevel < rTextNodeOfReferencedItem.GetActualListLevel() &&
( nRefNumFormat == REF_NUMBER || nRefNumFormat == REF_NUMBER_FULL_CONTEXT ) ) );
bool SwGetRefField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
{ switch( nWhichId )
{ case FIELD_PROP_USHORT1:
{
sal_Int16 nPart = 0; switch(GetFormat())
{ case REF_PAGE : nPart = ReferenceFieldPart::PAGE ; break; case REF_CHAPTER : nPart = ReferenceFieldPart::CHAPTER ; break; case REF_CONTENT : nPart = ReferenceFieldPart::TEXT ; break; case REF_UPDOWN : nPart = ReferenceFieldPart::UP_DOWN ; break; case REF_PAGE_PGDESC: nPart = ReferenceFieldPart::PAGE_DESC ; break; case REF_ONLYNUMBER : nPart = ReferenceFieldPart::CATEGORY_AND_NUMBER ; break; case REF_ONLYCAPTION: nPart = ReferenceFieldPart::ONLY_CAPTION ; break; case REF_ONLYSEQNO : nPart = ReferenceFieldPart::ONLY_SEQUENCE_NUMBER; break; // #i81002# case REF_NUMBER: nPart = ReferenceFieldPart::NUMBER; break; case REF_NUMBER_NO_CONTEXT: nPart = ReferenceFieldPart::NUMBER_NO_CONTEXT; break; case REF_NUMBER_FULL_CONTEXT: nPart = ReferenceFieldPart::NUMBER_FULL_CONTEXT; break;
}
rAny <<= nPart;
} break; case FIELD_PROP_USHORT2:
{
sal_Int16 nSource = 0; switch(m_nSubType)
{ case REF_SETREFATTR : nSource = ReferenceFieldSource::REFERENCE_MARK; break; case REF_SEQUENCEFLD: nSource = ReferenceFieldSource::SEQUENCE_FIELD; break; case REF_BOOKMARK : nSource = ReferenceFieldSource::BOOKMARK; break; case REF_OUTLINE : OSL_FAIL("not implemented"); break; case REF_FOOTNOTE : nSource = ReferenceFieldSource::FOOTNOTE; break; case REF_ENDNOTE : nSource = ReferenceFieldSource::ENDNOTE; break; case REF_STYLE : nSource = ReferenceFieldSource::STYLE; break;
}
rAny <<= nSource;
} break; case FIELD_PROP_USHORT3:
rAny <<= m_nFlags; break; case FIELD_PROP_PAR1:
{
OUString sTmp(GetPar1()); if(REF_SEQUENCEFLD == m_nSubType)
{
sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( UIName(sTmp), SwGetPoolIdFromName::TxtColl ); switch( nPoolId )
{ case RES_POOLCOLL_LABEL_ABB: case RES_POOLCOLL_LABEL_TABLE: case RES_POOLCOLL_LABEL_FRAME: case RES_POOLCOLL_LABEL_DRAWING: case RES_POOLCOLL_LABEL_FIGURE:
{
ProgName sTmp2(sTmp);
SwStyleNameMapper::FillProgName(nPoolId, sTmp2) ;
sTmp = sTmp2.toString();
} break;
}
} elseif (REF_STYLE == m_nSubType)
{
ProgName name;
SwStyleNameMapper::FillProgName(UIName{sTmp}, name, SwGetPoolIdFromName::TxtColl); if (name == sTmp)
{
SwStyleNameMapper::FillProgName(UIName{sTmp}, name, SwGetPoolIdFromName::ChrFmt);
}
sTmp = name.toString();
}
rAny <<= sTmp;
} break; case FIELD_PROP_PAR3:
rAny <<= ExpandImpl(nullptr); break; case FIELD_PROP_PAR4:
rAny <<= m_sSetReferenceLanguage; break; case FIELD_PROP_SHORT1:
rAny <<= static_cast<sal_Int16>(m_nSeqNo); break; default:
assert(false);
} returntrue;
}
bool SwGetRefField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
{ switch( nWhichId )
{ case FIELD_PROP_USHORT1:
{
sal_Int16 nPart = 0;
rAny >>= nPart; switch(nPart)
{ case ReferenceFieldPart::PAGE: nPart = REF_PAGE; break; case ReferenceFieldPart::CHAPTER: nPart = REF_CHAPTER; break; case ReferenceFieldPart::TEXT: nPart = REF_CONTENT; break; case ReferenceFieldPart::UP_DOWN: nPart = REF_UPDOWN; break; case ReferenceFieldPart::PAGE_DESC: nPart = REF_PAGE_PGDESC; break; case ReferenceFieldPart::CATEGORY_AND_NUMBER: nPart = REF_ONLYNUMBER; break; case ReferenceFieldPart::ONLY_CAPTION: nPart = REF_ONLYCAPTION; break; case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER : nPart = REF_ONLYSEQNO; break; // #i81002# case ReferenceFieldPart::NUMBER: nPart = REF_NUMBER; break; case ReferenceFieldPart::NUMBER_NO_CONTEXT: nPart = REF_NUMBER_NO_CONTEXT; break; case ReferenceFieldPart::NUMBER_FULL_CONTEXT: nPart = REF_NUMBER_FULL_CONTEXT; break; default: returnfalse;
}
SetFormat(nPart);
} break; case FIELD_PROP_USHORT2:
{
sal_Int16 nSource = 0;
rAny >>= nSource; switch(nSource)
{ case ReferenceFieldSource::REFERENCE_MARK : m_nSubType = REF_SETREFATTR ; break; case ReferenceFieldSource::SEQUENCE_FIELD :
{ if(REF_SEQUENCEFLD == m_nSubType) break;
m_nSubType = REF_SEQUENCEFLD;
ConvertProgrammaticToUIName();
} break; case ReferenceFieldSource::BOOKMARK : m_nSubType = REF_BOOKMARK ; break; case ReferenceFieldSource::FOOTNOTE : m_nSubType = REF_FOOTNOTE ; break; case ReferenceFieldSource::ENDNOTE : m_nSubType = REF_ENDNOTE ; break; case ReferenceFieldSource::STYLE : if (REF_STYLE != m_nSubType)
{
m_nSubType = REF_STYLE;
ConvertProgrammaticToUIName();
} break;
}
} break; case FIELD_PROP_PAR1:
{
OUString sTmpStr;
rAny >>= sTmpStr;
SetPar1(sTmpStr);
ConvertProgrammaticToUIName();
} break; case FIELD_PROP_PAR3:
{
OUString sTmpStr;
rAny >>= sTmpStr;
SetExpand( sTmpStr );
} break; case FIELD_PROP_PAR4:
rAny >>= m_sSetReferenceLanguage; break; case FIELD_PROP_USHORT3:
{
sal_uInt16 nSetFlags = 0;
rAny >>= nSetFlags;
m_nFlags = nSetFlags;
} break; case FIELD_PROP_SHORT1:
{
sal_Int16 nSetSeq = 0;
rAny >>= nSetSeq; if(nSetSeq >= 0)
m_nSeqNo = nSetSeq;
} break; default:
assert(false);
} returntrue;
}
void SwGetRefField::ConvertProgrammaticToUIName()
{ if (GetTyp() && REF_STYLE == m_nSubType)
{ // this is super ugly, but there isn't a sensible way to check in xmloff
SwDoc & rDoc{static_cast<SwGetRefFieldType*>(GetTyp())->GetDoc()}; if (rDoc.IsInXMLImport242())
{
SAL_INFO("sw.xml", "Potentially accepting erroneously produced UIName for style-ref field"); return;
}
ProgName const par1{GetPar1()};
UIName name;
SwStyleNameMapper::FillUIName(par1, name, SwGetPoolIdFromName::TxtColl); if (name.toString() == par1.toString())
{
SwStyleNameMapper::FillUIName(par1, name, SwGetPoolIdFromName::ChrFmt);
} if (name.toString() != par1.toString())
{
SetPar1(name.toString());
} return;
}
SwDoc& rDoc = static_cast<SwGetRefFieldType*>(GetTyp())->GetDoc(); const OUString rPar1 = GetPar1(); // don't convert when the name points to an existing field type if (rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, rPar1, false)) return;
sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromProgName( ProgName(rPar1), SwGetPoolIdFromName::TxtColl );
TranslateId pResId; switch( nPoolId )
{ case RES_POOLCOLL_LABEL_ABB:
pResId = STR_POOLCOLL_LABEL_ABB; break; case RES_POOLCOLL_LABEL_TABLE:
pResId = STR_POOLCOLL_LABEL_TABLE; break; case RES_POOLCOLL_LABEL_FRAME:
pResId = STR_POOLCOLL_LABEL_FRAME; break; case RES_POOLCOLL_LABEL_DRAWING:
pResId = STR_POOLCOLL_LABEL_DRAWING; break; case RES_POOLCOLL_LABEL_FIGURE:
pResId = STR_POOLCOLL_LABEL_FIGURE; break;
} if (pResId)
SetPar1(SwResId(pResId));
}
void SwGetRefFieldType::SwClientNotify(const SwModify&, const SfxHint& rHint)
{ if (rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == SfxHintId::SwObjectDying)
{ // forward to text fields, they "expand" the text
CallSwClientNotify(rHint); return;
} if (rHint.GetId() == SfxHintId::SwAttrSetChange)
{ auto pChangeHint = static_cast<const sw::AttrSetChangeHint*>(&rHint); if(!pChangeHint->m_pNew && !pChangeHint->m_pOld) // update to all GetReference fields // hopefully, this codepath is soon dead code, and // UpdateGetReferences gets only called directly
UpdateGetReferences(); else // forward to text fields, they "expand" the text
CallSwClientNotify(rHint); return;
} if (rHint.GetId() == SfxHintId::SwUpdateAttr)
{ auto pChangeHint = static_cast<const sw::UpdateAttrHint*>(&rHint); if(!pChangeHint->m_pNew && !pChangeHint->m_pOld) // update to all GetReference fields // hopefully, this codepath is soon dead code, and // UpdateGetReferences gets only called directly
UpdateGetReferences(); else // forward to text fields, they "expand" the text
CallSwClientNotify(rHint); return;
} if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); if(!pLegacy->m_pNew && !pLegacy->m_pOld) // update to all GetReference fields // hopefully, this codepath is soon dead code, and // UpdateGetReferences gets only called directly
UpdateGetReferences(); else // forward to text fields, they "expand" the text
CallSwClientNotify(rHint);
}
SwTextNode* SwGetRefFieldType::FindAnchorRefStyleMarginal(SwDoc* pDoc,
sal_uInt16 nFlags,
sal_Int32* pStart, sal_Int32* pEnd, const SwTextNode* pSelf, SwFrame* pContentFrame, const SwTextNode* pReference, std::u16string_view styleName)
{ // For marginals, styleref tries to act on the current page first // 1. Get the page we're on, search it from top to bottom
// 2. Search up from the top of the page
pTextNd = SearchForStyleAnchor(pSelf, nodes, SwNodeOffset(0), nPageStart - 1, /*bBackwards*/true, styleName, pStart, pEnd); if (pTextNd) return pTextNd;
// 3. Search down from the bottom of the page
pTextNd = SearchForStyleAnchor(pSelf, nodes, nPageEnd + 1, nodes.Count() - 1, /*bBackwards*/false, styleName, pStart, pEnd); if (pTextNd) return pTextNd;
// Word has case insensitive styles. LO has case sensitive styles. If we didn't find // it yet, maybe we could with a case insensitive search. Let's do that
SwTextNode* SwGetRefFieldType::FindAnchorRefStyleOther(SwDoc* pDoc,
sal_Int32* pStart, sal_Int32* pEnd, const SwTextNode* pSelf, const SwTextNode* pReference, std::u16string_view styleName)
{ // Normally, styleref does searches around the field position // For references, styleref acts from the position of the reference not the field // Happily, the previous code saves either one into pReference, so the following is generic for both
const SwNodes& nodes = pDoc->GetNodes();
if (&nodes != &pReference->GetNodes()) return nullptr;
// It is possible to end up here, with a pReference pointer which points to a node which has already been // removed from the nodes array, which means that calling GetIndex() returns an incorrect index.
SwNodeOffset nReference; if (!pReference->IsDisconnected())
nReference = pReference->GetIndex(); else
nReference = nodes.Count() - 1;
SwTextNode* pTextNd = nullptr;
// 1. Search up until we hit the top of the document
/// Get a sorted list of the field IDs from a document. /// @param[in] rDoc The document to search. /// @param[in,out] rIds The list of IDs found in the document. void RefIdsMap::GetFieldIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds)
{
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.26 Sekunden
(vorverarbeitet)
¤
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.