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 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>
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 OUString
* 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 OUString
*pUserButtonText
= 0 );
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
)
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();
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
242 namespace sfx
{ class ItemConnectionBase
; }
244 class SFX2_DLLPUBLIC SfxTabPage
: public TabPage
246 friend class SfxTabDialog
;
249 const SfxItemSet
* pSet
;
250 OUString aUserString
;
251 sal_Bool bHasExchangeSupport
;
254 SAL_DLLPRIVATE
void SetInputSet( const SfxItemSet
* pNew
) { pSet
= pNew
; }
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
);
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
; }
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!
287 // Set, refresh and update other Page
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();
309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */