sc/source/ui/view/cellsh1.cxx | 51 ++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 29 deletions(-)
New commits: commit 22dc2e5cd3e06e12f08dbb86df2df86860d301d6 Author: tagezi <lera.goncha...@gmail.com> Date: Sat Dec 23 13:17:47 2017 +0200 tdf#39593 deduplicate code in ScCellShell Change-Id: I764edf0c1fb093bf64ea3ea91f98f8586d9549f5 Reviewed-on: https://gerrit.libreoffice.org/47017 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 414f30bf9cac..4f075c981999 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -154,6 +154,26 @@ OUString FlagsToString( InsertDeleteFlags nFlags, } return aFlagsStr; } + +void SetTabNoAndCursor( const ScViewData* rViewData, const OUString& rCellId ) +{ + ScTabViewShell* pTabViewShell = rViewData->GetViewShell(); + assert(pTabViewShell); + const ScDocument& rDoc = rViewData->GetDocShell()->GetDocument(); + std::vector<sc::NoteEntry> aNotes; + rDoc.GetAllNoteEntries(aNotes); + + sal_uInt32 nId = rCellId.toUInt32(); + auto lComp = [nId](const sc::NoteEntry& rNote) { return rNote.mpNote->GetId() == nId; }; + + const auto& aFoundNoteIt = std::find_if(aNotes.begin(), aNotes.end(), lComp); + if (aFoundNoteIt != aNotes.end()) + { + ScAddress aFoundPos = aFoundNoteIt->maPos; + pTabViewShell->SetTabNo(aFoundPos.Tab()); + pTabViewShell->SetCursor(aFoundPos.Col(), aFoundPos.Row()); + } +} } void ScCellShell::ExecuteEdit( SfxRequest& rReq ) @@ -2190,21 +2210,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) if (!aCellId.isEmpty()) { - - ScDocument& rDoc = GetViewData()->GetDocShell()->GetDocument(); - std::vector<sc::NoteEntry> aNotes; - rDoc.GetAllNoteEntries(aNotes); - - sal_uInt32 nId = aCellId.toUInt32(); - auto lComp = [nId](const sc::NoteEntry& rNote) { return rNote.mpNote->GetId() == nId; }; - - const auto& aFoundNoteIt = std::find_if(aNotes.begin(), aNotes.end(), lComp); - if (aFoundNoteIt != aNotes.end()) - { - ScAddress aFoundPos = aFoundNoteIt->maPos; - pTabViewShell->SetTabNo(aFoundPos.Tab()); - pTabViewShell->SetCursor(aFoundPos.Col(), aFoundPos.Row()); - } + SetTabNoAndCursor( GetViewData(), aCellId ); } ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); @@ -2385,20 +2391,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) OUString aCellId = pIdItem->GetValue(); if (!aCellId.isEmpty()) { - ScDocument& rDoc = GetViewData()->GetDocShell()->GetDocument(); - std::vector<sc::NoteEntry> aNotes; - rDoc.GetAllNoteEntries(aNotes); - - sal_uInt32 nId = aCellId.toUInt32(); - auto lComp = [nId](const sc::NoteEntry& rNote) { return rNote.mpNote->GetId() == nId; }; - - const auto& aFoundNoteIt = std::find_if(aNotes.begin(), aNotes.end(), lComp); - if (aFoundNoteIt != aNotes.end()) - { - ScAddress aFoundPos = aFoundNoteIt->maPos; - pTabViewShell->SetTabNo(aFoundPos.Tab()); - pTabViewShell->SetCursor(aFoundPos.Col(), aFoundPos.Row()); - } + SetTabNoAndCursor( GetViewData(), aCellId ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits