From 0593041d86e479981485644abfd56f94289270de Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 19 May 2016 14:55:44 +0200 Subject: loplugin:unusedmethods in sfx2, SfxUnoControllerItem goes Change-Id: Ibbae76b45da924e44fb91dcb3548106e8b908fbf Reviewed-on: https://gerrit.libreoffice.org/25160 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/sfx2/bindings.hxx | 5 - include/sfx2/frame.hxx | 1 - include/sfx2/frmdescr.hxx | 51 --------- include/sfx2/frmhtml.hxx | 4 +- include/sfx2/itemconnect.hxx | 25 ----- include/sfx2/sidebar/ControllerItem.hxx | 5 - include/sfx2/unoctitm.hxx | 24 ----- sfx2/source/control/bindings.cxx | 100 ----------------- sfx2/source/control/unoctitm.cxx | 148 -------------------------- sfx2/source/doc/frmdescr.cxx | 36 ------- sfx2/source/sidebar/ControllerItem.cxx | 14 --- sfx2/source/view/classificationcontroller.cxx | 4 +- 12 files changed, 3 insertions(+), 414 deletions(-) diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx index 9d88ea25b52a..4aef796ec225 100644 --- a/include/sfx2/bindings.hxx +++ b/include/sfx2/bindings.hxx @@ -49,10 +49,8 @@ class SfxBindings; class SfxBindings_Impl; class Timer; class SfxWorkWindow; -class SfxUnoControllerItem; struct SfxFoundCache_Impl; class SfxFoundCacheArr_Impl; -class SfxUnoControllerArr_Impl; enum class SfxCallMode : sal_uInt16 { @@ -199,9 +197,6 @@ public: SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const; SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* ); SAL_DLLPRIVATE SfxBindings* GetSubBindings_Impl() const; - SAL_DLLPRIVATE void InvalidateUnoControllers_Impl(); - SAL_DLLPRIVATE void RegisterUnoController_Impl( SfxUnoControllerItem* ); - SAL_DLLPRIVATE void ReleaseUnoController_Impl( SfxUnoControllerItem* ); SAL_DLLPRIVATE void SetRecorder_Impl( css::uno::Reference< css::frame::XDispatchRecorder >& ); SAL_DLLPRIVATE void InvalidateSlotsInMap_Impl(); SAL_DLLPRIVATE void AddSlotToInvalidateSlotsMap_Impl( sal_uInt16 nId ); diff --git a/include/sfx2/frame.hxx b/include/sfx2/frame.hxx index 9264dcbf0d96..19a8656c2faa 100644 --- a/include/sfx2/frame.hxx +++ b/include/sfx2/frame.hxx @@ -70,7 +70,6 @@ class SfxFrameSetDescriptor; class SfxDispatcher; class Rectangle; class SfxRequest; -class SfxUnoControllerItem; class SystemWindow; class SfxFrameArr_Impl; diff --git a/include/sfx2/frmdescr.hxx b/include/sfx2/frmdescr.hxx index 633ac8b94fd0..ae28c0ea5254 100644 --- a/include/sfx2/frmdescr.hxx +++ b/include/sfx2/frmdescr.hxx @@ -135,57 +135,6 @@ public: SfxFrameDescriptor* Clone() const; }; -// No block to implement a =operator -struct SfxFrameProperties -{ - OUString aURL; - OUString aName; - long lMarginWidth; - long lMarginHeight; - long lSize; - long lSetSize; - long lFrameSpacing; - long lInheritedFrameSpacing; - ScrollingMode eScroll; - SizeSelector eSizeSelector; - SizeSelector eSetSizeSelector; - bool bHasBorder; - bool bBorderSet; - bool bResizable; - bool bSetResizable; - bool bIsRootSet; - bool bIsInColSet; - bool bHasBorderInherited; - SfxFrameDescriptor* pFrame; - -private: - SfxFrameProperties( SfxFrameProperties& ) {} -public: - SfxFrameProperties() - : lMarginWidth( SIZE_NOT_SET ), - lMarginHeight( SIZE_NOT_SET ), - lSize( 1L ), - lSetSize( 1L ), - lFrameSpacing( SPACING_NOT_SET ), - lInheritedFrameSpacing( SPACING_NOT_SET ), - eScroll( ScrollingAuto ), - eSizeSelector( SIZE_REL ), - eSetSizeSelector( SIZE_REL ), - bHasBorder( true ), - bBorderSet( true ), - bResizable( true ), - bSetResizable( true ), - bIsRootSet( false ), - bIsInColSet( false ), - bHasBorderInherited( true ), - pFrame( nullptr ) {} - - ~SfxFrameProperties() { delete pFrame; } - - bool operator ==( const SfxFrameProperties& ) const; - SfxFrameProperties& operator =( const SfxFrameProperties &rProp ); -}; - #endif // INCLUDED_SFX2_FRMDESCR_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/frmhtml.hxx b/include/sfx2/frmhtml.hxx index 616d5a973ce1..4ca4a30f04c5 100644 --- a/include/sfx2/frmhtml.hxx +++ b/include/sfx2/frmhtml.hxx @@ -31,9 +31,7 @@ class SfxMedium; class SFX2_DLLPUBLIC SfxFrameHTMLParser : public SfxHTMLParser { -protected: - SfxFrameHTMLParser( SvStream& rStream, bool bIsNewDoc=true, SfxMedium *pMediumPtr=nullptr ): - SfxHTMLParser( rStream, bIsNewDoc, pMediumPtr ) {}; + SfxFrameHTMLParser() = delete; public: // These methods can also be used by other parsers. diff --git a/include/sfx2/itemconnect.hxx b/include/sfx2/itemconnect.hxx index bfe9b253e926..21d663739fac 100644 --- a/include/sfx2/itemconnect.hxx +++ b/include/sfx2/itemconnect.hxx @@ -293,23 +293,6 @@ private: typedef ItemControlConnection< BoolItemWrapper, CheckBoxWrapper > CheckBoxConnection; -/** Connection between an item and the VCL NumericField. */ -template< typename ItemWrpT > -class NumericConnection : public ItemControlConnection< ItemWrpT, - NumericFieldWrapper< typename ItemWrpT::ItemValueType > > -{ - typedef ItemControlConnection< ItemWrpT, - NumericFieldWrapper< typename ItemWrpT::ItemValueType > > - ItemControlConnectionType; - -public: - typedef typename ItemControlConnectionType::ControlWrapperType NumericFieldWrapperType; - - explicit NumericConnection( sal_uInt16 nSlot, NumericField& rField, - ItemConnFlags nFlags = ITEMCONN_DEFAULT ); -}; - - /** Connection between an item and the VCL MetricField. Adds support of different field units during control value <-> item value @@ -493,14 +476,6 @@ bool ItemControlConnection< ItemWrpT, ControlWrpT >::FillItemSet( // Standard connections -template< typename ItemWrpT > -NumericConnection< ItemWrpT >::NumericConnection( - sal_uInt16 nSlot, NumericField& rField, ItemConnFlags nFlags ) : - ItemControlConnectionType( nSlot, rField, nFlags ) -{ -} - - template< typename ItemWrpT > MetricConnection< ItemWrpT >::MetricConnection( sal_uInt16 nSlot, MetricField& rField, FieldUnit eItemUnit, ItemConnFlags nFlags ) : diff --git a/include/sfx2/sidebar/ControllerItem.hxx b/include/sfx2/sidebar/ControllerItem.hxx index 7a52de26bae3..ef2bf845c9f6 100644 --- a/include/sfx2/sidebar/ControllerItem.hxx +++ b/include/sfx2/sidebar/ControllerItem.hxx @@ -94,11 +94,6 @@ public: */ void RequestUpdate(); - /** Return the extended help text for the command. - Returns an empty string when the UNO command name is not available. - */ - ::rtl::OUString GetHelpText() const; - /** Return the icon for the command. */ Image GetIcon() const; diff --git a/include/sfx2/unoctitm.hxx b/include/sfx2/unoctitm.hxx index 1eab7de7dfeb..8d58738ec694 100644 --- a/include/sfx2/unoctitm.hxx +++ b/include/sfx2/unoctitm.hxx @@ -42,30 +42,6 @@ class SfxBindings; class SfxFrame; class SfxDispatcher; -class SfxUnoControllerItem : public ::cppu::WeakImplHelper1< css::frame::XStatusListener > -{ - css::util::URL aCommand; - css::uno::Reference< css::frame::XDispatch > xDispatch; - SfxControllerItem* pCtrlItem; - SfxBindings* pBindings; - - css::uno::Reference< css::frame::XDispatch > TryGetDispatch( SfxFrame* pFrame ); - -public: - - SfxUnoControllerItem( SfxControllerItem*, SfxBindings&, const OUString& ); - virtual ~SfxUnoControllerItem(); - - // XStatusListener - virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& Event) throw( css::uno::RuntimeException, std::exception ) override; - - // Something else - virtual void SAL_CALL disposing(const css::lang::EventObject& Source) throw( css::uno::RuntimeException, std::exception ) override; - void GetNewDispatch(); - void ReleaseDispatch(); - void ReleaseBindings(); -}; - typedef cppu::OMultiTypeInterfaceContainerHelperVar SfxStatusDispatcher_Impl_ListenerContainer; diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 1aa909567294..ad1fb7166f9f 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -117,46 +117,6 @@ public: } }; -class SfxUnoControllerArr_Impl -{ - typedef std::vector DataType; - DataType maData; - -public: - - typedef DataType::iterator iterator; - - iterator begin() - { - return maData.begin(); - } - - iterator end() - { - return maData.end(); - } - - void erase( const iterator& it ) - { - maData.erase(it); - } - - SfxUnoControllerItem* operator[] ( size_t i ) - { - return maData[i]; - } - - size_t size() const - { - return maData.size(); - } - - void push_back( SfxUnoControllerItem* p ) - { - maData.push_back(p); - } -}; - enum class SfxPopupAction { DELETE, @@ -170,8 +130,6 @@ class SfxBindings_Impl public: css::uno::Reference< css::frame::XDispatchRecorder > xRecorder; css::uno::Reference< css::frame::XDispatchProvider > xProv; - SfxUnoControllerArr_Impl* - pUnoCtrlArr; SfxWorkWindow* pWorkWin; SfxBindings* pSubBindings; SfxBindings* pSuperBindings; @@ -214,7 +172,6 @@ SfxBindings::SfxBindings() pImp->pSubBindings = nullptr; pImp->pSuperBindings = nullptr; pImp->pWorkWin = nullptr; - pImp->pUnoCtrlArr = nullptr; pImp->nOwnRegLevel = nRegLevel; // all caches are valid (no pending invalidate-job) @@ -304,19 +261,6 @@ void SfxBindings::DeleteControllers_Impl() delete (*pImp->pCaches)[nCache-1]; pImp->pCaches->erase(pImp->pCaches->begin()+ nCache - 1); } - - if( pImp->pUnoCtrlArr ) - { - sal_uInt16 nCtrlCount = pImp->pUnoCtrlArr->size(); - for ( sal_uInt16 n=nCtrlCount; n>0; n-- ) - { - SfxUnoControllerItem *pCtrl = (*pImp->pUnoCtrlArr)[n-1]; - pCtrl->ReleaseBindings(); - } - - DBG_ASSERT( !pImp->pUnoCtrlArr->size(), "Do not remove UnoControllerItems!" ); - DELETEZ( pImp->pUnoCtrlArr ); - } } @@ -1738,7 +1682,6 @@ void SfxBindings::SetDispatcher( SfxDispatcher *pDisp ) SetDispatchProvider_Impl( xProv ); InvalidateAll( true ); - InvalidateUnoControllers_Impl(); if ( pDispatcher && !pOldDispat ) { @@ -1946,48 +1889,6 @@ SfxWorkWindow* SfxBindings::GetWorkWindow_Impl() const return pImp->pWorkWin; } -void SfxBindings::RegisterUnoController_Impl( SfxUnoControllerItem* pControl ) -{ - if ( !pImp->pUnoCtrlArr ) - pImp->pUnoCtrlArr = new SfxUnoControllerArr_Impl; - pImp->pUnoCtrlArr->push_back( pControl ); -} - -void SfxBindings::ReleaseUnoController_Impl( SfxUnoControllerItem* pControl ) -{ - if ( pImp->pUnoCtrlArr ) - { - SfxUnoControllerArr_Impl::iterator it = std::find( - pImp->pUnoCtrlArr->begin(), pImp->pUnoCtrlArr->end(), pControl ); - if ( it != pImp->pUnoCtrlArr->end() ) - { - pImp->pUnoCtrlArr->erase( it ); - return; - } - } - - if ( pImp->pSubBindings ) - pImp->pSubBindings->ReleaseUnoController_Impl( pControl ); -} - -void SfxBindings::InvalidateUnoControllers_Impl() -{ - if ( pImp->pUnoCtrlArr ) - { - sal_uInt16 nCount = pImp->pUnoCtrlArr->size(); - for ( sal_uInt16 n=nCount; n>0; n-- ) - { - SfxUnoControllerItem *pCtrl = (*pImp->pUnoCtrlArr)[n-1]; - css::uno::Reference< css::frame::XStatusListener > xRef( static_cast(pCtrl), css::uno::UNO_QUERY ); - pCtrl->ReleaseDispatch(); - pCtrl->GetNewDispatch(); - } - } - - if ( pImp->pSubBindings ) - pImp->pSubBindings->InvalidateUnoControllers_Impl(); -} - bool SfxBindings::IsInUpdate() const { bool bInUpdate = pImp->bInUpdate; @@ -2029,7 +1930,6 @@ void SfxBindings::SetDispatchProvider_Impl( const css::uno::Reference< css::fram { pImp->xProv = rProv; InvalidateAll( true ); - InvalidateUnoControllers_Impl(); } if ( pImp->pSubBindings ) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 8ec6c12a8d0f..899fcd831b87 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -107,154 +107,6 @@ const char* URLTypeNames[URLType_COUNT] = "double" }; -SfxUnoControllerItem::SfxUnoControllerItem( SfxControllerItem *pItem, SfxBindings& rBind, const OUString& rCmd ) - : pCtrlItem( pItem ) - , pBindings( &rBind ) -{ - DBG_ASSERT( !pCtrlItem || !pCtrlItem->IsBound(), "ControllerItem is incorrect!" ); - - aCommand.Complete = rCmd; - Reference< XURLTransformer > xTrans( URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); - xTrans->parseStrict( aCommand ); - pBindings->RegisterUnoController_Impl( this ); -} - -SfxUnoControllerItem::~SfxUnoControllerItem() -{ - // tell bindings to forget this controller ( if still connected ) - if ( pBindings ) - pBindings->ReleaseUnoController_Impl( this ); -} - -void SAL_CALL SfxUnoControllerItem::statusChanged(const css::frame::FeatureStateEvent& rEvent) throw ( css::uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - DBG_ASSERT( pCtrlItem, "dispatch implementation didn't respect our previous removeStatusListener call!" ); - - if ( rEvent.Requery ) - { - // Error can only happen if the old Dispatch is implemented incorrectly - // i.e. removeStatusListener did not work. But such things can happen... - // So protect before ReleaseDispatch from release! - css::uno::Reference< css::frame::XStatusListener > aRef( static_cast(this), css::uno::UNO_QUERY ); - ReleaseDispatch(); - if ( pCtrlItem ) - GetNewDispatch(); // asynchronous ?? - } - else if ( pCtrlItem ) - { - SfxItemState eState = SfxItemState::DISABLED; - SfxPoolItem* pItem = nullptr; - if ( rEvent.IsEnabled ) - { - eState = SfxItemState::DEFAULT; - css::uno::Type aType = rEvent.State.getValueType(); - - if ( aType == cppu::UnoType< bool >::get() ) - { - bool bTemp = false; - rEvent.State >>= bTemp ; - pItem = new SfxBoolItem( pCtrlItem->GetId(), bTemp ); - } - else if ( aType == cppu::UnoType< ::cppu::UnoUnsignedShortType >::get() ) - { - sal_uInt16 nTemp = 0; - rEvent.State >>= nTemp ; - pItem = new SfxUInt16Item( pCtrlItem->GetId(), nTemp ); - } - else if ( aType == cppu::UnoType::get() ) - { - sal_uInt32 nTemp = 0; - rEvent.State >>= nTemp ; - pItem = new SfxUInt32Item( pCtrlItem->GetId(), nTemp ); - } - else if ( aType == cppu::UnoType::get() ) - { - OUString sTemp ; - rEvent.State >>= sTemp ; - pItem = new SfxStringItem( pCtrlItem->GetId(), sTemp ); - } - else - pItem = new SfxVoidItem( pCtrlItem->GetId() ); - } - - pCtrlItem->StateChanged( pCtrlItem->GetId(), eState, pItem ); - delete pItem; - } -} - -void SAL_CALL SfxUnoControllerItem::disposing( const css::lang::EventObject& ) throw ( css::uno::RuntimeException, std::exception ) -{ - css::uno::Reference< css::frame::XStatusListener > aRef( static_cast(this), css::uno::UNO_QUERY ); - ReleaseDispatch(); -} - -void SfxUnoControllerItem::ReleaseDispatch() -{ - if ( xDispatch.is() ) - { - xDispatch->removeStatusListener( static_cast(this), aCommand ); - xDispatch.clear(); - } -} - -void SfxUnoControllerItem::GetNewDispatch() -{ - if ( !pBindings ) - { - // Bindings released - OSL_FAIL( "Tried to get dispatch, but no Bindings!" ); - return; - } - - // forget old dispatch - xDispatch.clear(); - - // no arms, no cookies ! - if ( !pBindings->GetDispatcher_Impl() || !pBindings->GetDispatcher_Impl()->GetFrame() ) - return; - - SfxFrame& rFrame = pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(); - SfxFrame *pParent = rFrame.GetParentFrame(); - if ( pParent ) - // parent may intercept - xDispatch = TryGetDispatch( pParent ); - - if ( !xDispatch.is() ) - { - // no interception - css::uno::Reference< css::frame::XFrame > xFrame = rFrame.GetFrameInterface(); - css::uno::Reference< css::frame::XDispatchProvider > xProv( xFrame, css::uno::UNO_QUERY ); - if ( xProv.is() ) - xDispatch = xProv->queryDispatch( aCommand, OUString(), 0 ); - } - - if ( xDispatch.is() ) - xDispatch->addStatusListener( static_cast(this), aCommand ); - else if ( pCtrlItem ) - pCtrlItem->StateChanged( pCtrlItem->GetId(), SfxItemState::DISABLED, nullptr ); -} - -css::uno::Reference< css::frame::XDispatch > SfxUnoControllerItem::TryGetDispatch( SfxFrame *pFrame ) -{ - css::uno::Reference< css::frame::XDispatch > xDisp; - SfxFrame *pParent = pFrame->GetParentFrame(); - if ( pParent ) - // parent may intercept - xDisp = TryGetDispatch( pParent ); - - return xDisp; -} - -void SfxUnoControllerItem::ReleaseBindings() -{ - // connection to binding is lost; so forget the binding and the dispatch - css::uno::Reference< css::frame::XStatusListener > aRef( static_cast(this), css::uno::UNO_QUERY ); - ReleaseDispatch(); - if ( pBindings ) - pBindings->ReleaseUnoController_Impl( this ); - pBindings = nullptr; -} void SfxStatusDispatcher::ReleaseAll() { diff --git a/sfx2/source/doc/frmdescr.cxx b/sfx2/source/doc/frmdescr.cxx index 96e51c17fb3d..8b67a02a3e2c 100644 --- a/sfx2/source/doc/frmdescr.cxx +++ b/sfx2/source/doc/frmdescr.cxx @@ -135,40 +135,4 @@ void SfxFrameDescriptor::SetWallpaper( const Wallpaper& rWallpaper ) pImp->pWallpaper = new Wallpaper( rWallpaper ); } -SfxFrameProperties& SfxFrameProperties::operator =( - const SfxFrameProperties &rProp ) -{ - aURL = rProp.aURL; - aName = rProp.aName; - lMarginWidth = rProp.lMarginWidth; - lMarginHeight = rProp.lMarginHeight; - lSize = rProp.lSize; - lSetSize = rProp.lSetSize; - lFrameSpacing = rProp.lFrameSpacing; - lInheritedFrameSpacing = rProp.lInheritedFrameSpacing; - eScroll = rProp.eScroll; - eSizeSelector = rProp.eSizeSelector; - eSetSizeSelector = rProp.eSetSizeSelector; - bHasBorder = rProp.bHasBorder; - bBorderSet = rProp.bBorderSet; - bResizable = rProp.bResizable; - bSetResizable = rProp.bSetResizable; - bIsRootSet = rProp.bIsRootSet; - bIsInColSet = rProp.bIsInColSet; - bHasBorderInherited = rProp.bHasBorderInherited; - pFrame = rProp.pFrame->Clone(); - return *this; -} - -bool SfxFrameProperties::operator ==( const SfxFrameProperties& rProp ) const -{ - return aURL == rProp.aURL && aName == rProp.aName && lMarginWidth == rProp.lMarginWidth && lMarginHeight == rProp.lMarginHeight && - lSize == rProp.lSize && eScroll == rProp.eScroll && eSizeSelector == rProp.eSizeSelector && - lSetSize == rProp.lSetSize && lFrameSpacing == rProp.lFrameSpacing && eSetSizeSelector == rProp.eSetSizeSelector && - bHasBorder == rProp.bHasBorder && bBorderSet == rProp.bBorderSet && - bResizable == rProp.bResizable && bSetResizable == rProp.bSetResizable; -} - - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/ControllerItem.cxx b/sfx2/source/sidebar/ControllerItem.cxx index aee857a0bfc0..9ca665ae61ad 100644 --- a/sfx2/source/sidebar/ControllerItem.cxx +++ b/sfx2/source/sidebar/ControllerItem.cxx @@ -179,20 +179,6 @@ void ControllerItem::ResetFrame() mxFrame = nullptr; } -::rtl::OUString ControllerItem::GetHelpText() const -{ - Help* pHelp = Application::GetHelp(); - if (pHelp != nullptr) - { - if (msCommandName.getLength() > 0) - { - const ::rtl::OUString sHelp (pHelp->GetHelpText(".uno:" + msCommandName, nullptr)); - return sHelp; - } - } - return ::rtl::OUString(); -} - Image ControllerItem::GetIcon() const { return GetImage(mxFrame, ".uno:" + msCommandName, false); diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx index 7abcdf650bde..1e932c85c774 100644 --- a/sfx2/source/view/classificationcontroller.cxx +++ b/sfx2/source/view/classificationcontroller.cxx @@ -94,7 +94,7 @@ public: virtual ~ClassificationControl(); virtual void dispose() override; virtual void Resize() override; - VclPtr getCategories(SfxClassificationPolicyType eType); + const VclPtr& getCategories(SfxClassificationPolicyType eType); std::size_t getLabelsSize(); OUString getCategoryType(ListBox& rCategory); }; @@ -311,7 +311,7 @@ void ClassificationControl::Resize() } } -VclPtr ClassificationControl::getCategories(SfxClassificationPolicyType eType) +const VclPtr& ClassificationControl::getCategories(SfxClassificationPolicyType eType) { return m_pCategories[eType]; } -- cgit