summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source')
-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, 82 insertions, 17 deletions
diff --git a/sfx2/source/view/lokcharthelper.cxx b/sfx2/source/view/lokcharthelper.cxx
index 903e4727eb62..23d84851f5a5 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->getPart() == nPartForCurView)
+ if (pViewShell->GetDocId() == pCurView->GetDocId() && 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 (pViewShell->getPart() == nPartForCurView)
+ if (pCurView && pViewShell->GetDocId() == pCurView->GetDocId() && 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 4fb7761cec95..2f78bfc1eaa5 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -69,11 +69,17 @@ 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());
}
@@ -147,7 +153,20 @@ int SfxLokHelper::getView(SfxViewShell* pViewShell)
std::size_t SfxLokHelper::getViewsCount()
{
SfxApplication* pApp = SfxApplication::Get();
- return !pApp ? 0 : pApp->GetViewShells_Impl().size();
+ 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;
}
bool SfxLokHelper::getViewIds(int* pArray, size_t nSize)
@@ -156,18 +175,45 @@ bool SfxLokHelper::getViewIds(int* pArray, size_t nSize)
if (!pApp)
return false;
- SfxViewShellArr_Impl& rViewArr = pApp->GetViewShells_Impl();
- if (rViewArr.size() > nSize)
- return false;
-
- for (std::size_t i = 0; i < rViewArr.size(); ++i)
+ 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)
{
- SfxViewShell* pViewShell = rViewArr[i];
- pArray[i] = static_cast<sal_Int32>(pViewShell->GetViewShellId());
+ 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));
+}
+
+int SfxLokHelper::getDocumentIdOfView(int nViewId)
+{
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while (pViewShell)
+ {
+ if (pViewShell->GetViewShellId() == ViewShellId(nViewId))
+ return static_cast<int>(pViewShell->GetDocId());
+ pViewShell = SfxViewShell::GetNext(*pViewShell);
+ }
+ return -1;
+}
+
LanguageTag SfxLokHelper::getDefaultLanguage()
{
return g_defaultLanguageTag;
@@ -252,13 +298,13 @@ void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell const*
void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload)
{
- if (SfxLokHelper::getViewsCount() <= 1 || DisableCallbacks::disabled())
+ if (DisableCallbacks::disabled())
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- if (pViewShell != pThisView)
+ if (pViewShell != pThisView && pViewShell->GetDocId() == pThisView-> GetDocId())
notifyOtherView(pThisView, pViewShell, nType, rKey, rPayload);
pViewShell = SfxViewShell::GetNext(*pViewShell);
@@ -371,10 +417,13 @@ 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)
{
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pDoc, bInvalidateAll);
+ if (pViewShell->GetDocId() == pCurrentViewShell-> GetDocId())
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pDoc, bInvalidateAll);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -406,10 +455,12 @@ 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)
{
- pViewShell->libreOfficeKitViewCallback(nType, payload);
+ if (pViewShell->GetDocId() == pCurrentViewShell->GetDocId())
+ pViewShell->libreOfficeKitViewCallback(nType, payload);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx
index 00b7b51590fe..ef919a2fd89f 100644
--- a/sfx2/source/view/viewimp.hxx
+++ b/sfx2/source/view/viewimp.hxx
@@ -59,6 +59,7 @@ 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 dcbdc9ceef3a..ad46e704478f 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -228,7 +228,9 @@ 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()
{
@@ -1096,7 +1098,6 @@ SfxViewShell::SfxViewShell
SfxViewShell::~SfxViewShell()
{
-
// Remove from list
const SfxViewShell *pThis = this;
SfxViewShellArr_Impl &rViewArr = SfxGetpApp()->GetViewShells_Impl();
@@ -1478,7 +1479,8 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->NotifyCursor(this);
+ if (pViewShell->GetDocId() == GetDocId())
+ pViewShell->NotifyCursor(this);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -1573,6 +1575,17 @@ 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);