bump product version to 4.2.0.1
[LibreOffice.git] / include / sfx2 / tabdlg.hxx
blob99b04f8c35bdc3f85e55d03c90176802620462f4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_TABDLG_HXX
20 #define INCLUDED_SFX2_TABDLG_HXX
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>
34 class SfxPoolItem;
35 class SfxTabDialog;
36 class SfxViewFrame;
37 class SfxTabPage;
38 class SfxBindings;
40 typedef SfxTabPage* (*CreateTabPage)(Window *pParent, const SfxItemSet &rAttrSet);
41 typedef sal_uInt16* (*GetTabPageRanges)(); // provides international Which-value
42 struct TabPageImpl;
44 struct TabDlg_Impl;
46 #define ID_TABCONTROL 1
47 #define RET_USER 100
48 #define RET_USER_CANCEL 101
50 class SFX2_DLLPUBLIC SfxTabDialogItem: public SfxSetItem
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;
60 class SFX2_DLLPUBLIC SfxTabDialog : public TabDialog
62 private:
63 friend class SfxTabPage;
64 friend class SfxTabDialogController;
66 SfxViewFrame* pFrame;
68 VclBox *m_pBox;
69 TabControl *m_pTabCtrl;
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;
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;
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;
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 OUString* pUserButtonText, const ResId* pResId );
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 );
116 VclButtonBox* m_pActionArea;
117 SfxItemSet* pExampleSet;
118 SfxItemSet* GetInputSetImpl();
119 SfxTabPage* GetTabPage( sal_uInt16 nPageId ) const;
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
125 bool PrepareLeaveCurrentPage();
127 /** save the position of the TabDialog and which tab page is the currently active one
129 void SavePosAndId();
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 );
140 SfxTabDialog( Window* pParent, const ResId &rResId, const SfxItemSet * = 0,
141 sal_Bool bEditFmt = sal_False, const OUString *pUserButtonText = 0 );
142 ~SfxTabDialog();
144 sal_uInt16 AddTabPage( const OString& rName, // Name of the label for the page in the notebook .ui
145 CreateTabPage pCreateFunc, // != 0
146 GetTabPageRanges pRangesFunc, // can be 0
147 sal_Bool bItemsOnDemand = sal_False);
149 sal_uInt16 AddTabPage ( const OString &rName, // Name of the label for the page in the notebook .ui
150 sal_uInt16 nPageCreateId ); // Identifier of the Factory Method to create the page
152 void AddTabPage( sal_uInt16 nId,
153 CreateTabPage pCreateFunc, // != 0
154 GetTabPageRanges pRangesFunc, // can be 0
155 sal_Bool bItemsOnDemand = sal_False);
158 void AddTabPage( sal_uInt16 nId,
159 const OUString &rRiderText,
160 CreateTabPage pCreateFunc, // != 0
161 GetTabPageRanges pRangesFunc, // can be 0
162 sal_Bool bItemsOnDemand = sal_False,
163 sal_uInt16 nPos = TAB_APPEND);
164 void AddTabPage( sal_uInt16 nId,
165 const Bitmap &rRiderBitmap,
166 CreateTabPage pCreateFunc, // != 0
167 GetTabPageRanges pRangesFunc, // can be 0
168 sal_Bool bItemsOnDemand = sal_False,
169 sal_uInt16 nPos = TAB_APPEND);
171 void AddTabPage( sal_uInt16 nId,
172 sal_Bool bItemsOnDemand = sal_False);
173 void AddTabPage( sal_uInt16 nId,
174 const OUString &rRiderText,
175 sal_Bool bItemsOnDemand = sal_False,
176 sal_uInt16 nPos = TAB_APPEND);
177 void AddTabPage( sal_uInt16 nId,
178 const Bitmap &rRiderBitmap,
179 sal_Bool bItemsOnDemand = sal_False,
180 sal_uInt16 nPos = TAB_APPEND);
182 void RemoveTabPage( const OString& rName ); // Name of the label for the page in the notebook .ui
183 void RemoveTabPage( sal_uInt16 nId );
185 void SetCurPageId(sal_uInt16 nId)
187 nAppPageId = nId;
189 void SetCurPageId(const OString& rName)
191 nAppPageId = m_pTabCtrl->GetPageId(rName);
193 sal_uInt16 GetCurPageId() const
195 return m_pTabCtrl->GetCurPageId();
198 SfxTabPage* GetCurTabPage() const
200 return GetTabPage(m_pTabCtrl->GetCurPageId());
203 OUString GetPageText( sal_uInt16 nPageId ) const
205 return m_pTabCtrl->GetPageText(nPageId);
208 void ShowPage( sal_uInt16 nId );
210 // may provide local slots converted by Map
211 const sal_uInt16* GetInputRanges( const SfxItemPool& );
212 void SetInputSet( const SfxItemSet* pInSet );
213 const SfxItemSet* GetOutputItemSet() const { return pOutSet; }
214 sal_Bool IsFormat() const { return bFmt; }
216 const PushButton& GetOKButton() const { return *m_pOKBtn; }
217 PushButton& GetOKButton() { return *m_pOKBtn; }
218 const CancelButton& GetCancelButton() const { return *m_pCancelBtn; }
219 CancelButton& GetCancelButton() { return *m_pCancelBtn; }
220 const HelpButton& GetHelpButton() const { return *m_pHelpBtn; }
221 HelpButton& GetHelpButton() { return *m_pHelpBtn; }
223 const PushButton* GetUserButton() const { return m_pUserBtn; }
224 PushButton* GetUserButton() { return m_pUserBtn; }
225 void RemoveResetButton();
227 short Execute();
228 void StartExecuteModal( const Link& rEndDialogHdl );
229 void Start( sal_Bool bShow = sal_True );
231 const SfxItemSet* GetExampleSet() const { return pExampleSet; }
232 SfxViewFrame* GetViewFrame() const { return pFrame; }
234 void SetApplyHandler(const Link& _rHdl);
236 SAL_DLLPRIVATE void Start_Impl();
238 //calls Ok without closing dialog
239 bool Apply();
242 namespace sfx { class ItemConnectionBase; }
244 class SFX2_DLLPUBLIC SfxTabPage: public TabPage
246 friend class SfxTabDialog;
248 private:
249 const SfxItemSet* pSet;
250 OUString aUserString;
251 sal_Bool bHasExchangeSupport;
252 TabPageImpl* pImpl;
254 SAL_DLLPRIVATE void SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
256 protected:
257 SfxTabPage( Window *pParent, const ResId &, const SfxItemSet &rAttrSet );
258 SfxTabPage(Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet);
260 sal_uInt16 GetSlot( sal_uInt16 nWhich ) const
261 { return pSet->GetPool()->GetSlotId( nWhich ); }
262 sal_uInt16 GetWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const
263 { return pSet->GetPool()->GetWhich( nSlot, bDeep ); }
264 const SfxPoolItem* GetOldItem( const SfxItemSet& rSet, sal_uInt16 nSlot, sal_Bool bDeep = sal_True );
265 SfxTabDialog* GetTabDialog() const;
267 void AddItemConnection( sfx::ItemConnectionBase* pConnection );
269 public:
270 virtual ~SfxTabPage();
272 const SfxItemSet& GetItemSet() const { return *pSet; }
274 virtual sal_Bool FillItemSet( SfxItemSet& );
275 virtual void Reset( const SfxItemSet& );
277 sal_Bool HasExchangeSupport() const
278 { return bHasExchangeSupport; }
279 void SetExchangeSupport( sal_Bool bNew = sal_True )
280 { bHasExchangeSupport = bNew; }
282 enum sfxpg {
283 KEEP_PAGE = 0x0000, // Error handling; page does not change
284 // 2. Fill an itemset for update
285 // parent examples, this pointer can be NULL all the time!
286 LEAVE_PAGE = 0x0001,
287 // Set, refresh and update other Page
288 REFRESH_SET = 0x0002
291 using TabPage::ActivatePage;
292 using TabPage::DeactivatePage;
293 virtual void ActivatePage( const SfxItemSet& );
294 virtual int DeactivatePage( SfxItemSet* pSet = 0 );
295 void SetUserData(const OUString& rString)
296 { aUserString = rString; }
297 OUString GetUserData() { return aUserString; }
298 virtual void FillUserData();
299 virtual sal_Bool IsReadOnly() const;
300 virtual void PageCreated (SfxAllItemSet aSet);
301 static const SfxPoolItem* GetItem( const SfxItemSet& rSet, sal_uInt16 nSlot, sal_Bool bDeep = sal_True );
303 void SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
304 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame();
307 #endif
309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */