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