diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-08 11:55:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-11 07:00:35 +0100 |
commit | 7df04009b98165f89c89f1e506ebafd2fecc8f5a (patch) | |
tree | 5629b360bd669d458dcfa0e3da7e7ce44c194363 | |
parent | eb5e2dea18835df78872a8b0e3446e604f749645 (diff) |
remove ControlDependencyManager
and just use our normal handlers, instead of this weird magic
Change-Id: I8245787bec2a755ce6aba31ed681577771537ca1
Reviewed-on: https://gerrit.libreoffice.org/67534
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | dbaccess/source/ui/dlg/admincontrols.cxx | 132 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/admincontrols.hxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/advancedsettings.hxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/detailpages.hxx | 1 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/generalpage.cxx | 30 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/generalpage.hxx | 4 | ||||
-rw-r--r-- | include/svtools/dialogcontrolling.hxx | 265 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/DateTime.hxx | 2 | ||||
-rw-r--r-- | solenv/clang-format/blacklist | 2 | ||||
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/source/misc/dialogcontrolling.cxx | 192 |
11 files changed, 53 insertions, 584 deletions
diff --git a/dbaccess/source/ui/dlg/admincontrols.cxx b/dbaccess/source/ui/dlg/admincontrols.cxx index 22303969b09a..517852513d51 100644 --- a/dbaccess/source/ui/dlg/admincontrols.cxx +++ b/dbaccess/source/ui/dlg/admincontrols.cxx @@ -28,101 +28,6 @@ namespace dbaui { - // TextResetOperatorEventFilter - class TextResetOperatorEventFilter : public ::svt::IWindowEventFilter - { - public: - TextResetOperatorEventFilter() - { - } - - // IWindowEventFilter - virtual bool payAttentionTo( const VclWindowEvent& _rEvent ) const override - { - return ( _rEvent.GetId() == VclEventId::WindowEnabled ) - || ( _rEvent.GetId() == VclEventId::WindowDisabled ) - || ( _rEvent.GetId() == VclEventId::EditModify ); - } - }; - - // TextResetOperator - class TextResetOperator :public ::svt::IWindowOperator - { - public: - explicit TextResetOperator( const OUString& _rDisabledText ) - :m_sDisabledText( _rDisabledText ) - { - } - - // IWindowOperator - virtual void operateOn( const VclWindowEvent& _rTrigger, vcl::Window& _rOperateOn ) const override; - - private: - const OUString m_sDisabledText; - OUString m_sUserText; - }; - - void TextResetOperator::operateOn( const VclWindowEvent& _rTrigger, vcl::Window& _rOperateOn ) const - { - OSL_ENSURE( _rTrigger.GetWindow() == &_rOperateOn, "TextResetOperator::operateOn: you're misusing this implementation!" ); - - switch ( _rTrigger.GetId() ) - { - case VclEventId::NONE: - // initial call - const_cast< TextResetOperator* >( this )->m_sUserText = _rTrigger.GetWindow()->GetText(); - break; - - case VclEventId::EditModify: - if ( _rTrigger.GetWindow()->IsEnabled() ) - const_cast< TextResetOperator* >( this )->m_sUserText = _rTrigger.GetWindow()->GetText(); - break; - - case VclEventId::WindowEnabled: - _rOperateOn.SetText( m_sUserText ); - break; - - case VclEventId::WindowDisabled: - _rOperateOn.SetText( m_sDisabledText ); - break; - - default: - OSL_FAIL( "TextResetOperator::operateOn: unexpected event ID!" ); - // all those IDs should have been filtered out by payAttentionTo - break; - } - } - - // TextResetOperatorController - class TextResetOperatorController_Base - { - protected: - explicit TextResetOperatorController_Base( const OUString& _rDisabledText ) - :m_pEventFilter( new TextResetOperatorEventFilter ) - ,m_pOperator( new TextResetOperator( _rDisabledText ) ) - { - } - - const ::svt::PWindowEventFilter& getEventFilter() const { return m_pEventFilter; } - const ::svt::PWindowOperator& getOperator() const { return m_pOperator; } - - private: - ::svt::PWindowEventFilter m_pEventFilter; - ::svt::PWindowOperator m_pOperator; - }; - - class TextResetOperatorController :public TextResetOperatorController_Base - ,public ::svt::DialogController - { - public: - TextResetOperatorController( vcl::Window& _rObservee, const OUString& _rDisabledText ) - :TextResetOperatorController_Base( _rDisabledText ) - ,::svt::DialogController( _rObservee, getEventFilter(), getOperator() ) - { - addDependentWindow( _rObservee ); - } - }; - // MySQLNativeSettings MySQLNativeSettings::MySQLNativeSettings( vcl::Window& _rParent, const Link<void*,void>& _rControlModificationLink ) :TabPage( &_rParent, "MysqlNativeSettings", "dbaccess/ui/mysqlnativesettings.ui" ), @@ -142,6 +47,8 @@ namespace dbaui get(m_pSocket, "socket"); get(m_pNamedPipe, "namedpipe"); + m_pHostName->SetText("localhost"); + m_pDatabaseName->SetModifyHdl( LINK(this, MySQLNativeSettings, EditModifyHdl) ); m_pHostName->SetModifyHdl( LINK(this, MySQLNativeSettings, EditModifyHdl) ); m_pPort->SetModifyHdl( LINK(this, MySQLNativeSettings, EditModifyHdl) ); @@ -149,14 +56,7 @@ namespace dbaui m_pNamedPipe->SetModifyHdl( LINK(this, MySQLNativeSettings, EditModifyHdl) ); m_pSocketRadio->SetToggleHdl( LINK(this, MySQLNativeSettings, RadioToggleHdl) ); m_pNamedPipeRadio->SetToggleHdl( LINK(this, MySQLNativeSettings, RadioToggleHdl) ); - - m_aControlDependencies.enableOnRadioCheck( *m_pHostPortRadio, *m_pHostNameLabel, *m_pHostName, *m_pPortLabel, *m_pPort, *m_pDefaultPort ); - m_aControlDependencies.enableOnRadioCheck( *m_pSocketRadio, *m_pSocket ); - m_aControlDependencies.enableOnRadioCheck( *m_pNamedPipeRadio, *m_pNamedPipe ); - - m_aControlDependencies.addController( std::shared_ptr<svt::DialogController>( - new TextResetOperatorController( *m_pHostName, "localhost" ) - ) ); + m_pHostPortRadio->SetToggleHdl( LINK(this, MySQLNativeSettings, RadioToggleHdl) ); // sockets are available on Unix systems only, named pipes only on Windows #ifdef UNX @@ -170,12 +70,36 @@ namespace dbaui IMPL_LINK(MySQLNativeSettings, RadioToggleHdl, RadioButton&, rRadioButton, void) { - m_aControlModificationLink.Call(&rRadioButton); + if (&rRadioButton == &*m_pSocketRadio || &rRadioButton == &*m_pNamedPipeRadio) + m_aControlModificationLink.Call(&rRadioButton); + bool bSelected = rRadioButton.IsChecked(); + if (&rRadioButton == &*m_pHostPortRadio) + { + m_pHostNameLabel->Enable(bSelected); + m_pHostName->Enable(bSelected); + m_pPortLabel->Enable(bSelected); + m_pPort->Enable(bSelected); + m_pDefaultPort->Enable(bSelected); + if (bSelected) + m_pHostName->SetText(m_sHostNameUserText); + else + m_pHostName->SetText("localhost"); + } + else if (&rRadioButton == &*m_pSocketRadio) + m_pSocket->Enable(bSelected); + else if (&rRadioButton == &*m_pNamedPipeRadio) + m_pNamedPipe->Enable(bSelected); } IMPL_LINK(MySQLNativeSettings, EditModifyHdl, Edit&, rEdit, void) { m_aControlModificationLink.Call(&rEdit); + + if (&rEdit == m_pHostName.get()) + { + if (m_pHostName->IsEnabled()) + m_sHostNameUserText = m_pHostName->GetText(); + } } MySQLNativeSettings::~MySQLNativeSettings() diff --git a/dbaccess/source/ui/dlg/admincontrols.hxx b/dbaccess/source/ui/dlg/admincontrols.hxx index de6aed4fdc9e..71366a09266f 100644 --- a/dbaccess/source/ui/dlg/admincontrols.hxx +++ b/dbaccess/source/ui/dlg/admincontrols.hxx @@ -26,8 +26,6 @@ #include <vcl/field.hxx> #include <vcl/fixed.hxx> -#include <svtools/dialogcontrolling.hxx> - namespace dbaui { @@ -48,8 +46,8 @@ namespace dbaui VclPtr<Edit> m_pSocket; VclPtr<Edit> m_pNamedPipe; Link<void*,void> m_aControlModificationLink; - ::svt::ControlDependencyManager - m_aControlDependencies; + OUString m_sHostNameUserText; + DECL_LINK(RadioToggleHdl, RadioButton&, void); DECL_LINK(EditModifyHdl, Edit&, void); diff --git a/dbaccess/source/ui/dlg/advancedsettings.hxx b/dbaccess/source/ui/dlg/advancedsettings.hxx index a285c733a2f0..a523e8e8d4ee 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.hxx +++ b/dbaccess/source/ui/dlg/advancedsettings.hxx @@ -23,8 +23,6 @@ #include "adminpages.hxx" #include <dsmeta.hxx> -#include <svtools/dialogcontrolling.hxx> - #include <vcl/field.hxx> #include <vector> diff --git a/dbaccess/source/ui/dlg/detailpages.hxx b/dbaccess/source/ui/dlg/detailpages.hxx index 6e50f67d59b5..47ba2089850a 100644 --- a/dbaccess/source/ui/dlg/detailpages.hxx +++ b/dbaccess/source/ui/dlg/detailpages.hxx @@ -30,7 +30,6 @@ #include "TextConnectionHelper.hxx" #include "admincontrols.hxx" -#include <svtools/dialogcontrolling.hxx> #include <o3tl/typed_flags_set.hxx> enum class OCommonBehaviourTabPageFlags { diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index 9f1c2c6f58a6..ba609c6a89b4 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -577,12 +577,6 @@ namespace dbaui m_pFT_DocListLabel->Enable( false ); m_pLB_DocumentList->Enable( false ); } - else - { - m_aControlDependencies.enableOnRadioCheck( *m_pRB_CreateDatabase, *m_pEmbeddedDBType, *m_pFT_EmbeddedDBLabel ); - m_aControlDependencies.enableOnRadioCheck( *m_pRB_ConnectDatabase, *m_pDatasourceType ); - m_aControlDependencies.enableOnRadioCheck( *m_pRB_OpenExistingDatabase, *m_pPB_OpenDatabase, *m_pFT_DocListLabel, *m_pLB_DocumentList ); - } m_pLB_DocumentList->SetDropDownLineCount( 20 ); if ( m_pLB_DocumentList->GetEntryCount() ) @@ -675,12 +669,34 @@ namespace dbaui m_aCreationModeHandler.Call( *this ); OnEmbeddedDBTypeSelected( *m_pEmbeddedDBType ); + + bool bValid, bReadonly; + getFlags( GetItemSet(), bValid, bReadonly ); + if ( bValid && !bReadonly ) + { + m_pEmbeddedDBType->Enable(m_pRB_CreateDatabase->IsChecked()); + m_pFT_EmbeddedDBLabel->Enable(m_pRB_CreateDatabase->IsChecked()); + } } - IMPL_LINK_NOARG( OGeneralPageWizard, OnSetupModeSelected, Button*, void ) + IMPL_LINK( OGeneralPageWizard, OnSetupModeSelected, Button*, pButton, void ) { m_aCreationModeHandler.Call( *this ); OnDatasourceTypeSelected(*m_pDatasourceType); + + bool bValid, bReadonly; + getFlags( GetItemSet(), bValid, bReadonly ); + if ( bValid && !bReadonly ) + { + if (pButton == m_pRB_ConnectDatabase.get()) + m_pDatasourceType->Enable(m_pRB_ConnectDatabase->IsChecked()); + else if (pButton == m_pRB_OpenExistingDatabase.get()) + { + m_pPB_OpenDatabase->Enable(m_pRB_OpenExistingDatabase->IsChecked()); + m_pFT_DocListLabel->Enable(m_pRB_OpenExistingDatabase->IsChecked()); + m_pLB_DocumentList->Enable(m_pRB_OpenExistingDatabase->IsChecked()); + } + } } IMPL_LINK_NOARG( OGeneralPageWizard, OnDocumentSelected, ListBox&, void ) diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx index 711913410e91..eb4ec41af21a 100644 --- a/dbaccess/source/ui/dlg/generalpage.hxx +++ b/dbaccess/source/ui/dlg/generalpage.hxx @@ -25,7 +25,6 @@ #include <vcl/fixed.hxx> #include <vcl/lstbox.hxx> #include <vcl/edit.hxx> -#include <svtools/dialogcontrolling.hxx> namespace dbaui { @@ -157,9 +156,6 @@ namespace dbaui Link<OGeneralPageWizard&,void> m_aDocumentSelectionHandler; /// to be called when a document in the RecentDoc list is selected Link<OGeneralPageWizard&,void> m_aChooseDocumentHandler; /// to be called when a recent document has been definitely chosen - ::svt::ControlDependencyManager - m_aControlDependencies; - bool m_bInitEmbeddedDBList : 1; void insertEmbeddedDBTypeEntryData( const OUString& _sType, const OUString& sDisplayName ); diff --git a/include/svtools/dialogcontrolling.hxx b/include/svtools/dialogcontrolling.hxx deleted file mode 100644 index a3915a3d40b3..000000000000 --- a/include/svtools/dialogcontrolling.hxx +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SVTOOLS_DIALOGCONTROLLING_HXX -#define INCLUDED_SVTOOLS_DIALOGCONTROLLING_HXX - -#include <svtools/svtdllapi.h> - -#include <tools/link.hxx> -#include <vcl/button.hxx> -#include <vcl/vclevent.hxx> - -#include <memory> - -namespace svt -{ - - - //= IWindowOperator - - /** an abstract interface for operating on a ->Window - */ - class SVT_DLLPUBLIC SAL_NO_VTABLE IWindowOperator - { - public: - /** called when an event happened which should be reacted to - - @param _rTrigger - the event which triggered the call. If the Id of the event is 0, then this is the initial - call which is made when ->_rOperateOn is added to the responsibility of the DialogController. - @param _rOperateOn - the window on which to operate - */ - virtual void operateOn( const VclWindowEvent& _rTrigger, vcl::Window& _rOperateOn ) const = 0; - - virtual ~IWindowOperator(); - }; - typedef std::shared_ptr< IWindowOperator > PWindowOperator; - - - //= IWindowEventFilter - - /** an abstract interface for deciding whether a ->VclWindowEvent - is worth paying attention to - */ - class SVT_DLLPUBLIC SAL_NO_VTABLE IWindowEventFilter - { - public: - virtual bool payAttentionTo( const VclWindowEvent& _rEvent ) const = 0; - - virtual ~IWindowEventFilter(); - }; - typedef std::shared_ptr< IWindowEventFilter > PWindowEventFilter; - - - //= DialogController - - struct DialogController_Data; - /** a class controlling interactions between dialog controls - - An instance of this class listens to all events fired by a certain - ->Control (more precise, a ->Window), the so-called instigator. - - Additionally, the ->DialogController maintains a list of windows which - are affected by changes in the instigator window. Let's call those the - dependent windows. - - Now, by help of an owner-provided ->IWindowEventFilter, the ->DialogController - decides which events are worth attention. By help of an owner-provided - ->IWindowOperator, it handles those events for all dependent windows. - */ - class SVT_DLLPUBLIC DialogController - { - private: - ::std::unique_ptr< DialogController_Data > m_pImpl; - - public: - DialogController( vcl::Window& _rInstigator, const PWindowEventFilter& _pEventFilter, const PWindowOperator& _pOperator ); - virtual ~DialogController(); - - /** adds a window to the list of dependent windows - - @param _rWindow - The window to add to the list of dependent windows. - - The caller is responsible for life-time control: The given window - must live at least as long as the ->DialogController instance does. - */ - void addDependentWindow( vcl::Window& _rWindow ); - - /** resets the controller so that no actions happened anymore. - - The instances is disfunctional after this method has been called. - */ - void reset(); - - private: - void impl_update( const VclWindowEvent& _rTriggerEvent, vcl::Window& _rWindow ); - - DECL_LINK( OnWindowEvent, VclWindowEvent&, void ); - - private: - DialogController( const DialogController& ) = delete; - DialogController& operator=( const DialogController& ) = delete; - }; - - //= ControlDependencyManager - - struct ControlDependencyManager_Data; - /** helper class for managing control dependencies - - Instances of this class are intended to be held as members of a dialog/tabpage/whatever - class, with easy administration of inter-control dependencies (such as "Enable - control X if and only if checkbox Y is checked). - */ - class SVT_DLLPUBLIC ControlDependencyManager - { - private: - ::std::unique_ptr< ControlDependencyManager_Data > m_pImpl; - - public: - ControlDependencyManager(); - ~ControlDependencyManager(); - - /** ensures that a given window is enabled or disabled, according to the check state - of a given radio button - @param _rRadio - denotes the radio button whose check state is to observe - @param _rDependentWindow - denotes the window which should be enabled when ->_rRadio is checked, and - disabled when it's unchecked - */ - void enableOnRadioCheck( RadioButton& _rRadio, vcl::Window& _rDependentWindow ); - void enableOnRadioCheck( RadioButton& _rRadio, vcl::Window& _rDependentWindow1, vcl::Window& _rDependentWindow2 ); - void enableOnRadioCheck( RadioButton& _rRadio, vcl::Window& _rDependentWindow1, vcl::Window& _rDependentWindow2, vcl::Window& _rDependentWindow3 ); - void enableOnRadioCheck( RadioButton& _rRadio, vcl::Window& _rDependentWindow1, vcl::Window& _rDependentWindow2, vcl::Window& _rDependentWindow3, vcl::Window& _rDependentWindow4, vcl::Window& _rDependentWindow5 ); - - /** adds a non-standard controller whose functionality is not covered by the other methods - - @param _pController - the controller to add to the manager. Must not be <NULL/>. - */ - void addController( const std::shared_ptr<DialogController>& _pController ); - - private: - ControlDependencyManager( const ControlDependencyManager& ) = delete; - ControlDependencyManager& operator=( const ControlDependencyManager& ) = delete; - }; - - - //= EnableOnCheck - - /** a helper class implementing the ->IWindowOperator interface, - which enables a dependent window depending on the check state of - an instigator window. - - @see DialogController - */ - template< class CHECKABLE > - class SVT_DLLPUBLIC EnableOnCheck : public IWindowOperator - { - public: - typedef CHECKABLE SourceType; - - private: - SourceType& m_rCheckable; - - public: - /** constructs the instance - - @param _rCheckable - a ->Window instance which supports a boolean method IsChecked. Usually - a ->RadioButton or ->CheckBox - */ - EnableOnCheck( SourceType& _rCheckable ) - :m_rCheckable( _rCheckable ) - { - } - - virtual void operateOn( const VclWindowEvent& /*_rTrigger*/, vcl::Window& _rOperateOn ) const override - { - _rOperateOn.Enable( m_rCheckable.IsChecked() ); - } - }; - - - //= FilterForRadioOrCheckToggle - - /** a helper class implementing the ->IWindowEventFilter interface, - which filters for radio buttons or check boxes being toggled. - - Technically, the class simply filters for the ->VclEventId::RadiobuttonToggle - and the ->VclEventId::CheckboxToggle event. - */ - class SVT_DLLPUBLIC FilterForRadioOrCheckToggle : public IWindowEventFilter - { - const vcl::Window& m_rWindow; - public: - FilterForRadioOrCheckToggle( const vcl::Window& _rWindow ) - :m_rWindow( _rWindow ) - { - } - - bool payAttentionTo( const VclWindowEvent& _rEvent ) const override - { - if ( ( _rEvent.GetWindow() == &m_rWindow ) - && ( ( _rEvent.GetId() == VclEventId::RadiobuttonToggle ) - || ( _rEvent.GetId() == VclEventId::CheckboxToggle ) - ) - ) - return true; - return false; - } - }; - - - //= RadioDependentEnabler - - /** a ->DialogController derivee which enables or disables its dependent windows, - depending on the check state of a radio button. - - The usage of this class is as simple as - <code> - pController = new RadioDependentEnabler( m_aOptionSelectSomething ); - pController->addDependentWindow( m_aLabelSelection ); - pController->addDependentWindow( m_aListSelection ); - </code> - - With this, both <code>m_aLabelSelection</code> and <code>m_aListSelection</code> will - be disabled if and only <code>m_aOptionSelectSomething</code> is checked. - */ - class SVT_DLLPUBLIC RadioDependentEnabler : public DialogController - { - public: - RadioDependentEnabler( RadioButton& _rButton ) - :DialogController( _rButton, - PWindowEventFilter( new FilterForRadioOrCheckToggle( _rButton ) ), - PWindowOperator( new EnableOnCheck< RadioButton >( _rButton ) ) ) - { - } - }; - - -} // namespace svt - - -#endif // INCLUDED_SVTOOLS_DIALOGCONTROLLING_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/reportdesign/source/ui/inc/DateTime.hxx b/reportdesign/source/ui/inc/DateTime.hxx index 2f7a1eaca881..0906c7906e57 100644 --- a/reportdesign/source/ui/inc/DateTime.hxx +++ b/reportdesign/source/ui/inc/DateTime.hxx @@ -24,8 +24,6 @@ #include <com/sun/star/util/XNumberFormats.hpp> #include <com/sun/star/lang/Locale.hpp> -#include <svtools/dialogcontrolling.hxx> - namespace rptui { class OReportController; diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index 075874d37c0f..c7d477027848 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -7031,7 +7031,6 @@ include/svtools/controldims.hxx include/svtools/ctrlbox.hxx include/svtools/ctrltool.hxx include/svtools/dialogclosedlistener.hxx -include/svtools/dialogcontrolling.hxx include/svtools/editbrowsebox.hxx include/svtools/editimplementation.hxx include/svtools/editsyntaxhighlighter.hxx @@ -13930,7 +13929,6 @@ svtools/source/misc/acceleratorexecute.cxx svtools/source/misc/bindablecontrolhelper.cxx svtools/source/misc/cliplistener.cxx svtools/source/misc/dialogclosedlistener.cxx -svtools/source/misc/dialogcontrolling.cxx svtools/source/misc/ehdl.cxx svtools/source/misc/embedhlp.cxx svtools/source/misc/embedtransfer.cxx diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index d17c85396e3d..d50cdaac4105 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -151,7 +151,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/misc/bindablecontrolhelper \ svtools/source/misc/cliplistener \ svtools/source/misc/dialogclosedlistener \ - svtools/source/misc/dialogcontrolling \ svtools/source/misc/ehdl \ svtools/source/misc/embedhlp \ svtools/source/misc/embedtransfer \ diff --git a/svtools/source/misc/dialogcontrolling.cxx b/svtools/source/misc/dialogcontrolling.cxx deleted file mode 100644 index f0bf61cf3a6b..000000000000 --- a/svtools/source/misc/dialogcontrolling.cxx +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <svtools/dialogcontrolling.hxx> -#include <vcl/window.hxx> -#include <osl/diagnose.h> -#include <tools/debug.hxx> - -#include <algorithm> - - -namespace svt -{ - - - //= IWindowOperator - - - IWindowOperator::~IWindowOperator() - { - } - - - //= IWindowEventFilter - - - IWindowEventFilter::~IWindowEventFilter() - { - } - - - //= DialogController_Data - - struct DialogController_Data - { - VclPtr<vcl::Window> xInstigator; - ::std::vector< VclPtr<vcl::Window> > aConcernedWindows; - PWindowEventFilter pEventFilter; - PWindowOperator pOperator; - - DialogController_Data( vcl::Window& _xInstigator, const PWindowEventFilter& _pEventFilter, const PWindowOperator& _pOperator ) - :xInstigator( &_xInstigator ) - ,pEventFilter( _pEventFilter ) - ,pOperator( _pOperator ) - { - } - }; - - - //= DialogController - - - DialogController::DialogController( vcl::Window& _xInstigator, const PWindowEventFilter& _pEventFilter, - const PWindowOperator& _pOperator ) - :m_pImpl( new DialogController_Data( _xInstigator, _pEventFilter, _pOperator ) ) - { - DBG_ASSERT( m_pImpl->pEventFilter.get() && m_pImpl->pOperator.get(), - "DialogController::DialogController: invalid filter and/or operator!" ); - - m_pImpl->xInstigator->AddEventListener( LINK( this, DialogController, OnWindowEvent ) ); - } - - - DialogController::~DialogController() - { - reset(); - } - - - void DialogController::reset() - { - if (m_pImpl->xInstigator) - m_pImpl->xInstigator->RemoveEventListener( LINK( this, DialogController, OnWindowEvent ) ); - m_pImpl->xInstigator.clear(); - m_pImpl->aConcernedWindows.clear(); - m_pImpl->pEventFilter.reset(); - m_pImpl->pOperator.reset(); - } - - - void DialogController::addDependentWindow( vcl::Window& _rWindow ) - { - m_pImpl->aConcernedWindows.emplace_back(&_rWindow ); - - VclWindowEvent aEvent( &_rWindow, VclEventId::NONE, nullptr ); - impl_update( aEvent, _rWindow ); - } - - - IMPL_LINK( DialogController, OnWindowEvent, VclWindowEvent&, _rEvent, void ) - { - if ( !m_pImpl->pEventFilter->payAttentionTo( _rEvent ) ) - return; - for (auto const& concernedWindow : m_pImpl->aConcernedWindows) - impl_update(_rEvent, *concernedWindow); - } - - - void DialogController::impl_update( const VclWindowEvent& _rTriggerEvent, vcl::Window& _rWindow ) - { - m_pImpl->pOperator->operateOn( _rTriggerEvent, _rWindow ); - } - - - //= ControlDependencyManager_Data - - struct ControlDependencyManager_Data - { - ::std::vector< std::shared_ptr<DialogController> > aControllers; - }; - - - //= ControlDependencyManager - - - ControlDependencyManager::ControlDependencyManager() - :m_pImpl( new ControlDependencyManager_Data ) - { - } - - - ControlDependencyManager::~ControlDependencyManager() - { - } - - - void ControlDependencyManager::addController( const std::shared_ptr<DialogController>& _pController ) - { - OSL_ENSURE(_pController != nullptr, "ControlDependencyManager::addController: invalid " - "controller, this will crash, sooner or later!"); - m_pImpl->aControllers.push_back( _pController ); - } - - - void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, vcl::Window& _rDependentWindow ) - { - std::shared_ptr<DialogController> pController( new RadioDependentEnabler( _rRadio ) ); - pController->addDependentWindow( _rDependentWindow ); - m_pImpl->aControllers.push_back( pController ); - } - - - void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, vcl::Window& _rDependentWindow1, vcl::Window& _rDependentWindow2 ) - { - std::shared_ptr<DialogController> pController( new RadioDependentEnabler( _rRadio ) ); - pController->addDependentWindow( _rDependentWindow1 ); - pController->addDependentWindow( _rDependentWindow2 ); - m_pImpl->aControllers.push_back( pController ); - } - - - void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, vcl::Window& _rDependentWindow1, vcl::Window& _rDependentWindow2, vcl::Window& _rDependentWindow3 ) - { - std::shared_ptr<DialogController> pController( new RadioDependentEnabler( _rRadio ) ); - pController->addDependentWindow( _rDependentWindow1 ); - pController->addDependentWindow( _rDependentWindow2 ); - pController->addDependentWindow( _rDependentWindow3 ); - m_pImpl->aControllers.push_back( pController ); - } - - - void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, vcl::Window& _rDependentWindow1, vcl::Window& _rDependentWindow2, vcl::Window& _rDependentWindow3, vcl::Window& _rDependentWindow4, vcl::Window& _rDependentWindow5 ) - { - std::shared_ptr<DialogController> pController( new RadioDependentEnabler( _rRadio ) ); - pController->addDependentWindow( _rDependentWindow1 ); - pController->addDependentWindow( _rDependentWindow2 ); - pController->addDependentWindow( _rDependentWindow3 ); - pController->addDependentWindow( _rDependentWindow4 ); - pController->addDependentWindow( _rDependentWindow5 ); - m_pImpl->aControllers.push_back( pController ); - } - -} // namespace svt - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |