summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-01-03 14:32:24 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-01-03 14:32:24 +0100
commitf82cd9c786933a641ab131758a9fc1bd291824cc (patch)
tree5d76fed083ddfa5b7657a550846582de4d8b51d2
parent36cdf3c35459df63ce137e550a6840a61865c0ca (diff)
Hold SfxInfoBarWindow by VclPtr
In SfxInfoBarContainerWindow::removeInfoBar, disposeAndClear is already called on the removed member (once found), so the ScopedVclPtr (also calling disposeAndClear when going out of scope) should not be necessary. Change-Id: Ibf4d19ebd5f1a6217e1d18ef0458c9b865667898
-rw-r--r--include/sfx2/infobar.hxx6
-rw-r--r--include/sfx2/viewfrm.hxx2
-rw-r--r--sfx2/source/dialog/infobar.cxx13
-rw-r--r--sfx2/source/view/classificationhelper.cxx1
-rw-r--r--sfx2/source/view/sfxbasecontroller.cxx2
-rw-r--r--sfx2/source/view/viewfrm.cxx8
6 files changed, 15 insertions, 17 deletions
diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index 2d732bdb7526..8cd6d6cb2804 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -84,14 +84,14 @@ class SfxInfoBarContainerWindow : public vcl::Window
virtual ~SfxInfoBarContainerWindow( ) override;
virtual void dispose() override;
- SfxInfoBarWindow* appendInfoBar(const OUString& sId,
+ VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId,
const OUString& sMessage,
const basegfx::BColor* pBackgroundColor,
const basegfx::BColor* pForegroundColor,
const basegfx::BColor* pMessageColor,
WinBits nMessageStyle);
- SfxInfoBarWindow* getInfoBar(const OUString& sId);
- void removeInfoBar(SfxInfoBarWindow* pInfoBar);
+ VclPtr<SfxInfoBarWindow> getInfoBar(const OUString& sId);
+ void removeInfoBar(VclPtr<SfxInfoBarWindow> const & pInfoBar);
virtual void Resize() override;
};
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index d25095483772..ed8a994bc741 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -170,7 +170,7 @@ public:
The buttons will be added from Right to Left at the right of the info bar. The parent, size
and position of each button will be changed: only the width will remain unchanged.
*/
- SfxInfoBarWindow* AppendInfoBar(const OUString& sId,
+ VclPtr<SfxInfoBarWindow> AppendInfoBar(const OUString& sId,
const OUString& sMessage,
const basegfx::BColor* pBackgroundColor = nullptr,
const basegfx::BColor* pForegroundColor = nullptr,
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index adec4e2629d1..d8fce1f9e202 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -279,7 +279,7 @@ void SfxInfoBarContainerWindow::dispose()
Window::dispose();
}
-SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId,
+VclPtr<SfxInfoBarWindow> SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId,
const OUString& sMessage,
const basegfx::BColor* pBackgroundColor,
const basegfx::BColor* pForegroundColor,
@@ -299,25 +299,22 @@ SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId,
return pInfoBar;
}
-SfxInfoBarWindow* SfxInfoBarContainerWindow::getInfoBar(const OUString& sId)
+VclPtr<SfxInfoBarWindow> SfxInfoBarContainerWindow::getInfoBar(const OUString& sId)
{
for (auto it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
{
if ((*it)->getId() == sId)
- return it->get();
+ return *it;
}
return nullptr;
}
-void SfxInfoBarContainerWindow::removeInfoBar(SfxInfoBarWindow* pInfoBar)
+void SfxInfoBarContainerWindow::removeInfoBar(VclPtr<SfxInfoBarWindow> const & pInfoBar)
{
- // Store a VclPtr to the pInfoBar while we remove it from m_pInfoBars
- ScopedVclPtr<SfxInfoBarWindow> pTmp(pInfoBar);
-
// Remove
for (auto it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
{
- if (pInfoBar == it->get())
+ if (pInfoBar == *it)
{
it->disposeAndClear();
m_pInfoBars.erase(it);
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 0bc1a991ab44..614ec9800a63 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/xml/sax/SAXParseException.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <sfx2/infobar.hxx>
#include <sfx2/objsh.hxx>
#include <o3tl/make_unique.hxx>
#include <comphelper/processfactory.hxx>
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index e732d27eccf4..4c298be7affc 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -1449,7 +1449,7 @@ void SfxBaseController::ShowInfoBars( )
{
// Get the Frame and show the InfoBar if not checked out
SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame();
- SfxInfoBarWindow* pInfoBar = pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ) );
+ auto pInfoBar = pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ) );
if (pInfoBar)
{
VclPtrInstance<PushButton> xBtn(&pViewFrame->GetWindow());
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 6e35adef40c1..42a259abaa95 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1201,7 +1201,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
{
bool bSignPDF = IsSignPDF(m_xObjSh);
- SfxInfoBarWindow* pInfoBar = AppendInfoBar("readonly", SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT));
+ auto pInfoBar = AppendInfoBar("readonly", SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT));
if (pInfoBar)
{
if (bSignPDF)
@@ -3063,7 +3063,7 @@ void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame )
SfxGetpApp()->SetViewFrame_Impl( pFrame );
}
-SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId,
+VclPtr<SfxInfoBarWindow> SfxViewFrame::AppendInfoBar( const OUString& sId,
const OUString& sMessage,
const basegfx::BColor* pBackgroundColor,
const basegfx::BColor* pForegroundColor,
@@ -3080,7 +3080,7 @@ SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId,
if (pChild)
{
SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
- SfxInfoBarWindow* pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, pBackgroundColor, pForegroundColor, pMessageColor, nMessageStyle);
+ auto pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, pBackgroundColor, pForegroundColor, pMessageColor, nMessageStyle);
ShowChildWindow(nId);
return pInfoBar;
}
@@ -3099,7 +3099,7 @@ void SfxViewFrame::RemoveInfoBar( const OUString& sId )
if (pChild)
{
SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
- SfxInfoBarWindow* pInfoBar = pInfoBarContainer->getInfoBar(sId);
+ auto pInfoBar = pInfoBarContainer->getInfoBar(sId);
pInfoBarContainer->removeInfoBar(pInfoBar);
ShowChildWindow(nId);
}