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