Kaydet (Commit) 9a1e6d91 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:unuseddefaultparam in sfx2

and fix an issue with calls to templated methods in the plugin

Change-Id: I9c9537a0690ff671286c007846d5f4cfb7d2982b
üst 6610ad9a
......@@ -129,10 +129,17 @@ bool UnusedDefaultParams::VisitCallExpr(CallExpr * callExpr) {
if (ignoreLocation(callExpr)) {
return true;
}
if (callExpr->getDirectCallee() == nullptr) {
const FunctionDecl* functionDecl;
if (isa<CXXMemberCallExpr>(callExpr)) {
functionDecl = dyn_cast<CXXMemberCallExpr>(callExpr)->getMethodDecl();
}
else {
functionDecl = callExpr->getDirectCallee();
}
if (functionDecl == nullptr) {
return true;
}
const FunctionDecl* functionDecl = callExpr->getDirectCallee()->getCanonicalDecl();
functionDecl = functionDecl->getCanonicalDecl();
// method overrides don't always specify the same default params (althogh they probably should)
// so we need to work our way up to the root method
while (isa<CXXMethodDecl>(functionDecl)) {
......@@ -141,6 +148,16 @@ bool UnusedDefaultParams::VisitCallExpr(CallExpr * callExpr) {
break;
functionDecl = *methodDecl->begin_overridden_methods();
}
// work our way back to the root definition for template methods
if (functionDecl->getInstantiatedFromMemberFunction())
functionDecl = functionDecl->getInstantiatedFromMemberFunction();
else if (functionDecl->getClassScopeSpecializationPattern())
functionDecl = functionDecl->getClassScopeSpecializationPattern();
// workaround clang-3.5 issue
#if CLANG_VERSION >= 30600
else if (functionDecl->getTemplateInstantiationPattern())
functionDecl = functionDecl->getTemplateInstantiationPattern();
#endif
auto n = functionDecl->getNumParams();
if (n == 0 || !functionDecl->getParamDecl(n - 1)->hasDefaultArg()) {
return true;
......
......@@ -369,10 +369,9 @@ void AbstractPasteDialog_Impl::SetObjName( const SvGlobalName & rClass, const OU
pDlg->SetObjName( rClass, rObjName );
}
SotClipboardFormatId AbstractPasteDialog_Impl::GetFormat( const TransferableDataHelper& aHelper,
const DataFlavorExVector* pFormats )
SotClipboardFormatId AbstractPasteDialog_Impl::GetFormat( const TransferableDataHelper& aHelper )
{
return pDlg->GetFormat( aHelper, pFormats );
return pDlg->GetFormat( aHelper );
}
void AbstractFmShowColsDialog_Impl::SetColumns(const ::Reference< css::container::XIndexContainer>& xCols)
......@@ -878,8 +877,7 @@ VclAbstractDialog* AbstractDialogFactory_Impl::CreateFrameDialog(
SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateTabDialog( sal_uInt32 nResId,
vcl::Window* pParent,
const SfxItemSet* pAttrSet,
SfxViewFrame* ,
bool /*bEditFmt*/ )
SfxViewFrame* )
{
SfxTabDialog* pDlg=nullptr;
switch ( nResId )
......@@ -902,8 +900,7 @@ SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateTabDialog( sal_uInt32 nR
SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateTabDialog( sal_uInt32 nResId,
vcl::Window* pParent,
const SfxItemSet* pAttrSet,
const Reference< frame::XFrame >& xViewFrame,
bool /*bEditFmt*/ )
const Reference< frame::XFrame >& xViewFrame )
{
VclPtr<SfxTabDialog> pDlg;
switch ( nResId )
......
......@@ -432,8 +432,7 @@ public:
DECL_ABSTDLG_BASE(AbstractPasteDialog_Impl, SvPasteObjectDialog )
virtual void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName ) override;
virtual void SetObjName( const SvGlobalName & rClass, const OUString & rObjName ) override;
virtual SotClipboardFormatId GetFormat( const TransferableDataHelper& aHelper,
const DataFlavorExVector* pFormats=nullptr ) override;
virtual SotClipboardFormatId GetFormat( const TransferableDataHelper& aHelper ) override;
};
class AbstractLinksDialog_Impl : public SfxAbstractLinksDialog
......@@ -495,13 +494,11 @@ public:
virtual SfxAbstractTabDialog* CreateTabDialog( sal_uInt32 nResId,
vcl::Window* pParent,
const SfxItemSet* pAttrSet,
SfxViewFrame* pViewFrame,
bool bEditFmt=false ) override;
SfxViewFrame* pViewFrame ) override;
virtual SfxAbstractTabDialog* CreateTabDialog( sal_uInt32 nResId,
vcl::Window* pParent,
const SfxItemSet* pAttrSet,
const css::uno::Reference< css::frame::XFrame >& xViewFrame,
bool bEditFmt=false ) override;
const css::uno::Reference< css::frame::XFrame >& xViewFrame ) override;
virtual SfxAbstractTabDialog* CreateTextTabDialog( vcl::Window* pParent,
const SfxItemSet* pAttrSet,
SdrView* pView ) override;
......
......@@ -78,8 +78,7 @@ struct SAL_DLLPUBLIC_RTTI SfxChildWinInfo
}
bool GetExtraData_Impl( SfxChildAlignment *pAlign,
SfxChildAlignment *pLastAlign = nullptr,
Size *pSize = nullptr,
sal_uInt16 *pLine = nullptr ) const;
Size *pSize = nullptr ) const;
};
// ChildWindow factory methods
......
......@@ -95,7 +95,7 @@ public:
SAL_DLLPRIVATE static bool IsFilterInstalled_Impl( const SfxFilter* pFilter );
DECL_DLLPRIVATE_LINK_TYPED( MaybeFileHdl_Impl, OUString*, bool );
sal_uInt32 GuessFilterIgnoringContent( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust = SfxFilterFlags::IMPORT ) const;
sal_uInt32 GuessFilterIgnoringContent( SfxMedium& rMedium, const SfxFilter ** ) const;
sal_uInt32 GuessFilter( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
sal_uInt32 GuessFilterControlDefaultUI( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED, bool bDefUI = true ) const;
sal_uInt32 DetectFilter( SfxMedium& rMedium, const SfxFilter ** ) const;
......
......@@ -46,7 +46,7 @@ public:
bool bWait = true );
virtual ~SfxProgress();
bool SetStateText( sal_uIntPtr nVal, const rtl::OUString &rVal, sal_uIntPtr nNewRange = 0 );
bool SetStateText( sal_uIntPtr nVal, const rtl::OUString &rVal );
bool SetState( sal_uIntPtr nVal, sal_uIntPtr nNewRange = 0 );
sal_uIntPtr GetState() const { return nVal; }
......
......@@ -95,8 +95,7 @@ class SfxAbstractPasteDialog : virtual public VclAbstractDialog
public:
virtual void Insert( SotClipboardFormatId nFormat, const rtl::OUString & rFormatName ) = 0;
virtual void SetObjName( const SvGlobalName & rClass, const rtl::OUString & rObjName ) = 0;
virtual SotClipboardFormatId GetFormat( const TransferableDataHelper& aHelper,
const DataFlavorExVector* pFormats=nullptr ) = 0;
virtual SotClipboardFormatId GetFormat( const TransferableDataHelper& aHelper ) = 0;
};
class SfxAbstractLinksDialog : virtual public VclAbstractDialog
......@@ -121,13 +120,11 @@ public:
virtual SfxAbstractTabDialog* CreateTabDialog( sal_uInt32 nResId,
vcl::Window* pParent,
const SfxItemSet* pAttrSet,
SfxViewFrame* pViewFrame,
bool bEditFmt=false ) = 0;
SfxViewFrame* pViewFrame ) = 0;
virtual SfxAbstractTabDialog* CreateTabDialog( sal_uInt32 nResId,
vcl::Window* pParent,
const SfxItemSet* pAttrSet,
const css::uno::Reference< css::frame::XFrame >& xViewFrame,
bool bEditFmt=false ) = 0;
const css::uno::Reference< css::frame::XFrame >& xViewFrame ) = 0;
virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ) = 0;
virtual GetTabPageRanges GetTabPageRangesFunc( sal_uInt16 nId ) = 0;
virtual SfxAbstractInsertObjectDialog* CreateInsertObjectDialog( vcl::Window* pParent, const OUString& rCommand,
......
......@@ -140,8 +140,7 @@ public:
sal_uInt16 nPos = TAB_APPEND);
void AddTabPage( sal_uInt16 nId,
const OUString &rRiderText,
bool bItemsOnDemand = false);
const OUString &rRiderText);
void RemoveTabPage( const OString& rName ); // Name of the label for the page in the notebook .ui
void RemoveTabPage( sal_uInt16 nId );
......@@ -188,7 +187,7 @@ public:
short Execute() override;
void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override;
void Start( bool bShow = true );
void Start();
const SfxItemSet* GetExampleSet() const { return pExampleSet; }
SfxItemSet* GetExampleSet() { return pExampleSet; }
......
......@@ -579,8 +579,7 @@ bool SfxChildWinInfo::GetExtraData_Impl
(
SfxChildAlignment *pAlign,
SfxChildAlignment *pLastAlign,
Size *pSize,
sal_uInt16 *pLine
Size *pSize
) const
{
// invalid?
......@@ -631,8 +630,6 @@ bool SfxChildWinInfo::GetExtraData_Impl
{
if ( pSize )
*pSize = aChildSize;
if ( pLine )
*pLine = (sal_uInt16) aChildPos.X();
return true;
}
return false;
......
......@@ -374,8 +374,7 @@ const SfxFilter* SfxFilterMatcher::GetAnyFilter( SfxFilterFlags nMust, SfxFilter
sal_uInt32 SfxFilterMatcher::GuessFilterIgnoringContent(
SfxMedium& rMedium,
const SfxFilter**ppFilter,
SfxFilterFlags nMust ) const
const SfxFilter**ppFilter ) const
{
uno::Reference<document::XTypeDetection> xDetection(
comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.TypeDetection"), uno::UNO_QUERY);
......@@ -394,7 +393,7 @@ sal_uInt32 SfxFilterMatcher::GuessFilterIgnoringContent(
{
// make sure filter list is initialized
m_rImpl.InitForIterating();
*ppFilter = GetFilter4EA( sTypeName, nMust );
*ppFilter = GetFilter4EA( sTypeName );
}
return *ppFilter ? ERRCODE_NONE : ERRCODE_ABORT;
......
......@@ -215,13 +215,12 @@ void SfxProgress::Stop()
bool SfxProgress::SetStateText
(
sal_uLong nNewVal, /* New value for the progress-bar */
const OUString& rNewVal, /* Status as Text */
sal_uLong nNewRange /* new maximum value, 0 for retaining the old */
const OUString& rNewVal /* Status as Text */
)
{
pImp->aStateText = rNewVal;
return SetState( nNewVal, nNewRange );
return SetState( nNewVal );
}
bool SfxProgress::SetState
......
......@@ -520,13 +520,12 @@ void SfxTabDialog::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl )
}
void SfxTabDialog::Start( bool bShow )
void SfxTabDialog::Start()
{
pImpl->bModal = false;
Start_Impl();
if ( bShow )
Show();
Show();
if ( IsVisible() && ( !HasChildPathFocus() || HasFocus() ) )
GrabFocusToFirstControl();
......@@ -575,9 +574,9 @@ void SfxTabDialog::Start_Impl()
ActivatePageHdl( m_pTabCtrl );
}
void SfxTabDialog::AddTabPage( sal_uInt16 nId, const OUString &rRiderText, bool bItemsOnDemand )
void SfxTabDialog::AddTabPage( sal_uInt16 nId, const OUString &rRiderText )
{
AddTabPage( nId, rRiderText, nullptr, nullptr, bItemsOnDemand );
AddTabPage( nId, rRiderText, nullptr, nullptr );
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment