loplugin:unusedfields in sfx2 part1
and fix a memory leak in NotebookbarTabControl where it was not freeing
it's m_pListener field
Change-Id: Ib9970c9084982d532fa38d1bc3c44180ab2c3c39
Reviewed-on: https://gerrit.libreoffice.org/39036
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/include/sfx2/docfilt.hxx b/include/sfx2/docfilt.hxx
index d4628b3..47454f9 100644
--- a/include/sfx2/docfilt.hxx
+++ b/include/sfx2/docfilt.hxx
@@ -60,7 +60,6 @@ class SFX2_DLLPUBLIC SfxFilter
SfxFilterFlags nFormatType;
sal_uIntPtr nVersion;
SotClipboardFormatId lFormat;
sal_uInt16 nDocIcon;
public:
SfxFilter( const OUString& rProvider, const OUString& rFilterName );
@@ -70,7 +69,6 @@ public:
SfxFilterFlags nFormatType,
SotClipboardFormatId lFormat,
const OUString &rTypeName,
sal_uInt16 nDocIcon,
const OUString &rMimeType,
const OUString &rUserData,
const OUString& rServiceName );
diff --git a/include/sfx2/frmdescr.hxx b/include/sfx2/frmdescr.hxx
index 6cbda80..1e6e49e 100644
--- a/include/sfx2/frmdescr.hxx
+++ b/include/sfx2/frmdescr.hxx
@@ -66,9 +66,7 @@ class SFX2_DLLPUBLIC SfxFrameDescriptor
ScrollingMode eScroll;
bool bHasBorder;
bool bHasBorderSet;
bool bResizeHorizontal;
bool bResizeVertical;
bool bReadOnly;
std::unique_ptr< SfxFrameDescriptor_Impl > pImpl;
public:
@@ -81,12 +79,11 @@ public:
{ return aURL; }
void SetURL( const OUString& rURL );
void SetActualURL( const OUString& rURL );
void SetReadOnly( bool bSet ) { bReadOnly = bSet;}
void SetEditable( bool bSet );
// Size
void SetResizable( bool bRes )
{ bResizeHorizontal = bResizeVertical = bRes; }
{ bResizeVertical = bRes; }
// FrameName
const OUString& GetName() const
diff --git a/include/sfx2/notebookbar/NotebookbarTabControl.hxx b/include/sfx2/notebookbar/NotebookbarTabControl.hxx
index c6ff08e..9f6640d 100644
--- a/include/sfx2/notebookbar/NotebookbarTabControl.hxx
+++ b/include/sfx2/notebookbar/NotebookbarTabControl.hxx
@@ -13,6 +13,7 @@
#include <vcl/toolbox.hxx>
#include <sfx2/dllapi.h>
#include <vcl/tabctrl.hxx>
#include <memory>
class ChangedUIEventListener;
@@ -22,6 +23,7 @@ friend class ChangedUIEventListener;
public:
NotebookbarTabControl( Window* pParent );
~NotebookbarTabControl() override;
virtual void StateChanged(StateChangedType nStateChange) override;
virtual Size calculateRequisition() const override;
@@ -34,7 +36,7 @@ private:
);
DECL_LINK(OpenNotebookbarPopupMenu, NotebookBar*, void);
ChangedUIEventListener* m_pListener;
std::unique_ptr<ChangedUIEventListener> m_pListener;
css::uno::Reference<css::frame::XFrame> m_xFrame;
protected:
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index a6dd243..6e70534 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -317,8 +317,6 @@ public:
SAL_DLLPRIVATE void CheckIPClient_Impl(SfxInPlaceClient*, const tools::Rectangle&);
SAL_DLLPRIVATE void PushSubShells_Impl( bool bPush=true );
SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( false ); }
SAL_DLLPRIVATE void TakeOwnership_Impl();
SAL_DLLPRIVATE void TakeFrameOwnership_Impl();
SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey);
/// The actual per-view implementation of lok::Document::registerCallback().
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 3c70609..1bc44bf 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -566,7 +566,7 @@ ScDocShellRef ScBootstrapFixture::load( bool bReadWrite,
{
std::shared_ptr<const SfxFilter> pFilter(new SfxFilter(
rFilter,
OUString(), nFilterFlags, nClipboardID, rTypeName, 0, OUString(),
OUString(), nFilterFlags, nClipboardID, rTypeName, OUString(),
rUserData, "private:factory/scalc"));
const_cast<SfxFilter*>(pFilter.get())->SetVersion(nFilterVersion);
@@ -658,7 +658,7 @@ ScDocShellRef ScBootstrapFixture::saveAndReload(
nExportFormat = SotClipboardFormatId::STARCHART_8;
std::shared_ptr<const SfxFilter> pExportFilter(new SfxFilter(
rFilter,
OUString(), nFormatType, nExportFormat, rTypeName, 0, OUString(),
OUString(), nFormatType, nExportFormat, rTypeName, OUString(),
rUserData, "private:factory/scalc*" ));
const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
aStoreMedium.SetFilter(pExportFilter);
@@ -704,7 +704,7 @@ std::shared_ptr<utl::TempFile> ScBootstrapFixture::exportTo( ScDocShell* pShell,
nExportFormat = SotClipboardFormatId::STARCHART_8;
std::shared_ptr<SfxFilter> pExportFilter(new SfxFilter(
aFilterName,
OUString(), nFormatType, nExportFormat, aFilterType, 0, OUString(),
OUString(), nFormatType, nExportFormat, aFilterType, OUString(),
OUString(), "private:factory/scalc*" ));
pExportFilter.get()->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
aStoreMedium.SetFilter(pExportFilter);
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index fb4d496..9eb2e49d 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -344,7 +344,7 @@ ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const OUSt
nExportFormat = SotClipboardFormatId::STARCHART_8;
std::shared_ptr<const SfxFilter> pExportFilter(new SfxFilter(
rFilter,
OUString(), nFormatType, nExportFormat, rTypeName, 0, OUString(),
OUString(), nFormatType, nExportFormat, rTypeName, OUString(),
rUserData, "private:factory/scalc*" ));
const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
aStoreMedium.SetFilter(pExportFilter);
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index ca2ec7d..02d3219 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1557,7 +1557,7 @@ void ScFiltersTest::testPassword_Impl(const OUString& aFileNameBase)
SotClipboardFormatId nFormat = SotClipboardFormatId::STARCALC_8;
std::shared_ptr<const SfxFilter> pFilter(new SfxFilter(
aFilterName,
OUString(), getFileFormats()[0].nFormatType, nFormat, aFilterType, 0, OUString(),
OUString(), getFileFormats()[0].nFormatType, nFormat, aFilterType, OUString(),
OUString(), "private:factory/scalc*" ));
const_cast<SfxFilter*>(pFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
diff --git a/sd/qa/unit/filters-test.cxx b/sd/qa/unit/filters-test.cxx
index 08babce..5866c34a 100644
--- a/sd/qa/unit/filters-test.cxx
+++ b/sd/qa/unit/filters-test.cxx
@@ -65,7 +65,7 @@ bool SdFiltersTest::load(const OUString &rFilter, const OUString &rURL,
{
std::shared_ptr<const SfxFilter> pFilter(new SfxFilter(
rFilter,
OUString(), nFilterFlags, nClipboardID, OUString(), 0, OUString(),
OUString(), nFilterFlags, nClipboardID, OUString(), OUString(),
rUserData, OUString() ));
const_cast<SfxFilter*>(pFilter.get())->SetVersion(nFilterVersion);
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index c416609..80f6693 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -131,7 +131,7 @@ protected:
OUString::createFromAscii( pFmt->pFilterName ),
OUString(), pFmt->nFormatType, nOptions,
OUString::createFromAscii( pFmt->pTypeName ),
0, OUString(),
OUString(),
OUString::createFromAscii( pFmt->pUserData ),
"private:factory/simpress*" );
pFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
@@ -168,7 +168,7 @@ protected:
OUString::createFromAscii(pFormat->pFilterName),
OUString(), pFormat->nFormatType, nExportFormat,
OUString::createFromAscii(pFormat->pTypeName),
0, OUString(),
OUString(),
OUString::createFromAscii(pFormat->pUserData),
"private:factory/simpress*" ));
const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
@@ -187,7 +187,7 @@ protected:
OUString::createFromAscii(pFormat->pFilterName),
OUString(), pFormat->nFormatType, nExportFormat,
OUString::createFromAscii(pFormat->pTypeName),
0, OUString(),
OUString(),
OUString::createFromAscii(pFormat->pUserData),
"private:factory/simpress*" ));
const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx
index ed12ff5..ef136761d 100644
--- a/sfx2/source/bastyp/fltfnc.cxx
+++ b/sfx2/source/bastyp/fltfnc.cxx
@@ -1040,7 +1040,6 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
nFlags ,
nClipboardId ,
sType ,
(sal_uInt16)nDocumentIconId ,
sMimeType ,
sUserData ,
sServiceName ));
@@ -1054,7 +1053,6 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
pFilt->nFormatType = nFlags;
pFilt->lFormat = nClipboardId;
pFilt->aTypeName = sType;
pFilt->nDocIcon = (sal_uInt16)nDocumentIconId;
pFilt->aMimeType = sMimeType;
pFilt->aUserData = sUserData;
pFilt->aServiceName = sServiceName;
diff --git a/sfx2/source/bastyp/frmhtml.cxx b/sfx2/source/bastyp/frmhtml.cxx
index b63d4e3..99b8e42 100644
--- a/sfx2/source/bastyp/frmhtml.cxx
+++ b/sfx2/source/bastyp/frmhtml.cxx
@@ -35,7 +35,6 @@ static sal_Char const sHTML_SC_yes[] = "YES";
static sal_Char const sHTML_SC_no[] = "NO";
static sal_Char const sHTML_SC_auto[] = "AUTO";
#define HTML_O_READONLY "READONLY"
#define HTML_O_EDIT "EDIT"
static HTMLOptionEnum<ScrollingMode> const aScrollingTable[] =
@@ -109,15 +108,7 @@ void SfxFrameHTMLParser::ParseFrameOptions(
pFrame->SetResizable( false );
break;
default:
if (rOption.GetTokenString().equalsIgnoreAsciiCase(HTML_O_READONLY))
{
const OUString& aStr = rOption.GetString();
bool bReadonly = true;
if ( aStr.equalsIgnoreAsciiCase("FALSE") )
bReadonly = false;
pFrame->SetReadOnly( bReadonly );
}
else if (rOption.GetTokenString().equalsIgnoreAsciiCase(HTML_O_EDIT))
if (rOption.GetTokenString().equalsIgnoreAsciiCase(HTML_O_EDIT))
{
const OUString& aStr = rOption.GetString();
bool bEdit = true;
diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx
index 8d8876b..99406c4 100644
--- a/sfx2/source/doc/docfilt.cxx
+++ b/sfx2/source/doc/docfilt.cxx
@@ -42,8 +42,7 @@ SfxFilter::SfxFilter( const OUString& rProvider, const OUString &rFilterName ) :
maProvider(rProvider),
nFormatType(SfxFilterFlags::NONE),
nVersion(0),
lFormat(SotClipboardFormatId::NONE),
nDocIcon(0)
lFormat(SotClipboardFormatId::NONE)
{
}
@@ -52,7 +51,6 @@ SfxFilter::SfxFilter( const OUString &rName,
SfxFilterFlags nType,
SotClipboardFormatId lFmt,
const OUString &rTypNm,
sal_uInt16 nIcon,
const OUString &rMimeType,
const OUString &rUsrDat,
const OUString &rServiceName ):
@@ -65,8 +63,7 @@ SfxFilter::SfxFilter( const OUString &rName,
aUIName(maFilterName),
nFormatType(nType),
nVersion(SOFFICE_FILEFORMAT_50),
lFormat(lFmt),
nDocIcon(nIcon)
lFormat(lFmt)
{
OUString aExts = GetWildcard().getGlob();
OUString aShort, aLong;
diff --git a/sfx2/source/doc/frmdescr.cxx b/sfx2/source/doc/frmdescr.cxx
index 5eb4fc2..3bb9977 100644
--- a/sfx2/source/doc/frmdescr.cxx
+++ b/sfx2/source/doc/frmdescr.cxx
@@ -43,9 +43,7 @@ SfxFrameDescriptor::SfxFrameDescriptor() :
eScroll( ScrollingMode::Auto ),
bHasBorder( true ),
bHasBorderSet( false ),
bResizeHorizontal( true ),
bResizeVertical( true ),
bReadOnly( false ),
pImpl( new SfxFrameDescriptor_Impl )
{
}
diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx
index 3c8f205..9bf86aa 100644
--- a/sfx2/source/notebookbar/NotebookbarTabControl.cxx
+++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx
@@ -136,6 +136,10 @@ NotebookbarTabControl::NotebookbarTabControl( Window* pParent )
{
}
NotebookbarTabControl::~NotebookbarTabControl()
{
}
void NotebookbarTabControl::StateChanged(StateChangedType nStateChange)
{
if( !m_bInitialized && SfxViewFrame::Current() )
@@ -146,7 +150,7 @@ void NotebookbarTabControl::StateChanged(StateChangedType nStateChange)
SetToolBox( static_cast<ToolBox*>( pShortcuts.get() ) );
SetIconClickHdl( LINK( this, NotebookbarTabControl, OpenNotebookbarPopupMenu ) );
m_pListener = new ChangedUIEventListener( this );
m_pListener.reset( new ChangedUIEventListener( this ) );
m_bInitialized = true;
}
diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx
index cda50d9..927b844 100644
--- a/sfx2/source/view/frame.cxx
+++ b/sfx2/source/view/frame.cxx
@@ -338,10 +338,6 @@ void SfxFrame::GetViewData_Impl()
SfxViewFrame* pViewFrame = GetCurrentViewFrame();
if( pViewFrame && pViewFrame->GetViewShell() )
{
const SfxMedium *pMed = GetCurrentDocument()->GetMedium();
bool bReadOnly = pMed->GetOpenMode() == SFX_STREAM_READONLY;
GetDescriptor()->SetReadOnly( bReadOnly );
SfxItemSet *pSet = GetDescriptor()->GetArgs();
bool bGetViewData = false;
if ( GetController().is() && pSet->GetItemState( SID_VIEW_DATA ) != SfxItemState::SET )
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index d08517f..97e4442 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -355,7 +355,7 @@ void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::disposing( const lang:
{
}
void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::queryClosing( const lang::EventObject& aEvent, sal_Bool bDeliverOwnership )
void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::queryClosing( const lang::EventObject& /*aEvent*/, sal_Bool /*bDeliverOwnership*/ )
{
SolarMutexGuard aGuard;
SfxViewShell* pShell = m_pController->GetViewShell_Impl();
@@ -364,16 +364,6 @@ void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::queryClosing( const la
bool bCanClose = pShell->PrepareClose( false );
if ( !bCanClose )
{
if ( bDeliverOwnership && ( !pShell->GetWindow() || !pShell->GetWindow()->IsReallyVisible() ) )
{
// ignore Ownership in case of visible frame (will be closed by user)
Reference < frame::XModel > xModel( aEvent.Source, uno::UNO_QUERY );
if ( xModel.is() )
pShell->TakeOwnership_Impl();
else
pShell->TakeFrameOwnership_Impl();
}
throw util::CloseVetoException("Controller disagree ...",static_cast< ::cppu::OWeakObject*>(this));
}
}
@@ -978,7 +968,6 @@ void SAL_CALL SfxBaseController::dispose()
if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell )
pFrame->GetFrame().SetIsClosing_Impl();
m_pData->m_pViewShell->DiscardClients_Impl();
m_pData->m_pViewShell->pImpl->m_bControllerSet = false;
if ( pFrame )
{
diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx
index 2994a21..976869a 100644
--- a/sfx2/source/view/viewimp.hxx
+++ b/sfx2/source/view/viewimp.hxx
@@ -43,13 +43,10 @@ struct SfxViewShell_Impl
{
::osl::Mutex aMutex;
::comphelper::OInterfaceContainerHelper2 aInterceptorContainer;
bool m_bControllerSet;
SfxShellArr_Impl aArr;
Size aMargin;
bool m_bHasPrintOptions;
bool m_bIsShowView;
bool m_bGotOwnership;
bool m_bGotFrameOwnership;
sal_uInt16 m_nFamily;
::rtl::Reference<SfxBaseController> m_pController;
std::unique_ptr< ::svt::AcceleratorExecute > m_xAccExec;
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 205c73e..dd81339 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -230,11 +230,8 @@ sal_uInt32 SfxViewShell_Impl::m_nLastViewShellId = 0;
SfxViewShell_Impl::SfxViewShell_Impl(SfxViewShellFlags const nFlags)
: aInterceptorContainer( aMutex )
, m_bControllerSet(false)
, m_bHasPrintOptions(nFlags & SfxViewShellFlags::HAS_PRINTOPTIONS)
, m_bIsShowView(!(nFlags & SfxViewShellFlags::NO_SHOW))
, m_bGotOwnership(false)
, m_bGotFrameOwnership(false)
, m_nFamily(0xFFFF) // undefined, default set by TemplateDialog
, m_pController(nullptr)
, mpIPClientList(nullptr)
@@ -1725,7 +1722,6 @@ void SfxViewShell::JumpToMark( const OUString& rMark )
void SfxViewShell::SetController( SfxBaseController* pController )
{
pImpl->m_pController = pController;
pImpl->m_bControllerSet = true;
// there should be no old listener, but if there is one, it should be disconnected
if ( pImpl->xClipboardListener.is() )
@@ -1916,20 +1912,6 @@ bool SfxViewShell::TryContextMenuInterception( Menu& rMenu, const OUString& rMen
return true;
}
void SfxViewShell::TakeOwnership_Impl()
{
// currently there is only one reason to take Ownership: a hidden frame is printed
// so the ViewShell will check this on EndPrint (->prnmon.cxx)
pImpl->m_bGotOwnership = true;
}
void SfxViewShell::TakeFrameOwnership_Impl()
{
// currently there is only one reason to take Ownership: a hidden frame is printed
// so the ViewShell will check this on EndPrint (->prnmon.cxx)
pImpl->m_bGotFrameOwnership = true;
}
bool SfxViewShell::HandleNotifyEvent_Impl( NotifyEvent& rEvent )
{
if (pImpl->m_pController.is())
diff --git a/starmath/qa/extras/mmlimport-test.cxx b/starmath/qa/extras/mmlimport-test.cxx
index 430209a..26f553b 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -59,7 +59,6 @@ private:
SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::TEMPLATE,
SotClipboardFormatId::STARCALC_8,
"MathML 2.0",
0,
OUString(),
OUString(),
"private:factory/smath*"));
diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx
index 0eff13b..5d07224 100644
--- a/sw/qa/core/filters-test.cxx
+++ b/sw/qa/core/filters-test.cxx
@@ -82,7 +82,7 @@ bool SwFiltersTest::filter(const OUString &rFilter, const OUString &rURL,
{
std::shared_ptr<const SfxFilter> pFilter(new SfxFilter(
rFilter, OUString(), nFilterFlags,
nClipboardID, OUString(), 0, OUString(),
nClipboardID, OUString(), OUString(),
rUserData, OUString()));
const_cast<SfxFilter*>(pFilter.get())->SetVersion(nFilterVersion);
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index e816a91..4148d93 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -190,7 +190,7 @@ void SwDocTest::testFileNameFields()
std::shared_ptr<SfxFilter> pFilter(new SfxFilter(
"Text",
OUString(), SfxFilterFlags::NONE, SotClipboardFormatId::NONE, OUString(), 0, OUString(),
OUString(), SfxFilterFlags::NONE, SotClipboardFormatId::NONE, OUString(), OUString(),
"TEXT", OUString() ));
aDstMed.SetFilter(pFilter);