Branch data 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 _SFXTABDLG_HXX
20 : : #define _SFXTABDLG_HXX
21 : :
22 : : #include "sal/config.h"
23 : : #include "sfx2/dllapi.h"
24 : : #include "sal/types.h"
25 : : #include <vcl/tabdlg.hxx>
26 : : #include <vcl/button.hxx>
27 : : #include <vcl/tabctrl.hxx>
28 : : #include <vcl/tabpage.hxx>
29 : : #include <svl/itempool.hxx>
30 : : #include <svl/itemset.hxx>
31 : : #include <com/sun/star/frame/XFrame.hpp>
32 : :
33 : : class SfxPoolItem;
34 : : class SfxTabDialog;
35 : : class SfxViewFrame;
36 : : class SfxTabPage;
37 : : class SfxBindings;
38 : :
39 : : typedef SfxTabPage* (*CreateTabPage)(Window *pParent, const SfxItemSet &rAttrSet);
40 : : typedef sal_uInt16* (*GetTabPageRanges)(); // provides international Which-value
41 : : struct TabPageImpl;
42 : :
43 : : struct TabDlg_Impl;
44 : :
45 : : #define ID_TABCONTROL 1
46 : : #define RET_USER 100
47 : : #define RET_USER_CANCEL 101
48 : :
49 [ # # ]: 0 : class SFX2_DLLPUBLIC SfxTabDialogItem: public SfxSetItem
50 : : {
51 : : public:
52 : : TYPEINFO();
53 : : SfxTabDialogItem( sal_uInt16 nId, const SfxItemSet& rItemSet );
54 : : SfxTabDialogItem(const SfxTabDialogItem& rAttr, SfxItemPool* pItemPool=NULL);
55 : : virtual SfxPoolItem* Clone(SfxItemPool* pToPool) const;
56 : : virtual SfxPoolItem* Create(SvStream& rStream, sal_uInt16 nVersion) const;
57 : : };
58 : :
59 : : class SFX2_DLLPUBLIC SfxTabDialog : public TabDialog
60 : : {
61 : : private:
62 : : friend class SfxTabPage;
63 : : friend class SfxTabDialogController;
64 : :
65 : : SfxViewFrame* pFrame;
66 : :
67 : : TabControl aTabCtrl;
68 : : OKButton aOKBtn;
69 : : PushButton* pUserBtn;
70 : : CancelButton aCancelBtn;
71 : : HelpButton aHelpBtn;
72 : : PushButton aResetBtn;
73 : : PushButton aBaseFmtBtn;
74 : :
75 : : const SfxItemSet* pSet;
76 : : SfxItemSet* pOutSet;
77 : : TabDlg_Impl* pImpl;
78 : : sal_uInt16* pRanges;
79 : : sal_uInt32 nResId;
80 : : sal_uInt16 nAppPageId;
81 : : sal_Bool bItemsReset;
82 : : sal_Bool bFmt;
83 : :
84 : : DECL_DLLPRIVATE_LINK( ActivatePageHdl, TabControl * );
85 : : DECL_DLLPRIVATE_LINK( DeactivatePageHdl, TabControl * );
86 : : DECL_DLLPRIVATE_LINK(OkHdl, void *);
87 : : DECL_DLLPRIVATE_LINK(ResetHdl, void *);
88 : : DECL_DLLPRIVATE_LINK(BaseFmtHdl, void *);
89 : : DECL_DLLPRIVATE_LINK(UserHdl, void *);
90 : : DECL_DLLPRIVATE_LINK(CancelHdl, void *);
91 : : SAL_DLLPRIVATE void Init_Impl(sal_Bool, const String *);
92 : :
93 : : protected:
94 : : virtual short Ok();
95 : : // Is deleted in Sfx!
96 : : virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId );
97 : : // Is not deleted in Sfx!
98 : : virtual const SfxItemSet* GetRefreshedSet();
99 : : virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
100 : : virtual long Notify( NotifyEvent& rNEvt );
101 : :
102 : : SfxItemSet* pExampleSet;
103 : : SfxItemSet* GetInputSetImpl();
104 : : SfxTabPage* GetTabPage( sal_uInt16 nPageId ) const;
105 : :
106 : : /** prepare to leace the current page. Calls the DeactivatePage method of the current page, (if necessary),
107 : : handles the item sets to copy.
108 : : @return sal_True if it is allowed to leave the current page, sal_False otherwise
109 : : */
110 : : bool PrepareLeaveCurrentPage();
111 : :
112 : : /** save the position of the TabDialog and which tab page is the currently active one
113 : : */
114 : : void SavePosAndId();
115 : :
116 : : public:
117 : : SfxTabDialog( Window* pParent, const ResId &rResId, const SfxItemSet * = 0,
118 : : sal_Bool bEditFmt = sal_False, const String *pUserButtonText = 0 );
119 : : SfxTabDialog( SfxViewFrame *pViewFrame, Window* pParent, const ResId &rResId,
120 : : const SfxItemSet * = 0, sal_Bool bEditFmt = sal_False,
121 : : const String *pUserButtonText = 0 );
122 : : ~SfxTabDialog();
123 : :
124 : : void AddTabPage( sal_uInt16 nId,
125 : : CreateTabPage pCreateFunc, // != 0
126 : : GetTabPageRanges pRangesFunc, // can be 0
127 : : sal_Bool bItemsOnDemand = sal_False);
128 : : void AddTabPage( sal_uInt16 nId,
129 : : const String &rRiderText,
130 : : CreateTabPage pCreateFunc, // != 0
131 : : GetTabPageRanges pRangesFunc, // can be 0
132 : : sal_Bool bItemsOnDemand = sal_False,
133 : : sal_uInt16 nPos = TAB_APPEND);
134 : : void AddTabPage( sal_uInt16 nId,
135 : : const Bitmap &rRiderBitmap,
136 : : CreateTabPage pCreateFunc, // != 0
137 : : GetTabPageRanges pRangesFunc, // can be 0
138 : : sal_Bool bItemsOnDemand = sal_False,
139 : : sal_uInt16 nPos = TAB_APPEND);
140 : :
141 : : void AddTabPage( sal_uInt16 nId,
142 : : sal_Bool bItemsOnDemand = sal_False);
143 : : void AddTabPage( sal_uInt16 nId,
144 : : const String &rRiderText,
145 : : sal_Bool bItemsOnDemand = sal_False,
146 : : sal_uInt16 nPos = TAB_APPEND);
147 : : void AddTabPage( sal_uInt16 nId,
148 : : const Bitmap &rRiderBitmap,
149 : : sal_Bool bItemsOnDemand = sal_False,
150 : : sal_uInt16 nPos = TAB_APPEND);
151 : :
152 : : void RemoveTabPage( sal_uInt16 nId );
153 : :
154 : 0 : void SetCurPageId( sal_uInt16 nId ) { nAppPageId = nId; }
155 : 0 : sal_uInt16 GetCurPageId() const
156 : 0 : { return aTabCtrl.GetCurPageId(); }
157 : : void ShowPage( sal_uInt16 nId );
158 : :
159 : : // may provide local slots converted by Map
160 : : const sal_uInt16* GetInputRanges( const SfxItemPool& );
161 : : void SetInputSet( const SfxItemSet* pInSet );
162 : 0 : const SfxItemSet* GetOutputItemSet() const { return pOutSet; }
163 : : sal_Bool IsFormat() const { return bFmt; }
164 : :
165 : : const OKButton& GetOKButton() const { return aOKBtn; }
166 : 0 : OKButton& GetOKButton() { return aOKBtn; }
167 : : const CancelButton& GetCancelButton() const { return aCancelBtn; }
168 : 0 : CancelButton& GetCancelButton() { return aCancelBtn; }
169 : : const HelpButton& GetHelpButton() const { return aHelpBtn; }
170 : : HelpButton& GetHelpButton() { return aHelpBtn; }
171 : :
172 : : const PushButton* GetUserButton() const { return pUserBtn; }
173 : 0 : PushButton* GetUserButton() { return pUserBtn; }
174 : : void RemoveResetButton();
175 : :
176 : : short Execute();
177 : : void StartExecuteModal( const Link& rEndDialogHdl );
178 : : void Start( sal_Bool bShow = sal_True );
179 : :
180 : 0 : const SfxItemSet* GetExampleSet() const { return pExampleSet; }
181 : : SfxViewFrame* GetViewFrame() const { return pFrame; }
182 : :
183 : : void EnableApplyButton(sal_Bool bEnable = sal_True);
184 : : sal_Bool IsApplyButtonEnabled() const;
185 : : void SetApplyHandler(const Link& _rHdl);
186 : :
187 : : SAL_DLLPRIVATE void Start_Impl();
188 : 0 : SAL_DLLPRIVATE sal_Bool OK_Impl() { return PrepareLeaveCurrentPage(); }
189 : : };
190 : :
191 : : namespace sfx { class ItemConnectionBase; }
192 : :
193 : : class SFX2_DLLPUBLIC SfxTabPage: public TabPage
194 : : {
195 : : friend class SfxTabDialog;
196 : :
197 : : private:
198 : : const SfxItemSet* pSet;
199 : : String aUserString;
200 : : sal_Bool bHasExchangeSupport;
201 : : SfxTabDialog* pTabDlg;
202 : : TabPageImpl* pImpl;
203 : :
204 : : SAL_DLLPRIVATE void SetTabDialog( SfxTabDialog* pNew ) { pTabDlg = pNew; }
205 : : SAL_DLLPRIVATE void SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
206 : :
207 : : protected:
208 : : SfxTabPage( Window *pParent, const ResId &, const SfxItemSet &rAttrSet );
209 : : SfxTabPage( Window *pParent, WinBits nStyle, const SfxItemSet &rAttrSet );
210 : :
211 : : sal_uInt16 GetSlot( sal_uInt16 nWhich ) const
212 : : { return pSet->GetPool()->GetSlotId( nWhich ); }
213 : 0 : sal_uInt16 GetWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const
214 : 0 : { return pSet->GetPool()->GetWhich( nSlot, bDeep ); }
215 : : const SfxPoolItem* GetOldItem( const SfxItemSet& rSet, sal_uInt16 nSlot, sal_Bool bDeep = sal_True );
216 : 0 : SfxTabDialog* GetTabDialog() const { return pTabDlg; }
217 : :
218 : : void AddItemConnection( sfx::ItemConnectionBase* pConnection );
219 : :
220 : : public:
221 : : virtual ~SfxTabPage();
222 : :
223 : 0 : const SfxItemSet& GetItemSet() const { return *pSet; }
224 : :
225 : : virtual sal_Bool FillItemSet( SfxItemSet& );
226 : : virtual void Reset( const SfxItemSet& );
227 : :
228 : 0 : sal_Bool HasExchangeSupport() const
229 : 0 : { return bHasExchangeSupport; }
230 : 0 : void SetExchangeSupport( sal_Bool bNew = sal_True )
231 : 0 : { bHasExchangeSupport = bNew; }
232 : :
233 : : enum sfxpg {
234 : : KEEP_PAGE = 0x0000, // Error handling; page does not change
235 : : // 2. Fill an itemset for update
236 : : // parent examples, this pointer can be NULL all the time!
237 : : LEAVE_PAGE = 0x0001,
238 : : // Set, refresh and update other Page
239 : : REFRESH_SET = 0x0002
240 : : };
241 : :
242 : : using TabPage::ActivatePage;
243 : : using TabPage::DeactivatePage;
244 : : virtual void ActivatePage( const SfxItemSet& );
245 : : virtual int DeactivatePage( SfxItemSet* pSet = 0 );
246 : 0 : void SetUserData(const String& rString)
247 : 0 : { aUserString = rString; }
248 : 0 : String GetUserData() { return aUserString; }
249 : : virtual void FillUserData();
250 : : virtual sal_Bool IsReadOnly() const;
251 : : virtual void PageCreated (SfxAllItemSet aSet);
252 : : static const SfxPoolItem* GetItem( const SfxItemSet& rSet, sal_uInt16 nSlot, sal_Bool bDeep = sal_True );
253 : :
254 : : void SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
255 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame();
256 : : };
257 : :
258 : : #endif
259 : :
260 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|