sc: filter: rtf: add method "AddFont"
[LibreOffice.git] / include / sfx2 / viewfrm.hxx
blob24d1c35dbe90bfff180c32be618b31cfadb06a7a
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_VIEWFRM_HXX
20 #define INCLUDED_SFX2_VIEWFRM_HXX
22 #include <memory>
23 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
25 #include <sal/types.h>
26 #include <svl/lstner.hxx>
27 #include <sfx2/frame.hxx>
28 #include <sfx2/objsh.hxx>
29 #include <sfx2/shell.hxx>
30 #include <svl/poolitem.hxx>
31 #include <vcl/svapp.hxx>
33 namespace weld {
34 class Button;
35 class Window;
37 class SvBorder;
38 class SfxDispatcher;
39 class SfxBindings;
40 class SfxProgress;
41 class SfxViewShell;
42 class Point;
43 class Size;
44 class SfxChildWindow;
45 class SfxInfoBarWindow;
46 enum class InfobarType;
47 class CommandPopupHandler;
49 class SFX2_DLLPUBLIC SfxViewFrame final : public SfxShell, public SfxListener
51 std::unique_ptr<struct SfxViewFrame_Impl> m_pImpl;
53 SfxObjectShellRef m_xObjSh;
54 std::unique_ptr<SfxDispatcher> m_pDispatcher;
55 SfxBindings* m_pBindings;
56 ImplSVHelpData* m_pHelpData;
57 ImplSVWinData* m_pWinData;
58 sal_uInt16 m_nAdjustPosPixelLock;
60 std::unique_ptr<CommandPopupHandler> m_pCommandPopupHandler;
62 SAL_DLLPRIVATE void Construct_Impl( SfxObjectShell *pObjSh );
63 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
64 DECL_DLLPRIVATE_LINK(GetInvolvedHandler, weld::Button&, void);
65 DECL_DLLPRIVATE_LINK(DonationHandler, weld::Button&, void);
66 DECL_DLLPRIVATE_LINK(WhatsNewHandler, weld::Button&, void);
67 DECL_DLLPRIVATE_LINK(SwitchReadOnlyHandler, weld::Button&, void);
68 DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void);
69 DECL_DLLPRIVATE_LINK(HiddenTrackChangesHandler, weld::Button&, void);
70 DECL_DLLPRIVATE_LINK(HyphenationMissingHandler, weld::Button&, void);
71 DECL_DLLPRIVATE_LINK(RefreshMasterPasswordHdl, weld::Button&, void);
72 SAL_DLLPRIVATE void KillDispatcher_Impl();
74 virtual ~SfxViewFrame() override;
76 public:
77 SfxViewFrame( SfxFrame& rFrame, SfxObjectShell *pDoc );
79 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWFRM)
81 private:
82 /// SfxInterface initializer.
83 static void InitInterface_Impl();
85 public:
87 static void SetViewFrame( SfxViewFrame* );
89 static SfxViewFrame* LoadHiddenDocument( SfxObjectShell const & i_rDoc, SfxInterfaceId i_nViewId );
90 static SfxViewFrame* LoadDocument( SfxObjectShell const & i_rDoc, SfxInterfaceId i_nViewId );
91 static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell const & i_rDoc, const SfxFrameItem* i_pFrameItem, SfxInterfaceId i_nViewId );
92 static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell const & i_rDoc, const css::uno::Reference< css::frame::XFrame >& i_rFrameItem );
93 static SfxViewFrame* DisplayNewDocument( SfxObjectShell const & i_rDoc, const SfxRequest& i_rCreateDocRequest );
95 static SfxViewFrame* Current();
96 static SfxViewFrame* GetFirst( const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true );
97 static SfxViewFrame* GetNext( const SfxViewFrame& rPrev, const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true );
99 static SfxViewFrame* Get( const css::uno::Reference< css::frame::XController>& i_rController, const SfxObjectShell* i_pDoc );
101 void DoActivate(bool bMDI);
102 void DoDeactivate(bool bMDI, SfxViewFrame const *pOld);
104 using SfxShell::GetDispatcher;
105 SfxDispatcher* GetDispatcher() { return m_pDispatcher.get(); }
106 SfxBindings& GetBindings() { return *m_pBindings; }
107 const SfxBindings& GetBindings() const { return *m_pBindings; }
108 vcl::Window& GetWindow() const;
109 weld::Window* GetFrameWeld() const;
111 SfxProgress* GetProgress() const;
113 void LockAdjustPosSizePixel()
114 { m_nAdjustPosPixelLock++; }
115 void UnlockAdjustPosSizePixel()
116 { m_nAdjustPosPixelLock--; }
117 void DoAdjustPosSizePixel( SfxViewShell * pSh,
118 const Point &rPos, const Size &rSize,
119 bool inplaceEditModeChange );
120 void Show();
121 bool IsVisible() const;
122 void ToTop();
123 void Enable( bool bEnable );
124 void Close();
125 virtual void Activate( bool bUI ) override;
126 virtual void Deactivate( bool bUI ) override;
128 void UpdateTitle();
130 // interne Handler
131 SAL_DLLPRIVATE void SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder );
132 SAL_DLLPRIVATE const SvBorder& GetBorderPixelImpl() const;
133 SAL_DLLPRIVATE void InvalidateBorderImpl( const SfxViewShell *pSh );
135 virtual SfxObjectShell* GetObjectShell() override;
136 SfxInterfaceId GetCurViewId() const;
137 SfxFrame& GetFrame() const;
138 SfxViewFrame* GetTopViewFrame() const;
140 bool DoClose();
141 static void GetTargetList( TargetList& rList )
142 { SfxFrame::GetDefaultTargetList( rList ); }
144 void SetModalMode( bool );
145 bool IsInModalMode() const;
146 void Resize(bool bForce=false);
148 void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true);
149 void ToggleChildWindow(sal_uInt16);
150 bool HasChildWindow(sal_uInt16);
151 bool KnowsChildWindow(sal_uInt16);
152 void ShowChildWindow(sal_uInt16,bool bVisible=true);
153 SfxChildWindow* GetChildWindow(sal_uInt16);
154 void ChildWindowExecute(SfxRequest&);
155 void ChildWindowState(SfxItemSet&);
157 /** Append a new InfoBar (see https://wiki.documentfoundation.org/Design/Whiteboards/Infobar).
159 The buttons will be added from Right to Left at the right of the info bar. The parent, size
160 and position of each button will be changed: only the width will remain unchanged.
162 VclPtr<SfxInfoBarWindow> AppendInfoBar(const OUString& sId,
163 const OUString& sPrimaryMessage,
164 const OUString& sSecondaryMessage,
165 InfobarType aInfobarType,
166 bool bShowCloseButton=true);
167 void RemoveInfoBar(std::u16string_view sId);
168 void UpdateInfoBar(std::u16string_view sId, const OUString& sPrimaryMessage,
169 const OUString& sSecondaryMessage,
170 InfobarType eType);
171 bool HasInfoBarWithID(std::u16string_view sId);
172 void AppendReadOnlyInfobar();
174 SAL_DLLPRIVATE void GetDocNumber_Impl();
175 SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh );
176 SAL_DLLPRIVATE void ReleaseObjectShell_Impl();
178 SAL_DLLPRIVATE void GetState_Impl( SfxItemSet &rSet );
179 void ExecReload_Impl(SfxRequest& rReq);
180 SAL_DLLPRIVATE void StateReload_Impl( SfxItemSet &rSet );
181 SAL_DLLPRIVATE void ExecView_Impl( SfxRequest &rReq );
182 SAL_DLLPRIVATE void StateView_Impl( SfxItemSet &rSet );
183 SAL_DLLPRIVATE void ExecHistory_Impl( SfxRequest &rReq );
184 SAL_DLLPRIVATE void StateHistory_Impl( SfxItemSet &rSet );
185 SAL_DLLPRIVATE void ForceOuterResize_Impl();
186 SAL_DLLPRIVATE void UpdateDocument_Impl();
188 SAL_DLLPRIVATE void LockObjectShell_Impl();
190 SAL_DLLPRIVATE void MakeActive_Impl( bool bActivate );
191 SAL_DLLPRIVATE const Size& GetMargin_Impl() const;
192 SAL_DLLPRIVATE OUString GetActualPresentationURL_Impl() const;
193 SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &);
194 SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &);
195 SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl();
196 SAL_DLLPRIVATE void AddDispatchMacroToBasic_Impl(const OUString& sMacro);
198 SAL_DLLPRIVATE void Exec_Impl(SfxRequest &);
199 SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &);
200 SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &);
202 SAL_DLLPRIVATE void SetCurViewId_Impl( const SfxInterfaceId i_nID );
204 private:
205 SAL_DLLPRIVATE bool SwitchToViewShell_Impl( sal_uInt16 nNo, bool bIsIndex = false );
206 SAL_DLLPRIVATE void PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell );
207 SAL_DLLPRIVATE void SaveCurrentViewData_Impl( const SfxInterfaceId i_nNewViewId );
209 /** loads the given existing document into the given frame
211 This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked.
213 @param i_rDoc
214 the document to load
215 @param i_rFrame
216 the frame to load the document into
217 @param i_rLoadArgs
218 the arguments to pass to the component loader. If this sequence is empty, then the current arguments of the
219 model will be obtained, and passed to the loader. This ensures that any arguments in the model will be preserved,
220 instead of being reset.
221 @param i_nViewId
222 the ID of the view to create
223 @throws Exception
224 if something goes wrong. The caller is responsible for handling this.
226 SAL_DLLPRIVATE static SfxViewShell* LoadViewIntoFrame_Impl(
227 const SfxObjectShell& i_rDoc,
228 const css::uno::Reference< css::frame::XFrame >& i_rFrame,
229 const css::uno::Sequence< css::beans::PropertyValue >& i_rLoadArgs,
230 const SfxInterfaceId i_nViewId,
231 const bool i_bHidden
234 /** loads the given existing document into the given frame
236 This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked.
238 If no frame is given, a blank top level frame is created.
240 If anything fails during the process, as much as possible is cleaned up.
242 @param i_rDoc
243 the document to load
244 @param i_rFrame
245 the frame to load the document into. Might be <NULL/>, in which case a new frame is created.
246 @param i_nViewId
247 the ID of the view to create
249 SAL_DLLPRIVATE static SfxViewFrame* LoadViewIntoFrame_Impl_NoThrow(
250 const SfxObjectShell& i_rDoc,
251 const css::uno::Reference< css::frame::XFrame >& i_rFrame,
252 const SfxInterfaceId i_nViewId,
253 const bool i_bHidden
258 class SFX2_DLLPUBLIC SfxViewFrameItem final : public SfxPoolItem
260 SfxViewFrame* pFrame;
262 public:
263 SfxViewFrameItem( SfxViewFrame *pViewFrame ):
264 SfxPoolItem( 0 ),
265 pFrame( pViewFrame)
268 virtual bool operator==( const SfxPoolItem& ) const override;
269 virtual SfxViewFrameItem* Clone( SfxItemPool *pPool = nullptr ) const override;
271 SfxViewFrame* GetFrame() const
272 { return pFrame; }
275 #endif
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */