From 5a7157d319477830426797532e02ac39d3b859f4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:29:03 +0200 Subject: Merging upstream version 4:24.2.1. Signed-off-by: Daniel Baumann --- sw/source/core/text/EnhancedPDFExportHelper.cxx | 7 +- sw/source/core/text/frmform.cxx | 2 +- sw/source/core/text/guess.cxx | 7 +- sw/source/core/text/inftxt.cxx | 2 +- sw/source/core/text/itratr.cxx | 2 +- sw/source/core/text/itrform2.cxx | 13 +- sw/source/core/text/porfld.cxx | 14 +- sw/source/core/text/porfly.cxx | 2 +- sw/source/core/text/porlay.cxx | 2 +- sw/source/core/text/porrst.cxx | 12 ++ sw/source/core/text/portxt.cxx | 12 +- sw/source/core/text/txtfly.cxx | 178 +++++++++++++----------- sw/source/core/text/txtfrm.cxx | 6 +- 13 files changed, 153 insertions(+), 106 deletions(-) (limited to 'sw/source/core/text') diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 499dcc2417..8ff764d92f 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -364,7 +364,10 @@ bool lcl_TryMoveToNonHiddenField(SwEditShell& rShell, const SwTextNode& rNd, con && *pStart <= pos && pos <= *pEnd) { SwRect charRect; - if (rShell.GetCurrFrame(false)->GetCharRect(charRect, pos, &cms, false) + std::pair const tmp(center, false); + SwContentFrame const*const pFrame( + pos.nNode.GetNode().GetTextNode()->getLayoutFrame(rShell.GetLayout(), &pos, &tmp)); + if (pFrame->GetCharRect(charRect, pos, &cms, false) && rRect.Overlaps(charRect)) { ret.push_back(rRect); @@ -1626,7 +1629,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements() { const SwFlyFrame* pFly = static_cast(pFrame); if (pFly->GetAnchorFrame()->FindFooterOrHeader() != nullptr - || pFly->GetFrameFormat().GetAttrSet().Get(RES_DECORATIVE).GetValue()) + || pFly->GetFrameFormat()->GetAttrSet().Get(RES_DECORATIVE).GetValue()) { nPDFType = vcl::PDFWriter::NonStructElement; } diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index 76a1df5621..e19b834a56 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -1120,7 +1120,7 @@ void SwTextFrame::FormatAdjust( SwTextFormatter &rLine, bool bOnlyContainsAsCharAnchoredObj = !IsFollow() && nStrLen == TextFrameIndex(1) && GetDrawObjs() && GetDrawObjs()->size() == 1 && - (*GetDrawObjs())[0]->GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR; + (*GetDrawObjs())[0]->GetFrameFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR; // Still try split text frame if we have columns. if (FindColFrame()) diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 3346fe345a..c3a94187a7 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -585,7 +585,12 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, m_nBreakStart = m_nBreakPos; - bHyph = BreakType::HYPHENATION == aResult.breakType; + bHyph = BreakType::HYPHENATION == aResult.breakType && + // allow hyphenation of the word only if it's not disabled by character formatting + LANGUAGE_NONE != rInf.GetTextFrame()->GetLangOfChar( + TextFrameIndex( sal_Int32(m_nBreakPos) + + aResult.rHyphenatedWord->getHyphenationPos() ), + 1, true, /*bNoneIfNoHyphenation=*/true ); if (bHyph && m_nBreakPos != TextFrameIndex(COMPLETE_STRING)) { diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 3d9121ef1e..8eced32e89 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1426,8 +1426,8 @@ void SwTextPaintInfo::DrawViewOpt( const SwLinePortion &rPor, || m_pFrame->GetTextNodeForParaProps()->HasMarkedLabel())) // #i27615# { bDraw = PortionType::Footnote != nWhich || m_pFrame->IsFootnoteAllowed(); + bDraw &= GetOpt().IsHardBlank(); } - bDraw &= GetOpt().IsHardBlank(); break; case PortionType::Bookmark: // no shading diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 24203ecb53..bb008d24a3 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -1576,7 +1576,7 @@ bool SwTextFrame::IsEmptyWithSplitFly() const } // It has a split fly anchored to it. - if (pFlyFrame->GetFrameFormat().GetVertOrient().GetPos() >= 0) + if (pFlyFrame->GetFrameFormat()->GetVertOrient().GetPos() >= 0) { return false; } diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index c0b4894f8a..6623000c33 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -420,7 +420,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) if (pAnchoredObj->RestartLayoutProcess() && !pAnchoredObj->IsTmpConsiderWrapInfluence()) { - SwFormatAnchor const& rAnchor(pAnchoredObj->GetFrameFormat().GetAnchor()); + SwFormatAnchor const& rAnchor(pAnchoredObj->GetFrameFormat()->GetAnchor()); assert(rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR || rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA); TextFrameIndex const nAnchor(GetTextFrame()->MapModelToViewPos(*rAnchor.GetContentAnchor())); if (pFollow->GetOffset() <= nAnchor @@ -1009,6 +1009,8 @@ bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) co case SwContentControlType::PLAIN_TEXT: { pDescriptor = std::make_unique(); + auto pEditWidget = static_cast(pDescriptor.get()); + pEditWidget->MultiLine = true; break; } case SwContentControlType::CHECKBOX: @@ -1016,8 +1018,13 @@ bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) co pDescriptor = std::make_unique(); auto pCheckBoxWidget = static_cast(pDescriptor.get()); pCheckBoxWidget->Checked = pContentControl->GetChecked(); - pCheckBoxWidget->OnValue = pContentControl->GetCheckedState(); - pCheckBoxWidget->OffValue = pContentControl->GetUncheckedState(); + // If it's checked already, then leave the default "Yes" OnValue unchanged, so the + // appropriate appearance is found by PDF readers. + if (!pCheckBoxWidget->Checked) + { + pCheckBoxWidget->OnValue = pContentControl->GetCheckedState(); + pCheckBoxWidget->OffValue = pContentControl->GetUncheckedState(); + } break; } case SwContentControlType::DROP_DOWN_LIST: diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 1a30a4ecd7..d2ae4be00d 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -402,10 +402,13 @@ bool SwFieldPortion::Format( SwTextFormatInfo &rInf ) // These characters should not be contained in the follow // field portion. They are handled via the HookChar mechanism. const sal_Unicode nNew = !aNew.isEmpty() ? aNew[0] : 0; - auto IsHook = [](const sal_Unicode cNew) -> bool + auto IsHook = [](const sal_Unicode cNew, bool const isSpace = false) -> bool { switch (cNew) { + case ' ': // tdf#159101 this one is not in ScanPortionEnd + // but is required for justified text + return isSpace; case CH_BREAK: case CH_TAB: case CHAR_HARDHYPHEN: // non-breaking hyphen @@ -422,7 +425,7 @@ bool SwFieldPortion::Format( SwTextFormatInfo &rInf ) return false; } }; - if (IsHook(nNew)) + if (IsHook(nNew, true)) { if (nNew == CH_BREAK) { @@ -599,9 +602,12 @@ bool SwNumberPortion::Format( SwTextFormatInfo &rInf ) if ( !mbLabelAlignmentPosAndSpaceModeActive ) { - if (!rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING) && + if ((!rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING) && // #i32902# - !IsFootnoteNumPortion() ) + !IsFootnoteNumPortion()) || + // tdf#159382 + (IsFootnoteNumPortion() && + rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::NO_GAP_AFTER_NOTE_NUMBER))) { nDiff = rInf.Left() + rInf.GetTextFrame()->GetTextNodeForParaProps()-> diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 14d1bf6eaa..19ac692cf4 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -168,7 +168,7 @@ void SwTextFrame::MoveFlyInCnt(SwTextFrame *pNew, { // Consider changed type of entries SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; - const SwFormatAnchor& rAnch = pAnchoredObj->GetFrameFormat().GetAnchor(); + const SwFormatAnchor& rAnch = pAnchoredObj->GetFrameFormat()->GetAnchor(); if (rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR) { const SwPosition* pPos = rAnch.GetContentAnchor(); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index cae54845be..2ba2fcf75f 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -748,7 +748,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) { bool bDeleted = false; size_t nAuthor = std::string::npos; - const SwFormatAnchor& rAnchor = pAnchoredObj->GetFrameFormat().GetAnchor(); + const SwFormatAnchor& rAnchor = pAnchoredObj->GetFrameFormat()->GetAnchor(); if ( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR ) { SwPosition aAnchor = *rAnchor.GetContentAnchor(); diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 029adca753..a4a0d3c713 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,7 @@ #include #include #include +#include #include #include @@ -74,6 +76,16 @@ void SwTmpEndPortion::Paint( const SwTextPaintInfo &rInf ) const SwFont aFont(*pOldFnt); + const SwDoc& rDoc = rInf.GetTextFrame()->GetDoc(); + if (aFont.IsSymbol(rDoc.getIDocumentLayoutAccess().GetCurrentViewShell())) + { + const SvxFontItem& rFontItem = rDoc.GetDefault(RES_CHRATR_FONT); + aFont.SetName( rFontItem.GetFamilyName(), SwFontScript::Latin ); + aFont.SetStyleName( rFontItem.GetStyleName(), SwFontScript::Latin ); + aFont.SetFamily( rFontItem.GetFamily(), SwFontScript::Latin ); + aFont.SetPitch( rFontItem.GetPitch(), SwFontScript::Latin ); + aFont.SetCharSet( rFontItem.GetCharSet(), SwFontScript::Latin ); + } // Paint strikeout/underline based on redline color and settings // (with an extra pilcrow in the background, because there is // no SetStrikeoutColor(), also SetUnderColor() doesn't work()). diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 85691ef21e..e58021ef09 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -325,14 +325,20 @@ bool SwTextPortion::Format_( SwTextFormatInfo &rInf ) // call with an extra space: shrinking can result a new word in the line // and a new space before that, which is also a shrank space - // (except if the line was already broken at a soft hyphen, i.e. inside a word) - if ( aGuess.BreakPos() < TextFrameIndex(rInf.GetText().getLength()) && + // (except if the line was already broken inside a word with hyphenation) + // TODO: handle the case, if the line contains extra amount of spaces + if ( + // no automatic hyphenation + !aGuess.HyphWord().is() && + // no hyphenation at soft hyphen + aGuess.BreakPos() < TextFrameIndex(rInf.GetText().getLength()) && rInf.GetText()[sal_Int32(aGuess.BreakPos())] != CHAR_SOFTHYPHEN ) { ++nSpacesInLine; } - bFull = !aGuess.Guess( *this, rInf, Height(), nSpacesInLine ); + if ( nSpacesInLine > 0 ) + bFull = !aGuess.Guess( *this, rInf, Height(), nSpacesInLine ); } // these are the possible cases: diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index ff5566f537..7c4d9a2e16 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -162,7 +162,7 @@ SwRect SwContourCache::CalcBoundRect( const SwAnchoredObject* pAnchoredObj, const bool bRight ) { SwRect aRet; - const SwFrameFormat* pFormat = &(pAnchoredObj->GetFrameFormat()); + const SwFrameFormat* pFormat = pAnchoredObj->GetFrameFormat(); bool bHandleContour(pFormat->GetSurround().IsContour()); if(!bHandleContour) @@ -594,7 +594,7 @@ void SwTextFly::DrawFlyRect( OutputDevice* pOut, const SwRect &rRect ) if (pFly) { // #i68520# - const SwFormatSurround& rSur = pAnchoredObjTmp->GetFrameFormat().GetSurround(); + const SwFormatSurround& rSur = pAnchoredObjTmp->GetFrameFormat()->GetSurround(); // OD 24.01.2003 #106593# - correct clipping of fly frame area. // Consider that fly frame background/shadow can be transparent @@ -655,8 +655,8 @@ bool SwTextFly::GetTop( const SwAnchoredObject* _pAnchoredObj, if( ( bInFootnote || bInFooterOrHeader ) && m_bTopRule ) { // #i26945# - const SwFrameFormat& rFrameFormat = _pAnchoredObj->GetFrameFormat(); - const SwFormatAnchor& rNewA = rFrameFormat.GetAnchor(); + const SwFrameFormat* pFrameFormat = _pAnchoredObj->GetFrameFormat(); + const SwFormatAnchor& rNewA = pFrameFormat->GetAnchor(); if (RndStdIds::FLY_AT_PAGE == rNewA.GetAnchorId()) { if ( bInFootnote ) @@ -664,7 +664,7 @@ bool SwTextFly::GetTop( const SwAnchoredObject* _pAnchoredObj, if ( bInFooterOrHeader ) { - const SwFormatVertOrient& aVert( rFrameFormat.GetVertOrient() ); + const SwFormatVertOrient& aVert(pFrameFormat->GetVertOrient()); bool bVertPrt = aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA || aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA; if( bVertPrt ) @@ -710,13 +710,14 @@ bool SwTextFly::GetTop( const SwAnchoredObject* _pAnchoredObj, { // Within chained Flys we only avoid Lower // #i68520# - const SwFormatChain &rChain = mpCurrAnchoredObj->GetFrameFormat().GetChain(); + const SwFrameFormat* pCurObjFormat = mpCurrAnchoredObj->GetFrameFormat(); + const SwFormatChain& rChain = pCurObjFormat->GetChain(); if ( !rChain.GetPrev() && !rChain.GetNext() ) { // #i26945# - const SwFormatAnchor& rNewA = _pAnchoredObj->GetFrameFormat().GetAnchor(); + const SwFormatAnchor& rNewA = _pAnchoredObj->GetFrameFormat()->GetAnchor(); // #i68520# - const SwFormatAnchor& rCurrA = mpCurrAnchoredObj->GetFrameFormat().GetAnchor(); + const SwFormatAnchor& rCurrA = pCurObjFormat->GetAnchor(); // If is anchored as character, its content // does not wrap around pNew @@ -768,78 +769,85 @@ bool SwTextFly::GetTop( const SwAnchoredObject* _pAnchoredObj, if ( bEvade ) { // #i26945# - const SwFormatAnchor& rNewA = _pAnchoredObj->GetFrameFormat().GetAnchor(); - OSL_ENSURE( RndStdIds::FLY_AS_CHAR != rNewA.GetAnchorId(), - "Don't call GetTop with a FlyInContentFrame" ); - if (RndStdIds::FLY_AT_PAGE == rNewA.GetAnchorId()) - return true; // We always avoid page anchored ones - - // If Flys anchored at paragraph are caught in a FlyCnt, then - // their influence ends at the borders of the FlyCnt! - // If we are currently formatting the text of the FlyCnt, then - // it has to get out of the way of the Frame anchored at paragraph! - // m_pCurrFrame is the anchor of pNew? - // #i26945# - const SwFrame* pTmp = _pAnchoredObj->GetAnchorFrame(); - if (pTmp == m_pCurrFrame) - return true; - if( pTmp->IsTextFrame() && ( pTmp->IsInFly() || pTmp->IsInFootnote() ) ) + if (const SwFrameFormat* pAnchoredObjFormat = _pAnchoredObj->GetFrameFormat()) { + const SwFormatAnchor& rNewA = pAnchoredObjFormat->GetAnchor(); + OSL_ENSURE(RndStdIds::FLY_AS_CHAR != rNewA.GetAnchorId(), + "Don't call GetTop with a FlyInContentFrame"); + if (RndStdIds::FLY_AT_PAGE == rNewA.GetAnchorId()) + return true; // We always avoid page anchored ones + + // If Flys anchored at paragraph are caught in a FlyCnt, then + // their influence ends at the borders of the FlyCnt! + // If we are currently formatting the text of the FlyCnt, then + // it has to get out of the way of the Frame anchored at paragraph! + // m_pCurrFrame is the anchor of pNew? // #i26945# - Point aPos = _pAnchoredObj->GetObjRect().Pos(); - pTmp = GetVirtualUpper( pTmp, aPos ); - } - // #i26945# - // If is a text frame inside a table, take the upper - // of the anchor frame, which contains the anchor position. - else if ( pTmp->IsTextFrame() && pTmp->IsInTab() ) - { - pTmp = const_cast(_pAnchoredObj) - ->GetAnchorFrameContainingAnchPos()->GetUpper(); - } - // #i28701# - consider all objects in same context, - // if wrapping style is considered on object positioning. - // Thus, text will wrap around negative positioned objects. - // #i3317# - remove condition on checking, - // if wrappings style is considered on object positioning. - // Thus, text is wrapping around negative positioned objects. - // #i35640# - no consideration of negative - // positioned objects, if wrapping style isn't considered on - // object position and former text wrapping is applied. - // This condition is typically for documents imported from the - // OpenOffice.org file format. - const IDocumentSettingAccess* pIDSA = &m_pCurrFrame->GetDoc().getIDocumentSettingAccess(); - if ( ( pIDSA->get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) || - !pIDSA->get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING) ) && - ::FindContext( pTmp, SwFrameType::None ) == ::FindContext(m_pCurrFrame, SwFrameType::None)) - { - return true; - } - - const SwFrame* pHeader = nullptr; - if (m_pCurrFrame->GetNext() != pTmp && - (IsFrameInSameContext( pTmp, m_pCurrFrame ) || - // #i13832#, #i24135# wrap around objects in page header - ( !pIDSA->get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING) && - nullptr != ( pHeader = pTmp->FindFooterOrHeader() ) && - m_pCurrFrame->IsInDocBody()))) - { - if( pHeader || RndStdIds::FLY_AT_FLY == rNewA.GetAnchorId() ) + const SwFrame* pTmp = _pAnchoredObj->GetAnchorFrame(); + if (pTmp == m_pCurrFrame) return true; - - // Compare indices: - // The Index of the other is retrieved from the anchor attr. - SwNodeOffset nTmpIndex = rNewA.GetAnchorNode()->GetIndex(); - // Now check whether the current paragraph is before the anchor - // of the displaced object in the text, then we don't have to - // get out of its way. - // If possible determine Index via SwFormatAnchor because - // otherwise it's quite expensive. - if (NODE_OFFSET_MAX == m_nCurrFrameNodeIndex) - m_nCurrFrameNodeIndex = m_pCurrFrame->GetTextNodeFirst()->GetIndex(); - - if (FrameContainsNode(*m_pCurrFrame, nTmpIndex) || nTmpIndex < m_nCurrFrameNodeIndex) + if (pTmp->IsTextFrame() && (pTmp->IsInFly() || pTmp->IsInFootnote())) + { + // #i26945# + Point aPos = _pAnchoredObj->GetObjRect().Pos(); + pTmp = GetVirtualUpper(pTmp, aPos); + } + // #i26945# + // If is a text frame inside a table, take the upper + // of the anchor frame, which contains the anchor position. + else if (pTmp->IsTextFrame() && pTmp->IsInTab()) + { + pTmp = const_cast(_pAnchoredObj) + ->GetAnchorFrameContainingAnchPos() + ->GetUpper(); + } + // #i28701# - consider all objects in same context, + // if wrapping style is considered on object positioning. + // Thus, text will wrap around negative positioned objects. + // #i3317# - remove condition on checking, + // if wrappings style is considered on object positioning. + // Thus, text is wrapping around negative positioned objects. + // #i35640# - no consideration of negative + // positioned objects, if wrapping style isn't considered on + // object position and former text wrapping is applied. + // This condition is typically for documents imported from the + // OpenOffice.org file format. + const IDocumentSettingAccess* pIDSA + = &m_pCurrFrame->GetDoc().getIDocumentSettingAccess(); + if ((pIDSA->get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) + || !pIDSA->get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING)) + && ::FindContext(pTmp, SwFrameType::None) + == ::FindContext(m_pCurrFrame, SwFrameType::None)) + { return true; + } + + const SwFrame* pHeader = nullptr; + if (m_pCurrFrame->GetNext() != pTmp + && (IsFrameInSameContext(pTmp, m_pCurrFrame) || + // #i13832#, #i24135# wrap around objects in page header + (!pIDSA->get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING) + && nullptr != (pHeader = pTmp->FindFooterOrHeader()) + && m_pCurrFrame->IsInDocBody()))) + { + if (pHeader || RndStdIds::FLY_AT_FLY == rNewA.GetAnchorId()) + return true; + + // Compare indices: + // The Index of the other is retrieved from the anchor attr. + SwNodeOffset nTmpIndex = rNewA.GetAnchorNode()->GetIndex(); + // Now check whether the current paragraph is before the anchor + // of the displaced object in the text, then we don't have to + // get out of its way. + // If possible determine Index via SwFormatAnchor because + // otherwise it's quite expensive. + if (NODE_OFFSET_MAX == m_nCurrFrameNodeIndex) + m_nCurrFrameNodeIndex = m_pCurrFrame->GetTextNodeFirst()->GetIndex(); + + if (FrameContainsNode(*m_pCurrFrame, nTmpIndex) + || nTmpIndex < m_nCurrFrameNodeIndex) + return true; + } } } } @@ -919,7 +927,7 @@ SwAnchoredObjList& SwTextFly::InitAnchoredObjList() !pAnchoredObj->ConsiderForTextWrap() || ( mbIgnoreObjsInHeaderFooter && !bFooterHeader && pAnchoredObj->GetAnchorFrame()->FindFooterOrHeader() ) || - ( bAllowCompatWrap && !pAnchoredObj->GetFrameFormat().GetFollowTextFlow().GetValue() ) + ( bAllowCompatWrap && !pAnchoredObj->GetFrameFormat()->GetFollowTextFlow().GetValue() ) ) { continue; @@ -957,13 +965,13 @@ SwAnchoredObjList& SwTextFly::InitAnchoredObjList() mpAnchoredObjList->insert( aInsPosIter, pAnchoredObj ); } - const SwFormatSurround &rFlyFormat = pAnchoredObj->GetFrameFormat().GetSurround(); + const SwFrameFormat* pObjFormat = pAnchoredObj->GetFrameFormat(); + const SwFormatSurround& rFlyFormat = pObjFormat->GetSurround(); // #i68520# if ( rFlyFormat.IsAnchorOnly() && pAnchoredObj->GetAnchorFrame() == GetMaster() ) { - const SwFormatVertOrient &rTmpFormat = - pAnchoredObj->GetFrameFormat().GetVertOrient(); + const SwFormatVertOrient &rTmpFormat = pObjFormat->GetVertOrient(); if( text::VertOrientation::BOTTOM != rTmpFormat.GetVertOrient() ) m_nMinBottom = ( aRectFnSet.IsVert() && m_nMinBottom ) ? std::min( m_nMinBottom, aBound.Left() ) : @@ -998,11 +1006,11 @@ SwTwips SwTextFly::CalcMinBottom() const for( size_t i = 0; i < nCount; ++i ) { SwAnchoredObject* pAnchoredObj = (*pDrawObj)[ i ]; - const SwFormatSurround &rFlyFormat = pAnchoredObj->GetFrameFormat().GetSurround(); + const SwFrameFormat* pObjFormat = pAnchoredObj->GetFrameFormat(); + const SwFormatSurround& rFlyFormat = pObjFormat->GetSurround(); if( rFlyFormat.IsAnchorOnly() ) { - const SwFormatVertOrient &rTmpFormat = - pAnchoredObj->GetFrameFormat().GetVertOrient(); + const SwFormatVertOrient &rTmpFormat = pObjFormat->GetVertOrient(); if( text::VertOrientation::BOTTOM != rTmpFormat.GetVertOrient() ) { const SwRect& aBound( pAnchoredObj->GetObjRectWithSpaces() ); @@ -1118,7 +1126,7 @@ bool SwTextFly::ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const if ( mpCurrAnchoredObj != pAnchoredObj && aRect.Overlaps( rRect ) ) { // #i68520# - const SwFormat* pFormat( &(pAnchoredObj->GetFrameFormat()) ); + const SwFormat* pFormat(pAnchoredObj->GetFrameFormat()); const SwFormatSurround &rSur = pFormat->GetSurround(); if( bAvoid ) { @@ -1405,7 +1413,7 @@ SwRect SwTextFly::AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj, css::text::WrapTextMode SwTextFly::GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const { - const SwFrameFormat* pFormat = &(pAnchoredObj->GetFrameFormat()); + const SwFrameFormat* pFormat = pAnchoredObj->GetFrameFormat(); const SwFormatSurround &rFlyFormat = pFormat->GetSurround(); css::text::WrapTextMode eSurroundForTextWrap = rFlyFormat.GetSurround(); diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 18eb78db83..302302a9a2 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1459,11 +1459,11 @@ SwDoc const& SwTextFrame::GetDoc() const } LanguageType SwTextFrame::GetLangOfChar(TextFrameIndex const nIndex, - sal_uInt16 const nScript, bool const bNoChar) const + sal_uInt16 const nScript, bool const bNoChar, bool const bNoneIfNoHyphenation) const { // a single character can be mapped uniquely! std::pair const pos(MapViewToModel(nIndex)); - return pos.first->GetLang(pos.second, bNoChar ? 0 : 1, nScript); + return pos.first->GetLang(pos.second, bNoChar ? 0 : 1, nScript, bNoneIfNoHyphenation); } void SwTextFrame::ResetPreps() @@ -3104,7 +3104,7 @@ bool SwTextFrame::Prepare( const PrepareHint ePrep, const void* pVoid, SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i]; // i#28701 - consider all // to-character anchored objects - if ( pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId() + if ( pAnchoredObj->GetFrameFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR ) { bFormat = true; -- cgit v1.2.3