LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - adminpages.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 31 0.0 %
Date: 2014-04-14 Functions: 0 77 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             :     class OGenericAdministrationPage    :public SfxTabPage
      93             :                                         ,public ::svt::IWizardPageController
      94             :     {
      95             :     private:
      96             :         Link            m_aModifiedHandler;     /// to be called if something on the page has been modified
      97             :         sal_Bool        m_abEnableRoadmap;
      98             :     protected:
      99             :         IDatabaseSettingsDialog*   m_pAdminDialog;
     100             :         IItemSetHelper* m_pItemSetHelper;
     101             :         FixedText*      m_pFT_HeaderText;
     102             : 
     103             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
     104             :                             m_xORB;
     105             :     public:
     106             :         OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet);
     107             :         OGenericAdministrationPage(Window* _pParent, const OString& _rId, const OUString& _rUIXMLDescription, const SfxItemSet& _rAttrSet);
     108             :         virtual ~OGenericAdministrationPage();
     109             : 
     110             :         /// set a handler which gets called every time something on the page has been modified
     111           0 :         void SetModifiedHandler(const Link& _rHandler) { m_aModifiedHandler = _rHandler; }
     112             : 
     113             :         /** Sets the ParentDialog
     114             :             @param  _pAdminDialog
     115             :                 the ParentDialog
     116             :             @param  _pItemSetHelper
     117             :                 the itemset helper
     118             :         */
     119           0 :         inline void SetAdminDialog(IDatabaseSettingsDialog* _pDialog,IItemSetHelper* _pItemSetHelper)
     120             :         {
     121             :             OSL_ENSURE(_pDialog && _pItemSetHelper,"Values are NULL!");
     122           0 :             m_pAdminDialog = _pDialog;
     123           0 :             m_pItemSetHelper = _pItemSetHelper;
     124           0 :         }
     125             : 
     126             :         /** Sets the ServiceFactory
     127             :             @param  _rxORB
     128             :                 The service factory.
     129             :         */
     130           0 :         void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > _rxORB)
     131             :         {
     132           0 :             m_xORB = _rxORB;
     133           0 :         }
     134             : 
     135             :         /** opens a dialog filled with all data sources available for this type and
     136             :             returns the selected on.
     137             :             @param  _eType
     138             :                 The type for which the data source dialog should be opened.
     139             :             @param  _sReturn
     140             :                 <OUT/> contains the selected name.
     141             :             @return
     142             :                 <FALSE/> if an error occurred, otherwise <TRUE/>
     143             :         */
     144             :         sal_Bool getSelectedDataSource(OUString& _sReturn,OUString& _sCurr);
     145             : 
     146             :         // svt::IWizardPageController
     147             :         virtual void initializePage() SAL_OVERRIDE;
     148             :         virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) SAL_OVERRIDE;
     149             :         virtual bool canAdvance() const SAL_OVERRIDE;
     150             : 
     151           0 :         void                SetRoadmapStateValue( sal_Bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; }
     152           0 :         bool                GetRoadmapStateValue() const { return m_abEnableRoadmap; }
     153             : 
     154             :     protected:
     155             :         /// default implementation: call FillItemSet, call prepareLeave,
     156             :         virtual int DeactivatePage(SfxItemSet* pSet) SAL_OVERRIDE;
     157             :         using SfxTabPage::DeactivatePage;
     158             :         /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
     159             :         virtual void Reset(const SfxItemSet& _rCoreAttrs) SAL_OVERRIDE;
     160             :         /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_True
     161             :         virtual void ActivatePage(const SfxItemSet& _rSet) SAL_OVERRIDE;
     162             : 
     163             :         // TabPage overridables
     164             :         virtual void    ActivatePage() SAL_OVERRIDE;
     165             : 
     166             :     protected:
     167           0 :         void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call((void*)this); }
     168             : 
     169             :         /// called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_True
     170           0 :         virtual sal_Bool prepareLeave() { return sal_True; }
     171             : 
     172             :         /** called from within Reset and ActivatePage, use to initialize the controls with the items from the given set
     173             :             @param      _bSaveValue     if set to sal_True, the implementation should call SaveValue on all relevant controls
     174             :         */
     175             :         virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
     176             : 
     177             :         /// analyze the invalid and the readonly flag which may be present in the set
     178             :         void getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly);
     179             : 
     180             :         /** will be called inside <method>implInitControls</method> to save the value if necessary
     181             :             @param  _rControlList
     182             :                 The list must be filled with the controls.
     183             :                 It is not allowed to clear the list before pusching data into it.
     184             :         */
     185             :         virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
     186             : 
     187             :         /** will be called inside <method>implInitControls</method> to disable if necessary
     188             :             @param  _rControlList
     189             :                 The list must be filled with the controls.
     190             :                 It is not allowed to clear the list before pusching data into it.
     191             :         */
     192             :         virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
     193             : 
     194             :     public:
     195             :         /** fills the Boolean value into the item set when the value changed.
     196             :             @param  _rSet
     197             :                 The item set where to put the new value into.
     198             :             @param  _pCheckBox
     199             :                 The check box which is checked.
     200             :             @param  _nID
     201             :                 The id in the itemset to set with the new value.
     202             :             @param  _bChangedSomething
     203             :                 <TRUE/> if something changed otherwise <FALSE/>
     204             :             @param _bRevertValue
     205             :                 set to <TRUE/> if the display value should be reverted before putting it into the set
     206             :         */
     207             :         static void fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, sal_uInt16 _nID, sal_Bool& _bChangedSomething, bool _bRevertValue = false);
     208             : 
     209             :         /** fills the int value into the item set when the value changed.
     210             :             @param  _rSet
     211             :                 The item set where to put the new value into.
     212             :             @param  _pEdit
     213             :                 The check box which is checked.
     214             :             @param  _nID
     215             :                 The id in the itemset to set with the new value.
     216             :             @param  _bChangedSomething
     217             :                 <TRUE/> if something changed otherwise <FALSE/>
     218             :         */
     219             :         static void fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,sal_uInt16 _nID,sal_Bool& _bChangedSomething);
     220             : 
     221             :         /** fills the String value into the item set when the value changed.
     222             :             @param  _rSet
     223             :                 The item set where to put the new value into.
     224             :             @param  _pEdit
     225             :                 The check box which is checked.
     226             :             @param  _nID
     227             :                 The id in the itemset to set with the new value.
     228             :             @param  _bChangedSomething
     229             :                 <TRUE/> if something changed otherwise <FALSE/>
     230             :         */
     231             :         static void fillString(SfxItemSet& _rSet,Edit* _pEdit,sal_uInt16 _nID,sal_Bool& _bChangedSomething);
     232             : 
     233             :     protected:
     234             :         // used to set the right Pane header of a wizard to bold
     235             :         void SetControlFontWeight(Window* _pWindow, FontWeight _eWeight = WEIGHT_BOLD);
     236             :         void SetHeaderText( sal_uInt16 _nFTResId, sal_uInt16 _StringResId);
     237             : 
     238             :         /** This link be used for controls where the tabpage does not need to take any special action when the control
     239             :             is modified. The implementation just calls callModifiedHdl.
     240             :         */
     241             :         DECL_LINK(OnControlModified, void*);
     242             :         DECL_LINK(OnTestConnectionClickHdl,PushButton*);
     243             : 
     244             :         /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method>
     245           0 :         virtual Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); }
     246             :     };
     247             : 
     248             :     // ControlRelation
     249             :     enum ControlRelation
     250             :     {
     251             :         RelatedControls, UnrelatedControls
     252             :     };
     253             : 
     254             :     // LayoutHelper
     255             :     class LayoutHelper
     256             :     {
     257             :     public:
     258             :         static void     positionBelow(
     259             :                             const Control& _rReference,
     260             :                             Control& _rControl,
     261             :                             const ControlRelation _eRelation,
     262             :                             const long _nIndentAppFont
     263             :                         );
     264             :         /** fits the button size to be large enough to contain the buttons text
     265             :         */
     266             :         static void fitSizeRightAligned( PushButton& io_button );
     267             :             // why is CalcMinimumSize not a virtual method of ::Window?
     268             :     };
     269             : 
     270             : }   // namespace dbaui
     271             : 
     272             : #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_ADMINPAGES_HXX
     273             : 
     274             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10