update emoji autocorrect entries from po-files
[LibreOffice.git] / include / sfx2 / tabdlg.hxx
bloba8f5526a77095bb145ceb7a7abbbe4c11eeceb51
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 VclPtr<SfxTabPage> (*CreateTabPage)(vcl::Window *pParent, const SfxItemSet *rAttrSet);
41 typedef const sal_uInt16* (*GetTabPageRanges)(); // provides international Which-value
42 struct TabPageImpl;
44 struct TabDlg_Impl;
46 #define RET_USER 100
47 #define RET_USER_CANCEL 101
49 class SFX2_DLLPUBLIC SfxTabDialogItem: public SfxSetItem
51 public:
52 TYPEINFO_OVERRIDE();
53 SfxTabDialogItem( sal_uInt16 nId, const SfxItemSet& rItemSet );
54 SfxTabDialogItem(const SfxTabDialogItem& rAttr, SfxItemPool* pItemPool=NULL);
55 virtual SfxPoolItem* Clone(SfxItemPool* pToPool) const SAL_OVERRIDE;
56 virtual SfxPoolItem* Create(SvStream& rStream, sal_uInt16 nVersion) const SAL_OVERRIDE;
59 class SFX2_DLLPUBLIC SfxTabDialog : public TabDialog
61 private:
62 friend class SfxTabPage;
63 friend class SfxTabDialogController;
65 SfxViewFrame* pFrame;
67 VclPtr<VclBox> m_pBox;
68 VclPtr<TabControl> m_pTabCtrl;
70 VclPtr<PushButton> m_pOKBtn;
71 VclPtr<PushButton> m_pApplyBtn;
72 VclPtr<PushButton> m_pUserBtn;
73 VclPtr<CancelButton> m_pCancelBtn;
74 VclPtr<HelpButton> m_pHelpBtn;
75 VclPtr<PushButton> m_pResetBtn;
76 VclPtr<PushButton> m_pBaseFmtBtn;
78 bool m_bOwnsOKBtn;
79 bool m_bOwnsCancelBtn;
80 bool m_bOwnsHelpBtn;
81 bool m_bOwnsResetBtn;
82 bool m_bOwnsBaseFmtBtn;
84 SfxItemSet* pSet;
85 SfxItemSet* pOutSet;
86 TabDlg_Impl* pImpl;
87 sal_uInt16* pRanges;
88 sal_uInt16 nAppPageId;
89 bool bItemsReset;
90 bool bStandardPushed;
92 DECL_DLLPRIVATE_LINK( ActivatePageHdl, TabControl * );
93 DECL_DLLPRIVATE_LINK_TYPED( DeactivatePageHdl, TabControl *, bool );
94 DECL_DLLPRIVATE_LINK(OkHdl, void *);
95 DECL_DLLPRIVATE_LINK(ResetHdl, void *);
96 DECL_DLLPRIVATE_LINK(BaseFmtHdl, void *);
97 DECL_DLLPRIVATE_LINK(UserHdl, void *);
98 DECL_DLLPRIVATE_LINK(CancelHdl, void *);
99 SAL_DLLPRIVATE void Init_Impl(bool bFmtFlag);
101 protected:
102 virtual short Ok();
103 // Is deleted in Sfx!
104 virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId );
105 // Is not deleted in Sfx!
106 virtual void RefreshInputSet();
107 virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
109 VclPtr<VclButtonBox> m_pActionArea;
110 SfxItemSet* pExampleSet;
111 SfxItemSet* GetInputSetImpl();
112 SfxTabPage* GetTabPage( sal_uInt16 nPageId ) const;
114 /** prepare to leace the current page. Calls the DeactivatePage method of the current page, (if necessary),
115 handles the item sets to copy.
116 @return sal_True if it is allowed to leave the current page, sal_False otherwise
118 bool PrepareLeaveCurrentPage();
120 /** save the position of the TabDialog and which tab page is the currently active one
122 void SavePosAndId();
124 public:
125 SfxTabDialog(vcl::Window* pParent,
126 const OUString& rID, const OUString& rUIXMLDescription,
127 const SfxItemSet * = 0, bool bEditFmt = false);
128 SfxTabDialog(SfxViewFrame *pViewFrame, vcl::Window* pParent,
129 const OUString& rID, const OUString& rUIXMLDescription,
130 const SfxItemSet * = 0, bool bEditFmt = false);
131 virtual ~SfxTabDialog();
132 virtual void dispose() SAL_OVERRIDE;
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);
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
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);
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);
164 void RemoveTabPage( const OString& rName ); // Name of the label for the page in the notebook .ui
165 void RemoveTabPage( sal_uInt16 nId );
167 void SetCurPageId(sal_uInt16 nId)
169 nAppPageId = nId;
171 void SetCurPageId(const OString& rName)
173 nAppPageId = m_pTabCtrl->GetPageId(rName);
175 sal_uInt16 GetCurPageId() const
177 return m_pTabCtrl->GetCurPageId();
180 SfxTabPage* GetCurTabPage() const
182 return GetTabPage(m_pTabCtrl->GetCurPageId());
185 OUString GetPageText( sal_uInt16 nPageId ) const
187 return m_pTabCtrl->GetPageText(nPageId);
190 void ShowPage( sal_uInt16 nId );
192 // may provide local slots converted by Map
193 const sal_uInt16* GetInputRanges( const SfxItemPool& );
194 void SetInputSet( const SfxItemSet* pInSet );
195 const SfxItemSet* GetOutputItemSet() const { return pOutSet; }
197 const PushButton& GetOKButton() const { return *m_pOKBtn; }
198 PushButton& GetOKButton() { return *m_pOKBtn; }
199 const CancelButton& GetCancelButton() const { return *m_pCancelBtn; }
200 CancelButton& GetCancelButton() { return *m_pCancelBtn; }
201 const HelpButton& GetHelpButton() const { return *m_pHelpBtn; }
202 HelpButton& GetHelpButton() { return *m_pHelpBtn; }
204 const PushButton* GetUserButton() const { return m_pUserBtn; }
205 PushButton* GetUserButton() { return m_pUserBtn; }
206 void RemoveResetButton();
207 void RemoveStandardButton();
209 short Execute() SAL_OVERRIDE;
210 void StartExecuteModal( const Link<>& rEndDialogHdl ) SAL_OVERRIDE;
211 void Start( bool bShow = true );
213 const SfxItemSet* GetExampleSet() const { return pExampleSet; }
214 SfxItemSet* GetExampleSet() { return pExampleSet; }
215 SfxViewFrame* GetViewFrame() const { return pFrame; }
217 void SetApplyHandler(const Link<>& _rHdl);
219 SAL_DLLPRIVATE void Start_Impl();
221 //calls Ok without closing dialog
222 bool Apply();
225 namespace sfx { class ItemConnectionBase; }
227 class SFX2_DLLPUBLIC SfxTabPage: public TabPage
229 friend class SfxTabDialog;
231 private:
232 const SfxItemSet* pSet;
233 OUString aUserString;
234 bool bHasExchangeSupport;
235 TabPageImpl* pImpl;
237 SAL_DLLPRIVATE void SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
239 protected:
240 SfxTabPage(vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet *rAttrSet);
242 sal_uInt16 GetSlot( sal_uInt16 nWhich ) const
243 { return pSet->GetPool()->GetSlotId( nWhich ); }
244 sal_uInt16 GetWhich( sal_uInt16 nSlot, bool bDeep = true ) const
245 { return pSet->GetPool()->GetWhich( nSlot, bDeep ); }
246 const SfxPoolItem* GetOldItem( const SfxItemSet& rSet, sal_uInt16 nSlot, bool bDeep = true );
247 SfxTabDialog* GetTabDialog() const;
249 void AddItemConnection( sfx::ItemConnectionBase* pConnection );
251 public:
252 virtual ~SfxTabPage();
253 virtual void dispose() SAL_OVERRIDE;
255 const SfxItemSet& GetItemSet() const { return *pSet; }
257 virtual bool FillItemSet( SfxItemSet* );
258 virtual void Reset( const SfxItemSet* );
260 bool HasExchangeSupport() const
261 { return bHasExchangeSupport; }
262 void SetExchangeSupport( bool bNew = true )
263 { bHasExchangeSupport = bNew; }
265 enum sfxpg {
266 KEEP_PAGE = 0x0000, // Error handling; page does not change
267 // 2. Fill an itemset for update
268 // parent examples, this pointer can be NULL all the time!
269 LEAVE_PAGE = 0x0001,
270 // Set, refresh and update other Page
271 REFRESH_SET = 0x0002
274 using TabPage::ActivatePage;
275 using TabPage::DeactivatePage;
276 virtual void ActivatePage( const SfxItemSet& );
277 virtual sfxpg DeactivatePage( SfxItemSet* pSet = 0 );
278 void SetUserData(const OUString& rString)
279 { aUserString = rString; }
280 OUString GetUserData() { return aUserString; }
281 virtual void FillUserData();
282 virtual bool IsReadOnly() const;
283 virtual void PageCreated (const SfxAllItemSet& aSet);
284 static const SfxPoolItem* GetItem( const SfxItemSet& rSet, sal_uInt16 nSlot, bool bDeep = true );
286 void SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
287 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame();
290 #endif
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */