Avoid potential negative array index access to cached text.
[LibreOffice.git] / embedserv / source / inc / docholder.hxx
blob844435e3de834ca9a38bea7f8f240ae9460f7413
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 .
20 #pragma once
22 #include "common.h"
23 #include <com/sun/star/frame/XLayoutManager.hpp>
24 #include <com/sun/star/util/XCloseListener.hpp>
25 #include <com/sun/star/frame/XTerminateListener.hpp>
26 #include <com/sun/star/util/XModifyListener.hpp>
27 #include <com/sun/star/frame/XFrame2.hpp>
28 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
29 #include <cppuhelper/implbase.hxx>
30 #include <cppuhelper/weakref.hxx>
32 #include <rtl/ref.hxx>
34 #include "embeddocaccess.hxx"
36 class EmbedDocument_Impl;
37 class Interceptor;
38 class CIIAObj;
40 namespace winwrap {
41 class CHatchWin;
45 class DocumentHolder :
46 public ::cppu::WeakImplHelper<
47 css::util::XCloseListener,
48 css::frame::XTerminateListener,
49 css::util::XModifyListener,
50 css::ui::XDockingAreaAcceptor>
52 private:
53 ::osl::Mutex m_aMutex;
55 bool m_bAllowInPlace;
56 LPOLEINPLACESITE m_pIOleIPSite;
57 LPOLEINPLACEFRAME m_pIOleIPFrame;
58 LPOLEINPLACEUIWINDOW m_pIOleIPUIWindow;
59 winwrap::CHatchWin* m_pCHatchWin;
61 ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOleAccess;
63 css::uno::WeakReference< css::frame::XDispatchProviderInterceptor > m_xInterceptorLocker;
64 rtl::Reference<Interceptor> m_pInterceptor;
66 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
68 RECT m_aBorder;
70 // contains top level system window data
71 bool m_bOnDeactivate;
72 HWND m_hWndxWinParent;
73 HWND m_hWndxWinCont;
74 HMENU m_nMenuHandle;
75 HMENU m_nMenuShared;
76 HOLEMENU m_nOLEMenu;
77 css::uno::Reference< css::awt::XWindow> m_xEditWindow;
79 css::uno::Reference< css::awt::XWindow> m_xContainerWindow;
81 css::uno::Reference< css::frame::XModel > m_xDocument;
82 sal_Int16 m_nMacroExecMode;
84 css::uno::Reference< css::frame::XLayoutManager> m_xLayoutManager;
87 css::uno::Reference< css::frame::XFrame2 > m_xFrame;
89 OUString m_aContainerName,m_aDocumentNamePart,m_aFilterName;
91 CComPtr< IDispatch > m_pIDispatch;
93 bool m_bLink;
96 css::uno::Reference< css::frame::XFrame2 > DocumentFrame();
99 css::uno::Reference< css::frame::XDispatchProviderInterceptor >
100 CreateNewInterceptor();
102 void ClearInterceptorInternally();
104 void LoadDocInFrame( bool bPluginMode );
105 public:
108 // the instance to which we belong
109 static HINSTANCE m_hInstance;
111 HWND GetEditWindowParentHandle() const
113 return m_hWndxWinParent;
116 void SetContainerWindowHandle(HWND hWndxWinCont)
118 m_hWndxWinCont = hWndxWinCont;
121 DocumentHolder(
122 const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory,
123 const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess );
125 ~DocumentHolder() override;
127 // Methods for inplace activation
130 BOOL isActive() const;
131 void DisableInplaceActivation(BOOL);
132 HRESULT InPlaceActivate(LPOLECLIENTSITE,BOOL);
133 void InPlaceDeactivate();
134 HRESULT UIActivate();
135 void UIDeactivate();
136 BOOL InPlaceMenuCreate();
137 BOOL InPlaceMenuDestroy();
139 static void OpenIntoWindow();
140 static BOOL Undo();
142 // further methods
144 void SetDocument(
145 const css::uno::Reference< css::frame::XModel >& xDoc,
146 bool bLink = false
149 bool ExecuteSuspendCloseFrame();
151 void DisconnectFrameDocument( bool bComplete = false );
152 void CloseDocument();
153 void CloseFrame();
154 void ClearInterceptor();
155 void FreeOffice();
157 void resizeWin( const SIZEL& rNewSize );
159 void setTitle(const OUString& aDocumentName);
160 OUString getTitle() const { return m_aDocumentNamePart; }
162 void setContainerName(const OUString& aContainerName);
163 OUString getContainerName() const { return m_aContainerName; }
164 void OnPosRectChanged(LPRECT lpRect) const;
165 void show();
167 bool HasFrame() { return m_xFrame.is(); }
168 bool IsLink() { return m_bLink; }
170 /** hides the document window, even in case of an external container
171 * side managed window.
174 void hide();
176 IDispatch* GetIDispatch();
178 HRESULT GetDocumentBorder( RECT *pRect );
179 // HRESULT SetVisArea( const RECTL *pRect );
180 // HRESULT GetVisArea( RECTL *pRect );
181 HRESULT SetExtent( const SIZEL *pSize );
182 HRESULT GetExtent( SIZEL *pSize );
183 // sets extension on the hatchwindow
184 HRESULT SetContRects(LPCRECT pRect);
185 HRESULT SetObjectRects(LPCRECT aRect, LPCRECT aClip);
187 HWND GetTopMostWinHandle() const
189 return m_hWndxWinParent;
192 css::uno::Reference< css::frame::XModel >
193 GetDocument() const
195 return m_xDocument;
198 // XEventListener
199 virtual void SAL_CALL
200 disposing( const css::lang::EventObject& aSource ) override;
202 // XCloseListener
203 virtual void SAL_CALL
204 queryClosing(
205 const css::lang::EventObject& aSource,
206 sal_Bool bGetsOwnership
207 ) override;
209 virtual void SAL_CALL
210 notifyClosing(
211 const css::lang::EventObject& aSource
212 ) override;
214 // XTerminateListener
215 virtual void SAL_CALL
216 queryTermination(
217 const css::lang::EventObject& aSource
218 ) override;
220 virtual void SAL_CALL
221 notifyTermination(
222 const css::lang::EventObject& aSource
223 ) override;
226 // XModifyListener
227 virtual void SAL_CALL
228 modified(
229 const css::lang::EventObject& aEvent
230 ) override;
232 // XDockingAreaAcceptor
234 virtual css::uno::Reference<
235 css::awt::XWindow> SAL_CALL
236 getContainerWindow(
237 ) override;
239 virtual sal_Bool SAL_CALL
240 requestDockingAreaSpace(
241 const css::awt::Rectangle& RequestedSpace
242 ) override;
244 virtual void SAL_CALL
245 setDockingAreaSpace(
246 const css::awt::Rectangle& BorderSpace
247 ) override;
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */