diff options
Diffstat (limited to 'sw/source/core/text/txtfld.cxx')
-rw-r--r-- | sw/source/core/text/txtfld.cxx | 405 |
1 files changed, 177 insertions, 228 deletions
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index e150f7f489f1..55e439096f3d 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -58,241 +58,143 @@ #include <editeng/colritem.hxx> #include <editeng/udlnitem.hxx> #include <editeng/crossedoutitem.hxx> +#include <officecfg/Office/Writer.hxx> static bool lcl_IsInBody( SwFrame const *pFrame ) { if ( pFrame->IsInDocBody() ) return true; - else - { - const SwFrame *pTmp = pFrame; - const SwFlyFrame *pFly; - while ( nullptr != (pFly = pTmp->FindFlyFrame()) ) - pTmp = pFly->GetAnchorFrame(); - return pTmp->IsInDocBody(); - } + + while (const SwFlyFrame* pFly = pFrame->FindFlyFrame()) + pFrame = pFly->GetAnchorFrame(); + return pFrame->IsInDocBody(); +} + +static OUString ExpandField(const SwField& rField, const SwTextFormatter& rFormatter, + const SwTextFormatInfo& rInf) +{ + if (rInf.GetOpt().IsFieldName()) + return rField.GetFieldName(); + + const SwViewShell* pSh = rInf.GetVsh(); + const SwDoc* pDoc(pSh ? pSh->GetDoc() : nullptr); + const bool bInClipboard(!pDoc || pDoc->IsClipBoard()); + return rField.ExpandField(bInClipboard, rFormatter.GetTextFrame()->getRootFrame()); } SwExpandPortion *SwTextFormatter::NewFieldPortion( SwTextFormatInfo &rInf, const SwTextAttr *pHint ) const { - SwExpandPortion *pRet = nullptr; - SwFrame *pFrame = m_pFrame; SwField *pField = const_cast<SwField*>(pHint->GetFormatField().GetField()); const bool bName = rInf.GetOpt().IsFieldName(); - SwCharFormat* pChFormat = nullptr; - bool bNewFlyPor = false; - sal_uInt16 subType = 0; - // set language const_cast<SwTextFormatter*>(this)->SeekAndChg( rInf ); if (pField->GetLanguage() != GetFnt()->GetLanguage()) - { pField->SetLanguage( GetFnt()->GetLanguage() ); - // let the visual note know about its new language - if (pField->GetTyp()->Which()==SwFieldIds::Postit) - const_cast<SwFormatField*> (&pHint->GetFormatField())->Broadcast( SwFormatFieldHint( &pHint->GetFormatField(), SwFormatFieldHintWhich::LANGUAGE ) ); - } SwViewShell *pSh = rInf.GetVsh(); - SwDoc *const pDoc( pSh ? pSh->GetDoc() : nullptr ); - bool const bInClipboard( pDoc == nullptr || pDoc->IsClipBoard() ); - bool bPlaceHolder = false; - switch( pField->GetTyp()->Which() ) + switch (pField->GetTyp()->Which()) { case SwFieldIds::Script: case SwFieldIds::Postit: - pRet = new SwPostItsPortion( SwFieldIds::Script == pField->GetTyp()->Which() ); - break; - + return new SwPostItsPortion(SwFieldIds::Script == pField->GetTyp()->Which()); case SwFieldIds::CombinedChars: - { - if( bName ) - pRet = new SwFieldPortion( pField->GetFieldName() ); - else - pRet = new SwCombinedPortion( pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - } + if (!bName) + return new SwCombinedPortion(ExpandField(*pField, *this, rInf)); break; - case SwFieldIds::HiddenText: - { - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwHiddenPortion(aStr); - } - break; - + return new SwHiddenPortion(ExpandField(*pField, *this, rInf)); case SwFieldIds::Chapter: - if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() ) - { - static_cast<SwChapterField*>(pField)->ChangeExpansion(*pFrame, - &static_txtattr_cast<SwTextField const*>(pHint)->GetTextNode()); - } + if (!bName && pSh && !pSh->Imp()->IsUpdateExpFields()) { - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion( aStr ); + static_cast<SwChapterField*>(pField)->ChangeExpansion( + *m_pFrame, &static_txtattr_cast<SwTextField const*>(pHint)->GetTextNode()); } break; - case SwFieldIds::DocStat: - if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() ) - { - static_cast<SwDocStatField*>(pField)->ChangeExpansion( pFrame ); - } + if (!bName && pSh && !pSh->Imp()->IsUpdateExpFields()) { - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion( aStr ); + static_cast<SwDocStatField*>(pField)->ChangeExpansion(m_pFrame); } - static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_PAGECOUNTFLD; break; - case SwFieldIds::PageNumber: - { - if( !bName && pSh && pSh->GetLayout() && !pSh->Imp()->IsUpdateExpFields() ) + if (!bName && pSh && pSh->GetLayout() && !pSh->Imp()->IsUpdateExpFields()) { - SwPageNumberFieldType *pPageNr = static_cast<SwPageNumberFieldType *>(pField->GetTyp()); + auto pPageNr = static_cast<SwPageNumberFieldType*>(pField->GetTyp()); const SwRootFrame* pTmpRootFrame = pSh->GetLayout(); const bool bVirt = pTmpRootFrame->IsVirtPageNum(); - sal_uInt16 nVirtNum = pFrame->GetVirtPageNum(); + sal_uInt16 nVirtNum = m_pFrame->GetVirtPageNum(); sal_uInt16 nNumPages = pTmpRootFrame->GetPageNum(); SvxNumType nNumFormat = SvxNumType(-1); - if(SVX_NUM_PAGEDESC == pField->GetFormat()) - nNumFormat = pFrame->FindPageFrame()->GetPageDesc()->GetNumType().GetNumberingType(); - static_cast<SwPageNumberField*>(pField) - ->ChangeExpansion(nVirtNum, nNumPages); - pPageNr->ChangeExpansion(pDoc, - bVirt, nNumFormat != SvxNumType(-1) ? &nNumFormat : nullptr); + if (SVX_NUM_PAGEDESC == pField->GetFormat()) + nNumFormat + = m_pFrame->FindPageFrame()->GetPageDesc()->GetNumType().GetNumberingType(); + static_cast<SwPageNumberField*>(pField)->ChangeExpansion(nVirtNum, nNumPages); + pPageNr->ChangeExpansion(pSh->GetDoc(), bVirt, + nNumFormat != SvxNumType(-1) ? &nNumFormat : nullptr); } - { - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion( aStr ); - } - static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_PAGENUMBERFLD; break; - } case SwFieldIds::GetExp: - { - if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() ) + if (!bName && pSh && !pSh->Imp()->IsUpdateExpFields()) { - SwGetExpField* pExpField = static_cast<SwGetExpField*>(pField); - if( !::lcl_IsInBody( pFrame ) ) + auto pExpField = static_cast<SwGetExpField*>(pField); + if (!::lcl_IsInBody(m_pFrame)) { - pExpField->ChgBodyTextFlag( false ); - pExpField->ChangeExpansion(*pFrame, - *static_txtattr_cast<SwTextField const*>(pHint)); + pExpField->ChgBodyTextFlag(false); + pExpField->ChangeExpansion(*m_pFrame, + *static_txtattr_cast<SwTextField const*>(pHint)); } - else if( !pExpField->IsInBodyText() ) + else if (!pExpField->IsInBodyText()) { // Was something else previously, thus: expand first, then convert it! - pExpField->ChangeExpansion(*pFrame, - *static_txtattr_cast<SwTextField const*>(pHint)); - pExpField->ChgBodyTextFlag( true ); + pExpField->ChangeExpansion(*m_pFrame, + *static_txtattr_cast<SwTextField const*>(pHint)); + pExpField->ChgBodyTextFlag(true); } } - { - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion( aStr ); - } break; - } case SwFieldIds::Database: - { - if( !bName ) + if (!bName) { - SwDBField* pDBField = static_cast<SwDBField*>(pField); - pDBField->ChgBodyTextFlag( ::lcl_IsInBody( pFrame ) ); - } - { - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion(aStr); + static_cast<SwDBField*>(pField)->ChgBodyTextFlag(::lcl_IsInBody(m_pFrame)); } break; - } case SwFieldIds::RefPageGet: - if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() ) + if (!bName && pSh && !pSh->Imp()->IsUpdateExpFields()) { - static_cast<SwRefPageGetField*>(pField)->ChangeExpansion(*pFrame, - static_txtattr_cast<SwTextField const*>(pHint)); - } - { - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion(aStr); + static_cast<SwRefPageGetField*>(pField)->ChangeExpansion( + *m_pFrame, static_txtattr_cast<SwTextField const*>(pHint)); } break; - case SwFieldIds::JumpEdit: - if( !bName ) - pChFormat = static_cast<SwJumpEditField*>(pField)->GetCharFormat(); - bNewFlyPor = true; - bPlaceHolder = true; - break; - case SwFieldIds::GetRef: - subType = static_cast<SwGetRefField*>(pField)->GetSubType(); + { + std::unique_ptr<SwFont> pFont; + if (!bName) { - OUString const str( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion(str); + pFont = std::make_unique<SwFont>(*m_pFont); + pFont->SetDiffFnt( + &static_cast<SwJumpEditField*>(pField)->GetCharFormat()->GetAttrSet(), + &m_pFrame->GetDoc().getIDocumentSettingAccess()); } - if( subType == REF_BOOKMARK ) - static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_BOOKMARKFLD; - else if( subType == REF_SETREFATTR ) - static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_SETREFATTRFLD; - break; - case SwFieldIds::DateTime: - subType = static_cast<SwDateTimeField*>(pField)->GetSubType(); + return new SwJumpFieldPortion(ExpandField(*pField, *this, rInf), pField->GetPar2(), + std::move(pFont), pField->GetFormat()); + } + case SwFieldIds::GetRef: + if (!bName) { - OUString const str( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion(str); + auto pGetRef = static_cast<SwGetRefField*>(pField); + if (pGetRef->GetSubType() == REF_STYLE) + pGetRef->UpdateField(static_txtattr_cast<SwTextField const*>(pHint), m_pFrame); } - if( subType & DATEFLD ) - static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_DATEFLD; - else if( subType & TIMEFLD ) - static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_TIMEFLD; break; default: - { - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion(aStr); - } - } - - if( bNewFlyPor ) - { - std::unique_ptr<SwFont> pTmpFnt; - if( !bName ) - { - pTmpFnt.reset(new SwFont( *m_pFont )); - pTmpFnt->SetDiffFnt(&pChFormat->GetAttrSet(), &m_pFrame->GetDoc().getIDocumentSettingAccess()); - } - OUString const aStr( bName - ? pField->GetFieldName() - : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) ); - pRet = new SwFieldPortion(aStr, std::move(pTmpFnt), bPlaceHolder); + break; } - - return pRet; + return new SwFieldPortion(ExpandField(*pField, *this, rInf)); } static SwFieldPortion * lcl_NewMetaPortion(SwTextAttr & rHint, const bool bPrefix) @@ -304,7 +206,8 @@ static SwFieldPortion * lcl_NewMetaPortion(SwTextAttr & rHint, const bool bPrefi OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?"); if (pField) { - pField->GetPrefixAndSuffix(bPrefix ? &fix : nullptr, bPrefix ? nullptr : &fix); + OUString color; + pField->GetPrefixAndSuffix(bPrefix ? &fix : nullptr, bPrefix ? nullptr : &fix, &color); } return new SwFieldPortion( fix ); } @@ -405,7 +308,12 @@ SwLinePortion *SwTextFormatter::NewExtraPortion( SwTextFormatInfo &rInf ) } if( !pRet ) { - pRet = new SwFieldPortion( "" ); + auto pFieldPortion = new SwFieldPortion( "" ); + if (pHint->Which() == RES_TXTATR_CONTENTCONTROL) + { + pFieldPortion->SetContentControl(true); + } + pRet = pFieldPortion; rInf.SetLen(TextFrameIndex(1)); } return pRet; @@ -423,39 +331,9 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm if( !pIDSA->get(DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING )) return; - SwFormatAutoFormat const& rListAutoFormat(static_cast<SwFormatAutoFormat const&>(rInf.GetTextFrame()->GetTextNodeForParaProps()->GetAttr(RES_PARATR_LIST_AUTOFMT))); + SwFormatAutoFormat const& rListAutoFormat(rInf.GetTextFrame()->GetTextNodeForParaProps()->GetAttr(RES_PARATR_LIST_AUTOFMT)); std::shared_ptr<SfxItemSet> pSet(rListAutoFormat.GetStyleHandle()); - // TODO remove this fallback (for WW8/RTF) - bool isDOCX = pIDSA->get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS); - if (!isDOCX && !pSet) - { - TextFrameIndex const nTextLen(rInf.GetTextFrame()->GetText().getLength()); - SwTextNode const* pNode(nullptr); - sw::MergedAttrIterReverse iter(*rInf.GetTextFrame()); - for (SwTextAttr const* pHint = iter.PrevAttr(&pNode); pHint; - pHint = iter.PrevAttr(&pNode)) - { - TextFrameIndex const nHintEnd( - rInf.GetTextFrame()->MapModelToView(pNode, pHint->GetAnyEnd())); - if (nHintEnd < nTextLen) - { - break; // only those at para end are interesting - } - // Formatting for the paragraph mark is usually set to apply only to the - // (non-existent) extra character at end of the text node, but there can be - // other hints too (ending at nTextLen), so look for all matching hints. - // Still the (non-existent) extra character at the end is preferred if it exists. - if (pHint->Which() == RES_TXTATR_AUTOFMT) - { - pSet = pHint->GetAutoFormat().GetStyleHandle(); - // When we find an empty hint (start == end) we got what we are looking for. - if (pHint->GetStart() == *pHint->End()) - break; - } - } - } - // Check each item and in case it should be ignored, then clear it. if (!pSet) return; @@ -473,7 +351,8 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm { if (!SwTextNode::IsIgnoredCharFormatForNumbering(nWhich, /*bIsCharStyle=*/true) && !pCleanedSet->HasItem(nWhich) - && !(pFormat && pFormat->HasItem(nWhich)) ) + && !(pFormat && pFormat->HasItem(nWhich)) + && rStyleAttrs.GetItemState(nWhich) > SfxItemState::DEFAULT) { // Copy from parent sets only allowed items which will not overwrite // values explicitly defined in current set (pCleanedSet) or in pFormat @@ -530,63 +409,84 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm if (oFontBackColor) pNumFnt->SetBackColor(oFontBackColor); - if (aHighlight != COL_TRANSPARENT) + if (aHighlight != COL_TRANSPARENT && !pCleanedSet->HasItem(RES_CHRATR_HIGHLIGHT)) pNumFnt->SetHighlightColor(aHighlight); } -static const SwRangeRedline* lcl_GetRedlineAtNodeInsertionOrDeletion( const SwTextNode& rTextNode ) +static const SwRangeRedline* lcl_GetRedlineAtNodeInsertionOrDeletion( const SwTextNode& rTextNode, + bool& bIsMoved ) { const SwDoc& rDoc = rTextNode.GetDoc(); SwRedlineTable::size_type nRedlPos = rDoc.getIDocumentRedlineAccess().GetRedlinePos( rTextNode, RedlineType::Any ); if( SwRedlineTable::npos != nRedlPos ) { - const sal_uLong nNdIdx = rTextNode.GetIndex(); - for( ; nRedlPos < rDoc.getIDocumentRedlineAccess().GetRedlineTable().size() ; ++nRedlPos ) + const SwNodeOffset nNdIdx = rTextNode.GetIndex(); + const SwRedlineTable& rTable = rDoc.getIDocumentRedlineAccess().GetRedlineTable(); + for( ; nRedlPos < rTable.size() ; ++nRedlPos ) { - const SwRangeRedline* pTmp = rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nRedlPos ]; + const SwRangeRedline* pTmp = rTable[ nRedlPos ]; + SwNodeOffset nStart = pTmp->GetPoint()->GetNodeIndex(), + nEnd = pTmp->GetMark()->GetNodeIndex(); + if( nStart > nEnd ) + std::swap(nStart, nEnd); if( RedlineType::Delete == pTmp->GetType() || RedlineType::Insert == pTmp->GetType() ) { - const SwPosition *pRStt = pTmp->Start(), *pREnd = pTmp->End(); - if( pRStt->nNode < nNdIdx && pREnd->nNode >= nNdIdx ) + if( nStart <= nNdIdx && nEnd > nNdIdx ) + { + bIsMoved = pTmp->IsMoved(); return pTmp; + } } + if( nStart > nNdIdx ) + break; } } return nullptr; } -static void lcl_setRedlineAttr( SwTextFormatInfo &rInf, const SwTextNode& rTextNode, const std::unique_ptr<SwFont>& pNumFnt ) +static bool lcl_setRedlineAttr( SwTextFormatInfo &rInf, const SwTextNode& rTextNode, const std::unique_ptr<SwFont>& pNumFnt ) { if ( rInf.GetVsh()->GetLayout()->IsHideRedlines() ) - return; + return false; - const SwRangeRedline* pRedlineNum = lcl_GetRedlineAtNodeInsertionOrDeletion( rTextNode ); + bool bIsMoved; + const SwRangeRedline* pRedlineNum = lcl_GetRedlineAtNodeInsertionOrDeletion( rTextNode, bIsMoved ); if (!pRedlineNum) - return; + return false; - std::unique_ptr<SfxItemSet> pSet; + // moved text: dark green with double underline or strikethrough + if ( bIsMoved ) + { + pNumFnt->SetColor(COL_GREEN); + if ( RedlineType::Delete == pRedlineNum->GetType() ) + pNumFnt->SetStrikeout(STRIKEOUT_DOUBLE); + else + pNumFnt->SetUnderline(LINESTYLE_DOUBLE); + return true; + } SwAttrPool& rPool = rInf.GetVsh()->GetDoc()->GetAttrPool(); - pSet = std::make_unique<SfxItemSet>(rPool, svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{}); + SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END-1> aSet(rPool); std::size_t aAuthor = (1 < pRedlineNum->GetStackCount()) ? pRedlineNum->GetAuthor( 1 ) : pRedlineNum->GetAuthor(); if ( RedlineType::Delete == pRedlineNum->GetType() ) - SW_MOD()->GetDeletedAuthorAttr(aAuthor, *pSet); + SW_MOD()->GetDeletedAuthorAttr(aAuthor, aSet); else - SW_MOD()->GetInsertAuthorAttr(aAuthor, *pSet); - - const SfxPoolItem* pItem = nullptr; - if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_COLOR, true, &pItem)) - pNumFnt->SetColor(static_cast<const SvxColorItem*>(pItem)->GetValue()); - if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_UNDERLINE, true, &pItem)) - pNumFnt->SetUnderline(static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle()); - if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_CROSSEDOUT, true, &pItem)) - pNumFnt->SetStrikeout( static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout() ); + SW_MOD()->GetInsertAuthorAttr(aAuthor, aSet); + + if (const SvxColorItem* pItem = aSet.GetItemIfSet(RES_CHRATR_COLOR)) + pNumFnt->SetColor(pItem->GetValue()); + if (const SvxUnderlineItem* pItem = aSet.GetItemIfSet(RES_CHRATR_UNDERLINE)) + pNumFnt->SetUnderline(pItem->GetLineStyle()); + if (const SvxCrossedOutItem* pItem = aSet.GetItemIfSet(RES_CHRATR_CROSSEDOUT)) + pNumFnt->SetStrikeout( pItem->GetStrikeout() ); + + return true; } SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) const @@ -657,7 +557,7 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con if( SVX_NUM_CHAR_SPECIAL == rNumFormat.GetNumberingType() ) { - const vcl::Font *pFormatFnt = rNumFormat.GetBulletFont(); + const std::optional<vcl::Font> pFormatFnt = rNumFormat.GetBulletFont(); // Build a new bullet font basing on the current paragraph font: std::unique_ptr<SwFont> pNumFnt(new SwFont( &rInf.GetCharAttr(), pIDSA )); @@ -715,11 +615,37 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con } else { - OUString aText( pTextNd->GetNumString(true, MAXLEVEL, m_pFrame->getRootFrame()) ); - if ( !aText.isEmpty() ) + // Show Changes mode shows the actual numbering (SwListRedlineType::HIDDEN) and + // the original one (SwListRedlineType::ORIGTEXT) instead of the fake numbering + // (SwListRedlineType::SHOW, which counts removed and inserted numbered paragraphs + // in a single list) + bool bHasHiddenNum = false; + OUString aText( pTextNd->GetNumString(true, MAXLEVEL, m_pFrame->getRootFrame(), SwListRedlineType::HIDDEN) ); + const SwDoc& rDoc = pTextNd->GetDoc(); + const SwRedlineTable& rTable = rDoc.getIDocumentRedlineAccess().GetRedlineTable(); + if ( rTable.size() && !rInf.GetVsh()->GetLayout()->IsHideRedlines() ) { - aText += pTextNd->GetLabelFollowedBy(); + OUString aHiddenText( pTextNd->GetNumString(true, MAXLEVEL, m_pFrame->getRootFrame(), SwListRedlineType::ORIGTEXT) ); + + if ( !aText.isEmpty() || !aHiddenText.isEmpty() ) + { + bool bDisplayChangedParagraphNumbering = officecfg::Office::Writer::Comparison::DisplayChangedParagraphNumbering::get(); + if (bDisplayChangedParagraphNumbering && aText != aHiddenText && !aHiddenText.isEmpty()) + { + bHasHiddenNum = true; + // show also original number after the actual one enclosed in [ and ], + // and replace tabulator with space to avoid messy indentation + // resulted by the longer numbering, e.g. "1.[2.]" instead of "1.". + aText = aText + "[" + aHiddenText + "]" + + pTextNd->GetLabelFollowedBy().replaceAll("\t", " "); + } + else if (!aText.isEmpty()) + aText += pTextNd->GetLabelFollowedBy(); + } } + else if (pTextNd->getIDocumentSettingAccess()->get(DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY) + || !aText.isEmpty()) + aText += pTextNd->GetLabelFollowedBy(); // Not just an optimization ... // A number portion without text will be assigned a width of 0. @@ -731,6 +657,28 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con // Build a new numbering font basing on the current paragraph font: std::unique_ptr<SwFont> pNumFnt(new SwFont( &rInf.GetCharAttr(), pIDSA )); + const SwTextNode& rTextNode = *rInf.GetTextFrame()->GetTextNodeForParaProps(); + if (const SwpHints* pHints = rTextNode.GetpSwpHints()) + { + // Also look for an empty character hint that sits at the paragraph end: + for (size_t i = 0; i < pHints->Count(); ++i) + { + const SwTextAttr* pHint = pHints->GetSortedByEnd(i); + if (pHint->Which() == RES_TXTATR_AUTOFMT && pHint->GetEnd() + && pHint->GetStart() == *pHint->GetEnd() + && pHint->GetStart() == rTextNode.GetText().getLength()) + { + std::shared_ptr<SfxItemSet> pSet + = pHint->GetAutoFormat().GetStyleHandle(); + if (pSet) + { + pNumFnt->SetDiffFnt(pSet.get(), pIDSA); + break; + } + } + } + } + // #i53199# if ( !pIDSA->get(DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) ) { @@ -748,7 +696,8 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con checkApplyParagraphMarkFormatToNumbering(pNumFnt.get(), rInf, pIDSA, pFormat); - lcl_setRedlineAttr( rInf, *pTextNd, pNumFnt ); + if ( !lcl_setRedlineAttr( rInf, *pTextNd, pNumFnt ) && bHasHiddenNum ) + pNumFnt->SetColor(NON_PRINTING_CHARACTER_COLOR); // we do not allow a vertical font pNumFnt->SetVertical( pNumFnt->GetOrientation(), m_pFrame->IsVertical() ); |