1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 #ifndef INCLUDED_SFX2_FRAME_HXX 20 #define INCLUDED_SFX2_FRAME_HXX 21 22 #include <sal/config.h> 23 #include <sfx2/dllapi.h> 24 #include <sfx2/shell.hxx> 25 #include <sal/types.h> 26 #include <com/sun/star/uno/Reference.h> 27 #include <com/sun/star/uno/Any.hxx> 28 #include <vcl/vclptr.hxx> 29 #include <rtl/ustring.hxx> 30 #include <svl/poolitem.hxx> 31 #include <tools/ref.hxx> 32 #include <memory> 33 #include <vector> 34 35 36 namespace com 37 { 38 namespace sun 39 { 40 namespace star 41 { 42 namespace frame 43 { 44 class XFrame; 45 class XController; 46 } 47 } 48 } 49 } 50 51 class SvBorder; 52 class SfxWorkWindow; 53 namespace vcl { class Window; } 54 class SfxFrame_Impl; 55 class SfxObjectShell; 56 class SfxViewFrame; 57 class SfxFrameDescriptor; 58 namespace tools { class Rectangle; } 59 class SystemWindow; 60 61 typedef ::std::vector<OUString> TargetList; 62 63 64 // SfxFrame is a management class for windows and their content. 65 // A SfxApplication represent a hierarchy of SfxFrames, with which the actual 66 // content in the derived classes is defined. The base class SfxFrame 67 // implements two aspects of frames: naming and control of its lifespan. 68 // Inside a frame hierarchy the parent frame always controls the lifespan of 69 // its child frames, even though they usually are not even produced by the 70 // parent. By calling DoCloser() on any frame in the hierarchy, 71 // a part of the "framework" can be removed, where frames unsubscribe 72 // from their parent frames. 73 74 75 class SFX2_DLLPUBLIC SfxFrame final : public SvCompatWeakBase<SfxFrame> 76 { 77 friend class SfxFrameIterator; 78 friend class SfxFrameWindow_Impl; 79 80 private: 81 std::unique_ptr< SfxFrame_Impl > pImpl; 82 VclPtr<vcl::Window> pWindow; 83 84 void Close(); 85 virtual ~SfxFrame(); 86 87 SAL_DLLPRIVATE SfxFrame( vcl::Window& i_rContainerWindow ); 88 89 public: 90 static SfxFrame* Create( const css::uno::Reference< css::frame::XFrame >& xFrame ); 91 static css::uno::Reference< css::frame::XFrame > 92 CreateBlankFrame(); 93 static SfxFrame* CreateHidden( SfxObjectShell const & rDoc, vcl::Window& rWindow, SfxInterfaceId nViewId ); 94 GetWindow() const95 vcl::Window& GetWindow() const { return *pWindow;} 96 void CancelTransfers(); 97 bool DoClose(); 98 99 void SetPresentationMode( bool bSet ); 100 SystemWindow* GetSystemWindow() const; 101 102 static SfxFrame* GetFirst(); 103 static SfxFrame* GetNext( SfxFrame& ); 104 105 SfxObjectShell* GetCurrentDocument() const; 106 SfxViewFrame* GetCurrentViewFrame() const; 107 108 bool GetHasTitle() const; 109 static void GetDefaultTargetList( TargetList& ); 110 void UpdateDescriptor( SfxObjectShell const *pDoc ); 111 void Resize(); 112 const css::uno::Reference< css::frame::XFrame >& 113 GetFrameInterface() const; 114 void Appear(); 115 void AppearWithUpdate(); 116 css::uno::Reference< css::frame::XController > 117 GetController() const; 118 119 bool IsInPlace() const; 120 121 SAL_DLLPRIVATE void DoClose_Impl(); 122 SAL_DLLPRIVATE void SetFrameInterface_Impl( const css::uno::Reference< css::frame::XFrame >& rFrame ); 123 SAL_DLLPRIVATE void ReleasingComponent_Impl(); 124 SAL_DLLPRIVATE void GetViewData_Impl(); 125 SAL_DLLPRIVATE void SetHasTitle( bool ); 126 SAL_DLLPRIVATE bool PrepareClose_Impl( bool bUI ); 127 SAL_DLLPRIVATE bool DocIsModified_Impl(); 128 SAL_DLLPRIVATE void SetCurrentViewFrame_Impl( SfxViewFrame* ); 129 SAL_DLLPRIVATE bool IsClosing_Impl() const; 130 SAL_DLLPRIVATE void SetIsClosing_Impl(); 131 132 // Methods for accessing the current set 133 SAL_DLLPRIVATE SfxFrameDescriptor* GetDescriptor() const; 134 135 SAL_DLLPRIVATE bool IsAutoLoadLocked_Impl() const; 136 137 SAL_DLLPRIVATE static void InsertTopFrame_Impl( SfxFrame* pFrame ); 138 SAL_DLLPRIVATE static void RemoveTopFrame_Impl( SfxFrame* pFrame ); 139 SAL_DLLPRIVATE void SetOwnsBindings_Impl( bool bSet ); 140 SAL_DLLPRIVATE bool OwnsBindings_Impl() const; 141 SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const; 142 SAL_DLLPRIVATE void SetToolSpaceBorderPixel_Impl( const SvBorder& ); 143 SAL_DLLPRIVATE tools::Rectangle GetTopOuterRectPixel_Impl() const; 144 SAL_DLLPRIVATE void CreateWorkWindow_Impl(); 145 SAL_DLLPRIVATE void GrabFocusOnComponent_Impl(); 146 147 SAL_DLLPRIVATE void PrepareForDoc_Impl( SfxObjectShell& i_rDoc ); 148 SAL_DLLPRIVATE void LockResize_Impl( bool bLock ); 149 SAL_DLLPRIVATE void SetMenuBarOn_Impl( bool bOn ); 150 SAL_DLLPRIVATE bool IsMenuBarOn_Impl() const; 151 SAL_DLLPRIVATE SystemWindow* GetTopWindow_Impl() const; 152 SAL_DLLPRIVATE bool IsMarkedHidden_Impl() const; 153 private: 154 SAL_DLLPRIVATE void Construct_Impl(); 155 }; 156 157 typedef SvCompatWeakRef<SfxFrame> SfxFrameWeakRef; 158 159 class SFX2_DLLPUBLIC SfxFrameItem final : public SfxPoolItem 160 { 161 SfxFrame* pFrame; 162 SfxFrameWeakRef wFrame; 163 164 public: 165 166 SfxFrameItem( sal_uInt16 nWhich, SfxViewFrame const *p ); 167 SfxFrameItem( SfxFrame *p ); 168 SfxFrameItem( sal_uInt16 nWhich, SfxFrame *p ); 169 170 virtual bool operator==( const SfxPoolItem& ) const override; 171 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override; 172 173 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; 174 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; 175 GetFrame() const176 SfxFrame* GetFrame() const { return wFrame; } 177 }; 178 179 class SFX2_DLLPUBLIC SfxUnoAnyItem final : public SfxPoolItem 180 { 181 css::uno::Any aValue; 182 public: 183 static SfxPoolItem* CreateDefault(); 184 SfxUnoAnyItem(); 185 SfxUnoAnyItem( sal_uInt16 nWhich, const css::uno::Any& rAny ); GetValue() const186 const css::uno::Any& GetValue() const 187 { return aValue; } 188 virtual bool operator==( const SfxPoolItem& ) const override; 189 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override; 190 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; 191 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; 192 }; 193 194 class SFX2_DLLPUBLIC SfxUnoFrameItem final : public SfxPoolItem 195 { 196 css::uno::Reference< css::frame::XFrame > 197 m_xFrame; 198 199 public: 200 static SfxPoolItem* CreateDefault(); 201 SfxUnoFrameItem(); 202 SfxUnoFrameItem( sal_uInt16 nWhich, const css::uno::Reference< css::frame::XFrame >& i_rFrame ); 203 const css::uno::Reference< css::frame::XFrame >& GetFrame() const204 GetFrame() const 205 { return m_xFrame; } 206 virtual bool operator==( const SfxPoolItem& ) const override; 207 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override; 208 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; 209 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; 210 }; 211 212 #endif 213 214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 215