summaryrefslogtreecommitdiff
path: root/sw/source/core/text/txtftn.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/text/txtftn.cxx')
-rw-r--r--sw/source/core/text/txtftn.cxx144
1 files changed, 88 insertions, 56 deletions
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index ea326a91ae3f..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,8 +248,9 @@ static SwTwips lcl_GetFootnoteLower( const SwTextFrame* pFrame, SwTwips nLower )
{
SwRect aRect( pAnchoredObj->GetObjRect() );
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) == nullptr ||
- static_cast<SwFlyFrame*>(pAnchoredObj)->isFrameAreaDefinitionValid() )
+ auto pFlyFrame = pAnchoredObj->DynCastFlyFrame();
+ if ( !pFlyFrame ||
+ pFlyFrame->isFrameAreaDefinitionValid() )
{
const SwTwips nBottom = aRectFnSet.GetBottom(aRect);
if ( aRectFnSet.YDiff( nBottom, nFlyLower ) > 0 )
@@ -287,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 );
}
@@ -655,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() ||
@@ -963,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);
@@ -989,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;
@@ -1180,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
{
@@ -1252,9 +1290,9 @@ namespace {
class SwFootnoteSave
{
- SwTextSizeInfo *pInf;
- SwFont *pFnt;
- std::unique_ptr<SwFont> pOld;
+ SwTextSizeInfo* m_pInf;
+ SwFont* m_pFnt;
+ std::unique_ptr<SwFont> m_pOld;
SwFootnoteSave(const SwFootnoteSave&) = delete;
SwFootnoteSave& operator=(const SwFootnoteSave&) = delete;
@@ -1269,32 +1307,31 @@ public:
}
-SwFootnoteSave::SwFootnoteSave( const SwTextSizeInfo &rInf,
- const SwTextFootnote* pTextFootnote,
- const bool bApplyGivenScriptType,
- const SwFontScript nGivenScriptType )
- : pInf( &const_cast<SwTextSizeInfo&>(rInf) )
- , pFnt( nullptr )
+SwFootnoteSave::SwFootnoteSave(const SwTextSizeInfo& rInf, const SwTextFootnote* pTextFootnote,
+ const bool bApplyGivenScriptType,
+ const SwFontScript nGivenScriptType)
+ : m_pInf(&const_cast<SwTextSizeInfo&>(rInf))
+ , m_pFnt(nullptr)
{
if( pTextFootnote && rInf.GetTextFrame() )
{
- pFnt = const_cast<SwTextSizeInfo&>(rInf).GetFont();
- pOld.reset( new SwFont( *pFnt ) );
- pOld->GetTox() = pFnt->GetTox();
- pFnt->GetTox() = 0;
+ m_pFnt = const_cast<SwTextSizeInfo&>(rInf).GetFont();
+ m_pOld.reset(new SwFont(*m_pFnt));
+ m_pOld->GetTox() = m_pFnt->GetTox();
+ m_pFnt->GetTox() = 0;
SwFormatFootnote& rFootnote = const_cast<SwFormatFootnote&>(pTextFootnote->GetFootnote());
const SwDoc *const pDoc = &rInf.GetTextFrame()->GetDoc();
// #i98418#
if ( bApplyGivenScriptType )
{
- pFnt->SetActual( nGivenScriptType );
+ m_pFnt->SetActual(nGivenScriptType);
}
else
{
// examine text and set script
OUString aTmpStr(rFootnote.GetViewNumStr(*pDoc, rInf.GetTextFrame()->getRootFrame()));
- pFnt->SetActual( SwScriptInfo::WhichFont(0, aTmpStr) );
+ m_pFnt->SetActual(SwScriptInfo::WhichFont(0, aTmpStr));
}
const SwEndNoteInfo* pInfo;
@@ -1303,51 +1340,46 @@ SwFootnoteSave::SwFootnoteSave( const SwTextSizeInfo &rInf,
else
pInfo = &pDoc->GetFootnoteInfo();
const SwAttrSet& rSet = pInfo->GetAnchorCharFormat(const_cast<SwDoc&>(*pDoc))->GetAttrSet();
- pFnt->SetDiffFnt( &rSet, &pDoc->getIDocumentSettingAccess() );
+ m_pFnt->SetDiffFnt(&rSet, &pDoc->getIDocumentSettingAccess());
// we reduce footnote size, if we are inside a double line portion
- if ( ! pOld->GetEscapement() && 50 == pOld->GetPropr() )
+ if (!m_pOld->GetEscapement() && 50 == m_pOld->GetPropr())
{
- Size aSize = pFnt->GetSize( pFnt->GetActual() );
- pFnt->SetSize( Size( aSize.Width() / 2,
- aSize.Height() / 2 ),
- pFnt->GetActual() );
+ Size aSize = m_pFnt->GetSize(m_pFnt->GetActual());
+ m_pFnt->SetSize(Size(aSize.Width() / 2, aSize.Height() / 2), m_pFnt->GetActual());
}
// set the correct rotation at the footnote font
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_ROTATE,
- true, &pItem ))
- pFnt->SetVertical( static_cast<const SvxCharRotateItem*>(pItem)->GetValue(),
- rInf.GetTextFrame()->IsVertical() );
+ if( const SvxCharRotateItem* pItem = rSet.GetItemIfSet( RES_CHRATR_ROTATE ) )
+ m_pFnt->SetVertical(pItem->GetValue(),
+ rInf.GetTextFrame()->IsVertical());
- pFnt->ChgPhysFnt( pInf->GetVsh(), *pInf->GetOut() );
+ m_pFnt->ChgPhysFnt(m_pInf->GetVsh(), *m_pInf->GetOut());
- if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND,
- true, &pItem ))
- pFnt->SetBackColor( static_cast<const SvxBrushItem*>(pItem)->GetColor() );
+ if( const SvxBrushItem* pItem = rSet.GetItemIfSet( RES_CHRATR_BACKGROUND ) )
+ m_pFnt->SetBackColor(pItem->GetColor());
}
else
- pFnt = nullptr;
+ m_pFnt = nullptr;
}
SwFootnoteSave::~SwFootnoteSave() COVERITY_NOEXCEPT_FALSE
{
- if( pFnt )
+ if (m_pFnt)
{
// Put back SwFont
- *pFnt = *pOld;
- pFnt->GetTox() = pOld->GetTox();
- pFnt->ChgPhysFnt( pInf->GetVsh(), *pInf->GetOut() );
- pOld.reset();
+ *m_pFnt = *m_pOld;
+ m_pFnt->GetTox() = m_pOld->GetTox();
+ m_pFnt->ChgPhysFnt(m_pInf->GetVsh(), *m_pInf->GetOut());
+ m_pOld.reset();
}
}
SwFootnotePortion::SwFootnotePortion( const OUString &rExpand,
SwTextFootnote *pFootn, sal_uInt16 nReal )
: SwFieldPortion( rExpand, nullptr )
- , pFootnote(pFootn)
- , nOrigHeight( nReal )
+ , m_pFootnote(pFootn)
+ , m_nOrigHeight( nReal )
// #i98418#
, mbPreferredScriptTypeSet( false )
, mnPreferredScriptType( SwFontScript::Latin )
@@ -1366,7 +1398,7 @@ bool SwFootnotePortion::Format( SwTextFormatInfo &rInf )
{
// #i98418#
// SwFootnoteSave aFootnoteSave( rInf, pFootnote );
- SwFootnoteSave aFootnoteSave( rInf, pFootnote, mbPreferredScriptTypeSet, mnPreferredScriptType );
+ SwFootnoteSave aFootnoteSave( rInf, m_pFootnote, mbPreferredScriptTypeSet, mnPreferredScriptType );
// the idx is manipulated in SwExpandPortion::Format
// this flag indicates, that a footnote is allowed to trigger
// an underflow during SwTextGuess::Guess
@@ -1385,7 +1417,7 @@ void SwFootnotePortion::Paint( const SwTextPaintInfo &rInf ) const
{
// #i98418#
// SwFootnoteSave aFootnoteSave( rInf, pFootnote );
- SwFootnoteSave aFootnoteSave( rInf, pFootnote, mbPreferredScriptTypeSet, mnPreferredScriptType );
+ SwFootnoteSave aFootnoteSave( rInf, m_pFootnote, mbPreferredScriptTypeSet, mnPreferredScriptType );
rInf.DrawViewOpt( *this, PortionType::Footnote );
SwExpandPortion::Paint( rInf );
}
@@ -1394,7 +1426,7 @@ SwPosSize SwFootnotePortion::GetTextSize( const SwTextSizeInfo &rInfo ) const
{
// #i98418#
// SwFootnoteSave aFootnoteSave( rInfo, pFootnote );
- SwFootnoteSave aFootnoteSave( rInfo, pFootnote, mbPreferredScriptTypeSet, mnPreferredScriptType );
+ SwFootnoteSave aFootnoteSave( rInfo, m_pFootnote, mbPreferredScriptTypeSet, mnPreferredScriptType );
return SwExpandPortion::GetTextSize( rInfo );
}
@@ -1407,11 +1439,11 @@ void SwFootnotePortion::SetPreferredScriptType( SwFontScript nPreferredScriptTyp
SwFieldPortion *SwQuoVadisPortion::Clone( const OUString &rExpand ) const
{
- return new SwQuoVadisPortion( rExpand, aErgo );
+ return new SwQuoVadisPortion( rExpand, m_aErgo );
}
-SwQuoVadisPortion::SwQuoVadisPortion( const OUString &rExp, const OUString& rStr )
- : SwFieldPortion( rExp ), aErgo(rStr)
+SwQuoVadisPortion::SwQuoVadisPortion( const OUString &rExp, OUString aStr )
+ : SwFieldPortion( rExp ), m_aErgo(std::move(aStr))
{
SetLen(TextFrameIndex(0));
SetWhichPor( PortionType::QuoVadis );
@@ -1450,13 +1482,13 @@ bool SwQuoVadisPortion::GetExpText( const SwTextSizeInfo &, OUString &rText ) co
// if this QuoVadisPortion has a follow, the follow is responsible for
// the ergo text.
if ( ! HasFollow() )
- rText += aErgo;
+ rText += m_aErgo;
return true;
}
void SwQuoVadisPortion::HandlePortion( SwPortionHandler& rPH ) const
{
- rPH.Special( GetLen(), m_aExpand + aErgo, GetWhichPor() );
+ rPH.Special( GetLen(), m_aExpand + m_aErgo, GetWhichPor() );
}
void SwQuoVadisPortion::Paint( const SwTextPaintInfo &rInf ) const