summaryrefslogtreecommitdiff
path: root/sfx2/source/view
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/view')
-rw-r--r--sfx2/source/view/lokcharthelper.cxx4
-rw-r--r--sfx2/source/view/lokhelper.cxx75
-rw-r--r--sfx2/source/view/viewimp.hxx1
-rw-r--r--sfx2/source/view/viewsh.cxx19
4 files changed, 17 insertions, 82 deletions
diff --git a/sfx2/source/view/lokcharthelper.cxx b/sfx2/source/view/lokcharthelper.cxx
index 23d84851f5a5..903e4727eb62 100644
--- a/sfx2/source/view/lokcharthelper.cxx
+++ b/sfx2/source/view/lokcharthelper.cxx
@@ -180,7 +180,7 @@ bool LokChartHelper::HitAny(const Point& aPos)
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- if (pViewShell->GetDocId() == pCurView->GetDocId() && pViewShell->getPart() == nPartForCurView)
+ if (pViewShell->getPart() == nPartForCurView)
{
LokChartHelper aChartHelper(pViewShell);
if (aChartHelper.Hit(aPos))
@@ -262,7 +262,7 @@ void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice,
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- if (pCurView && pViewShell->GetDocId() == pCurView->GetDocId() && pViewShell->getPart() == nPartForCurView)
+ if (pViewShell->getPart() == nPartForCurView)
{
LokChartHelper aChartHelper(pViewShell);
aChartHelper.PaintTile(rDevice, aTileRect);
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 2f78bfc1eaa5..4fb7761cec95 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -69,17 +69,11 @@ int SfxLokHelper::createView()
SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
if (!pViewFrame)
return -1;
- SfxViewShell* pPrevViewShell = SfxViewShell::Current();
- ViewShellDocId nId;
- if (pPrevViewShell)
- nId = pPrevViewShell->GetDocId();
SfxRequest aRequest(pViewFrame, SID_NEWWINDOW);
pViewFrame->ExecView_Impl(aRequest);
SfxViewShell* pViewShell = SfxViewShell::Current();
if (!pViewShell)
return -1;
- if (pPrevViewShell)
- pViewShell->SetDocId(nId);
return static_cast<sal_Int32>(pViewShell->GetViewShellId());
}
@@ -153,20 +147,7 @@ int SfxLokHelper::getView(SfxViewShell* pViewShell)
std::size_t SfxLokHelper::getViewsCount()
{
SfxApplication* pApp = SfxApplication::Get();
- if (!pApp)
- return 0;
-
- const SfxViewShell* const pCurrentViewShell = SfxViewShell::Current();
- const ViewShellDocId nCurrentDocId = pCurrentViewShell ? pCurrentViewShell->GetDocId() : ViewShellDocId(-1);
- std::size_t n = 0;
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- if (pViewShell->GetDocId() == nCurrentDocId)
- n++;
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
- return n;
+ return !pApp ? 0 : pApp->GetViewShells_Impl().size();
}
bool SfxLokHelper::getViewIds(int* pArray, size_t nSize)
@@ -175,43 +156,16 @@ bool SfxLokHelper::getViewIds(int* pArray, size_t nSize)
if (!pApp)
return false;
- const SfxViewShell* const pCurrentViewShell = SfxViewShell::Current();
- const ViewShellDocId nCurrentDocId = pCurrentViewShell ? pCurrentViewShell->GetDocId() : ViewShellDocId(-1);
- std::size_t n = 0;
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- if (n == nSize)
- return false;
- if (pViewShell->GetDocId() == nCurrentDocId)
- {
- pArray[n] = static_cast<sal_Int32>(pViewShell->GetViewShellId());
- n++;
- }
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
- return true;
-}
-
-void SfxLokHelper::setDocumentIdOfView(int nId)
-{
- SfxViewShell* pViewShell = SfxViewShell::Current();
- assert(pViewShell);
- if (!pViewShell)
- return;
- pViewShell->SetDocId(ViewShellDocId(nId));
-}
+ SfxViewShellArr_Impl& rViewArr = pApp->GetViewShells_Impl();
+ if (rViewArr.size() > nSize)
+ return false;
-int SfxLokHelper::getDocumentIdOfView(int nViewId)
-{
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
+ for (std::size_t i = 0; i < rViewArr.size(); ++i)
{
- if (pViewShell->GetViewShellId() == ViewShellId(nViewId))
- return static_cast<int>(pViewShell->GetDocId());
- pViewShell = SfxViewShell::GetNext(*pViewShell);
+ SfxViewShell* pViewShell = rViewArr[i];
+ pArray[i] = static_cast<sal_Int32>(pViewShell->GetViewShellId());
}
- return -1;
+ return true;
}
LanguageTag SfxLokHelper::getDefaultLanguage()
@@ -298,13 +252,13 @@ void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell const*
void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload)
{
- if (DisableCallbacks::disabled())
+ if (SfxLokHelper::getViewsCount() <= 1 || DisableCallbacks::disabled())
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- if (pViewShell != pThisView && pViewShell->GetDocId() == pThisView-> GetDocId())
+ if (pViewShell != pThisView)
notifyOtherView(pThisView, pViewShell, nType, rKey, rPayload);
pViewShell = SfxViewShell::GetNext(*pViewShell);
@@ -417,13 +371,10 @@ void SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc
if (!comphelper::LibreOfficeKit::isActive() || DisableCallbacks::disabled())
return;
- // FIXME: Do we know whether it is the views for the document that is in the "current" view that has changed?
- const SfxViewShell* const pCurrentViewShell = SfxViewShell::Current();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- if (pViewShell->GetDocId() == pCurrentViewShell-> GetDocId())
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pDoc, bInvalidateAll);
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pDoc, bInvalidateAll);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -455,12 +406,10 @@ void SfxLokHelper::notifyAllViews(int nType, const OString& rPayload)
return;
const auto payload = rPayload.getStr();
- const SfxViewShell* const pCurrentViewShell = SfxViewShell::Current();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- if (pViewShell->GetDocId() == pCurrentViewShell->GetDocId())
- pViewShell->libreOfficeKitViewCallback(nType, payload);
+ pViewShell->libreOfficeKitViewCallback(nType, payload);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx
index ef919a2fd89f..00b7b51590fe 100644
--- a/sfx2/source/view/viewimp.hxx
+++ b/sfx2/source/view/viewimp.hxx
@@ -59,7 +59,6 @@ struct SfxViewShell_Impl
bool m_bTiledSearching;
static sal_uInt32 m_nLastViewShellId;
const ViewShellId m_nViewShellId;
- ViewShellDocId m_nDocId;
explicit SfxViewShell_Impl(SfxViewShellFlags const nFlags);
~SfxViewShell_Impl();
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index ad46e704478f..dcbdc9ceef3a 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -228,9 +228,7 @@ SfxViewShell_Impl::SfxViewShell_Impl(SfxViewShellFlags const nFlags)
, m_pLibreOfficeKitViewData(nullptr)
, m_bTiledSearching(false)
, m_nViewShellId(SfxViewShell_Impl::m_nLastViewShellId++)
-, m_nDocId(-1)
-{
-}
+{}
SfxViewShell_Impl::~SfxViewShell_Impl()
{
@@ -1098,6 +1096,7 @@ SfxViewShell::SfxViewShell
SfxViewShell::~SfxViewShell()
{
+
// Remove from list
const SfxViewShell *pThis = this;
SfxViewShellArr_Impl &rViewArr = SfxGetpApp()->GetViewShells_Impl();
@@ -1479,8 +1478,7 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- if (pViewShell->GetDocId() == GetDocId())
- pViewShell->NotifyCursor(this);
+ pViewShell->NotifyCursor(this);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -1575,17 +1573,6 @@ ViewShellId SfxViewShell::GetViewShellId() const
return pImpl->m_nViewShellId;
}
-void SfxViewShell::SetDocId(ViewShellDocId nId)
-{
- assert(static_cast<int>(pImpl->m_nDocId) == -1);
- pImpl->m_nDocId = nId;
-}
-
-ViewShellDocId SfxViewShell::GetDocId() const
-{
- return pImpl->m_nDocId;
-}
-
void SfxViewShell::NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload)
{
SfxLokHelper::notifyOtherViews(this, nType, rKey, rPayload);