From b624b13b3d5a8e573c7de8158cadc66b1982d157 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 26 Mar 2021 13:35:54 +0200 Subject: loplugin:flatten Change-Id: Ib7a895fba66f8dc9b6501e61631c02694053b7fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113157 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/uibase/utlui/content.cxx | 106 ++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'sw/source/uibase/utlui') diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index fe9da9cfc0e1..265f2b28dc90 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -3165,34 +3165,34 @@ void SwContentTree::HideTree() static void lcl_SelectByContentTypeAndName(SwContentTree* pThis, weld::TreeView& rContentTree, std::u16string_view rContentTypeName, std::u16string_view rName) { - if (!rName.empty()) + if (rName.empty()) + return; + + // find content type entry + std::unique_ptr xIter(rContentTree.make_iterator()); + bool bFoundEntry = rContentTree.get_iter_first(*xIter); + while (bFoundEntry && rContentTypeName != rContentTree.get_text(*xIter)) + bFoundEntry = rContentTree.iter_next_sibling(*xIter); + // find content type content entry and select it + if (bFoundEntry) { - // find content type entry - std::unique_ptr xIter(rContentTree.make_iterator()); - bool bFoundEntry = rContentTree.get_iter_first(*xIter); - while (bFoundEntry && rContentTypeName != rContentTree.get_text(*xIter)) - bFoundEntry = rContentTree.iter_next_sibling(*xIter); - // find content type content entry and select it - if (bFoundEntry) + 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 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 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; } } } @@ -3405,41 +3405,41 @@ void SwContentTree::SelectOutlinesWithSelection() } } while (pCursor && pCursor != pFirstCursor); - if (!aOutlinePositions.empty()) - { - // remove duplicates before selecting - aOutlinePositions.erase(std::unique(aOutlinePositions.begin(), aOutlinePositions.end()), - aOutlinePositions.end()); + if (aOutlinePositions.empty()) + return; - m_xTreeView->unselect_all(); + // remove duplicates before selecting + aOutlinePositions.erase(std::unique(aOutlinePositions.begin(), aOutlinePositions.end()), + aOutlinePositions.end()); - for (auto nOutlinePosition : aOutlinePositions) - { - m_xTreeView->all_foreach([this, nOutlinePosition](const weld::TreeIter& rEntry){ - if (lcl_IsContent(rEntry, *m_xTreeView) && - reinterpret_cast( - m_xTreeView->get_id(rEntry).toInt64())->GetParent()->GetType() == - ContentTypeId::OUTLINE) + m_xTreeView->unselect_all(); + + for (auto nOutlinePosition : aOutlinePositions) + { + m_xTreeView->all_foreach([this, nOutlinePosition](const weld::TreeIter& rEntry){ + if (lcl_IsContent(rEntry, *m_xTreeView) && + reinterpret_cast( + m_xTreeView->get_id(rEntry).toInt64())->GetParent()->GetType() == + ContentTypeId::OUTLINE) + { + if (reinterpret_cast( + m_xTreeView->get_id(rEntry).toInt64())->GetOutlinePos() == + nOutlinePosition) { - if (reinterpret_cast( - m_xTreeView->get_id(rEntry).toInt64())->GetOutlinePos() == - nOutlinePosition) - { - std::unique_ptr xParent = - m_xTreeView->make_iterator(&rEntry); - if (m_xTreeView->iter_parent(*xParent) && - !m_xTreeView->get_row_expanded(*xParent)) - m_xTreeView->expand_row(*xParent); - m_xTreeView->select(rEntry); - return true; - } + std::unique_ptr xParent = + m_xTreeView->make_iterator(&rEntry); + if (m_xTreeView->iter_parent(*xParent) && + !m_xTreeView->get_row_expanded(*xParent)) + m_xTreeView->expand_row(*xParent); + m_xTreeView->select(rEntry); + return true; } - return false; - }); - } - - Select(); + } + return false; + }); } + + Select(); } void SwContentTree::MoveOutline(SwOutlineNodes::size_type nTargetPos) -- cgit