LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - adminpages.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 32 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 74 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_DBACCESS_SOURCE_UI_DLG_ADMINPAGES_HXX
      21             : #define INCLUDED_DBACCESS_SOURCE_UI_DLG_ADMINPAGES_HXX
      22             : 
      23             : #include <sfx2/tabdlg.hxx>
      24             : #include "dsntypes.hxx"
      25             : #include "commontypes.hxx"
      26             : #include <svtools/wizardmachine.hxx>
      27             : #include <vcl/field.hxx>
      28             : #include <vcl/fixed.hxx>
      29             : 
      30             : class NumericField;
      31             : class Edit;
      32             : namespace dbaui
      33             : {
      34             :     /// helper class to wrap the savevalue and disable call
      35           0 :     class SAL_NO_VTABLE ISaveValueWrapper
      36             :     {
      37             :     public:
      38             :         virtual ~ISaveValueWrapper() = 0;
      39             :         virtual bool SaveValue() = 0;
      40             :         virtual bool Disable() = 0;
      41             :     };
      42             : 
      43           0 :     template < class T > class OSaveValueWrapper : public ISaveValueWrapper
      44             :     {
      45             :         T*  m_pSaveValue;
      46             :     public:
      47           0 :         OSaveValueWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
      48           0 :         { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
      49             : 
      50           0 :         virtual bool SaveValue() SAL_OVERRIDE { m_pSaveValue->SaveValue(); return true;} // bool return value only for stl
      51           0 :         virtual bool Disable() SAL_OVERRIDE { m_pSaveValue->Disable(); return true;} // bool return value only for stl
      52             :     };
      53             : 
      54           0 :     template < class T > class ODisableWrapper : public ISaveValueWrapper
      55             :     {
      56             :         T*  m_pSaveValue;
      57             :     public:
      58           0 :         ODisableWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
      59           0 :         { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
      60             : 
      61           0 :         virtual bool SaveValue() SAL_OVERRIDE { return true;} // bool return value only for stl
      62           0 :         virtual bool Disable() SAL_OVERRIDE { m_pSaveValue->Disable(); return true;} // bool return value only for stl
      63             :     };
      64             : 
      65             :     struct TSaveValueWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
      66             :     {
      67           0 :         bool operator() (ISaveValueWrapper* lhs)
      68             :         {
      69           0 :             return lhs->SaveValue();
      70             :         }
      71             :     };
      72             :     struct TDisableWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
      73             :     {
      74           0 :         bool operator() (ISaveValueWrapper* lhs)
      75             :         {
      76           0 :             return lhs->Disable();
      77             :         }
      78             :     };
      79             : 
      80             :     struct TDeleteWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
      81             :     {
      82           0 :         bool operator() (ISaveValueWrapper* lhs)
      83             :         {
      84           0 :             delete lhs;
      85           0 :             return true;
      86             :         }
      87             :     };
      88             : 
      89             :     // OGenericAdministrationPage
      90             :     class IDatabaseSettingsDialog;
      91             :     class IItemSetHelper;
      92           0 :     class OGenericAdministrationPage    :public SfxTabPage
      93             :                                         ,public ::svt::IWizardPageController
      94             :     {
      95             :     private:
      96             :         Link<OGenericAdministrationPage const *, void> m_aModifiedHandler; /// to be called if something on the page has been modified
      97             :         bool        m_abEnableRoadmap;
      98             :     protected:
      99             :         IDatabaseSettingsDialog*   m_pAdminDialog;
     100             :         IItemSetHelper* m_pItemSetHelper;
     101             : 
     102             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
     103             :                             m_xORB;
     104             :     public:
     105             :         OGenericAdministrationPage(vcl::Window* _pParent, const OString& _rId, const OUString& _rUIXMLDescription, const SfxItemSet& _rAttrSet);
     106             :         /// set a handler which gets called every time something on the page has been modified
     107           0 :         void SetModifiedHandler(const Link<OGenericAdministrationPage const *, void>& _rHandler) { m_aModifiedHandler = _rHandler; }
     108             : 
     109             :         /** Sets the ParentDialog
     110             :             @param  _pAdminDialog
     111             :                 the ParentDialog
     112             :             @param  _pItemSetHelper
     113             :                 the itemset helper
     114             :         */
     115           0 :         inline void SetAdminDialog(IDatabaseSettingsDialog* _pDialog,IItemSetHelper* _pItemSetHelper)
     116             :         {
     117             :             OSL_ENSURE(_pDialog && _pItemSetHelper,"Values are NULL!");
     118           0 :             m_pAdminDialog = _pDialog;
     119           0 :             m_pItemSetHelper = _pItemSetHelper;
     120           0 :         }
     121             : 
     122             :         /** Sets the ServiceFactory
     123             :             @param  _rxORB
     124             :                 The service factory.
     125             :         */
     126           0 :         void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxORB)
     127             :         {
     128           0 :             m_xORB = rxORB;
     129           0 :         }
     130             : 
     131             :         /** opens a dialog filled with all data sources available for this type and
     132             :             returns the selected on.
     133             :             @param  _eType
     134             :                 The type for which the data source dialog should be opened.
     135             :             @param  _sReturn
     136             :                 <OUT/> contains the selected name.
     137             :             @return
     138             :                 <FALSE/> if an error occurred, otherwise <TRUE/>
     139             :         */
     140             :         bool getSelectedDataSource(OUString& _sReturn, OUString& _sCurr);
     141             : 
     142             :         // svt::IWizardPageController
     143             :         virtual void initializePage() SAL_OVERRIDE;
     144             :         virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) SAL_OVERRIDE;
     145             :         virtual bool canAdvance() const SAL_OVERRIDE;
     146             : 
     147           0 :         void                SetRoadmapStateValue( bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; }
     148           0 :         bool                GetRoadmapStateValue() const { return m_abEnableRoadmap; }
     149             : 
     150             :     protected:
     151             :         /// default implementation: call FillItemSet, call prepareLeave,
     152             :         virtual sfxpg DeactivatePage(SfxItemSet* pSet) SAL_OVERRIDE;
     153             :         using SfxTabPage::DeactivatePage;
     154             :         /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
     155             :         virtual void Reset(const SfxItemSet* _rCoreAttrs) SAL_OVERRIDE;
     156             :         /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_True
     157             :         virtual void ActivatePage(const SfxItemSet& _rSet) SAL_OVERRIDE;
     158             : 
     159             :         // TabPage overridables
     160             :         virtual void    ActivatePage() SAL_OVERRIDE;
     161             : 
     162             :     protected:
     163           0 :         void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call(this); }
     164             : 
     165             :         /// called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_True
     166           0 :         virtual bool prepareLeave() { return true; }
     167             : 
     168             :         /** called from within Reset and ActivatePage, use to initialize the controls with the items from the given set
     169             :             @param      _bSaveValue     if set to sal_True, the implementation should call SaveValue on all relevant controls
     170             :         */
     171             :         virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue);
     172             : 
     173             :         /// analyze the invalid and the readonly flag which may be present in the set
     174             :         static void getFlags(const SfxItemSet& _rSet, bool& _rValid, bool& _rReadonly);
     175             : 
     176             :         /** will be called inside <method>implInitControls</method> to save the value if necessary
     177             :             @param  _rControlList
     178             :                 The list must be filled with the controls.
     179             :                 It is not allowed to clear the list before pusching data into it.
     180             :         */
     181             :         virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
     182             : 
     183             :         /** will be called inside <method>implInitControls</method> to disable if necessary
     184             :             @param  _rControlList
     185             :                 The list must be filled with the controls.
     186             :                 It is not allowed to clear the list before pusching data into it.
     187             :         */
     188             :         virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
     189             : 
     190             :     public:
     191             :         /** fills the Boolean value into the item set when the value changed.
     192             :             @param  _rSet
     193             :                 The item set where to put the new value into.
     194             :             @param  _pCheckBox
     195             :                 The check box which is checked.
     196             :             @param  _nID
     197             :                 The id in the itemset to set with the new value.
     198             :             @param  _bChangedSomething
     199             :                 <TRUE/> if something changed otherwise <FALSE/>
     200             :             @param _bRevertValue
     201             :                 set to <TRUE/> if the display value should be reverted before putting it into the set
     202             :         */
     203             :         static void fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, sal_uInt16 _nID, bool& _bChangedSomething, bool _bRevertValue = false);
     204             : 
     205             :         /** fills the int value into the item set when the value changed.
     206             :             @param  _rSet
     207             :                 The item set where to put the new value into.
     208             :             @param  _pEdit
     209             :                 The check box which is checked.
     210             :             @param  _nID
     211             :                 The id in the itemset to set with the new value.
     212             :             @param  _bChangedSomething
     213             :                 <TRUE/> if something changed otherwise <FALSE/>
     214             :         */
     215             :         static void fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,sal_uInt16 _nID, bool& _bChangedSomething);
     216             : 
     217             :         /** fills the String value into the item set when the value changed.
     218             :             @param  _rSet
     219             :                 The item set where to put the new value into.
     220             :             @param  _pEdit
     221             :                 The check box which is checked.
     222             :             @param  _nID
     223             :                 The id in the itemset to set with the new value.
     224             :             @param  _bChangedSomething
     225             :                 <TRUE/> if something changed otherwise <FALSE/>
     226             :         */
     227             :         static void fillString(SfxItemSet& _rSet,Edit* _pEdit,sal_uInt16 _nID, bool& _bChangedSomething);
     228             : 
     229             :     protected:
     230             :         /** This link be used for controls where the tabpage does not need to take any special action when the control
     231             :             is modified. The implementation just calls callModifiedHdl.
     232             :         */
     233             :         DECL_LINK(OnControlModified, void*);
     234             :         DECL_LINK(OnTestConnectionClickHdl, PushButton*);
     235             : 
     236             :         /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method>
     237           0 :         virtual Link<> getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); }
     238             :     };
     239             : 
     240             :     // ControlRelation
     241             :     enum ControlRelation
     242             :     {
     243             :         RelatedControls, UnrelatedControls
     244             :     };
     245             : 
     246             :     // LayoutHelper
     247             :     class LayoutHelper
     248             :     {
     249             :     public:
     250             :         static void     positionBelow(
     251             :                             const Control& _rReference,
     252             :                             Control& _rControl,
     253             :                             const ControlRelation _eRelation,
     254             :                             const long _nIndentAppFont
     255             :                         );
     256             :         /** fits the button size to be large enough to contain the buttons text
     257             :         */
     258             :         static void fitSizeRightAligned( PushButton& io_button );
     259             :             // why is CalcMinimumSize not a virtual method of vcl::Window?
     260             :     };
     261             : 
     262             : }   // namespace dbaui
     263             : 
     264             : #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_ADMINPAGES_HXX
     265             : 
     266             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11