diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-29 11:47:22 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-29 11:39:22 +0000 |
commit | 389d4d414291879b9097658080e405a06dc0c1fc (patch) | |
tree | 0ad97411ad459437b4973bd9eb0c3c6566a0c853 /sfx2 | |
parent | move range detection to ScViewData::SelectionFillDOOM() (diff) | |
download | core-389d4d414291879b9097658080e405a06dc0c1fc.tar.gz core-389d4d414291879b9097658080e405a06dc0c1fc.zip |
sfx2: introduce SfxViewShell::GetViewShellId()
This is quite similar to SwFrame::GetFrameId(), i.e. it assigns a
numeric identifier to each instance to help debugging, as those
identifiers are stable accross runs.
Change-Id: I9cc57e316435f0284a1d481a956a703be859d67e
Reviewed-on: https://gerrit.libreoffice.org/27669
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 29 | ||||
-rw-r--r-- | sfx2/source/view/viewimp.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 9 |
3 files changed, 17 insertions, 23 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 09d78cf8601d..856a007a4206 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -17,42 +17,24 @@ #include <shellimpl.hxx> -namespace -{ - -/// Assigns a view ID to a view shell. -int shellToView(SfxViewShell* pViewShell) -{ - // Deleted view shells are not removed from this map, so view IDs are not - // reused when deleting, then creating a view. - static std::map<SfxViewShell*, int> aViewMap; - auto it = aViewMap.find(pViewShell); - if (it != aViewMap.end()) - return it->second; - - int nViewId = aViewMap.size(); - aViewMap[pViewShell] = nViewId; - return nViewId; -} -} - int SfxLokHelper::createView() { SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); SfxRequest aRequest(pViewFrame, SID_NEWWINDOW); pViewFrame->ExecView_Impl(aRequest); - return shellToView(SfxViewShell::Current()); + return SfxViewShell::Current()->GetViewShellId(); } void SfxLokHelper::destroyView(int nId) { + unsigned nViewShellId = nId; SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); for (std::size_t i = 0; i < rViewArr.size(); ++i) { SfxViewShell* pViewShell = rViewArr[i]; - if (shellToView(pViewShell) == nId) + if (pViewShell->GetViewShellId() == nViewShellId) { SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); SfxRequest aRequest(pViewFrame, SID_CLOSEWIN); @@ -64,12 +46,13 @@ void SfxLokHelper::destroyView(int nId) void SfxLokHelper::setView(int nId) { + unsigned nViewShellId = nId; SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); for (std::size_t i = 0; i < rViewArr.size(); ++i) { SfxViewShell* pViewShell = rViewArr[i]; - if (shellToView(pViewShell) == nId) + if (pViewShell->GetViewShellId() == nViewShellId) { if (pViewShell == SfxViewShell::Current()) return; @@ -86,7 +69,7 @@ int SfxLokHelper::getView(SfxViewShell* pViewShell) { if (!pViewShell) pViewShell = SfxViewShell::Current(); - return shellToView(pViewShell); + return pViewShell->GetViewShellId(); } std::size_t SfxLokHelper::getViews() diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx index fa3e6800c016..95fdf8260df4 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -62,6 +62,8 @@ struct SfxViewShell_Impl void* m_pLibreOfficeKitViewData; /// Set if we are in the middle of a tiled search. bool m_bTiledSearching; + static sal_uInt32 m_nLastViewShellId; + const sal_uInt32 m_nViewShellId; explicit SfxViewShell_Impl(SfxViewShellFlags const nFlags); ~SfxViewShell_Impl(); diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 21086334dc78..6ffd25313749 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -238,6 +238,8 @@ public: size_t size() const { return maData.size(); } }; +sal_uInt32 SfxViewShell_Impl::m_nLastViewShellId = 0; + SfxViewShell_Impl::SfxViewShell_Impl(SfxViewShellFlags const nFlags) : aInterceptorContainer( aMutex ) , m_bControllerSet(false) @@ -252,6 +254,7 @@ SfxViewShell_Impl::SfxViewShell_Impl(SfxViewShellFlags const nFlags) , m_pLibreOfficeKitViewCallback(nullptr) , m_pLibreOfficeKitViewData(nullptr) , m_bTiledSearching(false) +, m_nViewShellId(SfxViewShell_Impl::m_nLastViewShellId++) {} SfxViewShell_Impl::~SfxViewShell_Impl() @@ -1502,10 +1505,16 @@ int SfxViewShell::getPart() const return 0; } +sal_uInt32 SfxViewShell::GetViewShellId() const +{ + return pImpl->m_nViewShellId; +} + void SfxViewShell::dumpAsXml(xmlTextWriterPtr pWriter) const { xmlTextWriterStartElement(pWriter, BAD_CAST("sfxViewShell")); xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), BAD_CAST(OString::number(GetViewShellId()).getStr())); xmlTextWriterEndElement(pWriter); } |