diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 12:31:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 14:58:51 +0200 |
commit | 29489b33b435683021b72cb2bce27aba8cb7a430 (patch) | |
tree | 8e4e1c59d56d5ed0d0ca4d088419067041e4553a /sw | |
parent | a4244c0f05b95ded277a3a7ed217bf0451daa996 (diff) |
loplugin:flatten
Change-Id: I3b4226a9d089ec9aedab95d96e50a068f57a76c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123991
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/crsr/swcrsr.cxx | 62 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentContentOperationsManager.cxx | 74 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 48 | ||||
-rw-r--r-- | sw/source/core/doc/docnum.cxx | 52 | ||||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 30 | ||||
-rw-r--r-- | sw/source/core/text/porlay.cxx | 98 | ||||
-rw-r--r-- | sw/source/core/text/porrst.cxx | 42 | ||||
-rw-r--r-- | sw/source/core/txtnode/atrfld.cxx | 46 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/html/htmlflywriter.cxx | 52 | ||||
-rw-r--r-- | sw/source/filter/indexing/IndexingExport.cxx | 34 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par3.cxx | 38 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mmconfigitem.cxx | 24 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarTxtControl.cxx | 34 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx | 47 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 136 | ||||
-rw-r--r-- | sw/source/uibase/utlui/gotodlg.cxx | 22 |
18 files changed, 432 insertions, 432 deletions
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index a8adba16c10e..c799a0da3551 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1630,43 +1630,43 @@ void SwCursor::ExpandToSentenceBorders(SwRootFrame const*const pLayout) { SwTextNode* pStartNd = Start()->nNode.GetNode().GetTextNode(); SwTextNode* pEndNd = End()->nNode.GetNode().GetTextNode(); - if (pStartNd && pEndNd) - { - if (!HasMark()) - SetMark(); + if (!pStartNd || !pEndNd) + return; - OUString sStartText( lcl_MaskDeletedRedlines( pStartNd ) ); - OUString sEndText( pStartNd == pEndNd? sStartText : lcl_MaskDeletedRedlines( pEndNd ) ); + if (!HasMark()) + SetMark(); - SwCursorSaveState aSave( *this ); - sal_Int32 nStartPos = Start()->nContent.GetIndex(); - sal_Int32 nEndPos = End()->nContent.GetIndex(); + OUString sStartText( lcl_MaskDeletedRedlines( pStartNd ) ); + OUString sEndText( pStartNd == pEndNd? sStartText : lcl_MaskDeletedRedlines( pEndNd ) ); - { - HideWrapper w(pLayout, pStartNd, nStartPos, &sStartText); + SwCursorSaveState aSave( *this ); + sal_Int32 nStartPos = Start()->nContent.GetIndex(); + sal_Int32 nEndPos = End()->nContent.GetIndex(); - w.m_nPtIndex = g_pBreakIt->GetBreakIter()->beginOfSentence( - *w.m_pText, w.m_nPtIndex, - g_pBreakIt->GetLocale( pStartNd->GetLang( nStartPos ) ) ); - } - { - HideWrapper w(pLayout, pEndNd, nEndPos, &sEndText); + { + HideWrapper w(pLayout, pStartNd, nStartPos, &sStartText); - w.m_nPtIndex = g_pBreakIt->GetBreakIter()->endOfSentence( - *w.m_pText, w.m_nPtIndex, - g_pBreakIt->GetLocale( pEndNd->GetLang( nEndPos ) ) ); - } + w.m_nPtIndex = g_pBreakIt->GetBreakIter()->beginOfSentence( + *w.m_pText, w.m_nPtIndex, + g_pBreakIt->GetLocale( pStartNd->GetLang( nStartPos ) ) ); + } + { + HideWrapper w(pLayout, pEndNd, nEndPos, &sEndText); - // it is allowed to place the PaM just behind the last - // character in the text thus <= ...Len - if (nStartPos <= pStartNd->GetText().getLength() && nStartPos >= 0) - { - *GetMark() = SwPosition(*pStartNd, nStartPos); - } - if (nEndPos <= pEndNd->GetText().getLength() && nEndPos >= 0) - { - *GetPoint() = SwPosition(*pEndNd, nEndPos); - } + w.m_nPtIndex = g_pBreakIt->GetBreakIter()->endOfSentence( + *w.m_pText, w.m_nPtIndex, + g_pBreakIt->GetLocale( pEndNd->GetLang( nEndPos ) ) ); + } + + // it is allowed to place the PaM just behind the last + // character in the text thus <= ...Len + if (nStartPos <= pStartNd->GetText().getLength() && nStartPos >= 0) + { + *GetMark() = SwPosition(*pStartNd, nStartPos); + } + if (nEndPos <= pEndNd->GetText().getLength() && nEndPos >= 0) + { + *GetPoint() = SwPosition(*pEndNd, nEndPos); } } diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 4504b74bafd3..2f0ae4676697 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -1263,36 +1263,36 @@ namespace //local functions originally from docfmt.cxx SwRangeRedline * pRedline = new SwRangeRedline( RedlineType::Format, rRg ); auto const result(rDoc.getIDocumentRedlineAccess().AppendRedline( pRedline, true)); // store original text attributes to reject formatting change - if (IDocumentRedlineAccess::AppendResult::IGNORED != result) + if (IDocumentRedlineAccess::AppendResult::IGNORED == result) + return; + + // no existing format redline in the range + if (!xExtra) { - // no existing format redline in the range - if (!xExtra) - { - // Apply the first character's attributes to the ReplaceText - SfxItemSetFixed<RES_CHRATR_BEGIN, RES_TXTATR_WITHEND_END - 1, - RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1> aSet( rDoc.GetAttrPool() ); - SwTextNode * pNode = rRg.Start()->nNode.GetNode().GetTextNode(); - pNode->GetParaAttr( aSet, rRg.Start()->nContent.GetIndex() + 1, rRg.End()->nContent.GetIndex() ); + // Apply the first character's attributes to the ReplaceText + SfxItemSetFixed<RES_CHRATR_BEGIN, RES_TXTATR_WITHEND_END - 1, + RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1> aSet( rDoc.GetAttrPool() ); + SwTextNode * pNode = rRg.Start()->nNode.GetNode().GetTextNode(); + pNode->GetParaAttr( aSet, rRg.Start()->nContent.GetIndex() + 1, rRg.End()->nContent.GetIndex() ); - aSet.ClearItem( RES_TXTATR_REFMARK ); - aSet.ClearItem( RES_TXTATR_TOXMARK ); - aSet.ClearItem( RES_TXTATR_CJK_RUBY ); - aSet.ClearItem( RES_TXTATR_INETFMT ); - aSet.ClearItem( RES_TXTATR_META ); - aSet.ClearItem( RES_TXTATR_METAFIELD ); + aSet.ClearItem( RES_TXTATR_REFMARK ); + aSet.ClearItem( RES_TXTATR_TOXMARK ); + aSet.ClearItem( RES_TXTATR_CJK_RUBY ); + aSet.ClearItem( RES_TXTATR_INETFMT ); + aSet.ClearItem( RES_TXTATR_META ); + aSet.ClearItem( RES_TXTATR_METAFIELD ); - // After GetParaAttr aSet can contain INVALID_POOL_ITEM items, e.g. RES_TXTATR_CHARFMT - // and (a copy of) this SfxItemSet can be passed to MSWordExportBase::OutputItemSet - // which doesn't handle INVALID_POOL_ITEM items so clear InvalidItems here - aSet.ClearInvalidItems(); + // After GetParaAttr aSet can contain INVALID_POOL_ITEM items, e.g. RES_TXTATR_CHARFMT + // and (a copy of) this SfxItemSet can be passed to MSWordExportBase::OutputItemSet + // which doesn't handle INVALID_POOL_ITEM items so clear InvalidItems here + aSet.ClearInvalidItems(); - xExtra.reset(new SwRedlineExtraData_FormatColl("", USHRT_MAX, &aSet)); - } + xExtra.reset(new SwRedlineExtraData_FormatColl("", USHRT_MAX, &aSet)); + } - if (xExtra) - { - pRedline->SetExtraData(xExtra.get() ); - } + if (xExtra) + { + pRedline->SetExtraData(xExtra.get() ); } } @@ -2672,20 +2672,20 @@ void DocumentContentOperationsManager::MoveAndJoin( SwPaM& rPaM, SwPosition& rPo aIdx--; // in front of the move area! bool bRet = MoveRange( rPaM, rPos, SwMoveFlags::DEFAULT ); - if( bRet && !bOneNode ) + if( !bRet || bOneNode ) + return; + + if( bJoinText ) + ++aIdx; + SwTextNode * pTextNd = aIdx.GetNode().GetTextNode(); + SwNodeIndex aNxtIdx( aIdx ); + if( pTextNd && pTextNd->CanJoinNext( &aNxtIdx ) ) { - if( bJoinText ) - ++aIdx; - SwTextNode * pTextNd = aIdx.GetNode().GetTextNode(); - SwNodeIndex aNxtIdx( aIdx ); - if( pTextNd && pTextNd->CanJoinNext( &aNxtIdx ) ) - { - { // Block so SwIndex into node is deleted before Join - m_rDoc.CorrRel( aNxtIdx, SwPosition( aIdx, SwIndex(pTextNd, - pTextNd->GetText().getLength()) ), 0, true ); - } - pTextNd->JoinNext(); + { // Block so SwIndex into node is deleted before Join + m_rDoc.CorrRel( aNxtIdx, SwPosition( aIdx, SwIndex(pTextNd, + pTextNd->GetText().getLength()) ), 0, true ); } + pTextNd->JoinNext(); } } diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 82342dfbbb2e..2d799dccc6eb 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -437,36 +437,38 @@ namespace // delete the empty tracked table row (i.e. if it's last tracked deletion was accepted) void lcl_DeleteTrackedTableRow ( const SwPosition* pPos ) { - if ( const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox() ) - { - const SwTableLine* pLine = pBox->GetUpper(); - const SvxPrintItem *pHasTextChangesOnlyProp = - pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); - // empty table row with property "HasTextChangesOnly" = false - if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() && - pLine->IsEmpty() ) - { - SwCursor aCursor( *pPos, nullptr ); - pPos->GetDoc().DeleteRow( aCursor ); - } + const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox(); + if ( !pBox ) + return; + + const SwTableLine* pLine = pBox->GetUpper(); + const SvxPrintItem *pHasTextChangesOnlyProp = + pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); + // empty table row with property "HasTextChangesOnly" = false + if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() && + pLine->IsEmpty() ) + { + SwCursor aCursor( *pPos, nullptr ); + pPos->GetDoc().DeleteRow( aCursor ); } } // at rejection of a deletion in a table, remove the tracking of the table row void lcl_RemoveTrackingOfTableRow( const SwPosition* pPos ) { - if ( const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox() ) + const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox(); + if ( !pBox ) + return; + + const SwTableLine* pLine = pBox->GetUpper(); + const SvxPrintItem *pHasTextChangesOnlyProp = + pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); + // table row property "HasTextChangesOnly" is set and its value is false + if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() ) { - const SwTableLine* pLine = pBox->GetUpper(); - const SvxPrintItem *pHasTextChangesOnlyProp = - pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); - // table row property "HasTextChangesOnly" is set and its value is false - if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() ) - { - SvxPrintItem aUnsetTracking(RES_PRINT, true); - SwCursor aCursor( *pPos, nullptr ); - pPos->GetDoc().SetRowNotTracked( aCursor, aUnsetTracking ); - } + SvxPrintItem aUnsetTracking(RES_PRINT, true); + SwCursor aCursor( *pPos, nullptr ); + pPos->GetDoc().SetRowNotTracked( aCursor, aUnsetTracking ); } } diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 644d360bc6bf..60b8d82e7aa2 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1180,39 +1180,39 @@ void SwDoc::ReplaceNumRule( const SwPosition& rPos, { SwNumRule *pOldRule = FindNumRulePtr( rOldRule ), *pNewRule = FindNumRulePtr( rNewRule ); - if( pOldRule && pNewRule && pOldRule != pNewRule ) + if( !pOldRule || !pNewRule || pOldRule == pNewRule ) + return; + + SwUndoInsNum* pUndo = nullptr; + if (GetIDocumentUndoRedo().DoesUndo()) { - SwUndoInsNum* pUndo = nullptr; - if (GetIDocumentUndoRedo().DoesUndo()) - { - // Start/End for attributes! - GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr ); - pUndo = new SwUndoInsNum( rPos, *pNewRule, rOldRule ); - GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo)); - } + // Start/End for attributes! + GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr ); + pUndo = new SwUndoInsNum( rPos, *pNewRule, rOldRule ); + GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo)); + } - SwNumRule::tTextNodeList aTextNodeList; - pOldRule->GetTextNodeList( aTextNodeList ); - if ( !aTextNodeList.empty() ) - { - SwRegHistory aRegH( pUndo ? pUndo->GetHistory() : nullptr ); + SwNumRule::tTextNodeList aTextNodeList; + pOldRule->GetTextNodeList( aTextNodeList ); + if ( !aTextNodeList.empty() ) + { + SwRegHistory aRegH( pUndo ? pUndo->GetHistory() : nullptr ); - const SwTextNode* pGivenTextNode = rPos.nNode.GetNode().GetTextNode(); - SwNumRuleItem aRule( rNewRule ); - for ( SwTextNode* pTextNd : aTextNodeList ) + const SwTextNode* pGivenTextNode = rPos.nNode.GetNode().GetTextNode(); + SwNumRuleItem aRule( rNewRule ); + for ( SwTextNode* pTextNd : aTextNodeList ) + { + if ( pGivenTextNode && + pGivenTextNode->GetListId() == pTextNd->GetListId() ) { - if ( pGivenTextNode && - pGivenTextNode->GetListId() == pTextNd->GetListId() ) - { - aRegH.RegisterInModify( pTextNd, *pTextNd ); + aRegH.RegisterInModify( pTextNd, *pTextNd ); - pTextNd->SetAttr( aRule ); - pTextNd->NumRuleChgd(); - } + pTextNd->SetAttr( aRule ); + pTextNd->NumRuleChgd(); } - GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); - getIDocumentState().SetModified(); } + GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); + getIDocumentState().SetModified(); } } diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index f00e49883b4d..d6b49f81df75 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1422,19 +1422,19 @@ void SwTextBoxNode::AddTextBox(SdrObject* pDrawObject, SwFrameFormat* pNewTextBo void SwTextBoxNode::DelTextBox(const SdrObject* pDrawObject) { assert(pDrawObject); - if (!m_pTextBoxes.empty()) + if (m_pTextBoxes.empty()) + return; + + for (auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end();) { - for (auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end();) + if (it->m_pDrawObject == pDrawObject) { - if (it->m_pDrawObject == pDrawObject) - { - m_pOwnerShapeFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat( - it->m_pTextBoxFormat); - it = m_pTextBoxes.erase(it); - break; - } - ++it; + m_pOwnerShapeFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat( + it->m_pTextBoxFormat); + it = m_pTextBoxes.erase(it); + break; } + ++it; } } diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 76c961168110..9d25671ee56a 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2547,23 +2547,23 @@ SwFrameFormat::~SwFrameFormat() } } - if( nullptr != m_pOtherTextBoxFormat ) + if( nullptr == m_pOtherTextBoxFormat ) + return; + + auto pObj = FindRealSdrObject(); + if (Which() == RES_FLYFRMFMT && pObj) { - auto pObj = FindRealSdrObject(); - if (Which() == RES_FLYFRMFMT && pObj) - { - // This is a fly-frame-format just delete this - // textbox entry from the draw-frame-format. - m_pOtherTextBoxFormat->DelTextBox(pObj); - } + // This is a fly-frame-format just delete this + // textbox entry from the draw-frame-format. + m_pOtherTextBoxFormat->DelTextBox(pObj); + } - if (Which() == RES_DRAWFRMFMT) - { - // This format is the owner shape, so its time - // to del the textbox node. - delete m_pOtherTextBoxFormat; - m_pOtherTextBoxFormat = nullptr; - } + if (Which() == RES_DRAWFRMFMT) + { + // This format is the owner shape, so its time + // to del the textbox node. + delete m_pOtherTextBoxFormat; + m_pOtherTextBoxFormat = nullptr; } } diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 1380e886fed5..5e80f7cb1b30 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -627,70 +627,70 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) SetRedline( bHasRedline ); // redlining: set crossing out for deleted anchored objects - if ( bHasFlyPortion ) + if ( !bHasFlyPortion ) + return; + + SwLinePortion *pPos = mpNextPortion; + TextFrameIndex nLineLength; + while ( pPos ) { - SwLinePortion *pPos = mpNextPortion; - TextFrameIndex nLineLength; - while ( pPos ) + TextFrameIndex const nPorSttIdx = rInf.GetLineStart() + nLineLength; + nLineLength += pPos->GetLen(); + // anchored as characters + if( pPos->IsFlyCntPortion() ) { - TextFrameIndex const nPorSttIdx = rInf.GetLineStart() + nLineLength; - nLineLength += pPos->GetLen(); - // anchored as characters - if( pPos->IsFlyCntPortion() ) + bool bDeleted = false; + size_t nAuthor = std::string::npos; + if ( bHasRedline ) { - bool bDeleted = false; - size_t nAuthor = std::string::npos; - if ( bHasRedline ) - { - OUString sRedlineText; - bool bHasRedlineEnd; - enum RedlineType eRedlineEnd; - std::pair<SwTextNode const*, sal_Int32> const flyStart( - rInf.GetTextFrame()->MapViewToModel(nPorSttIdx)); - bool bHasFlyRedline = rLine.GetRedln()->CheckLine(flyStart.first->GetIndex(), - flyStart.second, flyStart.first->GetIndex(), flyStart.second, sRedlineText, - bHasRedlineEnd, eRedlineEnd, /*pAuthorAtPos=*/&nAuthor); - bDeleted = bHasFlyRedline && eRedlineEnd == RedlineType::Delete; - } - static_cast<SwFlyCntPortion*>(pPos)->SetDeleted(bDeleted); - static_cast<SwFlyCntPortion*>(pPos)->SetAuthor(nAuthor); + OUString sRedlineText; + bool bHasRedlineEnd; + enum RedlineType eRedlineEnd; + std::pair<SwTextNode const*, sal_Int32> const flyStart( + rInf.GetTextFrame()->MapViewToModel(nPorSttIdx)); + bool bHasFlyRedline = rLine.GetRedln()->CheckLine(flyStart.first->GetIndex(), + flyStart.second, flyStart.first->GetIndex(), flyStart.second, sRedlineText, + bHasRedlineEnd, eRedlineEnd, /*pAuthorAtPos=*/&nAuthor); + bDeleted = bHasFlyRedline && eRedlineEnd == RedlineType::Delete; } - // anchored to characters - else if ( pPos->IsFlyPortion() ) + static_cast<SwFlyCntPortion*>(pPos)->SetDeleted(bDeleted); + static_cast<SwFlyCntPortion*>(pPos)->SetAuthor(nAuthor); + } + // anchored to characters + else if ( pPos->IsFlyPortion() ) + { + const IDocumentRedlineAccess& rIDRA = + rInf.GetTextFrame()->GetDoc().getIDocumentRedlineAccess(); + SwSortedObjs *pObjs = rInf.GetTextFrame()->GetDrawObjs(); + if ( pObjs && IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) ) { - const IDocumentRedlineAccess& rIDRA = - rInf.GetTextFrame()->GetDoc().getIDocumentRedlineAccess(); - SwSortedObjs *pObjs = rInf.GetTextFrame()->GetDrawObjs(); - if ( pObjs && IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) ) + for ( size_t i = 0; rInf.GetTextFrame()->GetDrawObjs() && i < pObjs->size(); ++i ) { - for ( size_t i = 0; rInf.GetTextFrame()->GetDrawObjs() && i < pObjs->size(); ++i ) + SwAnchoredObject* pAnchoredObj = (*rInf.GetTextFrame()->GetDrawObjs())[i]; + if ( auto pFly = pAnchoredObj->DynCastFlyFrame() ) { - SwAnchoredObject* pAnchoredObj = (*rInf.GetTextFrame()->GetDrawObjs())[i]; - if ( auto pFly = pAnchoredObj->DynCastFlyFrame() ) + bool bDeleted = false; + size_t nAuthor = std::string::npos; + const SwFormatAnchor& rAnchor = pAnchoredObj->GetFrameFormat().GetAnchor(); + if ( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR ) { - bool bDeleted = false; - size_t nAuthor = std::string::npos; - const SwFormatAnchor& rAnchor = pAnchoredObj->GetFrameFormat().GetAnchor(); - if ( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR ) + SwPosition aAnchor = *rAnchor.GetContentAnchor(); + SwRedlineTable::size_type n = 0; + const SwRangeRedline* pFnd = + rIDRA.GetRedlineTable().FindAtPosition( aAnchor, n ); + if ( pFnd && RedlineType::Delete == pFnd->GetType() ) { - SwPosition aAnchor = *rAnchor.GetContentAnchor(); - SwRedlineTable::size_type n = 0; - const SwRangeRedline* pFnd = - rIDRA.GetRedlineTable().FindAtPosition( aAnchor, n ); - if ( pFnd && RedlineType::Delete == pFnd->GetType() ) - { - bDeleted = true; - nAuthor = pFnd->GetAuthor(); - } + bDeleted = true; + nAuthor = pFnd->GetAuthor(); } - pFly->SetDeleted(bDeleted); - pFly->SetAuthor(nAuthor); } + pFly->SetDeleted(bDeleted); + pFly->SetAuthor(nAuthor); } } } - pPos = pPos->GetNextPortion(); } + pPos = pPos->GetNextPortion(); } } diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 95ec669dddcc..c762056c30fe 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -120,34 +120,34 @@ void SwBreakPortion::Paint( const SwTextPaintInfo &rInf ) const rInf.DrawLineBreak( *this ); // paint redlining - if (m_eRedline != RedlineType::None) + if (m_eRedline == RedlineType::None) + return; + + sal_Int16 nNoBreakWidth = rInf.GetTextSize(S_NOBREAK_FOR_REDLINE).Width(); + if ( nNoBreakWidth > 0 ) { - sal_Int16 nNoBreakWidth = rInf.GetTextSize(S_NOBREAK_FOR_REDLINE).Width(); - if ( nNoBreakWidth > 0 ) - { - // approximate portion size with multiple no-break spaces - // and draw these spaces (at least a single one) by DrawText - // painting the requested redline underline/strikeout - sal_Int16 nSpaces = (LINE_BREAK_WIDTH + nNoBreakWidth/2) / nNoBreakWidth; - OUStringBuffer aBuf(S_NOBREAK_FOR_REDLINE); - for (sal_Int16 i = 1; i < nSpaces; ++i) - aBuf.append(S_NOBREAK_FOR_REDLINE); + // approximate portion size with multiple no-break spaces + // and draw these spaces (at least a single one) by DrawText + // painting the requested redline underline/strikeout + sal_Int16 nSpaces = (LINE_BREAK_WIDTH + nNoBreakWidth/2) / nNoBreakWidth; + OUStringBuffer aBuf(S_NOBREAK_FOR_REDLINE); + for (sal_Int16 i = 1; i < nSpaces; ++i) + aBuf.append(S_NOBREAK_FOR_REDLINE); - const SwFont* pOldFnt = rInf.GetFont(); + const SwFont* pOldFnt = rInf.GetFont(); - SwFont aFont(*pOldFnt); + SwFont aFont(*pOldFnt); - if (m_eRedline == RedlineType::Delete) - aFont.SetUnderline( LINESTYLE_NONE ); - else - aFont.SetStrikeout( STRIKEOUT_NONE ); + if (m_eRedline == RedlineType::Delete) + aFont.SetUnderline( LINESTYLE_NONE ); + else + aFont.SetStrikeout( STRIKEOUT_NONE ); - const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont); + const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont); - rInf.DrawText(aBuf.makeStringAndClear(), *this); + rInf.DrawText(aBuf.makeStringAndClear(), *this); - const_cast<SwTextPaintInfo&>(rInf).SetFont(const_cast<SwFont*>(pOldFnt)); - } + const_cast<SwTextPaintInfo&>(rInf).SetFont(const_cast<SwFont*>(pOldFnt)); } } diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 05d10a2aae40..c9ced5ea7a1d 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -376,35 +376,35 @@ void SwFormatField::UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* p } if(bTriggerNode) pTextNd->TriggerNodeUpdate(sw::LegacyModifyHint(pNodeOld, pNodeNew)); - if(bExpand) + if(!bExpand) + return; + + bool bForceNotify = pOld == nullptr && pNew == nullptr; + if (bForceNotify) { - bool bForceNotify = pOld == nullptr && pNew == nullptr; - if (bForceNotify) + // Force notify was added for conditional text fields, at least the below fields need + // no forced notify. + const SwField* pField = mpTextField->GetFormatField().GetField(); + const SwFieldIds nWhich = pField->GetTyp()->Which(); + if (nWhich == SwFieldIds::DocInfo) { - // Force notify was added for conditional text fields, at least the below fields need - // no forced notify. - const SwField* pField = mpTextField->GetFormatField().GetField(); - const SwFieldIds nWhich = pField->GetTyp()->Which(); - if (nWhich == SwFieldIds::DocInfo) + auto pDocInfoField = static_cast<const SwDocInfoField*>(pField); + sal_uInt16 nSubType = pDocInfoField->GetSubType(); + // Do not consider extended SubTypes. + nSubType &= 0xff; + switch (nSubType) { - auto pDocInfoField = static_cast<const SwDocInfoField*>(pField); - sal_uInt16 nSubType = pDocInfoField->GetSubType(); - // Do not consider extended SubTypes. - nSubType &= 0xff; - switch (nSubType) - { - case nsSwDocInfoSubType::DI_TITLE: - case nsSwDocInfoSubType::DI_SUBJECT: - case nsSwDocInfoSubType::DI_CHANGE: - case nsSwDocInfoSubType::DI_CUSTOM: - bForceNotify = false; - break; - } + case nsSwDocInfoSubType::DI_TITLE: + case nsSwDocInfoSubType::DI_SUBJECT: + case nsSwDocInfoSubType::DI_CHANGE: + case nsSwDocInfoSubType::DI_CUSTOM: + bForceNotify = false; + break; } } - - mpTextField->ExpandTextField(bForceNotify); } + + mpTextField->ExpandTextField(bForceNotify); } bool SwFormatField::GetInfo( SfxPoolItem& rInfo ) const diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index dcf25fadde59..4c35a9248665 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1416,10 +1416,9 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& if (!pEntry) { // Hack to skip the dummy CursorNotIgnoreTables property - if (rPropertyName == "CursorNotIgnoreTables") - return; - else + if (rPropertyName != "CursorNotIgnoreTables") throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast <cppu::OWeakObject*> (this)); + return; } const sal_uInt8 nMemberId(pEntry->nMemberId); diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 6c7d9003ceb3..fc7bf6edbc80 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -1757,32 +1757,32 @@ static Writer& OutHTML_FrameFormatAsDivOrSpan( Writer& rWrt, static void OutHTML_ImageOLEStart(SwHTMLWriter& rHTMLWrt, const Graphic& rGraphic, const SwFrameFormat& rFrameFormat) { - if (rHTMLWrt.mbReqIF && rHTMLWrt.m_bExportImagesAsOLE) - { - // Write the original image as an RTF fragment. - OUString aFileName; - if (rHTMLWrt.GetOrigFileName()) - aFileName = *rHTMLWrt.GetOrigFileName(); - INetURLObject aURL(aFileName); - OUString aName = aURL.getBase() + "_" + aURL.getExtension() + "_" - + OUString::number(rGraphic.GetChecksum(), 16); - aURL.setBase(aName); - aURL.setExtension(u"ole"); - aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); - - SvFileStream aOutStream(aFileName, StreamMode::WRITE); - if (!SwReqIfReader::WrapGraphicInRtf(rGraphic, rFrameFormat, aOutStream)) - SAL_WARN("sw.html", "SwReqIfReader::WrapGraphicInRtf() failed"); - - // Refer to this data. - aFileName = URIHelper::simpleNormalizedMakeRelative(rHTMLWrt.GetBaseURL(), aFileName); - rHTMLWrt.Strm().WriteOString( - OStringConcatenation("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object)); - rHTMLWrt.Strm().WriteOString(OStringConcatenation(" data=\"" + aFileName.toUtf8() + "\"")); - rHTMLWrt.Strm().WriteOString(" type=\"text/rtf\""); - rHTMLWrt.Strm().WriteOString(">"); - rHTMLWrt.OutNewLine(); - } + if (!rHTMLWrt.mbReqIF || !rHTMLWrt.m_bExportImagesAsOLE) + return; + + // Write the original image as an RTF fragment. + OUString aFileName; + if (rHTMLWrt.GetOrigFileName()) + aFileName = *rHTMLWrt.GetOrigFileName(); + INetURLObject aURL(aFileName); + OUString aName = aURL.getBase() + "_" + aURL.getExtension() + "_" + + OUString::number(rGraphic.GetChecksum(), 16); + aURL.setBase(aName); + aURL.setExtension(u"ole"); + aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); + + SvFileStream aOutStream(aFileName, StreamMode::WRITE); + if (!SwReqIfReader::WrapGraphicInRtf(rGraphic, rFrameFormat, aOutStream)) + SAL_WARN("sw.html", "SwReqIfReader::WrapGraphicInRtf() failed"); + + // Refer to this data. + aFileName = URIHelper::simpleNormalizedMakeRelative(rHTMLWrt.GetBaseURL(), aFileName); + rHTMLWrt.Strm().WriteOString( + OStringConcatenation("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object)); + rHTMLWrt.Strm().WriteOString(OStringConcatenation(" data=\"" + aFileName.toUtf8() + "\"")); + rHTMLWrt.Strm().WriteOString(" type=\"text/rtf\""); + rHTMLWrt.Strm().WriteOString(">"); + rHTMLWrt.OutNewLine(); } /// Ends the OLE version of an image in the ReqIF + OLE case. diff --git a/sw/source/filter/indexing/IndexingExport.cxx b/sw/source/filter/indexing/IndexingExport.cxx index e4532aaf6f34..97e90b08bc89 100644 --- a/sw/source/filter/indexing/IndexingExport.cxx +++ b/sw/source/filter/indexing/IndexingExport.cxx @@ -120,24 +120,24 @@ public: m_rXmlWriter.endElement(); SdrTextObj* pTextObject = dynamic_cast<SdrTextObj*>(pObject); - if (pTextObject) + if (!pTextObject) + return; + + OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject(); + if (!pOutlinerParagraphObject) + return; + + const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject(); + for (sal_Int32 nParagraph = 0; nParagraph < aEdit.GetParagraphCount(); ++nParagraph) { - OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject(); - if (pOutlinerParagraphObject) - { - const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject(); - for (sal_Int32 nParagraph = 0; nParagraph < aEdit.GetParagraphCount(); ++nParagraph) - { - OUString sText = aEdit.GetText(nParagraph); - - m_rXmlWriter.startElement("paragraph"); - m_rXmlWriter.attribute("index", nParagraph); - m_rXmlWriter.attribute("node_type", "common"); - m_rXmlWriter.attribute("object_name", pObject->GetName()); - m_rXmlWriter.content(sText); - m_rXmlWriter.endElement(); - } - } + OUString sText = aEdit.GetText(nParagraph); + + m_rXmlWriter.startElement("paragraph"); + m_rXmlWriter.attribute("index", nParagraph); + m_rXmlWriter.attribute("node_type", "common"); + m_rXmlWriter.attribute("object_name", pObject->GetName()); + m_rXmlWriter.content(sText); + m_rXmlWriter.endElement(); } } diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index f8bf63264e62..44b43a1f864d 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -1766,28 +1766,28 @@ void SwWW8ImplReader::RegisterNumFormatOnStyle(sal_uInt16 nStyle) rStyleInf.maWordLR.reset(ItemGet<SvxLRSpaceItem>(*rStyleInf.m_pFormat, RES_LR_SPACE).Clone()); // Phase 2: refresh StyleDef after reading all Lists - if (rStyleInf.m_nLFOIndex < USHRT_MAX && rStyleInf.m_nListLevel < WW8ListManager::nMaxLevel) - { - std::vector<sal_uInt8> aParaSprms; - SwNumRule* pNmRule = m_xLstManager->GetNumRuleForActivation( - rStyleInf.m_nLFOIndex, rStyleInf.m_nListLevel, aParaSprms); + if (rStyleInf.m_nLFOIndex >= USHRT_MAX || rStyleInf.m_nListLevel >= WW8ListManager::nMaxLevel) + return; - if (pNmRule != nullptr) - { - if (rStyleInf.IsWW8BuiltInHeadingStyle() - && rStyleInf.HasWW8OutlineLevel()) - { - rStyleInf.m_pOutlineNumrule = pNmRule; - } - else - { - rStyleInf.m_pFormat->SetFormatAttr( - SwNumRuleItem(pNmRule->GetName())); - rStyleInf.m_bHasStyNumRule = true; - } + std::vector<sal_uInt8> aParaSprms; + SwNumRule* pNmRule = m_xLstManager->GetNumRuleForActivation( + rStyleInf.m_nLFOIndex, rStyleInf.m_nListLevel, aParaSprms); - SetStyleIndent(rStyleInf, pNmRule->Get(rStyleInf.m_nListLevel)); + if (pNmRule != nullptr) + { + if (rStyleInf.IsWW8BuiltInHeadingStyle() + && rStyleInf.HasWW8OutlineLevel()) + { + rStyleInf.m_pOutlineNumrule = pNmRule; } + else + { + rStyleInf.m_pFormat->SetFormatAttr( + SwNumRuleItem(pNmRule->GetName())); + rStyleInf.m_bHasStyNumRule = true; + } + + SetStyleIndent(rStyleInf, pNmRule->Get(rStyleInf.m_nListLevel)); } } diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx index 36986ba59f5e..cd46d6b386eb 100644 --- a/sw/source/uibase/dbui/mmconfigitem.cxx +++ b/sw/source/uibase/dbui/mmconfigitem.cxx @@ -330,18 +330,18 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() : } } //check if the saved documents still exist - if(m_aSavedDocuments.hasElements()) - { - uno::Sequence< OUString > aTempDocuments(m_aSavedDocuments.getLength()); - auto begin = aTempDocuments.getArray(); - OUString* pTempDocuments = std::copy_if(std::cbegin(m_aSavedDocuments), std::cend(m_aSavedDocuments), begin, - [](const OUString& rDoc) { return SWUnoHelper::UCB_IsFile( rDoc ); }); - sal_Int32 nIndex = static_cast<sal_Int32>(std::distance(begin, pTempDocuments)); - if(nIndex < m_aSavedDocuments.getLength()) - { - m_aSavedDocuments.swap(aTempDocuments); - m_aSavedDocuments.realloc(nIndex); - } + if(!m_aSavedDocuments.hasElements()) + return; + + uno::Sequence< OUString > aTempDocuments(m_aSavedDocuments.getLength()); + auto begin = aTempDocuments.getArray(); + OUString* pTempDocuments = std::copy_if(std::cbegin(m_aSavedDocuments), std::cend(m_aSavedDocuments), begin, + [](const OUString& rDoc) { return SWUnoHelper::UCB_IsFile( rDoc ); }); + sal_Int32 nIndex = static_cast<sal_Int32>(std::distance(begin, pTempDocuments)); + if(nIndex < m_aSavedDocuments.getLength()) + { + m_aSavedDocuments.swap(aTempDocuments); + m_aSavedDocuments.realloc(nIndex); } } diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx index f520501c13f1..df1636ea510c 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx @@ -251,23 +251,23 @@ void SidebarTextControl::Paint(vcl::RenderContext& rRenderContext, const tools:: DoPaint(rRenderContext, rRect); - if (mrSidebarWin.GetLayoutStatus() == SwPostItHelper::DELETED) - { - const AntialiasingFlags nFormerAntialiasing( rRenderContext.GetAntialiasing() ); - const bool bIsAntiAliasing = officecfg::Office::Common::Drawinglayer::AntiAliasing::get(); - if ( bIsAntiAliasing ) - rRenderContext.SetAntialiasing(AntialiasingFlags::Enable); - rRenderContext.SetLineColor(mrSidebarWin.GetChangeColor()); - rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos), - rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), - aSize.Height() * 0.95))); - rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), - 0)), - rRenderContext.PixelToLogic(aPos + Point(0, - aSize.Height() * 0.95))); - if ( bIsAntiAliasing ) - rRenderContext.SetAntialiasing(nFormerAntialiasing); - } + if (mrSidebarWin.GetLayoutStatus() != SwPostItHelper::DELETED) + return; + + const AntialiasingFlags nFormerAntialiasing( rRenderContext.GetAntialiasing() ); + const bool bIsAntiAliasing = officecfg::Office::Common::Drawinglayer::AntiAliasing::get(); + if ( bIsAntiAliasing ) + rRenderContext.SetAntialiasing(AntialiasingFlags::Enable); + rRenderContext.SetLineColor(mrSidebarWin.GetChangeColor()); + rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos), + rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), + aSize.Height() * 0.95))); + rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), + 0)), + rRenderContext.PixelToLogic(aPos + Point(0, + aSize.Height() * 0.95))); + if ( bIsAntiAliasing ) + rRenderContext.SetAntialiasing(nFormerAntialiasing); } void SidebarTextControl::MakeVisible() diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx index bd7274bde397..48c2de119311 100644 --- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx +++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx @@ -387,30 +387,29 @@ static void MetadataToTreeNode(const css::uno::Reference<css::uno::XInterface>& { uno::Reference<rdf::XMetadatable> xMeta(rSource, uno::UNO_QUERY_THROW); // don't add tree node "Metadata Reference", if there is no xml:id - if (xMeta.is() && !xMeta->getMetadataReference().Second.isEmpty()) - { - svx::sidebar::TreeNode aCurNode; - aCurNode.sNodeName = PropertyNametoRID("MetadataReference"); - aCurNode.NodeType = svx::sidebar::TreeNode::ComplexProperty; - - aCurNode.children.push_back( - SimplePropToTreeNode("xml:id", uno::makeAny(xMeta->getMetadataReference().Second))); - - // list associated (predicate, object) pairs of the actual subject - // under the tree node "Metadata Reference" - SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current()); - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(pDocSh->GetBaseModel(), - uno::UNO_QUERY); - const uno::Reference<rdf::XRepository>& xRepo = xDocumentMetadataAccess->getRDFRepository(); - const css::uno::Reference<css::rdf::XResource> xSubject(rSource, uno::UNO_QUERY); - std::map<OUString, OUString> xStatements - = SwRDFHelper::getStatements(pDocSh->GetBaseModel(), xRepo->getGraphNames(), xSubject); - for (const auto& pair : xStatements) - aCurNode.children.push_back( - SimplePropToTreeNode(pair.first, uno::makeAny(pair.second))); - - rNode.children.push_back(aCurNode); - } + if (!xMeta.is() || xMeta->getMetadataReference().Second.isEmpty()) + return; + + svx::sidebar::TreeNode aCurNode; + aCurNode.sNodeName = PropertyNametoRID("MetadataReference"); + aCurNode.NodeType = svx::sidebar::TreeNode::ComplexProperty; + + aCurNode.children.push_back( + SimplePropToTreeNode("xml:id", uno::makeAny(xMeta->getMetadataReference().Second))); + + // list associated (predicate, object) pairs of the actual subject + // under the tree node "Metadata Reference" + SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current()); + uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(pDocSh->GetBaseModel(), + uno::UNO_QUERY); + const uno::Reference<rdf::XRepository>& xRepo = xDocumentMetadataAccess->getRDFRepository(); + const css::uno::Reference<css::rdf::XResource> xSubject(rSource, uno::UNO_QUERY); + std::map<OUString, OUString> xStatements + = SwRDFHelper::getStatements(pDocSh->GetBaseModel(), xRepo->getGraphNames(), xSubject); + for (const auto& pair : xStatements) + aCurNode.children.push_back(SimplePropToTreeNode(pair.first, uno::makeAny(pair.second))); + + rNode.children.push_back(aCurNode); } static svx::sidebar::TreeNode diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 34588eee0dbe..3e91ee202e21 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -3378,64 +3378,64 @@ static void lcl_SelectByContentTypeAndAddress(SwContentTree* pThis, weld::TreeVi bFoundEntry = rContentTree.iter_next_sibling(*xIter); } - if (bFoundEntry) - { - // assure content type entry is expanded - rContentTree.expand_row(*xIter); + if (!bFoundEntry) + return; - // find content type content entry and select it - const void* p = nullptr; - while (rContentTree.iter_next(*xIter) && lcl_IsContent(*xIter, rContentTree)) + // assure content type entry is expanded + rContentTree.expand_row(*xIter); + + // find content type content entry and select it + const void* p = nullptr; + while (rContentTree.iter_next(*xIter) && lcl_IsContent(*xIter, rContentTree)) + { + void* pUserData = reinterpret_cast<void*>(rContentTree.get_id(*xIter).toInt64()); + switch( nType ) { - void* pUserData = reinterpret_cast<void*>(rContentTree.get_id(*xIter).toInt64()); - switch( nType ) + case ContentTypeId::FOOTNOTE: { - case ContentTypeId::FOOTNOTE: - { - assert(dynamic_cast<SwTextFootnoteContent*>(static_cast<SwTypeNumber*>(pUserData))); - SwTextFootnoteContent* pCnt = static_cast<SwTextFootnoteContent*>(pUserData); - p = pCnt->GetTextFootnote(); - break; - } - case ContentTypeId::URLFIELD: - { - assert(dynamic_cast<SwURLFieldContent*>(static_cast<SwTypeNumber*>(pUserData))); - SwURLFieldContent* pCnt = static_cast<SwURLFieldContent*>(pUserData); - p = static_cast<const SwTextAttr*>(pCnt->GetINetAttr()); - break; - } - case ContentTypeId::TEXTFIELD: - { - assert(dynamic_cast<SwTextFieldContent*>(static_cast<SwTypeNumber*>(pUserData))); - SwTextFieldContent* pCnt = static_cast/*reinterpret_cast*/<SwTextFieldContent*>(pUserData); - p = pCnt->GetFormatField()->GetField(); - break; - } - case ContentTypeId::POSTIT: - { - assert(dynamic_cast<SwPostItContent*>(static_cast<SwTypeNumber*>(pUserData))); - SwPostItContent* pCnt = static_cast<SwPostItContent*>(pUserData); - p = pCnt->GetPostIt()->GetField(); - break; - } - default: - break; + assert(dynamic_cast<SwTextFootnoteContent*>(static_cast<SwTypeNumber*>(pUserData))); + SwTextFootnoteContent* pCnt = static_cast<SwTextFootnoteContent*>(pUserData); + p = pCnt->GetTextFootnote(); + break; } - if (ptr == p) + case ContentTypeId::URLFIELD: { - // get first selected for comparison - std::unique_ptr<weld::TreeIter> xFirstSelected(rContentTree.make_iterator()); - if (!rContentTree.get_selected(xFirstSelected.get())) - xFirstSelected.reset(); - if (rContentTree.count_selected_rows() != 1 || - rContentTree.iter_compare(*xIter, *xFirstSelected) != 0) - { - // unselect all entries and make passed entry visible and selected - rContentTree.set_cursor(*xIter); - pThis->Select(); - } - return; + assert(dynamic_cast<SwURLFieldContent*>(static_cast<SwTypeNumber*>(pUserData))); + SwURLFieldContent* pCnt = static_cast<SwURLFieldContent*>(pUserData); + p = static_cast<const SwTextAttr*>(pCnt->GetINetAttr()); + break; + } + case ContentTypeId::TEXTFIELD: + { + assert(dynamic_cast<SwTextFieldContent*>(static_cast<SwTypeNumber*>(pUserData))); + SwTextFieldContent* pCnt = static_cast/*reinterpret_cast*/<SwTextFieldContent*>(pUserData); + p = pCnt->GetFormatField()->GetField(); + break; + } + case ContentTypeId::POSTIT: + { + assert(dynamic_cast<SwPostItContent*>(static_cast<SwTypeNumber*>(pUserData))); + SwPostItContent* pCnt = static_cast<SwPostItContent*>(pUserData); + p = pCnt->GetPostIt()->GetField(); + break; } + default: + break; + } + if (ptr == p) + { + // get first selected for comparison + std::unique_ptr<weld::TreeIter> xFirstSelected(rContentTree.make_iterator()); + if (!rContentTree.get_selected(xFirstSelected.get())) + xFirstSelected.reset(); + if (rContentTree.count_selected_rows() != 1 || + rContentTree.iter_compare(*xIter, *xFirstSelected) != 0) + { + // unselect all entries and make passed entry visible and selected + rContentTree.set_cursor(*xIter); + pThis->Select(); + } + return; } } } @@ -3452,26 +3452,26 @@ static void lcl_SelectByContentTypeAndName(SwContentTree* pThis, weld::TreeView& while (bFoundEntry && rContentTypeName != rContentTree.get_text(*xIter)) bFoundEntry = rContentTree.iter_next_sibling(*xIter); // find content type content entry and select it - if (bFoundEntry) + if (!bFoundEntry) + return; + + rContentTree.expand_row(*xIter); // assure content type entry is expanded + while (rContentTree.iter_next(*xIter) && lcl_IsContent(*xIter, rContentTree)) { - rContentTree.expand_row(*xIter); // assure content type entry is expanded - while (rContentTree.iter_next(*xIter) && lcl_IsContent(*xIter, rContentTree)) + if (rName == rContentTree.get_text(*xIter)) { - if (rName == rContentTree.get_text(*xIter)) + // get first selected for comparison + std::unique_ptr<weld::TreeIter> xFirstSelected(rContentTree.make_iterator()); + if (!rContentTree.get_selected(xFirstSelected.get())) + xFirstSelected.reset(); + if (rContentTree.count_selected_rows() != 1 || + rContentTree.iter_compare(*xIter, *xFirstSelected) != 0) { - // get first selected for comparison - std::unique_ptr<weld::TreeIter> xFirstSelected(rContentTree.make_iterator()); - if (!rContentTree.get_selected(xFirstSelected.get())) - xFirstSelected.reset(); - if (rContentTree.count_selected_rows() != 1 || - rContentTree.iter_compare(*xIter, *xFirstSelected) != 0) - { - // unselect all entries and make passed entry visible and selected - rContentTree.set_cursor(*xIter); - pThis->Select(); - } - break; + // unselect all entries and make passed entry visible and selected + rContentTree.set_cursor(*xIter); + pThis->Select(); } + break; } } } diff --git a/sw/source/uibase/utlui/gotodlg.cxx b/sw/source/uibase/utlui/gotodlg.cxx index 050f6507bfc8..9ab0d366db35 100644 --- a/sw/source/uibase/utlui/gotodlg.cxx +++ b/sw/source/uibase/utlui/gotodlg.cxx @@ -49,19 +49,19 @@ SwGotoPageDlg::SwGotoPageDlg(weld::Window* pParent, SfxBindings* _pBindings) IMPL_LINK_NOARG(SwGotoPageDlg, PageModifiedHdl, weld::Entry&, void) { - if (!mxMtrPageCtrl->get_text().isEmpty()) - { - int page_value = mxMtrPageCtrl->get_text().toInt32(); + if (mxMtrPageCtrl->get_text().isEmpty()) + return; - if (page_value <= 0) - mxMtrPageCtrl->set_value(1); - else if (page_value > mnMaxPageCnt) - mxMtrPageCtrl->set_value(mnMaxPageCnt); - else - mxMtrPageCtrl->set_value(page_value); + int page_value = mxMtrPageCtrl->get_text().toInt32(); - mxMtrPageCtrl->set_position(-1); - } + if (page_value <= 0) + mxMtrPageCtrl->set_value(1); + else if (page_value > mnMaxPageCnt) + mxMtrPageCtrl->set_value(mnMaxPageCnt); + else + mxMtrPageCtrl->set_value(page_value); + + mxMtrPageCtrl->set_position(-1); } SwView* SwGotoPageDlg::GetCreateView() const |