LCOV - code coverage report
Current view: top level - cui/source/inc - iconcdlg.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 15 0.0 %
Date: 2014-11-03 Functions: 0 12 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 CTRLS_OFFSET        3
      35             : #define RET_USER        100
      36             : #define RET_USER_CANCEL 101
      37             : 
      38             : // forward-declarations
      39             : struct IconChoicePageData;
      40             : class IconChoiceDialog;
      41             : class IconChoicePage;
      42             : 
      43             : // Create-Function
      44             : typedef IconChoicePage* (*CreatePage)(vcl::Window *pParent, IconChoiceDialog* pDlg, const SfxItemSet &rAttrSet);
      45             : typedef const sal_uInt16*         (*GetPageRanges)(); // gives international Which-value
      46             : 
      47             : /// Data-structure for pages in dialog
      48             : struct IconChoicePageData
      49             : {
      50             :     sal_uInt16 nId;
      51             :     CreatePage fnCreatePage;    ///< pointer to the factory
      52             :     GetPageRanges fnGetRanges;  ///< pointer to the ranges-function
      53             :     IconChoicePage* pPage;      ///< the TabPage itself
      54             :     bool bOnDemand;         ///< Flag: ItemSet onDemand
      55             :     bool bRefresh;          ///< Flag: page has to be newly initialized
      56             : 
      57             :     // constructor
      58           0 :     IconChoicePageData( sal_uInt16 Id, CreatePage fnPage, GetPageRanges fnRanges, bool bDemand )
      59             :         : nId           ( Id ),
      60             :           fnCreatePage  ( fnPage ),
      61             :           fnGetRanges   ( fnRanges ),
      62             :           pPage         ( NULL ),
      63             :           bOnDemand     ( bDemand ),
      64           0 :           bRefresh      ( false )
      65           0 :     {}
      66             : };
      67             : 
      68             : class IconChoicePage : public TabPage
      69             : {
      70             :     using TabPage::ActivatePage;
      71             :     using TabPage::DeactivatePage;
      72             : 
      73             : private :
      74             :     const SfxItemSet*   pSet;
      75             :     OUString            aUserString;
      76             :     bool                bHasExchangeSupport;
      77             :     IconChoiceDialog*   pDialog;
      78             : 
      79             :     void                SetDialog( IconChoiceDialog* pNew ) { pDialog = pNew; }
      80             :     IconChoiceDialog*   GetDialog() const { return pDialog; }
      81             : 
      82             :     void                SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
      83             : 
      84             :     void                ImplInitSettings();
      85             : 
      86             : protected :
      87             :     IconChoicePage( vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet );
      88             : 
      89             :     sal_uInt16              GetSlot( sal_uInt16 nWhich ) const  { return pSet->GetPool()->GetSlotId( nWhich ); }
      90           0 :     sal_uInt16              GetWhich( sal_uInt16 nSlot ) const  { return pSet->GetPool()->GetWhich( nSlot ); }
      91             : 
      92             : public :
      93             :     virtual             ~IconChoicePage();
      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 void        FillUserData();
     117             :     virtual bool        IsReadOnly() const;
     118             :     virtual bool    QueryClose();
     119             : 
     120             :     void                StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     121             :     void                DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     122             : };
     123             : 
     124             : class IconChoiceDialog : public ModalDialog
     125             : {
     126             : private :
     127             :     friend class IconChoicePage;
     128             : 
     129             :     ::std::vector< IconChoicePageData* > maPageList;
     130             : 
     131             :     SvtIconChoiceCtrl       *m_pIconCtrl;
     132             : 
     133             :     sal_uInt16                  mnCurrentPageId;
     134             : 
     135             :     // Buttons
     136             :     OKButton                *m_pOKBtn;
     137             :     PushButton              *m_pApplyBtn;
     138             :     CancelButton            *m_pCancelBtn;
     139             :     HelpButton              *m_pHelpBtn;
     140             :     PushButton              *m_pResetBtn;
     141             : 
     142             :     VclVBox                 *m_pTabContainer;
     143             :     const SfxItemSet*       pSet;
     144             :     SfxItemSet*             pOutSet;
     145             :     SfxItemSet*             pExampleSet;
     146             :     sal_uInt16*                 pRanges;
     147             : 
     148             :     bool                    bHideResetBtn;
     149             :     bool                    bModal;
     150             :     bool                    bInOK;
     151             :     bool                    bItemsReset;
     152             : 
     153             :     DECL_LINK ( ChosePageHdl_Impl, void * );
     154             :     DECL_LINK(OkHdl, void *);
     155             :     DECL_LINK(ApplyHdl, void *);
     156             :     DECL_LINK(ResetHdl, void *);
     157             :     DECL_LINK(CancelHdl, void *);
     158             : 
     159             :     IconChoicePageData*     GetPageData ( sal_uInt16 nId );
     160             :     void                    Start_Impl();
     161             :     bool                    OK_Impl();
     162             : 
     163             :     void                    FocusOnIcon ( sal_uInt16 nId );
     164             : 
     165             : protected :
     166             :     void                    ShowPageImpl ( IconChoicePageData* pData );
     167             :     void                    HidePageImpl ( IconChoicePageData* pData );
     168             : 
     169             :     virtual void            PageCreated( sal_uInt16 nId, IconChoicePage& rPage );
     170             :     virtual SfxItemSet*     CreateInputItemSet( sal_uInt16 nId );
     171             :     inline SfxItemSet*      GetInputSetImpl() { return (SfxItemSet*)pSet; }
     172           0 :     inline IconChoicePage*  GetTabPage( sal_uInt16 nPageId )
     173           0 :                                 { return ( GetPageData (nPageId)->pPage?GetPageData (nPageId)->pPage:NULL); }
     174             :     const SfxItemSet*       GetRefreshedSet();
     175             : 
     176             :     void                    ActivatePageImpl ();
     177             :     bool                    DeActivatePageImpl ();
     178             :     void                    ResetPageImpl ();
     179             : 
     180             :     short                   Ok();
     181             : 
     182             : public :
     183             : 
     184             :     // the IconChoiceCtrl's could also be set in the Ctor
     185             :     IconChoiceDialog ( vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
     186             :                        const SfxItemSet * pItemSet = 0 );
     187             :     virtual ~IconChoiceDialog ();
     188             : 
     189             :     // interface
     190             :     SvxIconChoiceCtrlEntry* AddTabPage(
     191             :         sal_uInt16 nId, const OUString& rIconText, const Image& rChoiceIcon,
     192             :         CreatePage pCreateFunc /* != NULL */, GetPageRanges pRangesFunc = NULL /* NULL allowed*/,
     193             :         bool bItemsOnDemand = false, sal_uLong nPos = TREELIST_APPEND );
     194             : 
     195           0 :     void                SetCurPageId( sal_uInt16 nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); }
     196           0 :     sal_uInt16              GetCurPageId() const       { return mnCurrentPageId; }
     197             :     void                ShowPage( sal_uInt16 nId );
     198             : 
     199             :     /// gives via map converted local slots if applicable
     200             :     const sal_uInt16*   GetInputRanges( const SfxItemPool& );
     201             :     void                SetInputSet( const SfxItemSet* pInSet );
     202             :     const SfxItemSet*   GetOutputItemSet() const { return pOutSet; }
     203             : 
     204             :     const OKButton&     GetOKButton() const { return *m_pOKBtn; }
     205           0 :     OKButton&           GetOKButton() { return *m_pOKBtn; }
     206             :     const PushButton&   GetApplyButton() const { return *m_pApplyBtn; }
     207           0 :     PushButton&         GetApplyButton() { return *m_pApplyBtn; }
     208             :     const CancelButton& GetCancelButton() const { return *m_pCancelBtn; }
     209           0 :     CancelButton&       GetCancelButton() { return *m_pCancelBtn; }
     210             :     const HelpButton&   GetHelpButton() const { return *m_pHelpBtn; }
     211             :     HelpButton&         GetHelpButton() { return *m_pHelpBtn; }
     212             : 
     213             :     short               Execute() SAL_OVERRIDE;
     214             :     void                Start( bool bShow = true );
     215             :     bool            QueryClose();
     216             : 
     217             :     const SfxItemSet*   GetExampleSet() const { return pExampleSet; }
     218             : 
     219             :     void                SetCtrlStyle();
     220             : };
     221             : 
     222             : #endif // INCLUDED_CUI_SOURCE_INC_ICONCDLG_HXX
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10