diff options
Diffstat (limited to 'sw/source/core/text/txtftn.cxx')
-rw-r--r-- | sw/source/core/text/txtftn.cxx | 70 |
1 files changed, 52 insertions, 18 deletions
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx index 5b4b9f7492e0..c1fa749c93f5 100644 --- a/sw/source/core/text/txtftn.cxx +++ b/sw/source/core/text/txtftn.cxx @@ -21,6 +21,7 @@ #include <string_view> +#include <utility> #include <viewsh.hxx> #include <doc.hxx> #include <IDocumentLayoutAccess.hxx> @@ -53,6 +54,13 @@ #include <frmtool.hxx> #include <ndindex.hxx> #include <IDocumentSettingAccess.hxx> +#include <IDocumentRedlineAccess.hxx> +#include <swmodule.hxx> +#include <unotextrange.hxx> +#include <redline.hxx> +#include <editeng/colritem.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/crossedoutitem.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/CharSet.hpp> @@ -240,7 +248,7 @@ static SwTwips lcl_GetFootnoteLower( const SwTextFrame* pFrame, SwTwips nLower ) { SwRect aRect( pAnchoredObj->GetObjRect() ); - auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pAnchoredObj ); + auto pFlyFrame = pAnchoredObj->DynCastFlyFrame(); if ( !pFlyFrame || pFlyFrame->isFrameAreaDefinitionValid() ) { @@ -288,7 +296,7 @@ SwTwips SwTextFrame::GetFootnoteLine( const SwTextFootnote *pFootnote ) const &pFootnote->GetTextNode(), pFootnote->GetStart())); aLine.CharToLine( nPos ); - nRet = aLine.Y() + SwTwips(aLine.GetLineHeight()); + nRet = aLine.Y() + aLine.GetLineHeight(); if( IsVertical() ) nRet = SwitchHorizontalToVertical( nRet ); } @@ -656,7 +664,7 @@ void SwTextFrame::ConnectFootnote( SwTextFootnote *pFootnote, const SwTwips nDea mbInFootnoteConnect = false; return; } - else if( pSrcFrame ) + else if (pSrcFrame && pFootnoteFrame) { SwFootnoteBossFrame *pFootnoteBoss = pFootnoteFrame->FindFootnoteBossFrame(); if( !pFootnoteBoss->IsInSct() || @@ -964,16 +972,15 @@ SwNumberPortion *SwTextFormatter::NewFootnoteNumPortion( SwTextFormatInfo const pNumFnt->SetWeight( WEIGHT_NORMAL, SwFontScript::CJK ); pNumFnt->SetWeight( WEIGHT_NORMAL, SwFontScript::CTL ); - const auto xAnchor = rFootnote.getAnchor(*pDoc); - uno::Reference<beans::XPropertySet> xAnchorProps(xAnchor, uno::UNO_QUERY); - if (xAnchorProps.is()) + const rtl::Reference<SwXTextRange> xAnchor = rFootnote.getAnchor(*pDoc); + if (xAnchor.is()) { - auto aAny = xAnchorProps->getPropertyValue("CharFontCharSet"); + auto aAny = xAnchor->getPropertyValue("CharFontCharSet"); sal_Int16 eCharSet; if ((aAny >>= eCharSet) && eCharSet == awt::CharSet::SYMBOL) { OUString aFontName; - aAny = xAnchorProps->getPropertyValue("CharFontName"); + aAny = xAnchor->getPropertyValue("CharFontName"); if (aAny >>= aFontName) { pNumFnt->SetName(aFontName, SwFontScript::Latin); @@ -990,6 +997,36 @@ SwNumberPortion *SwTextFormatter::NewFootnoteNumPortion( SwTextFormatInfo const pNumFnt->SetDiffFnt(&rSet, pIDSA ); pNumFnt->SetVertical( pNumFnt->GetOrientation(), m_pFrame->IsVertical() ); + // tdf#85610 apply redline coloring to the footnote numbering in the footnote area + SwUnoInternalPaM aPam(*pDoc); + if ( ::sw::XTextRangeToSwPaM(aPam, xAnchor) ) + { + SwRedlineTable::size_type nRedlinePos = 0; + const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); + const SwRangeRedline* pRedline = rTable.FindAtPosition( *aPam.Start(), nRedlinePos ); + if (pRedline) + { + SwAttrPool& rPool = pDoc->GetAttrPool(); + SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END-1> aSet(rPool); + + std::size_t aAuthor = (1 < pRedline->GetStackCount()) + ? pRedline->GetAuthor( 1 ) + : pRedline->GetAuthor(); + + if ( RedlineType::Delete == pRedline->GetType() ) + SW_MOD()->GetDeletedAuthorAttr(aAuthor, aSet); + else + 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() ); + } + } + SwFootnoteNumPortion* pNewPor = new SwFootnoteNumPortion( aFootnoteText, std::move(pNumFnt) ); pNewPor->SetLeft( !m_pFrame->IsRightToLeft() ); return pNewPor; @@ -1181,7 +1218,7 @@ TextFrameIndex SwTextFormatter::FormatQuoVadis(TextFrameIndex const nOffset) if( nDiff < 0 ) { nLastLeft = pQuo->GetAscent(); - nQuoWidth = static_cast<sal_uInt16>(-nDiff + nLastLeft); + nQuoWidth = o3tl::narrowing<sal_uInt16>(-nDiff + nLastLeft); } else { @@ -1313,17 +1350,14 @@ SwFootnoteSave::SwFootnoteSave(const SwTextSizeInfo& rInf, const SwTextFootnote* } // set the correct rotation at the footnote font - const SfxPoolItem* pItem; - if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_ROTATE, - true, &pItem )) - m_pFnt->SetVertical(static_cast<const SvxCharRotateItem*>(pItem)->GetValue(), + if( const SvxCharRotateItem* pItem = rSet.GetItemIfSet( RES_CHRATR_ROTATE ) ) + m_pFnt->SetVertical(pItem->GetValue(), rInf.GetTextFrame()->IsVertical()); m_pFnt->ChgPhysFnt(m_pInf->GetVsh(), *m_pInf->GetOut()); - if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, - true, &pItem )) - m_pFnt->SetBackColor(static_cast<const SvxBrushItem*>(pItem)->GetColor()); + if( const SvxBrushItem* pItem = rSet.GetItemIfSet( RES_CHRATR_BACKGROUND ) ) + m_pFnt->SetBackColor(pItem->GetColor()); } else m_pFnt = nullptr; @@ -1408,8 +1442,8 @@ SwFieldPortion *SwQuoVadisPortion::Clone( const OUString &rExpand ) const return new SwQuoVadisPortion( rExpand, m_aErgo ); } -SwQuoVadisPortion::SwQuoVadisPortion( const OUString &rExp, const OUString& rStr ) - : SwFieldPortion( rExp ), m_aErgo(rStr) +SwQuoVadisPortion::SwQuoVadisPortion( const OUString &rExp, OUString aStr ) + : SwFieldPortion( rExp ), m_aErgo(std::move(aStr)) { SetLen(TextFrameIndex(0)); SetWhichPor( PortionType::QuoVadis ); |