diff options
-rw-r--r-- | compilerplugins/clang/redundantcast.cxx | 63 | ||||
-rw-r--r-- | compilerplugins/clang/test/redundantcast.cxx | 34 | ||||
-rw-r--r-- | reportdesign/inc/UndoActions.hxx | 28 | ||||
-rw-r--r-- | reportdesign/source/core/sdr/UndoActions.cxx | 30 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Navigator.cxx | 8 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/ReportController.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/RptUndo.hxx | 12 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/SectionWindow.hxx | 4 | ||||
-rw-r--r-- | reportdesign/source/ui/misc/RptUndo.cxx | 6 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 28 | ||||
-rw-r--r-- | reportdesign/source/ui/report/SectionWindow.cxx | 16 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ViewsWindow.cxx | 16 |
12 files changed, 159 insertions, 88 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index bdf23d9094cf..2f905d355720 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -161,6 +161,7 @@ public: private: bool visitBinOp(BinaryOperator const * expr); bool isOkToRemoveArithmeticCast(QualType t1, QualType t2, const Expr* subExpr); + bool isOverloadedFunction(FunctionDecl const * decl); }; bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) { @@ -362,9 +363,10 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) { if (ignoreLocation(expr)) { return true; } - auto const sub = compat::getSubExprAsWritten(expr); - auto const t1 = sub->getType(); auto const t2 = expr->getTypeAsWritten(); + bool const fnptr = t2->isFunctionPointerType() || t2->isMemberFunctionPointerType(); + auto const sub = fnptr ? expr->getSubExpr() : compat::getSubExprAsWritten(expr); + auto const t1 = sub->getType(); auto const nonClassObjectType = t2->isObjectType() && !(t2->isRecordType() || t2->isArrayType()); if (nonClassObjectType && t2.hasLocalQualifiers()) { @@ -445,6 +447,23 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) { { return true; } + // Don't warn if a static_cast on a pointer to function or member function is used to + // disambiguate an overloaded function: + if (fnptr) { + auto e = sub->IgnoreParenImpCasts(); + if (auto const e1 = dyn_cast<UnaryOperator>(e)) { + if (e1->getOpcode() == UO_AddrOf) { + e = e1->getSubExpr()->IgnoreParenImpCasts(); + } + } + if (auto const e1 = dyn_cast<DeclRefExpr>(e)) { + if (auto const fdecl = dyn_cast<FunctionDecl>(e1->getDecl())) { + if (isOverloadedFunction(fdecl)) { + return true; + } + } + } + } // Suppress warnings from static_cast<bool> in C++ definition of assert in // <https://sourceware.org/git/?p=glibc.git;a=commit; // h=b5889d25e9bf944a89fdd7bcabf3b6c6f6bb6f7c> "assert: Support types @@ -625,7 +644,9 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp // ), and only to cases where the sub-expression already is a prvalue of // non-class type (and thus the cast is unlikely to be meant to create a // temporary): - auto const sub = compat::getSubExprAsWritten(expr); + auto const t1 = expr->getTypeAsWritten(); + bool const fnptr = t1->isFunctionPointerType() || t1->isMemberFunctionPointerType(); + auto const sub = fnptr ? expr->getSubExpr() : compat::getSubExprAsWritten(expr); if (sub->getValueKind() != VK_RValue || expr->getType()->isRecordType() || isa<InitListExpr>(sub) || isa<CXXStdInitializerListExpr>(sub)) { @@ -643,6 +664,24 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp } } + // Don't warn if a functional cast on a pointer to function or member function is used to + // disambiguate an overloaded function: + if (fnptr) { + auto e = sub->IgnoreParenImpCasts(); + if (auto const e1 = dyn_cast<UnaryOperator>(e)) { + if (e1->getOpcode() == UO_AddrOf) { + e = e1->getSubExpr()->IgnoreParenImpCasts(); + } + } + if (auto const e1 = dyn_cast<DeclRefExpr>(e)) { + if (auto const fdecl = dyn_cast<FunctionDecl>(e1->getDecl())) { + if (isOverloadedFunction(fdecl)) { + return true; + } + } + } + } + // See the commit message of d0e7d020fa405ab94f19916ec96fbd4611da0031 // "socket.c -> socket.cxx" for the reason to have // @@ -666,7 +705,6 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp } } - auto const t1 = expr->getTypeAsWritten(); auto const t2 = sub->getType(); if (t1.getCanonicalType() != t2.getCanonicalType()) return true; @@ -766,6 +804,23 @@ bool RedundantCast::visitBinOp(BinaryOperator const * expr) { return true; } +bool RedundantCast::isOverloadedFunction(FunctionDecl const * decl) { + auto const ctx = decl->getDeclContext(); + if (!compat::isLookupContext(*ctx)) { + return false; + } + auto const canon = decl->getCanonicalDecl(); + auto const res = ctx->lookup(decl->getDeclName()); + for (auto d = res.begin(); d != res.end(); ++d) { + if (auto const f = dyn_cast<FunctionDecl>(*d)) { + if (f->getCanonicalDecl() != canon) { + return true; + } + } + } + return false; +} + loplugin::Plugin::Registration<RedundantCast> X("redundantcast", true); } diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx index 20578079c2cb..70fcdf3340cb 100644 --- a/compilerplugins/clang/test/redundantcast.cxx +++ b/compilerplugins/clang/test/redundantcast.cxx @@ -340,6 +340,40 @@ void testDynamicCast() { (void) dynamic_cast<S3 *>(s2); } +void overload(int); +void overload(long); +void nonOverload(); + +struct Overload { + int overload(); + long overload() const; + void nonOverload(); +}; + +void testOverloadResolution() { + (void) static_cast<void (*)(long)>(overload); + (void) static_cast<void (*)(long)>((overload)); + (void) static_cast<void (*)(long)>(&overload); + (void) static_cast<void (*)(long)>((&overload)); + (void) static_cast<void (*)(long)>(&((overload))); + (void) static_cast<void (*)()>(nonOverload); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<void (*)()>((nonOverload)); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<void (*)()>(&nonOverload); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<void (*)()>((&nonOverload)); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<void (*)()>(&((nonOverload))); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<long (Overload::*)() const>(&Overload::overload); + (void) static_cast<void (Overload::*)()>(&Overload::nonOverload); // expected-error {{static_cast from 'void (Overload::*)()' prvalue to 'void (Overload::*)()' prvalue is redundant [loplugin:redundantcast]}} + + using OverloadFn = void (*)(long); + (void) OverloadFn(overload); + using NonOverloadFn = void (*)(); + (void) NonOverloadFn(nonOverload); // expected-error {{redundant functional cast from 'void (*)()' to 'NonOverloadFn' (aka 'void (*)()') [loplugin:redundantcast]}} + using OverloadMemFn = long (Overload::*)() const; + (void) OverloadMemFn(&Overload::overload); + using NonOverloadMemFn = void (Overload::*)(); + (void) NonOverloadMemFn(&Overload::nonOverload); // expected-error {{redundant functional cast from 'void (Overload::*)()' to 'NonOverloadMemFn' (aka 'void (Overload::*)()') [loplugin:redundantcast]}} +}; + int main() { testConstCast(); testStaticCast(); diff --git a/reportdesign/inc/UndoActions.hxx b/reportdesign/inc/UndoActions.hxx index 7df624f28418..82dd992f5686 100644 --- a/reportdesign/inc/UndoActions.hxx +++ b/reportdesign/inc/UndoActions.hxx @@ -71,7 +71,7 @@ namespace rptui bool getHeaderOn() { return m_xGroup->getHeaderOn(); } bool getFooterOn() { return m_xGroup->getFooterOn(); } - static ::std::mem_fun_t< css::uno::Reference< css::report::XSection> , OGroupHelper> getMemberFunction(const css::uno::Reference< css::report::XSection >& _xSection); + static ::std::function<css::uno::Reference< css::report::XSection>(OGroupHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection >& _xSection); }; @@ -96,7 +96,7 @@ namespace rptui bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); } bool getPageFooterOn() { return m_xReport->getPageFooterOn(); } - static ::std::mem_fun_t< css::uno::Reference< css::report::XSection> , OReportHelper> getMemberFunction(const css::uno::Reference< css::report::XSection >& _xSection); + static ::std::function<css::uno::Reference< css::report::XSection>(OReportHelper *)> getMemberFunction(const css::uno::Reference< css::report::XSection >& _xSection); }; @@ -196,13 +196,11 @@ namespace rptui class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction : public OUndoContainerAction { OReportHelper m_aReportHelper; - ::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OReportHelper> m_pMemberFunction; + ::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction; public: OUndoReportSectionAction(SdrModel& rMod ,Action _eAction - ,::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OReportHelper> _pMemberFunction + ,::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction ,const css::uno::Reference< css::report::XReportDefinition >& _xReport ,const css::uno::Reference< css::uno::XInterface>& xElem ,const char* pCommentId); @@ -217,13 +215,11 @@ namespace rptui class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction : public OUndoContainerAction { OGroupHelper m_aGroupHelper; - ::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OGroupHelper> m_pMemberFunction; + ::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction; public: OUndoGroupSectionAction(SdrModel& rMod ,Action _eAction - ,::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OGroupHelper> _pMemberFunction + ,::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction ,const css::uno::Reference< css::report::XGroup >& _xGroup ,const css::uno::Reference< css::uno::XInterface>& xElem ,const char* pCommentId); @@ -264,15 +260,13 @@ namespace rptui class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction : public ORptUndoPropertyAction { OReportHelper m_aReportHelper; - ::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OReportHelper> m_pMemberFunction; + ::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction; protected: virtual css::uno::Reference< css::beans::XPropertySet> getObject() override; public: OUndoPropertyReportSectionAction(SdrModel& rMod ,const css::beans::PropertyChangeEvent& evt - ,::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OReportHelper> _pMemberFunction + ,::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction ,const css::uno::Reference< css::report::XReportDefinition >& _xReport ); }; @@ -283,15 +277,13 @@ namespace rptui class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction : public ORptUndoPropertyAction { OGroupHelper m_aGroupHelper; - ::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OGroupHelper> m_pMemberFunction; + ::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction; protected: virtual css::uno::Reference< css::beans::XPropertySet> getObject() override; public: OUndoPropertyGroupSectionAction(SdrModel& rMod ,const css::beans::PropertyChangeEvent& evt - ,::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OGroupHelper> _pMemberFunction + ,::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction ,const css::uno::Reference< css::report::XGroup >& _xGroup ); }; diff --git a/reportdesign/source/core/sdr/UndoActions.cxx b/reportdesign/source/core/sdr/UndoActions.cxx index df9bd7fafc77..825fd7b8f574 100644 --- a/reportdesign/source/core/sdr/UndoActions.cxx +++ b/reportdesign/source/core/sdr/UndoActions.cxx @@ -54,27 +54,27 @@ namespace rptui using namespace container; using namespace report; -::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> OGroupHelper::getMemberFunction(const Reference< XSection >& _xSection) +::std::function<uno::Reference<report::XSection>(OGroupHelper *)> OGroupHelper::getMemberFunction(const Reference< XSection >& _xSection) { - ::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter); + ::std::function<uno::Reference<report::XSection>(OGroupHelper *)> pMemFunSection = ::std::mem_fn(&OGroupHelper::getFooter); uno::Reference< report::XGroup> xGroup = _xSection->getGroup(); if ( xGroup->getHeaderOn() && xGroup->getHeader() == _xSection ) - pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader); + pMemFunSection = ::std::mem_fn(&OGroupHelper::getHeader); return pMemFunSection; } -::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> OReportHelper::getMemberFunction(const Reference< XSection >& _xSection) +::std::function<uno::Reference<report::XSection>(OReportHelper *)> OReportHelper::getMemberFunction(const Reference< XSection >& _xSection) { uno::Reference< report::XReportDefinition> xReportDefinition(_xSection->getReportDefinition()); - ::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> pMemFunSection = ::std::mem_fun(&OReportHelper::getReportFooter); + ::std::function<uno::Reference<report::XSection>(OReportHelper *)> pMemFunSection = ::std::mem_fn(&OReportHelper::getReportFooter); if ( xReportDefinition->getReportHeaderOn() && xReportDefinition->getReportHeader() == _xSection ) - pMemFunSection = ::std::mem_fun(&OReportHelper::getReportHeader); + pMemFunSection = ::std::mem_fn(&OReportHelper::getReportHeader); else if ( xReportDefinition->getPageHeaderOn() && xReportDefinition->getPageHeader() == _xSection ) - pMemFunSection = ::std::mem_fun(&OReportHelper::getPageHeader); + pMemFunSection = ::std::mem_fn(&OReportHelper::getPageHeader); else if ( xReportDefinition->getPageFooterOn() && xReportDefinition->getPageFooter() == _xSection ) - pMemFunSection = ::std::mem_fun(&OReportHelper::getPageFooter); + pMemFunSection = ::std::mem_fn(&OReportHelper::getPageFooter); else if ( xReportDefinition->getDetail() == _xSection ) - pMemFunSection = ::std::mem_fun(&OReportHelper::getDetail); + pMemFunSection = ::std::mem_fn(&OReportHelper::getDetail); return pMemFunSection; } @@ -242,8 +242,7 @@ void OUndoContainerAction::Redo() OUndoGroupSectionAction::OUndoGroupSectionAction(SdrModel& _rMod ,Action _eAction - ,::std::mem_fun_t< uno::Reference< report::XSection > - ,OGroupHelper> _pMemberFunction + ,::std::function<uno::Reference< report::XSection >(OGroupHelper *)> _pMemberFunction ,const uno::Reference< report::XGroup >& _xGroup ,const Reference< XInterface > & xElem ,const char* pCommentId) @@ -288,8 +287,7 @@ void OUndoGroupSectionAction::implReRemove( ) OUndoReportSectionAction::OUndoReportSectionAction(SdrModel& _rMod ,Action _eAction - ,::std::mem_fun_t< uno::Reference< report::XSection > - ,OReportHelper> _pMemberFunction + ,::std::function<uno::Reference< report::XSection >(OReportHelper *)> _pMemberFunction ,const uno::Reference< report::XReportDefinition >& _xReport ,const Reference< XInterface > & xElem ,const char* pCommentId) @@ -388,8 +386,7 @@ OUString ORptUndoPropertyAction::GetComment() const OUndoPropertyGroupSectionAction::OUndoPropertyGroupSectionAction(SdrModel& _rMod ,const PropertyChangeEvent& evt - ,::std::mem_fun_t< uno::Reference< report::XSection > - ,OGroupHelper> _pMemberFunction + ,::std::function<uno::Reference< report::XSection >(OGroupHelper *)> _pMemberFunction ,const uno::Reference< report::XGroup >& _xGroup ) :ORptUndoPropertyAction(_rMod,evt) @@ -405,8 +402,7 @@ Reference< XPropertySet> OUndoPropertyGroupSectionAction::getObject() OUndoPropertyReportSectionAction::OUndoPropertyReportSectionAction(SdrModel& _rMod ,const PropertyChangeEvent& evt - ,::std::mem_fun_t< uno::Reference< report::XSection > - ,OReportHelper> _pMemberFunction + ,::std::function<uno::Reference< report::XSection >(OReportHelper *)> _pMemberFunction ,const uno::Reference< report::XReportDefinition >& _xReport ) :ORptUndoPropertyAction(_rMod,evt) diff --git a/reportdesign/source/ui/dlg/Navigator.cxx b/reportdesign/source/ui/dlg/Navigator.cxx index 4afc637bb944..9fd07a97704f 100644 --- a/reportdesign/source/ui/dlg/Navigator.cxx +++ b/reportdesign/source/ui/dlg/Navigator.cxx @@ -823,12 +823,12 @@ void NavigatorTree::UserData::_propertyChanged(const beans::PropertyChangeEvent& { sal_Int32 nPos = 1; uno::Reference< report::XGroup> xGroup(_rEvent.Source,uno::UNO_QUERY); - ::std::mem_fun_t< bool,OGroupHelper> pIsOn = ::std::mem_fun(&OGroupHelper::getHeaderOn); - ::std::mem_fun_t< uno::Reference<report::XSection> ,OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader); + ::std::function<bool(OGroupHelper *)> pIsOn = ::std::mem_fn(&OGroupHelper::getHeaderOn); + ::std::function<uno::Reference<report::XSection>(OGroupHelper *)> pMemFunSection = ::std::mem_fn(&OGroupHelper::getHeader); if ( bFooterOn ) { - pIsOn = ::std::mem_fun(&OGroupHelper::getFooterOn); - pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter); + pIsOn = ::std::mem_fn(&OGroupHelper::getFooterOn); + pMemFunSection = ::std::mem_fn(&OGroupHelper::getFooter); nPos = m_pTree->GetChildCount(pEntry) - 1; } diff --git a/reportdesign/source/ui/inc/ReportController.hxx b/reportdesign/source/ui/inc/ReportController.hxx index fe45320beeaa..483ef5379c5e 100644 --- a/reportdesign/source/ui/inc/ReportController.hxx +++ b/reportdesign/source/ui/inc/ReportController.hxx @@ -199,7 +199,7 @@ namespace rptui ,sal_Int32 _nGroupPos ,bool _bShow); - void executeMethodWithUndo(const char* pUndoStrId,const ::std::mem_fun_t<void,ODesignView>& _pMemfun); + void executeMethodWithUndo(const char* pUndoStrId,const ::std::function<void(ODesignView *)>& _pMemfun); void alignControlsWithUndo(const char* pUndoStrId, ControlModification _nControlModification, bool _bAlignAtSection = false); css::uno::Reference< css::frame::XFrame > getXFrame(); diff --git a/reportdesign/source/ui/inc/RptUndo.hxx b/reportdesign/source/ui/inc/RptUndo.hxx index 201d2ef320d9..9c125121b9e1 100644 --- a/reportdesign/source/ui/inc/RptUndo.hxx +++ b/reportdesign/source/ui/inc/RptUndo.hxx @@ -66,8 +66,7 @@ namespace rptui class OReportSectionUndo : public OSectionUndo { OReportHelper m_aReportHelper; - ::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OReportHelper> m_pMemberFunction; + ::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> m_pMemberFunction; void implReInsert( ) override; void implReRemove( ) override; @@ -77,8 +76,7 @@ namespace rptui //OReportSectionUndo( const css::uno::Reference< css::report::XSection >& _xSection OReportSectionUndo( OReportModel& rMod ,sal_uInt16 _nSlot - ,::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OReportHelper> _pMemberFunction + ,::std::function<css::uno::Reference< css::report::XSection >(OReportHelper *)> _pMemberFunction ,const css::uno::Reference< css::report::XReportDefinition >& _xReport ,Action _eAction); virtual ~OReportSectionUndo() override; @@ -89,8 +87,7 @@ namespace rptui class OGroupSectionUndo : public OSectionUndo { OGroupHelper m_aGroupHelper; - ::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OGroupHelper> m_pMemberFunction; + ::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> m_pMemberFunction; mutable OUString m_sName; @@ -102,8 +99,7 @@ namespace rptui //OGroupSectionUndo( const css::uno::Reference< css::report::XSection >& _xSection OGroupSectionUndo( OReportModel& rMod ,sal_uInt16 _nSlot - ,::std::mem_fun_t< css::uno::Reference< css::report::XSection > - ,OGroupHelper> _pMemberFunction + ,::std::function<css::uno::Reference< css::report::XSection >(OGroupHelper *)> _pMemberFunction ,const css::uno::Reference< css::report::XGroup >& _xGroup ,Action _eAction ,const char* pCommentID); diff --git a/reportdesign/source/ui/inc/SectionWindow.hxx b/reportdesign/source/ui/inc/SectionWindow.hxx index 42f01962bc59..a08bf82a27a5 100644 --- a/reportdesign/source/ui/inc/SectionWindow.hxx +++ b/reportdesign/source/ui/inc/SectionWindow.hxx @@ -66,7 +66,7 @@ namespace rptui * \param _pIsSectionOn * @return sal_True when title was set otherwise FALSE */ - bool setGroupSectionTitle(const css::uno::Reference< css::report::XGroup>& _xGroup,const char* pResId,::std::mem_fun_t< css::uno::Reference< css::report::XSection> , OGroupHelper> _pGetSection, const ::std::mem_fun_t<bool, OGroupHelper>& _pIsSectionOn); + bool setGroupSectionTitle(const css::uno::Reference< css::report::XGroup>& _xGroup,const char* pResId,::std::function<css::uno::Reference< css::report::XSection>(OGroupHelper *)> _pGetSection, const ::std::function<bool(OGroupHelper *)>& _pIsSectionOn); /** set the title of the (report/page) header or footer * @@ -76,7 +76,7 @@ namespace rptui * \param _pIsSectionOn * @return sal_True when title was set otherwise FALSE */ - bool setReportSectionTitle(const css::uno::Reference< css::report::XReportDefinition>& _xReport,const char* pResId,::std::mem_fun_t< css::uno::Reference< css::report::XSection> , OReportHelper> _pGetSection, const ::std::mem_fun_t<bool, OReportHelper>& _pIsSectionOn); + bool setReportSectionTitle(const css::uno::Reference< css::report::XReportDefinition>& _xReport,const char* pResId,::std::function<css::uno::Reference< css::report::XSection>(OReportHelper *)> _pGetSection, const ::std::function<bool(OReportHelper *)>& _pIsSectionOn); void ImplInitSettings(); DECL_LINK(Collapsed, OColorListener&, void); diff --git a/reportdesign/source/ui/misc/RptUndo.cxx b/reportdesign/source/ui/misc/RptUndo.cxx index 95b11ef1498f..9ef880f34e3e 100644 --- a/reportdesign/source/ui/misc/RptUndo.cxx +++ b/reportdesign/source/ui/misc/RptUndo.cxx @@ -216,8 +216,7 @@ void OSectionUndo::Redo() OReportSectionUndo::OReportSectionUndo(OReportModel& _rMod,sal_uInt16 _nSlot - ,::std::mem_fun_t< uno::Reference< report::XSection > - ,OReportHelper> _pMemberFunction + ,::std::function<uno::Reference< report::XSection >(OReportHelper *)> _pMemberFunction ,const uno::Reference< report::XReportDefinition >& _xReport ,Action _eAction) : OSectionUndo(_rMod,_nSlot,_eAction,nullptr) @@ -253,8 +252,7 @@ void OReportSectionUndo::implReRemove( ) OGroupSectionUndo::OGroupSectionUndo(OReportModel& _rMod,sal_uInt16 _nSlot - ,::std::mem_fun_t< uno::Reference< report::XSection > - ,OGroupHelper> _pMemberFunction + ,::std::function<uno::Reference< report::XSection >(OGroupHelper *)> _pMemberFunction ,const uno::Reference< report::XGroup >& _xGroup ,Action _eAction ,const char* pCommentID) diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 9b47422943b7..63ee8bf3e020 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -1022,13 +1022,13 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > } break; case SID_CUT: - executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Cut)); + executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fn(&ODesignView::Cut)); break; case SID_COPY: getDesignView()->Copy(); break; case SID_PASTE: - executeMethodWithUndo(RID_STR_UNDO_PASTE,::std::mem_fun(&ODesignView::Paste)); + executeMethodWithUndo(RID_STR_UNDO_PASTE,::std::mem_fn(&ODesignView::Paste)); break; case SID_FRAME_TO_TOP: @@ -1161,7 +1161,7 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > } } else - executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Delete)); + executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fn(&ODesignView::Delete)); break; case SID_GRID_USE: getDesignView()->setGridSnap(m_bGridUse = !m_bGridUse); @@ -2235,7 +2235,7 @@ void SAL_CALL OReportController::disposing( const lang::EventObject& Source ) static sal_uInt16 lcl_getNonVisbleGroupsBefore( const uno::Reference< report::XGroups>& _xGroups ,sal_Int32 _nGroupPos - ,::std::mem_fun_t<bool,OGroupHelper> const & _pGroupMemberFunction) + ,::std::function<bool(OGroupHelper *)> const & _pGroupMemberFunction) { uno::Reference< report::XGroup> xGroup; sal_uInt16 nNonVisibleGroups = 0; @@ -2253,8 +2253,8 @@ static sal_uInt16 lcl_getNonVisbleGroupsBefore( const uno::Reference< report::XG void OReportController::groupChange( const uno::Reference< report::XGroup>& _xGroup,const OUString& _sPropName,sal_Int32 _nGroupPos,bool _bShow) { - ::std::mem_fun_t<bool,OGroupHelper> pMemFun = ::std::mem_fun(&OGroupHelper::getHeaderOn); - ::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader); + ::std::function<bool(OGroupHelper *)> pMemFun = ::std::mem_fn(&OGroupHelper::getHeaderOn); + ::std::function<uno::Reference<report::XSection>(OGroupHelper *)> pMemFunSection = ::std::mem_fn(&OGroupHelper::getHeader); OUString sColor(DBGROUPHEADER); sal_uInt16 nPosition = 0; bool bHandle = false; @@ -2266,8 +2266,8 @@ void OReportController::groupChange( const uno::Reference< report::XGroup>& _xGr } else if ( _sPropName == PROPERTY_FOOTERON ) { - pMemFun = ::std::mem_fun(&OGroupHelper::getFooterOn); - pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter); + pMemFun = ::std::mem_fn(&OGroupHelper::getFooterOn); + pMemFunSection = ::std::mem_fn(&OGroupHelper::getFooter); nPosition = getDesignView()->getSectionCount(); if ( m_xReportDefinition->getPageFooterOn() ) @@ -2574,7 +2574,7 @@ void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHi } } -void OReportController::executeMethodWithUndo(const char* pUndoStrId,const ::std::mem_fun_t<void,ODesignView>& _pMemfun) +void OReportController::executeMethodWithUndo(const char* pUndoStrId,const ::std::function<void(ODesignView *)>& _pMemfun) { const OUString sUndoAction = RptResId(pUndoStrId); UndoContext aUndoContext( getUndoManager(), sUndoAction ); @@ -3745,13 +3745,13 @@ void OReportController::switchReportSection(const sal_Int16 _nId) pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) ); addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO - ,::std::mem_fun(&OReportHelper::getReportHeader) + ,::std::mem_fn(&OReportHelper::getReportHeader) ,m_xReportDefinition ,bSwitchOn ? Inserted : Removed )); addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO - ,::std::mem_fun(&OReportHelper::getReportFooter) + ,::std::mem_fn(&OReportHelper::getReportFooter) ,m_xReportDefinition ,bSwitchOn ? Inserted : Removed )); @@ -3793,14 +3793,14 @@ void OReportController::switchPageSection(const sal_Int16 _nId) addUndoAction(new OReportSectionUndo(*m_aReportModel ,SID_PAGEHEADER_WITHOUT_UNDO - ,::std::mem_fun(&OReportHelper::getPageHeader) + ,::std::mem_fn(&OReportHelper::getPageHeader) ,m_xReportDefinition ,bSwitchOn ? Inserted : Removed )); addUndoAction(new OReportSectionUndo(*m_aReportModel ,SID_PAGEFOOTER_WITHOUT_UNDO - ,::std::mem_fun(&OReportHelper::getPageFooter) + ,::std::mem_fn(&OReportHelper::getPageFooter) ,m_xReportDefinition ,bSwitchOn ? Inserted : Removed )); @@ -3881,7 +3881,7 @@ void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader if ( _bUndo ) addUndoAction(new OGroupSectionUndo(*m_aReportModel ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO - ,_bHeader ? ::std::mem_fun(&OGroupHelper::getHeader) : ::std::mem_fun(&OGroupHelper::getFooter) + ,_bHeader ? ::std::mem_fn(&OGroupHelper::getHeader) : ::std::mem_fn(&OGroupHelper::getFooter) ,xGroup ,bSwitchOn ? Inserted : Removed , ( _bHeader ? diff --git a/reportdesign/source/ui/report/SectionWindow.cxx b/reportdesign/source/ui/report/SectionWindow.cxx index 60aed187e069..e1aaf1ad048f 100644 --- a/reportdesign/source/ui/report/SectionWindow.cxx +++ b/reportdesign/source/ui/report/SectionWindow.cxx @@ -141,10 +141,10 @@ void OSectionWindow::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) else if ( _rEvent.PropertyName == PROPERTY_NAME && !xSection->getGroup().is() ) { uno::Reference< report::XReportDefinition > xReport = xSection->getReportDefinition(); - if ( setReportSectionTitle(xReport,RID_STR_REPORT_HEADER,::std::mem_fun(&OReportHelper::getReportHeader),::std::mem_fun(&OReportHelper::getReportHeaderOn)) - || setReportSectionTitle(xReport,RID_STR_REPORT_FOOTER,::std::mem_fun(&OReportHelper::getReportFooter),::std::mem_fun(&OReportHelper::getReportFooterOn)) - || setReportSectionTitle(xReport,RID_STR_PAGE_HEADER,::std::mem_fun(&OReportHelper::getPageHeader),::std::mem_fun(&OReportHelper::getPageHeaderOn)) - || setReportSectionTitle(xReport,RID_STR_PAGE_FOOTER,::std::mem_fun(&OReportHelper::getPageFooter),::std::mem_fun(&OReportHelper::getPageFooterOn)) ) + if ( setReportSectionTitle(xReport,RID_STR_REPORT_HEADER,::std::mem_fn(&OReportHelper::getReportHeader),::std::mem_fn(&OReportHelper::getReportHeaderOn)) + || setReportSectionTitle(xReport,RID_STR_REPORT_FOOTER,::std::mem_fn(&OReportHelper::getReportFooter),::std::mem_fn(&OReportHelper::getReportFooterOn)) + || setReportSectionTitle(xReport,RID_STR_PAGE_HEADER,::std::mem_fn(&OReportHelper::getPageHeader),::std::mem_fn(&OReportHelper::getPageHeaderOn)) + || setReportSectionTitle(xReport,RID_STR_PAGE_FOOTER,::std::mem_fn(&OReportHelper::getPageFooter),::std::mem_fn(&OReportHelper::getPageFooterOn)) ) { m_aStartMarker->Invalidate(InvalidateFlags::NoErase); } @@ -159,14 +159,14 @@ void OSectionWindow::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) else if ( _rEvent.PropertyName == PROPERTY_EXPRESSION ) { uno::Reference< report::XGroup > xGroup(_rEvent.Source,uno::UNO_QUERY); - if ( xGroup.is() && !setGroupSectionTitle(xGroup,RID_STR_HEADER,::std::mem_fun(&OGroupHelper::getHeader),::std::mem_fun(&OGroupHelper::getHeaderOn))) + if ( xGroup.is() && !setGroupSectionTitle(xGroup,RID_STR_HEADER,::std::mem_fn(&OGroupHelper::getHeader),::std::mem_fn(&OGroupHelper::getHeaderOn))) { - setGroupSectionTitle(xGroup,RID_STR_FOOTER,::std::mem_fun(&OGroupHelper::getFooter),::std::mem_fun(&OGroupHelper::getFooterOn)); + setGroupSectionTitle(xGroup,RID_STR_FOOTER,::std::mem_fn(&OGroupHelper::getFooter),::std::mem_fn(&OGroupHelper::getFooterOn)); } } } -bool OSectionWindow::setReportSectionTitle(const uno::Reference< report::XReportDefinition>& _xReport,const char* pResId,::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> _pGetSection, const ::std::mem_fun_t<bool,OReportHelper>& _pIsSectionOn) +bool OSectionWindow::setReportSectionTitle(const uno::Reference< report::XReportDefinition>& _xReport,const char* pResId,::std::function<uno::Reference<report::XSection>(OReportHelper *)> _pGetSection, const ::std::function<bool(OReportHelper *)>& _pIsSectionOn) { OReportHelper aReportHelper(_xReport); const bool bRet = _pIsSectionOn(&aReportHelper) && _pGetSection(&aReportHelper) == m_aReportSection->getSection(); @@ -179,7 +179,7 @@ bool OSectionWindow::setReportSectionTitle(const uno::Reference< report::XReport return bRet; } -bool OSectionWindow::setGroupSectionTitle(const uno::Reference< report::XGroup>& _xGroup,const char* pResId,::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> _pGetSection, const ::std::mem_fun_t<bool,OGroupHelper>& _pIsSectionOn) +bool OSectionWindow::setGroupSectionTitle(const uno::Reference< report::XGroup>& _xGroup,const char* pResId,::std::function<uno::Reference<report::XSection>(OGroupHelper *)> _pGetSection, const ::std::function<bool(OGroupHelper *)>& _pIsSectionOn) { OGroupHelper aGroupHelper(_xGroup); const bool bRet = _pIsSectionOn(&aGroupHelper) && _pGetSection(&aGroupHelper) == m_aReportSection->getSection() ; diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index 3479f3bfdfc7..40faf078ee5c 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -771,8 +771,8 @@ void OViewsWindow::alignMarkedObjects(ControlModification _nControlModification, bool bMove = true; - ::std::mem_fun_t<long&,tools::Rectangle> aGetFun = ::std::mem_fun<long&,tools::Rectangle>(&tools::Rectangle::Bottom); - ::std::mem_fun_t<long&,tools::Rectangle> aRefFun = ::std::mem_fun<long&,tools::Rectangle>(&tools::Rectangle::Top); + ::std::function<long&(tools::Rectangle *)> aGetFun = ::std::mem_fn(static_cast<long&(tools::Rectangle:: *)()>(&tools::Rectangle::Bottom)); + ::std::function<long&(tools::Rectangle *)> aRefFun = ::std::mem_fn(static_cast<long&(tools::Rectangle:: *)()>(&tools::Rectangle::Top)); TRectangleMap::const_iterator aRectIter = aSortRectangles.begin(); TRectangleMap::const_iterator aRectEnd = aSortRectangles.end(); for (;aRectIter != aRectEnd ; ++aRectIter) @@ -791,8 +791,8 @@ void OViewsWindow::alignMarkedObjects(ControlModification _nControlModification, switch(_nControlModification) { case ControlModification::TOP : - aGetFun = ::std::mem_fun<long&,tools::Rectangle>(&tools::Rectangle::Top); - aRefFun = ::std::mem_fun<long&,tools::Rectangle>(&tools::Rectangle::Bottom); + aGetFun = ::std::mem_fn(static_cast<long&(tools::Rectangle:: *)()>(&tools::Rectangle::Top)); + aRefFun = ::std::mem_fn(static_cast<long&(tools::Rectangle:: *)()>(&tools::Rectangle::Bottom)); pValue = &nYMov; break; case ControlModification::BOTTOM: @@ -805,16 +805,16 @@ void OViewsWindow::alignMarkedObjects(ControlModification _nControlModification, bMove = false; break; case ControlModification::RIGHT : - aGetFun = ::std::mem_fun<long&,tools::Rectangle>(&tools::Rectangle::Right); - aRefFun = ::std::mem_fun<long&,tools::Rectangle>(&tools::Rectangle::Left); + aGetFun = ::std::mem_fn(static_cast<long&(tools::Rectangle:: *)()>(&tools::Rectangle::Right)); + aRefFun = ::std::mem_fn(static_cast<long&(tools::Rectangle:: *)()>(&tools::Rectangle::Left)); break; case ControlModification::CENTER_HORIZONTAL: nXMov = aCenter.X() - aObjRect.Center().X(); bMove = false; break; case ControlModification::LEFT : - aGetFun = ::std::mem_fun<long&,tools::Rectangle>(&tools::Rectangle::Left); - aRefFun = ::std::mem_fun<long&,tools::Rectangle>(&tools::Rectangle::Right); + aGetFun = ::std::mem_fn(static_cast<long&(tools::Rectangle:: *)()>(&tools::Rectangle::Left)); + aRefFun = ::std::mem_fn(static_cast<long&(tools::Rectangle:: *)()>(&tools::Rectangle::Right)); break; default: bMove = false; |