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