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 : OKButton *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 : virtual long Notify( NotifyEvent& rNEvt );
116 :
117 : VclButtonBox* m_pActionArea;
118 : SfxItemSet* pExampleSet;
119 : SfxItemSet* GetInputSetImpl();
120 : SfxTabPage* GetTabPage( sal_uInt16 nPageId ) const;
121 :
122 : /** prepare to leace the current page. Calls the DeactivatePage method of the current page, (if necessary),
123 : handles the item sets to copy.
124 : @return sal_True if it is allowed to leave the current page, sal_False otherwise
125 : */
126 : bool PrepareLeaveCurrentPage();
127 :
128 : /** save the position of the TabDialog and which tab page is the currently active one
129 : */
130 : void SavePosAndId();
131 :
132 : public:
133 : SfxTabDialog( Window* pParent, const ResId &rResId, const SfxItemSet * = 0,
134 : sal_Bool bEditFmt = sal_False, const String *pUserButtonText = 0 );
135 : SfxTabDialog( SfxViewFrame *pViewFrame, Window* pParent, const ResId &rResId,
136 : const SfxItemSet * = 0, sal_Bool bEditFmt = sal_False,
137 : const String *pUserButtonText = 0 );
138 : SfxTabDialog( SfxViewFrame *pViewFrame, Window* pParent,
139 : const rtl::OString& rID, const rtl::OUString& rUIXMLDescription,
140 : const SfxItemSet * = 0, sal_Bool bEditFmt = sal_False,
141 : const String *pUserButtonText = 0 );
142 : ~SfxTabDialog();
143 :
144 : void AddTabPage( sal_uInt16 nId,
145 : CreateTabPage pCreateFunc, // != 0
146 : GetTabPageRanges pRangesFunc, // can be 0
147 : sal_Bool bItemsOnDemand = sal_False);
148 : sal_uInt16 AddTabPage( const OString& rName,
149 : CreateTabPage pCreateFunc, // != 0
150 : GetTabPageRanges pRangesFunc, // can be 0
151 : sal_Bool bItemsOnDemand = sal_False);
152 :
153 :
154 : void AddTabPage( sal_uInt16 nId,
155 : const String &rRiderText,
156 : CreateTabPage pCreateFunc, // != 0
157 : GetTabPageRanges pRangesFunc, // can be 0
158 : sal_Bool bItemsOnDemand = sal_False,
159 : sal_uInt16 nPos = TAB_APPEND);
160 : void AddTabPage( sal_uInt16 nId,
161 : const Bitmap &rRiderBitmap,
162 : CreateTabPage pCreateFunc, // != 0
163 : GetTabPageRanges pRangesFunc, // can be 0
164 : sal_Bool bItemsOnDemand = sal_False,
165 : sal_uInt16 nPos = TAB_APPEND);
166 :
167 : void AddTabPage( sal_uInt16 nId,
168 : sal_Bool bItemsOnDemand = sal_False);
169 : void AddTabPage( sal_uInt16 nId,
170 : const String &rRiderText,
171 : sal_Bool bItemsOnDemand = sal_False,
172 : sal_uInt16 nPos = TAB_APPEND);
173 : void AddTabPage( sal_uInt16 nId,
174 : const Bitmap &rRiderBitmap,
175 : sal_Bool bItemsOnDemand = sal_False,
176 : sal_uInt16 nPos = TAB_APPEND);
177 :
178 : void RemoveTabPage( sal_uInt16 nId );
179 :
180 0 : void SetCurPageId( sal_uInt16 nId ) { nAppPageId = nId; }
181 0 : sal_uInt16 GetCurPageId() const
182 0 : { return m_pTabCtrl->GetCurPageId(); }
183 : void ShowPage( sal_uInt16 nId );
184 :
185 : // may provide local slots converted by Map
186 : const sal_uInt16* GetInputRanges( const SfxItemPool& );
187 : void SetInputSet( const SfxItemSet* pInSet );
188 0 : const SfxItemSet* GetOutputItemSet() const { return pOutSet; }
189 : sal_Bool IsFormat() const { return bFmt; }
190 :
191 : const OKButton& GetOKButton() const { return *m_pOKBtn; }
192 0 : OKButton& GetOKButton() { return *m_pOKBtn; }
193 : const CancelButton& GetCancelButton() const { return *m_pCancelBtn; }
194 0 : CancelButton& GetCancelButton() { return *m_pCancelBtn; }
195 : const HelpButton& GetHelpButton() const { return *m_pHelpBtn; }
196 : HelpButton& GetHelpButton() { return *m_pHelpBtn; }
197 :
198 : const PushButton* GetUserButton() const { return m_pUserBtn; }
199 0 : PushButton* GetUserButton() { return m_pUserBtn; }
200 : void RemoveResetButton();
201 :
202 : short Execute();
203 : void StartExecuteModal( const Link& rEndDialogHdl );
204 : void Start( sal_Bool bShow = sal_True );
205 :
206 0 : const SfxItemSet* GetExampleSet() const { return pExampleSet; }
207 : SfxViewFrame* GetViewFrame() const { return pFrame; }
208 :
209 : void EnableApplyButton(sal_Bool bEnable = sal_True);
210 : sal_Bool IsApplyButtonEnabled() const;
211 : void SetApplyHandler(const Link& _rHdl);
212 :
213 : SAL_DLLPRIVATE void Start_Impl();
214 0 : bool OK_Impl()
215 : {
216 0 : bool bRet = PrepareLeaveCurrentPage();
217 0 : if (bRet)
218 0 : Ok();
219 0 : return bRet;
220 : }
221 : };
222 :
223 : namespace sfx { class ItemConnectionBase; }
224 :
225 : class SFX2_DLLPUBLIC SfxTabPage: public TabPage
226 : {
227 : friend class SfxTabDialog;
228 :
229 : private:
230 : const SfxItemSet* pSet;
231 : String aUserString;
232 : sal_Bool bHasExchangeSupport;
233 : SfxTabDialog* pTabDlg;
234 : TabPageImpl* pImpl;
235 :
236 : SAL_DLLPRIVATE void SetTabDialog( SfxTabDialog* pNew ) { pTabDlg = pNew; }
237 : SAL_DLLPRIVATE void SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
238 :
239 : protected:
240 : SfxTabPage( Window *pParent, const ResId &, const SfxItemSet &rAttrSet );
241 : SfxTabPage(Window *pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription, const SfxItemSet &rAttrSet);
242 : SfxTabPage( Window *pParent, WinBits nStyle, const SfxItemSet &rAttrSet );
243 :
244 : sal_uInt16 GetSlot( sal_uInt16 nWhich ) const
245 : { return pSet->GetPool()->GetSlotId( nWhich ); }
246 0 : sal_uInt16 GetWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const
247 0 : { return pSet->GetPool()->GetWhich( nSlot, bDeep ); }
248 : const SfxPoolItem* GetOldItem( const SfxItemSet& rSet, sal_uInt16 nSlot, sal_Bool bDeep = sal_True );
249 0 : SfxTabDialog* GetTabDialog() const { return pTabDlg; }
250 :
251 : void AddItemConnection( sfx::ItemConnectionBase* pConnection );
252 :
253 : public:
254 : virtual ~SfxTabPage();
255 :
256 0 : const SfxItemSet& GetItemSet() const { return *pSet; }
257 :
258 : virtual sal_Bool FillItemSet( SfxItemSet& );
259 : virtual void Reset( const SfxItemSet& );
260 :
261 0 : sal_Bool HasExchangeSupport() const
262 0 : { return bHasExchangeSupport; }
263 0 : void SetExchangeSupport( sal_Bool bNew = sal_True )
264 0 : { bHasExchangeSupport = bNew; }
265 :
266 : enum sfxpg {
267 : KEEP_PAGE = 0x0000, // Error handling; page does not change
268 : // 2. Fill an itemset for update
269 : // parent examples, this pointer can be NULL all the time!
270 : LEAVE_PAGE = 0x0001,
271 : // Set, refresh and update other Page
272 : REFRESH_SET = 0x0002
273 : };
274 :
275 : using TabPage::ActivatePage;
276 : using TabPage::DeactivatePage;
277 : virtual void ActivatePage( const SfxItemSet& );
278 : virtual int DeactivatePage( SfxItemSet* pSet = 0 );
279 0 : void SetUserData(const String& rString)
280 0 : { aUserString = rString; }
281 0 : String GetUserData() { return aUserString; }
282 : virtual void FillUserData();
283 : virtual sal_Bool IsReadOnly() const;
284 : virtual void PageCreated (SfxAllItemSet aSet);
285 : static const SfxPoolItem* GetItem( const SfxItemSet& rSet, sal_uInt16 nSlot, sal_Bool bDeep = sal_True );
286 :
287 : void SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
288 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame();
289 : };
290 :
291 : #endif
292 :
293 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|