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 _SFX_CHILDWIN_HXX 24 #define _SFX_CHILDWIN_HXX 25 26 #include "sal/config.h" 27 #include "sfx2/dllapi.h" 28 #include "sal/types.h" 29 #include <vcl/window.hxx> 30 #include <com/sun/star/frame/XFrame.hpp> 31 32 #ifdef ENABLE_INIMANAGER//MUSTINI 33 #include "inimgr.hxx" 34 #endif 35 #include <sfx2/shell.hxx> 36 #include <sfx2/chalign.hxx> 37 38 class SfxWorkWindow; 39 class SfxModule; 40 class SfxBindings; 41 class SfxShell; 42 class SfxChildWindow; 43 class SfxChildWindowContext; 44 class SfxChildWinContextArr_Impl; 45 46 //ASDBG #ifndef _XFRAME_REF 47 //ASDBG #define _XFRAME_REF 48 //ASDBG USR_DECLIMPL_REF( ::com::sun::star::frame::XFrame, ::com::sun::star::uno::XInterface ); 49 //ASDBG #endif 50 51 #define SFX_CHILDWIN_ZOOMIN 0x01 // ganz eingeklapptes Float 52 #define SFX_CHILDWIN_SMALL 0x02 // halb eingeklapptes Float 53 #define SFX_CHILDWIN_FORCEDOCK 0x04 // Float verboten 54 #define SFX_CHILDWIN_AUTOHIDE 0x08 // DockingWindow im AutoHide-Modus 55 #define SFX_CHILDWIN_TASK 0x10 // ChildWindow innerhalb der Task 56 #define SFX_CHILDWIN_CANTGETFOCUS 0x20 // ChildWindow kann keinen Focus bekommen 57 #define SFX_CHILDWIN_ALWAYSAVAILABLE 0x40 // ChildWindow is never disabled 58 #define SFX_CHILDWIN_NEVERHIDE 0x80 // ChildWindow is can always made visible/is visible 59 #define CHILDWIN_NOPOS USHRT_MAX 60 61 // Konfiguration eines ChildWindows 62 struct SfxChildWinInfo 63 { 64 sal_Bool bVisible; 65 Point aPos; 66 Size aSize; 67 sal_uInt16 nFlags; 68 String aExtraString; 69 ByteString aWinState; 70 SfxChildWinInfoSfxChildWinInfo71 SfxChildWinInfo() 72 { 73 bVisible = sal_False; 74 nFlags = 0; 75 } 76 //#if 0 // _SOLAR__PRIVATE 77 sal_Bool GetExtraData_Impl( SfxChildAlignment *pAlign, 78 SfxChildAlignment *pLastAlign = 0, 79 Size *pSize = 0, 80 sal_uInt16 *pLine = 0, 81 sal_uInt16 *pPos = 0 ) const; 82 //#endif 83 }; 84 85 // Factory-Methode eines ChildWindows 86 typedef SfxChildWindow* (*SfxChildWinCtor)( ::Window *pParentWindow, 87 sal_uInt16 nId, 88 SfxBindings *pBindings, 89 SfxChildWinInfo *pInfo); 90 91 // Factory-Methode eines ChildWindowsContexts 92 typedef SfxChildWindowContext* (*SfxChildWinContextCtor)( ::Window *pParentWindow, 93 SfxBindings *pBindings, 94 SfxChildWinInfo *pInfo); 95 struct SfxChildWinContextFactory 96 { 97 SfxChildWinContextCtor pCtor; // Factory-Methode 98 sal_uInt16 nContextId; // Identifier f"ur das SfxInterface 99 SfxChildWinInfo aInfo; // Konfiguration 100 SfxChildWinContextFactorySfxChildWinContextFactory101 SfxChildWinContextFactory( SfxChildWinContextCtor pTheCtor, sal_uInt16 nID ) 102 : pCtor(pTheCtor) 103 , nContextId(nID) 104 {} 105 }; 106 107 SV_DECL_PTRARR_DEL( SfxChildWinContextArr_Impl, SfxChildWinContextFactory*, 2, 2 ) 108 109 struct SfxChildWinFactory 110 { 111 SfxChildWinCtor pCtor; // Factory-Methode 112 sal_uInt16 nId; // ChildWindow-Id ( SlotId ) 113 SfxChildWinInfo aInfo; // Konfiguration 114 sal_uInt16 nPos; // ggf. Position im UI 115 SfxChildWinContextArr_Impl *pArr; // Array f"ur Contexte 116 SfxChildWinFactorySfxChildWinFactory117 SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, 118 sal_uInt16 n ) 119 : pCtor(pTheCtor) 120 , nId( nID ) 121 , nPos(n) 122 , pArr( NULL ) 123 {} 124 125 //#if 0 // _SOLAR__PRIVATE ~SfxChildWinFactorySfxChildWinFactory126 ~SfxChildWinFactory() 127 { 128 delete pArr; 129 } 130 //#else 131 // Der WIN16-Compiler versucht dort zu "ubersetzen, wo dieser Header 132 // included wird, und kann dann nat"urlich nicht linken, wenn inline ... 133 // ~SfxChildWinFactory(); 134 //#endif 135 }; 136 137 class FloatingWindow; 138 struct SfxChildWindow_Impl; 139 class SFX2_DLLPUBLIC SfxChildWindowContext 140 { 141 friend class SfxChildWindow; 142 ::Window* pWindow; 143 sal_uInt16 nContextId; 144 145 protected: 146 SfxChildWindowContext( sal_uInt16 nId ); 147 148 public: 149 virtual ~SfxChildWindowContext(); 150 SetWindow(::Window * pWin)151 void SetWindow( ::Window* pWin ) 152 { pWindow=pWin; } GetWindow() const153 ::Window* GetWindow() const 154 { return pWindow; } GetContextId() const155 sal_uInt16 GetContextId() const 156 { return nContextId; } 157 158 FloatingWindow* GetFloatingWindow() const; 159 SfxChildAlignment GetAlignment() const; 160 161 virtual void Resizing( Size& rSize ); 162 virtual sal_Bool Close(); 163 static void RegisterChildWindowContext(SfxModule*, sal_uInt16, SfxChildWinContextFactory*); 164 }; 165 166 class SFX2_DLLPUBLIC SfxChildWindow 167 { 168 ::Window* pParent; // parent window ( Topwindow ) 169 sal_uInt16 nType; // ChildWindow-Id 170 171 protected: 172 SfxChildAlignment eChildAlignment;// aktuelles ::com::sun::star::drawing::Alignment 173 ::Window* pWindow; // eigentlicher Inhalt 174 SfxChildWindow_Impl* pImp; // Imp-Daten 175 176 private: 177 SfxChildWindowContext* pContext; // bei kontextsensitiven ChildWindows: 178 // weiteres window in pWindow 179 SAL_DLLPRIVATE SfxChildWindowContext* GetContext() const180 GetContext() const 181 { return pContext; } 182 183 protected: 184 SfxChildWindow(::Window *pParentWindow, sal_uInt16 nId); 185 186 public: 187 virtual ~SfxChildWindow(); 188 void Destroy(); GetWindow() const189 ::Window* GetWindow() const 190 { return pWindow; } GetParent() const191 ::Window* GetParent() const 192 { return pParent; } GetAlignment() const193 SfxChildAlignment GetAlignment() const 194 { return eChildAlignment; } 195 void SetAlignment(SfxChildAlignment eAlign); GetSizePixel() const196 Size GetSizePixel() const 197 { return pWindow->GetSizePixel(); } 198 void SetPosSizePixel(const Point& rPoint, Size& rSize); GetPosPixel()199 Point GetPosPixel() 200 { return pWindow->GetPosPixel(); } 201 //<!--Modified by PengYunQuan for Validity Cell Range Picker 202 virtual void Hide(); 203 virtual void Show( sal_uInt16 nFlags ); 204 //-->Modified by PengYunQuan for Validity Cell Range Picker GetFlags() const205 sal_uInt16 GetFlags() const 206 { return GetInfo().nFlags; } 207 sal_Bool CanGetFocus() const; 208 sal_uInt16 GetPosition(); GetType()209 sal_uInt16 GetType() 210 { return nType; } 211 212 void CreateContext( sal_uInt16 nContextId, SfxBindings& ); GetContextId() const213 sal_uInt16 GetContextId() const 214 { return pContext ? pContext->GetContextId(): 0; } 215 GetContextWindow() const216 ::Window* GetContextWindow() const 217 { return pContext ? pContext->GetWindow(): 0; } 218 219 ::Window* GetContextWindow( SfxModule *pModule ) const; 220 221 virtual SfxChildWinInfo GetInfo() const; 222 void SaveStatus(const SfxChildWinInfo& rInfo); 223 224 static void RegisterChildWindow(SfxModule*, SfxChildWinFactory*); 225 226 static SfxChildWindow* CreateChildWindow( sal_uInt16, ::Window*, SfxBindings*, SfxChildWinInfo&); 227 void SetHideNotDelete( sal_Bool bOn ); 228 sal_Bool IsHideNotDelete() const; 229 void SetHideAtToggle( sal_Bool bOn ); 230 sal_Bool IsHideAtToggle() const; 231 sal_Bool IsVisible() const; 232 void SetWantsFocus( sal_Bool ); 233 sal_Bool WantsFocus() const; 234 235 virtual sal_Bool QueryClose(); 236 virtual com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame(); 237 void SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & ); 238 239 //#if 0 // _SOLAR__PRIVATE 240 SAL_DLLPRIVATE static void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo&); 241 SAL_DLLPRIVATE void SetVisible_Impl( sal_Bool bVis ); 242 SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* ); 243 //SfxWorkWindow* GetWorkWindow_Impl() const; 244 SAL_DLLPRIVATE void Activate_Impl(); 245 SAL_DLLPRIVATE void Deactivate_Impl(); 246 247 SAL_DLLPRIVATE SfxChildWindowContext* GetContext_Impl() const248 GetContext_Impl() const 249 { return pContext; } 250 SAL_DLLPRIVATE void SetFactory_Impl( SfxChildWinFactory* ); 251 //#endif 252 }; 253 254 //------------------------------------------------------------------ 255 //! demn"achst hinf"allig ! 256 #define SFX_DECL_CHILDWINDOW_CONTEXT(Class) \ 257 static SfxChildWindowContext* CreateImpl(::Window *pParent, \ 258 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \ 259 static void RegisterChildWindowContext(SfxModule *pMod=0); \ 260 261 //! Das Macro der Zukunft ... 262 #define SFX_DECL_CHILDWINDOWCONTEXT(Class) \ 263 static SfxChildWindowContext* CreateImpl(::Window *pParent, \ 264 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \ 265 static void RegisterChildWindowContext(sal_uInt16, SfxModule *pMod=0); \ 266 267 //! demn"achst hinf"allig ! 268 #define SFX_IMPL_CHILDWINDOW_CONTEXT(Class, MyID, ShellClass) \ 269 SfxChildWindowContext* __EXPORT Class::CreateImpl( ::Window *pParent, \ 270 SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \ 271 { \ 272 SfxChildWindowContext *pContext = new Class(pParent, \ 273 /* cast is safe here! */static_cast< sal_uInt16 >(ShellClass::GetInterfaceId()), \ 274 pBindings,pInfo); \ 275 return pContext; \ 276 } \ 277 void Class::RegisterChildWindowContext(SfxModule* pMod) \ 278 { \ 279 SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \ 280 Class::CreateImpl, \ 281 /* cast is safe here! */static_cast< sal_uInt16 >(ShellClass::GetInterfaceId()) ); \ 282 SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \ 283 } 284 285 //! Das Macro der Zukunft ... 286 // CreateImpl mu\s noch als Parameter die Factory mitbekommen wg. ContextId 287 // Solange wird diese Id auf 0 gesetzt und in SfxChildWindow::CreateContext gepatched 288 #define SFX_IMPL_CHILDWINDOWCONTEXT(Class, MyID) \ 289 SfxChildWindowContext* __EXPORT Class::CreateImpl( ::Window *pParent, \ 290 SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \ 291 { \ 292 SfxChildWindowContext *pContext = new Class(pParent,0,pBindings,pInfo);\ 293 return pContext; \ 294 } \ 295 void Class::RegisterChildWindowContext(sal_uInt16 nId, SfxModule* pMod) \ 296 { \ 297 SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \ 298 Class::CreateImpl, nId ); \ 299 SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \ 300 } 301 302 #define SFX_DECL_CHILDWINDOW(Class) \ 303 public : \ 304 static SfxChildWindow* CreateImpl(::Window *pParent, sal_uInt16 nId, \ 305 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \ 306 static void RegisterChildWindow (sal_Bool bVisible=sal_False, SfxModule *pMod=NULL, sal_uInt16 nFlags=0); \ 307 static sal_uInt16 GetChildWindowId ();\ 308 virtual SfxChildWinInfo GetInfo() const 309 310 #define SFX_IMPL_CHILDWINDOW(Class, MyID) \ 311 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS) 312 313 #define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \ 314 SfxChildWindow* __EXPORT Class::CreateImpl( ::Window *pParent, \ 315 sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \ 316 { \ 317 SfxChildWindow *pWin = new Class(pParent, nId, pBindings, pInfo);\ 318 return pWin; \ 319 } \ 320 sal_uInt16 __EXPORT Class::GetChildWindowId () \ 321 { return MyID; } \ 322 void Class::RegisterChildWindow (sal_Bool bVis, SfxModule *pMod, sal_uInt16 nFlags) \ 323 { \ 324 SfxChildWinFactory *pFact = new SfxChildWinFactory( \ 325 Class::CreateImpl, MyID, Pos ); \ 326 pFact->aInfo.nFlags |= nFlags; \ 327 pFact->aInfo.bVisible = bVis; \ 328 SfxChildWindow::RegisterChildWindow(pMod, pFact); \ 329 } 330 331 #define SFX_IMPL_FLOATINGWINDOW(Class, MyID) \ 332 SFX_IMPL_CHILDWINDOW(Class, MyID) \ 333 SfxChildWinInfo __EXPORT Class::GetInfo() const \ 334 { \ 335 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ 336 ((SfxFloatingWindow*)GetWindow())->FillInfo( aInfo ); \ 337 return aInfo; } 338 339 #define SFX_IMPL_MODELESSDIALOG(Class, MyID) \ 340 SFX_IMPL_CHILDWINDOW(Class, MyID) \ 341 SfxChildWinInfo __EXPORT Class::GetInfo() const \ 342 { \ 343 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ 344 ((SfxModelessDialog*)GetWindow())->FillInfo( aInfo ); \ 345 return aInfo; } 346 347 #define SFX_IMPL_DOCKINGWINDOW(Class, MyID) \ 348 SFX_IMPL_CHILDWINDOW(Class, MyID) \ 349 SfxChildWinInfo __EXPORT Class::GetInfo() const \ 350 { \ 351 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ 352 ((SfxDockingWindow*)GetWindow())->FillInfo( aInfo ); \ 353 return aInfo; } 354 355 #define SFX_IMPL_TOOLBOX(Class, MyID) \ 356 SFX_IMPL_CHILDWINDOW(Class, MyID) \ 357 SfxChildWinInfo __EXPORT Class::GetInfo() const \ 358 { \ 359 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ 360 ((SfxToolbox*)GetWindow())->FillInfo( aInfo ); \ 361 return aInfo; } 362 363 //------------------------------------------------------------------ 364 365 #endif 366