1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _SFXTABDLG_HXX 24 #define _SFXTABDLG_HXX 25 26 #include "sal/config.h" 27 #include "sfx2/dllapi.h" 28 #include "sal/types.h" 29 #include <vcl/tabdlg.hxx> 30 #include <vcl/button.hxx> 31 #include <vcl/tabctrl.hxx> 32 #include <vcl/tabpage.hxx> 33 #include <svl/itempool.hxx> 34 #include <svl/itemset.hxx> 35 #include <com/sun/star/frame/XFrame.hpp> 36 37 #if ENABLE_LAYOUT 38 #include <layout/layout.hxx> 39 namespace layout { class SfxTabDialog; class SfxTabDialogController; } 40 #endif /* ENABLE_LAYOUT */ 41 42 class SfxPoolItem; 43 class SfxTabDialog; 44 class SfxViewFrame; 45 class SfxTabPage; 46 class SfxBindings; 47 48 #ifndef ENABLE_LAYOUT_SFX_TABDIALOG 49 #define ENABLE_LAYOUT_SFX_TABDIALOG 0 50 #define NAMESPACE_LAYOUT_SFX_TABDIALOG 51 #define END_NAMESPACE_LAYOUT_SFX_TABDIALOG 52 #define LAYOUT_NS_SFX_TABDIALOG 53 #endif /* !ENABLE_LAYOUT_SFX_TABDIALOG*/ 54 55 typedef SfxTabPage* (*CreateTabPage)(Window *pParent, const SfxItemSet &rAttrSet); 56 typedef sal_uInt16* (*GetTabPageRanges)(); // liefert internationale Which-Wert 57 struct TabPageImpl; 58 class SfxUs_Impl; 59 60 #if ENABLE_LAYOUT_SFX_TABDIALOG 61 #include <layout/layout-pre.hxx> 62 #undef SfxTabDialog 63 #undef SfxTabPage 64 #endif /* ENABLE_LAYOUT_SFX_TABDIALOG */ 65 66 NAMESPACE_LAYOUT_SFX_TABDIALOG 67 68 struct TabDlg_Impl; 69 70 #define ID_TABCONTROL 1 71 #define RET_USER 100 72 #define RET_USER_CANCEL 101 73 74 class SFX2_DLLPUBLIC SfxTabDialogItem: public SfxSetItem 75 { 76 public: 77 TYPEINFO(); 78 SfxTabDialogItem( sal_uInt16 nId, const SfxItemSet& rItemSet ); 79 SfxTabDialogItem(const SfxTabDialogItem& rAttr, SfxItemPool* pItemPool=NULL); 80 virtual SfxPoolItem* Clone(SfxItemPool* pToPool) const; 81 virtual SfxPoolItem* Create(SvStream& rStream, sal_uInt16 nVersion) const; 82 }; 83 84 class SFX2_DLLPUBLIC SfxTabDialog : public TabDialog 85 { 86 private: 87 friend class SfxTabPage; 88 friend class SfxTabDialogController; 89 90 SfxViewFrame* pFrame; 91 92 TabControl aTabCtrl; 93 OKButton aOKBtn; 94 PushButton* pUserBtn; 95 CancelButton aCancelBtn; 96 HelpButton aHelpBtn; 97 PushButton aResetBtn; 98 PushButton aBaseFmtBtn; 99 100 const SfxItemSet* pSet; 101 SfxItemSet* pOutSet; 102 TabDlg_Impl* pImpl; 103 sal_uInt16* pRanges; 104 sal_uInt32 nResId; 105 sal_uInt16 nAppPageId; 106 sal_Bool bItemsReset; 107 sal_Bool bFmt; 108 109 //#if 0 // _SOLAR__PRIVATE 110 DECL_DLLPRIVATE_LINK( ActivatePageHdl, TabControl * ); 111 DECL_DLLPRIVATE_LINK( DeactivatePageHdl, TabControl * ); 112 DECL_DLLPRIVATE_LINK( OkHdl, Button * ); 113 DECL_DLLPRIVATE_LINK( ResetHdl, Button * ); 114 DECL_DLLPRIVATE_LINK( BaseFmtHdl, Button * ); 115 DECL_DLLPRIVATE_LINK( UserHdl, Button * ); 116 DECL_DLLPRIVATE_LINK( CancelHdl, Button * ); 117 SAL_DLLPRIVATE void Init_Impl(sal_Bool, const String *); 118 //#endif 119 120 protected: 121 virtual short Ok(); 122 // wird im Sfx gel"oscht! 123 virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId ); 124 // wird *nicht* im Sfx gel"oscht! 125 virtual const SfxItemSet* GetRefreshedSet(); 126 virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ); 127 virtual long Notify( NotifyEvent& rNEvt ); 128 129 SfxItemSet* pExampleSet; 130 SfxItemSet* GetInputSetImpl(); 131 SfxTabPage* GetTabPage( sal_uInt16 nPageId ) const; 132 133 sal_Bool IsInOK() const; 134 /** prepare to leace the current page. Calls the DeactivatePage method of the current page, (if necessary), 135 handles the item sets to copy. 136 @return sal_True if it is allowed to leave the current page, sal_False otherwise 137 */ 138 bool PrepareLeaveCurrentPage(); 139 140 public: 141 SfxTabDialog( Window* pParent, const ResId &rResId, sal_uInt16 nSetId, SfxBindings& rBindings, 142 sal_Bool bEditFmt = sal_False, const String *pUserButtonText = 0 ); 143 SfxTabDialog( Window* pParent, const ResId &rResId, const SfxItemSet * = 0, 144 sal_Bool bEditFmt = sal_False, const String *pUserButtonText = 0 ); 145 SfxTabDialog( SfxViewFrame *pViewFrame, Window* pParent, const ResId &rResId, 146 const SfxItemSet * = 0, sal_Bool bEditFmt = sal_False, 147 const String *pUserButtonText = 0 ); 148 ~SfxTabDialog(); 149 150 void AddTabPage( sal_uInt16 nId, 151 CreateTabPage pCreateFunc, // != 0 152 GetTabPageRanges pRangesFunc, // darf 0 sein 153 sal_Bool bItemsOnDemand = sal_False); 154 void AddTabPage( sal_uInt16 nId, 155 const String &rRiderText, 156 CreateTabPage pCreateFunc, // != 0 157 GetTabPageRanges pRangesFunc, // darf 0 sein 158 sal_Bool bItemsOnDemand = sal_False, 159 sal_uInt16 nPos = TAB_APPEND); 160 void AddTabPage( sal_uInt16 nId, 161 const Bitmap &rRiderBitmap, 162 CreateTabPage pCreateFunc, // != 0 163 GetTabPageRanges pRangesFunc, // darf 0 sein 164 sal_Bool bItemsOnDemand = sal_False, 165 sal_uInt16 nPos = TAB_APPEND); 166 167 void AddTabPage( sal_uInt16 nId, 168 sal_Bool bItemsOnDemand = sal_False); 169 void AddTabPage( sal_uInt16 nId, 170 const String &rRiderText, 171 sal_Bool bItemsOnDemand = sal_False, 172 sal_uInt16 nPos = TAB_APPEND); 173 void AddTabPage( sal_uInt16 nId, 174 const Bitmap &rRiderBitmap, 175 sal_Bool bItemsOnDemand = sal_False, 176 sal_uInt16 nPos = TAB_APPEND); 177 178 void RemoveTabPage( sal_uInt16 nId ); 179 SetCurPageId(sal_uInt16 nId)180 void SetCurPageId( sal_uInt16 nId ) { nAppPageId = nId; } GetCurPageId() const181 sal_uInt16 GetCurPageId() const 182 { return aTabCtrl.GetCurPageId(); } 183 void ShowPage( sal_uInt16 nId ); 184 185 // liefert ggf. per Map konvertierte lokale Slots 186 const sal_uInt16* GetInputRanges( const SfxItemPool& ); 187 void SetInputSet( const SfxItemSet* pInSet ); GetOutputItemSet() const188 const SfxItemSet* GetOutputItemSet() const { return pOutSet; } 189 const SfxItemSet* GetOutputItemSet( sal_uInt16 nId ) const; 190 int FillOutputItemSet(); IsFormat() const191 sal_Bool IsFormat() const { return bFmt; } 192 GetOKButton() const193 const OKButton& GetOKButton() const { return aOKBtn; } GetOKButton()194 OKButton& GetOKButton() { return aOKBtn; } GetCancelButton() const195 const CancelButton& GetCancelButton() const { return aCancelBtn; } GetCancelButton()196 CancelButton& GetCancelButton() { return aCancelBtn; } GetHelpButton() const197 const HelpButton& GetHelpButton() const { return aHelpBtn; } GetHelpButton()198 HelpButton& GetHelpButton() { return aHelpBtn; } GetResetButton() const199 const PushButton& GetResetButton() const { return aResetBtn; } GetResetButton()200 PushButton& GetResetButton() { return aResetBtn; } 201 202 const PushButton* GetApplyButton() const; 203 PushButton* GetApplyButton(); 204 GetUserButton() const205 const PushButton* GetUserButton() const { return pUserBtn; } GetUserButton()206 PushButton* GetUserButton() { return pUserBtn; } 207 void RemoveResetButton(); 208 209 short Execute(); 210 void StartExecuteModal( const Link& rEndDialogHdl ); 211 void Start( sal_Bool bShow = sal_True ); 212 213 #if !ENABLE_LAYOUT_SFX_TABDIALOG GetExampleSet() const214 const SfxItemSet* GetExampleSet() const { return pExampleSet; } 215 #else /* ENABLE_LAYOUT_SFX_TABDIALOG */ GetExampleSet() const216 SfxItemSet* GetExampleSet() const { return 0; } 217 #endif /* ENABLE_LAYOUT_SFX_TABDIALOG */ GetViewFrame() const218 SfxViewFrame* GetViewFrame() const { return pFrame; } 219 220 void EnableApplyButton(sal_Bool bEnable = sal_True); 221 sal_Bool IsApplyButtonEnabled() const; 222 void SetApplyHandler(const Link& _rHdl); 223 Link GetApplyHandler() const; 224 225 //#if 0 // _SOLAR__PRIVATE 226 SAL_DLLPRIVATE void Start_Impl(); OK_Impl()227 SAL_DLLPRIVATE sal_Bool OK_Impl() { return PrepareLeaveCurrentPage(); } 228 //#endif 229 }; 230 231 END_NAMESPACE_LAYOUT_SFX_TABDIALOG 232 233 #if ENABLE_LAYOUT_SFX_TABDIALOG 234 #include <layout/layout-post.hxx> 235 #endif /* ENABLE_LAYOUT_SFX_TABDIALOG */ 236 237 #if !ENABLE_LAYOUT_SFX_TABDIALOG 238 239 namespace sfx { class ItemConnectionBase; } 240 241 class SFX2_DLLPUBLIC SfxTabPage: public TabPage 242 { 243 friend class SfxTabDialog; 244 #if ENABLE_LAYOUT 245 friend class layout::SfxTabDialog; 246 #endif 247 248 private: 249 const SfxItemSet* pSet; 250 String aUserString; 251 sal_Bool bHasExchangeSupport; 252 SfxTabDialog* pTabDlg; 253 TabPageImpl* pImpl; 254 SetTabDialog(SfxTabDialog * pNew)255 SAL_DLLPRIVATE void SetTabDialog( SfxTabDialog* pNew ) { pTabDlg = pNew; } SetInputSet(const SfxItemSet * pNew)256 SAL_DLLPRIVATE void SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; } 257 258 protected: 259 SfxTabPage( Window *pParent, const ResId &, const SfxItemSet &rAttrSet ); 260 SfxTabPage( Window *pParent, WinBits nStyle, const SfxItemSet &rAttrSet ); 261 GetSlot(sal_uInt16 nWhich) const262 sal_uInt16 GetSlot( sal_uInt16 nWhich ) const 263 { return pSet->GetPool()->GetSlotId( nWhich ); } GetWhich(sal_uInt16 nSlot,sal_Bool bDeep=sal_True) const264 sal_uInt16 GetWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const 265 { return pSet->GetPool()->GetWhich( nSlot, bDeep ); } 266 const SfxPoolItem* GetOldItem( const SfxItemSet& rSet, sal_uInt16 nSlot, sal_Bool bDeep = sal_True ); 267 const SfxPoolItem* GetExchangeItem( const SfxItemSet& rSet, sal_uInt16 nSlot ); GetTabDialog() const268 SfxTabDialog* GetTabDialog() const { return pTabDlg; } 269 270 void AddItemConnection( sfx::ItemConnectionBase* pConnection ); 271 272 public: 273 virtual ~SfxTabPage(); 274 GetItemSet() const275 const SfxItemSet& GetItemSet() const { return *pSet; } 276 277 virtual sal_Bool FillItemSet( SfxItemSet& ); 278 virtual void Reset( const SfxItemSet& ); 279 HasExchangeSupport() const280 sal_Bool HasExchangeSupport() const 281 { return bHasExchangeSupport; } SetExchangeSupport(sal_Bool bNew=sal_True)282 void SetExchangeSupport( sal_Bool bNew = sal_True ) 283 { bHasExchangeSupport = bNew; } 284 285 enum sfxpg { 286 KEEP_PAGE = 0x0000, // Fehlerbehandlung; Seite nicht wechseln 287 // 2. F"ullen eines ItemSets f"ur die Aktualilsierung 288 // "ubergeordneter Beispiele; dieser Pointer kann immer 289 // NULL sein!! 290 LEAVE_PAGE = 0x0001, 291 // Set aktualisieren und andere Page aktualisieren 292 REFRESH_SET = 0x0002 293 }; 294 295 using TabPage::ActivatePage; 296 using TabPage::DeactivatePage; 297 virtual void ActivatePage( const SfxItemSet& ); 298 virtual int DeactivatePage( SfxItemSet* pSet = 0 ); SetUserData(const String & rString)299 void SetUserData(const String& rString) 300 { aUserString = rString; } GetUserData()301 String GetUserData() { return aUserString; } 302 virtual void FillUserData(); 303 virtual sal_Bool IsReadOnly() const; 304 virtual void PageCreated (SfxAllItemSet aSet); //add CHINA001 305 static const SfxPoolItem* GetItem( const SfxItemSet& rSet, sal_uInt16 nSlot, sal_Bool bDeep = sal_True ); 306 307 void SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame); 308 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame(); 309 }; 310 311 #endif /* !ENABLE_LAYOUT_SFX_TABDIALOG */ 312 313 #endif 314 315