diff options
author | tagezi <lera.goncharuk@gmail.com> | 2017-12-23 13:17:47 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-01-20 09:47:31 +0100 |
commit | 22dc2e5cd3e06e12f08dbb86df2df86860d301d6 (patch) | |
tree | 99d2b44fbc814b889e2531a57550b37a47191412 | |
parent | cd2c076f6478c6f06f9834f599f6c65354039d60 (diff) |
tdf#39593 deduplicate code in ScCellShell
Change-Id: I764edf0c1fb093bf64ea3ea91f98f8586d9549f5
Reviewed-on: https://gerrit.libreoffice.org/47017
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 51 |
1 files changed, 22 insertions, 29 deletions
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 ); } } |