1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 _SFXTABDLG_HXX
20 #define _SFXTABDLG_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>
40 typedef SfxTabPage
* (*CreateTabPage
)(Window
*pParent
, const SfxItemSet
&rAttrSet
);
41 typedef sal_uInt16
* (*GetTabPageRanges
)(); // provides international Which-value
46 #define ID_TABCONTROL 1
48 #define RET_USER_CANCEL 101
50 class SFX2_DLLPUBLIC SfxTabDialogItem
: public SfxSetItem
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
63 friend class SfxTabPage
;
64 friend class SfxTabDialogController
;
69 TabControl
*m_pTabCtrl
;
72 PushButton
* m_pApplyBtn
;
73 PushButton
* m_pUserBtn
;
74 CancelButton
* m_pCancelBtn
;
75 HelpButton
* m_pHelpBtn
;
76 PushButton
* m_pResetBtn
;
77 PushButton
* m_pBaseFmtBtn
;
81 bool m_bOwnsActionArea
;
85 bool m_bOwnsCancelBtn
;
88 bool m_bOwnsBaseFmtBtn
;
90 const SfxItemSet
* pSet
;
95 sal_uInt16 nAppPageId
;
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
);
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
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 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 );
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
);
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
155 void AddTabPage( sal_uInt16 nId
,
156 CreateTabPage pCreateFunc
, // != 0
157 GetTabPageRanges pRangesFunc
, // can be 0
158 sal_Bool bItemsOnDemand
= sal_False
);
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
);
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
);
185 void RemoveTabPage( const OString
& rName
); // Name of the label for the page in the notebook .ui
186 void RemoveTabPage( sal_uInt16 nId
);
188 void SetCurPageId(sal_uInt16 nId
)
192 void SetCurPageId(const OString
& rName
)
194 nAppPageId
= m_pTabCtrl
->GetPageId(rName
);
196 sal_uInt16
GetCurPageId() const
198 return m_pTabCtrl
->GetCurPageId();
200 void ShowPage( sal_uInt16 nId
);
202 // may provide local slots converted by Map
203 const sal_uInt16
* GetInputRanges( const SfxItemPool
& );
204 void SetInputSet( const SfxItemSet
* pInSet
);
205 const SfxItemSet
* GetOutputItemSet() const { return pOutSet
; }
206 sal_Bool
IsFormat() const { return bFmt
; }
208 const OKButton
& GetOKButton() const { return *m_pOKBtn
; }
209 OKButton
& GetOKButton() { return *m_pOKBtn
; }
210 const CancelButton
& GetCancelButton() const { return *m_pCancelBtn
; }
211 CancelButton
& GetCancelButton() { return *m_pCancelBtn
; }
212 const HelpButton
& GetHelpButton() const { return *m_pHelpBtn
; }
213 HelpButton
& GetHelpButton() { return *m_pHelpBtn
; }
215 const PushButton
* GetUserButton() const { return m_pUserBtn
; }
216 PushButton
* GetUserButton() { return m_pUserBtn
; }
217 void RemoveResetButton();
220 void StartExecuteModal( const Link
& rEndDialogHdl
);
221 void Start( sal_Bool bShow
= sal_True
);
223 const SfxItemSet
* GetExampleSet() const { return pExampleSet
; }
224 SfxViewFrame
* GetViewFrame() const { return pFrame
; }
226 void EnableApplyButton(sal_Bool bEnable
= sal_True
);
227 sal_Bool
IsApplyButtonEnabled() const;
228 void SetApplyHandler(const Link
& _rHdl
);
230 SAL_DLLPRIVATE
void Start_Impl();
232 //calls Ok without closing dialog
236 namespace sfx
{ class ItemConnectionBase
; }
238 class SFX2_DLLPUBLIC SfxTabPage
: public TabPage
240 friend class SfxTabDialog
;
243 const SfxItemSet
* pSet
;
245 sal_Bool bHasExchangeSupport
;
246 SfxTabDialog
* pTabDlg
;
249 SAL_DLLPRIVATE
void SetTabDialog( SfxTabDialog
* pNew
) { pTabDlg
= pNew
; }
250 SAL_DLLPRIVATE
void SetInputSet( const SfxItemSet
* pNew
) { pSet
= pNew
; }
253 SfxTabPage( Window
*pParent
, const ResId
&, const SfxItemSet
&rAttrSet
);
254 SfxTabPage(Window
*pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
, const SfxItemSet
&rAttrSet
);
256 sal_uInt16
GetSlot( sal_uInt16 nWhich
) const
257 { return pSet
->GetPool()->GetSlotId( nWhich
); }
258 sal_uInt16
GetWhich( sal_uInt16 nSlot
, sal_Bool bDeep
= sal_True
) const
259 { return pSet
->GetPool()->GetWhich( nSlot
, bDeep
); }
260 const SfxPoolItem
* GetOldItem( const SfxItemSet
& rSet
, sal_uInt16 nSlot
, sal_Bool bDeep
= sal_True
);
261 SfxTabDialog
* GetTabDialog() const { return pTabDlg
; }
263 void AddItemConnection( sfx::ItemConnectionBase
* pConnection
);
266 virtual ~SfxTabPage();
268 const SfxItemSet
& GetItemSet() const { return *pSet
; }
270 virtual sal_Bool
FillItemSet( SfxItemSet
& );
271 virtual void Reset( const SfxItemSet
& );
273 sal_Bool
HasExchangeSupport() const
274 { return bHasExchangeSupport
; }
275 void SetExchangeSupport( sal_Bool bNew
= sal_True
)
276 { bHasExchangeSupport
= bNew
; }
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!
283 // Set, refresh and update other Page
287 using TabPage::ActivatePage
;
288 using TabPage::DeactivatePage
;
289 virtual void ActivatePage( const SfxItemSet
& );
290 virtual int DeactivatePage( SfxItemSet
* pSet
= 0 );
291 void SetUserData(const String
& rString
)
292 { aUserString
= rString
; }
293 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
);
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();
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */