diff options
Diffstat (limited to 'sfx2/source/view/lokhelper.cxx')
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 97e17168d2c6..3a306cfbe362 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -14,54 +14,55 @@ #include <shellimpl.hxx> -int SfxLokHelper::createView() +std::uintptr_t SfxLokHelper::createView() { SfxViewFrame* pViewFrame = SfxViewFrame::Current(); SfxRequest aRequest(pViewFrame, SID_NEWWINDOW); pViewFrame->ExecView_Impl(aRequest); - // The SfxViewShell ctor always puts the view shell to the end of the vector. - SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); - return rViewArr.size() - 1; + return reinterpret_cast<std::uintptr_t>(SfxViewShell::Current()); } -void SfxLokHelper::destroyView(std::size_t nId) +void SfxLokHelper::destroyView(std::uintptr_t nId) { SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); - if (nId > rViewArr.size() - 1) - return; - SfxViewShell* pViewShell = rViewArr[nId]; - SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); - SfxRequest aRequest(pViewFrame, SID_CLOSEWIN); - pViewFrame->Exec_Impl(aRequest); + for (std::size_t i = 0; i < rViewArr.size(); ++i) + { + SfxViewShell* pViewShell = rViewArr[i]; + if (reinterpret_cast<std::uintptr_t>(pViewShell) == nId) + { + SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + SfxRequest aRequest(pViewFrame, SID_CLOSEWIN); + pViewFrame->Exec_Impl(aRequest); + break; + } + } } -void SfxLokHelper::setView(std::size_t nId) +void SfxLokHelper::setView(std::uintptr_t nId) { SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); - if (nId > rViewArr.size() - 1) - return; - SfxViewShell* pViewShell = rViewArr[nId]; - if (pViewShell->GetViewFrame() == SfxViewFrame::Current()) - return; + for (std::size_t i = 0; i < rViewArr.size(); ++i) + { + SfxViewShell* pViewShell = rViewArr[i]; + if (reinterpret_cast<std::uintptr_t>(pViewShell) == nId) + { + if (pViewShell == SfxViewShell::Current()) + return; + + SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + pViewFrame->MakeActive_Impl(false); + return; + } + } - if (SfxViewFrame* pViewFrame = pViewShell->GetViewFrame()) - pViewFrame->MakeActive_Impl(false); } -std::size_t SfxLokHelper::getView() +std::uintptr_t SfxLokHelper::getView() { - SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); - SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - for (std::size_t i = 0; i < rViewArr.size(); ++i) - { - if (rViewArr[i]->GetViewFrame() == pViewFrame) - return i; - } - assert(false); - return 0; + return reinterpret_cast<std::uintptr_t>(SfxViewShell::Current()); } std::size_t SfxLokHelper::getViews() |