LCOV - code coverage report
Current view: top level - cui/source/inc - iconcdlg.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 16 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 13 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             : #ifndef INCLUDED_CUI_SOURCE_INC_ICONCDLG_HXX
      20             : #define INCLUDED_CUI_SOURCE_INC_ICONCDLG_HXX
      21             : 
      22             : #include <rtl/ustring.hxx>
      23             : #include <svl/itempool.hxx>
      24             : #include <svl/itemset.hxx>
      25             : #include <svtools/ivctrl.hxx>
      26             : #include <vcl/tabpage.hxx>
      27             : #include <vcl/msgbox.hxx>
      28             : #include <vcl/dialog.hxx>
      29             : #include <vcl/button.hxx>
      30             : #include <vcl/image.hxx>
      31             : #include <vcl/layout.hxx>
      32             : #include <vector>
      33             : 
      34             : #define RET_USER        100
      35             : #define RET_USER_CANCEL 101
      36             : 
      37             : // forward-declarations
      38             : struct IconChoicePageData;
      39             : class IconChoiceDialog;
      40             : class IconChoicePage;
      41             : 
      42             : // Create-Function
      43             : typedef VclPtr<IconChoicePage> (*CreatePage)(vcl::Window *pParent, IconChoiceDialog* pDlg, const SfxItemSet &rAttrSet);
      44             : typedef const sal_uInt16*      (*GetPageRanges)(); // gives international Which-value
      45             : 
      46             : /// Data-structure for pages in dialog
      47           0 : struct IconChoicePageData
      48             : {
      49             :     sal_uInt16 nId;
      50             :     CreatePage fnCreatePage;    ///< pointer to the factory
      51             :     GetPageRanges fnGetRanges;  ///< pointer to the ranges-function
      52             :     VclPtr<IconChoicePage> pPage;      ///< the TabPage itself
      53             :     bool bOnDemand;         ///< Flag: ItemSet onDemand
      54             :     bool bRefresh;          ///< Flag: page has to be newly initialized
      55             : 
      56             :     // constructor
      57           0 :     IconChoicePageData( sal_uInt16 Id, CreatePage fnPage, GetPageRanges fnRanges, bool bDemand )
      58             :         : nId           ( Id ),
      59             :           fnCreatePage  ( fnPage ),
      60             :           fnGetRanges   ( fnRanges ),
      61             :           pPage         ( NULL ),
      62             :           bOnDemand     ( bDemand ),
      63           0 :           bRefresh      ( false )
      64           0 :     {}
      65             : };
      66             : 
      67             : class IconChoicePage : public TabPage
      68             : {
      69             :     using TabPage::ActivatePage;
      70             :     using TabPage::DeactivatePage;
      71             : 
      72             : private :
      73             :     const SfxItemSet*   pSet;
      74             :     OUString            aUserString;
      75             :     bool                bHasExchangeSupport;
      76             :     VclPtr<IconChoiceDialog>   pDialog;
      77             : 
      78             :     void                SetDialog( IconChoiceDialog* pNew ) { pDialog = pNew; }
      79             :     IconChoiceDialog*   GetDialog() const { return pDialog; }
      80             : 
      81             :     void                SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
      82             : 
      83             :     void                ImplInitSettings();
      84             : 
      85             : protected :
      86             :     IconChoicePage( vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet );
      87             : 
      88             :     sal_uInt16          GetSlot( sal_uInt16 nWhich ) const  { return pSet->GetPool()->GetSlotId( nWhich ); }
      89           0 :     sal_uInt16          GetWhich( sal_uInt16 nSlot ) const  { return pSet->GetPool()->GetWhich( nSlot ); }
      90             : 
      91             : public :
      92             :     virtual ~IconChoicePage();
      93             :     virtual void        dispose() SAL_OVERRIDE;
      94             : 
      95           0 :     const SfxItemSet&   GetItemSet() const { return *pSet; }
      96             : 
      97             :     virtual bool        FillItemSet( SfxItemSet* ) = 0;
      98             :     virtual void        Reset( const SfxItemSet& ) = 0;
      99             : 
     100           0 :     bool                HasExchangeSupport() const              { return bHasExchangeSupport; }
     101           0 :     void                SetExchangeSupport( bool bNew = true )  { bHasExchangeSupport = bNew; }
     102             : 
     103             :     enum {
     104             :         KEEP_PAGE = 0x0000, ///< error handling
     105             :         /** 2nd filling of an ItemSet for updating superior examples;
     106             :             this pointer can always be NULL!! */
     107             :         LEAVE_PAGE = 0x0001,
     108             :         /// refresh set and update other pages
     109             :         REFRESH_SET = 0x0002
     110             :     };
     111             : 
     112             :     virtual void        ActivatePage( const SfxItemSet& );
     113             :     virtual int         DeactivatePage( SfxItemSet* pSet = 0 );
     114             :     void                SetUserData(const OUString& rString)  { aUserString = rString; }
     115           0 :     OUString            GetUserData() { return aUserString; }
     116             :     virtual bool        QueryClose();
     117             : 
     118             :     void                StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     119             :     void                DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     120             : };
     121             : 
     122             : class IconChoiceDialog : public ModalDialog
     123             : {
     124             : private :
     125             :     friend class IconChoicePage;
     126             : 
     127             :     ::std::vector< IconChoicePageData* > maPageList;
     128             : 
     129             :     VclPtr<SvtIconChoiceCtrl>       m_pIconCtrl;
     130             : 
     131             :     sal_uInt16                  mnCurrentPageId;
     132             : 
     133             :     // Buttons
     134             :     VclPtr<OKButton>                m_pOKBtn;
     135             :     VclPtr<PushButton>              m_pApplyBtn;
     136             :     VclPtr<CancelButton>            m_pCancelBtn;
     137             :     VclPtr<HelpButton>              m_pHelpBtn;
     138             :     VclPtr<PushButton>              m_pResetBtn;
     139             : 
     140             :     VclPtr<VclVBox>                 m_pTabContainer;
     141             :     const SfxItemSet*       pSet;
     142             :     SfxItemSet*             pOutSet;
     143             :     SfxItemSet*             pExampleSet;
     144             :     sal_uInt16*                 pRanges;
     145             : 
     146             :     bool                    bHideResetBtn;
     147             :     bool                    bModal;
     148             :     bool                    bInOK;
     149             :     bool                    bItemsReset;
     150             : 
     151             :     DECL_LINK ( ChosePageHdl_Impl, void * );
     152             :     DECL_LINK(OkHdl, void *);
     153             :     DECL_LINK(ApplyHdl, void *);
     154             :     DECL_LINK(ResetHdl, void *);
     155             :     DECL_LINK(CancelHdl, void *);
     156             : 
     157             :     IconChoicePageData*     GetPageData ( sal_uInt16 nId );
     158             :     void                    Start_Impl();
     159             :     bool                    OK_Impl();
     160             : 
     161             :     void                    FocusOnIcon ( sal_uInt16 nId );
     162             : 
     163             : protected :
     164             :     static void             ShowPageImpl ( IconChoicePageData* pData );
     165             :     static void             HidePageImpl ( IconChoicePageData* pData );
     166             : 
     167             :     virtual void            PageCreated( sal_uInt16 nId, IconChoicePage& rPage );
     168             :     static SfxItemSet*      CreateInputItemSet( sal_uInt16 nId );
     169             :     inline SfxItemSet*      GetInputSetImpl() { return const_cast<SfxItemSet*>(pSet); }
     170           0 :     inline IconChoicePage*  GetTabPage( sal_uInt16 nPageId )
     171           0 :                                 { return ( GetPageData (nPageId)->pPage ? GetPageData (nPageId)->pPage.get() : NULL); }
     172             :     static void             RefreshInputSet();
     173             : 
     174             :     void                    ActivatePageImpl ();
     175             :     bool                    DeActivatePageImpl ();
     176             :     void                    ResetPageImpl ();
     177             : 
     178             :     short                   Ok();
     179             : 
     180             : public :
     181             : 
     182             :     // the IconChoiceCtrl's could also be set in the Ctor
     183             :     IconChoiceDialog ( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription,
     184             :                        const SfxItemSet * pItemSet = 0 );
     185             :     virtual ~IconChoiceDialog ();
     186             :     virtual void dispose() SAL_OVERRIDE;
     187             : 
     188             :     // interface
     189             :     SvxIconChoiceCtrlEntry* AddTabPage(
     190             :         sal_uInt16 nId, const OUString& rIconText, const Image& rChoiceIcon,
     191             :         CreatePage pCreateFunc /* != NULL */, GetPageRanges pRangesFunc = NULL /* NULL allowed*/,
     192             :         bool bItemsOnDemand = false, sal_uLong nPos = TREELIST_APPEND );
     193             : 
     194           0 :     void                SetCurPageId( sal_uInt16 nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); }
     195           0 :     sal_uInt16              GetCurPageId() const       { return mnCurrentPageId; }
     196             :     void                ShowPage( sal_uInt16 nId );
     197             : 
     198             :     /// gives via map converted local slots if applicable
     199             :     const sal_uInt16*   GetInputRanges( const SfxItemPool& );
     200             :     void                SetInputSet( const SfxItemSet* pInSet );
     201             :     const SfxItemSet*   GetOutputItemSet() const { return pOutSet; }
     202             : 
     203             :     const OKButton&     GetOKButton() const { return *m_pOKBtn; }
     204           0 :     OKButton&           GetOKButton() { return *m_pOKBtn; }
     205             :     const PushButton&   GetApplyButton() const { return *m_pApplyBtn; }
     206           0 :     PushButton&         GetApplyButton() { return *m_pApplyBtn; }
     207             :     const CancelButton& GetCancelButton() const { return *m_pCancelBtn; }
     208           0 :     CancelButton&       GetCancelButton() { return *m_pCancelBtn; }
     209             :     const HelpButton&   GetHelpButton() const { return *m_pHelpBtn; }
     210             :     HelpButton&         GetHelpButton() { return *m_pHelpBtn; }
     211             : 
     212             :     short               Execute() SAL_OVERRIDE;
     213             :     void                Start( bool bShow = true );
     214             :     bool            QueryClose();
     215             : 
     216             :     const SfxItemSet*   GetExampleSet() const { return pExampleSet; }
     217             : 
     218             :     void                SetCtrlStyle();
     219             : };
     220             : 
     221             : #endif // INCLUDED_CUI_SOURCE_INC_ICONCDLG_HXX
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11