diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-29 11:47:22 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-01 09:45:07 +0200 |
commit | f89209f23c1541fec83b6f7d3e67c5b9bc3c5678 (patch) | |
tree | 380764ad76ba339fde824eaeebaabe6293292b99 /sfx2 | |
parent | f6e08a1440a6c1b7f3b5aede21f3c9bf4b58cc2c (diff) |
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.
Reviewed-on: https://gerrit.libreoffice.org/27669
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 389d4d414291879b9097658080e405a06dc0c1fc)
Conflicts:
compilerplugins/clang/badstatics.cxx
Change-Id: I9cc57e316435f0284a1d481a956a703be859d67e
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 9b1c1428bd2e..81f39e1c4d8c 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -66,6 +66,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 8210d88497b1..c8ce31afa57a 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -297,6 +297,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) @@ -313,6 +315,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() @@ -1649,10 +1652,16 @@ int SfxViewShell::getPart() const return 0; } +sal_uInt32 SfxViewShell::GetViewShellId() const +{ + return pImp->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); } |