[Libreoffice-commits] core.git: include/vcl sfx2/source vcl/source
Noel Grandin
noel at peralex.com
Tue Jun 28 08:10:18 UTC 2016
include/vcl/builder.hxx | 4 +-
include/vcl/notebookbar.hxx | 20 +++---------
sfx2/source/notebookbar/SfxNotebookBar.cxx | 4 +-
vcl/source/control/contexttabctrl.cxx | 2 -
vcl/source/control/notebookbar.cxx | 46 +++++++++++++++++------------
5 files changed, 38 insertions(+), 38 deletions(-)
New commits:
commit 4ae3f434ad3006285f1766c187f9e7a99edc170b
Author: Noel Grandin <noel at peralex.com>
Date: Tue Jun 28 10:02:06 2016 +0200
loplugin:refcounting on NotebookBar
extending two different ref-counted base classes is a no-no
Change-Id: Iabbf98c0cba73a1b1643b4275d15af7608b2e827
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 353d818..13ff420 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -351,8 +351,8 @@ private:
void handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader);
VclPtr<vcl::Window> handleObject(vcl::Window *pParent, xmlreader::XmlReader &reader);
void handlePacking(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader);
- std::vector<vcl::EnumContext::Context> handleStyle(xmlreader::XmlReader &reader);
- vcl::EnumContext::Context getContext(xmlreader::XmlReader &reader);
+ static std::vector<vcl::EnumContext::Context> handleStyle(xmlreader::XmlReader &reader);
+ static vcl::EnumContext::Context getContext(xmlreader::XmlReader &reader);
void applyPackingProperty(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader);
void collectProperty(xmlreader::XmlReader &reader, const OString &rID, stringmap &rVec);
static void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap);
diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx
index 37fa7ee..128bf8f 100644
--- a/include/vcl/notebookbar.hxx
+++ b/include/vcl/notebookbar.hxx
@@ -13,13 +13,13 @@
#include <vcl/builder.hxx>
#include <vcl/ctrl.hxx>
#include <vcl/contexttabctrl.hxx>
-#include <com/sun/star/ui/XContextChangeEventListener.hpp>
#include <vcl/EnumContext.hxx>
+#include <com/sun/star/ui/XContextChangeEventListener.hpp>
/// This implements Widget Layout-based notebook-like menu bar.
-class NotebookBar : public Control, public VclBuilderContainer,
- public css::ui::XContextChangeEventListener
+class NotebookBar : public Control, public VclBuilderContainer
{
+friend class NotebookBarContextChangeEventListener;
public:
NotebookBar(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame);
virtual ~NotebookBar();
@@ -30,21 +30,13 @@ public:
virtual void StateChanged(StateChangedType nType) override;
- // XContextChangeEventListener
- virtual void SAL_CALL notifyContextChangeEvent(const css::ui::ContextChangeEventObject& rEvent)
- throw (css::uno::RuntimeException, std::exception) override;
-
- virtual ::css::uno::Any SAL_CALL queryInterface(const ::css::uno::Type& aType)
- throw (::css::uno::RuntimeException, ::std::exception) override;
- virtual void SAL_CALL acquire() throw () override;
- virtual void SAL_CALL release() throw () override;
- virtual void SAL_CALL disposing(const ::css::lang::EventObject&)
- throw (::css::uno::RuntimeException, ::std::exception) override;
-
+ const css::uno::Reference<css::ui::XContextChangeEventListener>& getContextChangeEventListener() const { return m_pEventListener; }
private:
+ css::uno::Reference<css::ui::XContextChangeEventListener> m_pEventListener;
VclPtr<ContextTabControl> m_pTabControl;
};
+
#endif // INCLUDED_VCL_NOTEBOOKBAR_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 8652df7..c68b486 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -73,7 +73,7 @@ void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
if(xFrame.is() && xMultiplexer.is())
{
xMultiplexer->addContextChangeEventListener(
- pSysWindow->GetNotebookBar().get(),
+ pSysWindow->GetNotebookBar()->getContextChangeEventListener(),
xFrame->getController());
}
}
@@ -91,7 +91,7 @@ void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow)
if (pSysWindow->GetNotebookBar() && xMultiplexer.is())
{
xMultiplexer->removeAllContextChangeEventListeners(
- pSysWindow->GetNotebookBar().get());
+ pSysWindow->GetNotebookBar()->getContextChangeEventListener());
}
}
diff --git a/vcl/source/control/contexttabctrl.cxx b/vcl/source/control/contexttabctrl.cxx
index 29e43ad..5fa526a 100644
--- a/vcl/source/control/contexttabctrl.cxx
+++ b/vcl/source/control/contexttabctrl.cxx
@@ -39,7 +39,7 @@ void ContextTabControl::SetContext( vcl::EnumContext::Context eContext )
TabPage* pPage = static_cast<TabPage*>(GetChild(nChild));
if (pPage->HasContext(eContext) || pPage->HasContext(vcl::EnumContext::Context::Context_Any))
- EnablePage(nChild + 1, true);
+ EnablePage(nChild + 1);
else
EnablePage(nChild + 1, false);
diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx
index 939fa10..c100a62 100644
--- a/vcl/source/control/notebookbar.cxx
+++ b/vcl/source/control/notebookbar.cxx
@@ -10,9 +10,30 @@
#include <vcl/layout.hxx>
#include <vcl/notebookbar.hxx>
#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/implbase.hxx>
+
+/**
+ * split from the main class since it needs different ref-counting mana
+ */
+class NotebookBarContextChangeEventListener : public ::cppu::WeakImplHelper<css::ui::XContextChangeEventListener>
+{
+ VclPtr<NotebookBar> mpParent;
+public:
+ NotebookBarContextChangeEventListener(NotebookBar *p) : mpParent(p) {}
+ virtual ~NotebookBarContextChangeEventListener() {}
+
+ // XContextChangeEventListener
+ virtual void SAL_CALL notifyContextChangeEvent(const css::ui::ContextChangeEventObject& rEvent)
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL disposing(const ::css::lang::EventObject&)
+ throw (::css::uno::RuntimeException, ::std::exception) override;
+};
+
+
NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame)
- : Control(pParent)
+ : Control(pParent), m_pEventListener(new NotebookBarContextChangeEventListener(this))
{
SetStyle(GetStyle() | WB_DIALOGCONTROL);
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame);
@@ -27,6 +48,7 @@ NotebookBar::~NotebookBar()
void NotebookBar::dispose()
{
disposeBuilder();
+ m_pEventListener.clear();
Control::dispose();
}
@@ -78,31 +100,17 @@ void NotebookBar::StateChanged(StateChangedType nType)
Control::StateChanged(nType);
}
-void SAL_CALL NotebookBar::notifyContextChangeEvent(const css::ui::ContextChangeEventObject& rEvent)
+void SAL_CALL NotebookBarContextChangeEventListener::notifyContextChangeEvent(const css::ui::ContextChangeEventObject& rEvent)
throw (css::uno::RuntimeException, std::exception)
{
- m_pTabControl->SetContext(vcl::EnumContext::GetContextEnum(rEvent.ContextName));
-}
-
-::css::uno::Any SAL_CALL NotebookBar::queryInterface(const ::css::uno::Type& aType)
- throw (::css::uno::RuntimeException, ::std::exception)
-{
- return ::cppu::queryInterface(aType, static_cast<css::ui::XContextChangeEventListener*>(this));
-}
-
-void SAL_CALL NotebookBar::acquire() throw ()
-{
- Control::acquire();
+ mpParent->m_pTabControl->SetContext(vcl::EnumContext::GetContextEnum(rEvent.ContextName));
}
-void SAL_CALL NotebookBar::release() throw ()
-{
- Control::release();
-}
-void SAL_CALL NotebookBar::disposing(const ::css::lang::EventObject&)
+void SAL_CALL NotebookBarContextChangeEventListener::disposing(const ::css::lang::EventObject&)
throw (::css::uno::RuntimeException, ::std::exception)
{
+ mpParent.clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list