Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / include / sfx2 / childwin.hxx
blobc52a1258b7000bdb79973fa91aa5c3fb1655d1f4
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_CHILDWIN_HXX
20 #define INCLUDED_SFX2_CHILDWIN_HXX
22 #include <memory>
23 #include <sal/config.h>
25 #include <sfx2/dllapi.h>
26 #include <sal/types.h>
27 #include <o3tl/typed_flags_set.hxx>
28 #include <vcl/window.hxx>
30 #include <sfx2/chalign.hxx>
31 #include <sfx2/basedlgs.hxx>
32 #include <comphelper/lok.hxx>
34 namespace com::sun::star::frame { class XFrame; }
36 class SfxWorkWindow;
37 class SfxModule;
38 class SfxChildWindow;
39 class SfxBindings;
41 enum class SfxChildWindowFlags
43 NONE = 0x000,
44 FORCEDOCK = 0x004, // Float forbidden
45 TASK = 0x010, // ChildWindow inside the Task
46 CANTGETFOCUS = 0x020, // ChildWindow can not get focus
47 ALWAYSAVAILABLE = 0x040, // ChildWindow is never disabled
48 NEVERHIDE = 0x080, // ChildWindow is always visible
49 NEVERCLONE = 0x100, // ChildWindow is not recreated in new view
52 namespace o3tl
54 template<> struct typed_flags<SfxChildWindowFlags> : is_typed_flags<SfxChildWindowFlags, 0x1f4> {};
58 #define CHILDWIN_NOPOS USHRT_MAX
60 // ChildWindow Configuration
61 struct SAL_DLLPUBLIC_RTTI SfxChildWinInfo
63 OUString aExtraString;
64 OUString aModule;
65 OUString aWinState;
66 Point aPos;
67 Size aSize;
68 SfxChildWindowFlags nFlags;
69 bool bVisible;
71 SfxChildWinInfo()
73 bVisible = false;
74 nFlags = SfxChildWindowFlags::NONE;
76 bool GetExtraData_Impl( SfxChildAlignment *pAlign ) const;
79 // ChildWindow factory methods
80 typedef std::unique_ptr<SfxChildWindow> (*SfxChildWinCtor)( vcl::Window *pParentWindow,
81 sal_uInt16 nId,
82 SfxBindings *pBindings,
83 SfxChildWinInfo *pInfo);
85 struct SFX2_DLLPUBLIC SfxChildWinFactory
87 SfxChildWinCtor pCtor; // Factory method
88 SfxChildWinInfo aInfo; // Configuration
89 sal_uInt16 nId; // ChildWindow-Id ( SlotId )
90 sal_uInt16 nPos; // Position in UI
92 SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, sal_uInt16 n );
95 struct SfxChildWindow_Impl;
97 extern SFX2_DLLPUBLIC bool ParentIsFloatingWindow(const vcl::Window *pParent);
99 class SFX2_DLLPUBLIC SfxChildWindow
101 VclPtr<vcl::Window> pParent; // parent window ( Topwindow )
102 VclPtr<vcl::Window> pWindow; // actual contents
103 std::unique_ptr< SfxChildWindow_Impl> pImpl; // Implementation data
104 std::shared_ptr<SfxDialogController> xController; // actual contents
105 SfxChildAlignment eChildAlignment; // Current css::drawing::Alignment
106 // Another window in pWindow
107 sal_uInt16 nType; // ChildWindow-Id
108 SAL_DLLPRIVATE void ClearWorkwin();
110 protected:
111 void SetWindow(const VclPtr<vcl::Window>& p) { pWindow = p; }
112 SfxChildWindow(vcl::Window *pParentWindow, sal_uInt16 nId);
114 public:
115 virtual ~SfxChildWindow();
116 void Destroy();
117 vcl::Window* GetWindow() const
118 { return pWindow; }
119 void SetController(const std::shared_ptr<SfxDialogController>& controller) { xController = controller; }
120 void ClearController() { xController.reset(); }
121 std::shared_ptr<SfxDialogController>& GetController() { return xController; }
122 const std::shared_ptr<SfxDialogController>& GetController() const { return xController; }
123 vcl::Window* GetParent() const
124 { return pParent; }
125 SfxChildAlignment GetAlignment() const
126 { return eChildAlignment; }
127 void SetAlignment(SfxChildAlignment eAlign);
128 virtual void Hide();
129 virtual void Show( ShowFlags nFlags );
130 sal_uInt16 GetPosition() const;
131 sal_uInt16 GetType() const
132 { return nType; }
134 virtual SfxChildWinInfo GetInfo() const;
135 void SaveStatus(const SfxChildWinInfo& rInfo);
137 static void RegisterChildWindow(SfxModule*, const SfxChildWinFactory&);
139 static std::unique_ptr<SfxChildWindow> CreateChildWindow( sal_uInt16, vcl::Window*, SfxBindings*, SfxChildWinInfo &);
140 void SetHideNotDelete( bool bOn );
141 bool IsHideNotDelete() const;
142 bool IsVisible() const;
143 void SetWantsFocus( bool );
144 bool WantsFocus() const;
146 virtual bool QueryClose();
147 const css::uno::Reference< css::frame::XFrame >& GetFrame() const;
148 void SetFrame( const css::uno::Reference< css::frame::XFrame > & );
150 SAL_DLLPRIVATE static void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo&);
151 void SetVisible_Impl( bool bVis );
152 SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
153 SAL_DLLPRIVATE void Activate_Impl();
155 SAL_DLLPRIVATE void SetFactory_Impl( const SfxChildWinFactory* );
158 const int nCloseResponseToJustHide = -42;
160 #define SFX_DECL_CHILDWINDOW(Class) \
161 public : \
162 static std::unique_ptr<SfxChildWindow> CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \
163 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
164 static void RegisterChildWindow (bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); \
165 virtual SfxChildWinInfo GetInfo() const override
167 #define SFX_DECL_CHILDWINDOW_WITHID(Class) \
168 SFX_DECL_CHILDWINDOW(Class); \
169 static sal_uInt16 GetChildWindowId ()\
171 #define SFX_IMPL_CHILDWINDOW(Class, MyID) \
172 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS)
174 #define SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
175 SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, CHILDWIN_NOPOS)
177 #define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
178 std::unique_ptr<SfxChildWindow> Class::CreateImpl( vcl::Window *pParent, \
179 sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
181 return std::make_unique<Class>(pParent, nId, pBindings, pInfo);\
183 void Class::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags) \
185 SfxChildWinFactory aFact( \
186 Class::CreateImpl, MyID, Pos ); \
187 if (comphelper::LibreOfficeKit::isActive() && nFlags == SfxChildWindowFlags::NONE) \
188 nFlags |= SfxChildWindowFlags::NEVERCLONE; \
189 aFact.aInfo.nFlags |= nFlags; \
190 aFact.aInfo.bVisible = bVis; \
191 SfxChildWindow::RegisterChildWindow(pMod, aFact); \
194 #define SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, Pos) \
195 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
196 sal_uInt16 Class::GetChildWindowId () \
197 { return MyID; } \
199 #define SFX_IMPL_MODELESSDIALOGCONTOLLER(Class, MyID) \
200 SFX_IMPL_CHILDWINDOW(Class, MyID) \
201 SfxChildWinInfo Class::GetInfo() const \
203 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
204 static_cast<const SfxModelessDialogController*>(GetController().get())->FillInfo( aInfo ); \
205 return aInfo; }
207 #define SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(Class, MyID) \
208 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
209 SfxChildWinInfo Class::GetInfo() const \
211 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
212 static_cast<const SfxModelessDialogController*>(GetController().get())->FillInfo( aInfo ); \
213 return aInfo; }
215 #define SFX_IMPL_DOCKINGWINDOW(Class, MyID) \
216 SFX_IMPL_CHILDWINDOW(Class, MyID) \
217 SfxChildWinInfo Class::GetInfo() const \
219 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
220 static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \
221 return aInfo; }
223 #define SFX_IMPL_DOCKINGWINDOW_WITHID(Class, MyID) \
224 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
225 SfxChildWinInfo Class::GetInfo() const \
227 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
228 static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \
229 return aInfo; }
231 bool GetPosSizeFromString( std::u16string_view rStr, Point& rPos, Size& rSize );
233 bool GetSplitSizeFromString( std::u16string_view rStr, Size& rSize );
235 #endif
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */