diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /embedserv/source/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'embedserv/source/inc')
-rw-r--r-- | embedserv/source/inc/common.h | 50 | ||||
-rw-r--r-- | embedserv/source/inc/docholder.hxx | 253 | ||||
-rw-r--r-- | embedserv/source/inc/embeddoc.hxx | 195 | ||||
-rw-r--r-- | embedserv/source/inc/embeddocaccess.hxx | 80 | ||||
-rw-r--r-- | embedserv/source/inc/embservconst.h | 46 | ||||
-rw-r--r-- | embedserv/source/inc/iipaobj.hxx | 64 | ||||
-rw-r--r-- | embedserv/source/inc/intercept.hxx | 149 | ||||
-rw-r--r-- | embedserv/source/inc/servprov.hxx | 82 | ||||
-rw-r--r-- | embedserv/source/inc/stdafx.h | 51 | ||||
-rw-r--r-- | embedserv/source/inc/syswinwrapper.hxx | 176 |
10 files changed, 1146 insertions, 0 deletions
diff --git a/embedserv/source/inc/common.h b/embedserv/source/inc/common.h new file mode 100644 index 000000000..3fcc6712d --- /dev/null +++ b/embedserv/source/inc/common.h @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_COMMON_H +#define INCLUDED_EMBEDSERV_SOURCE_INC_COMMON_H + +#include "stdafx.h" +#include <initguid.h> + +#include <rtl/ustring.hxx> +#include <osl/interlck.h> +#include <comphelper/classids.hxx> + +#include "embservconst.h" + +namespace com::sun::star { + namespace lang { + class XMultiServiceFactory; + } + namespace frame { + class XModel; + } + namespace beans { + struct PropertyValue; + } + namespace io { + class XInputStream; + class XOutputStream; + } +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/docholder.hxx b/embedserv/source/inc/docholder.hxx new file mode 100644 index 000000000..7cb85af0f --- /dev/null +++ b/embedserv/source/inc/docholder.hxx @@ -0,0 +1,253 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_DOCHOLDER_HXX +#define INCLUDED_EMBEDSERV_SOURCE_INC_DOCHOLDER_HXX + +#include "common.h" +#include <com/sun/star/frame/XLayoutManager.hpp> +#include <com/sun/star/util/XCloseListener.hpp> +#include <com/sun/star/frame/XTerminateListener.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/frame/XFrame2.hpp> +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +#include <rtl/ref.hxx> + +#include "embeddocaccess.hxx" + +class EmbedDocument_Impl; +class Interceptor; +class CIIAObj; + +namespace winwrap { + class CHatchWin; +} + + +class DocumentHolder : + public ::cppu::WeakImplHelper< + css::util::XCloseListener, + css::frame::XTerminateListener, + css::util::XModifyListener, + css::ui::XDockingAreaAcceptor> +{ +private: + ::osl::Mutex m_aMutex; + + bool m_bAllowInPlace; + LPOLEINPLACESITE m_pIOleIPSite; + LPOLEINPLACEFRAME m_pIOleIPFrame; + LPOLEINPLACEUIWINDOW m_pIOleIPUIWindow; + winwrap::CHatchWin* m_pCHatchWin; + + ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOleAccess; + + css::uno::WeakReference< css::frame::XDispatchProviderInterceptor > m_xInterceptorLocker; + Interceptor* m_pInterceptor; + + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + + RECT m_aBorder; + + // contains top level system window data + bool m_bOnDeactivate; + HWND m_hWndxWinParent; + HWND m_hWndxWinCont; + HMENU m_nMenuHandle; + HMENU m_nMenuShared; + HOLEMENU m_nOLEMenu; + css::uno::Reference< css::awt::XWindow> m_xEditWindow; + + css::uno::Reference< css::awt::XWindow> m_xContainerWindow; + + css::uno::Reference< css::frame::XModel > m_xDocument; + sal_Int16 m_nMacroExecMode; + + css::uno::Reference< css::frame::XLayoutManager> m_xLayoutManager; + + + css::uno::Reference< css::frame::XFrame2 > m_xFrame; + + OUString m_aContainerName,m_aDocumentNamePart,m_aFilterName; + + CComPtr< IDispatch > m_pIDispatch; + + bool m_bLink; + + + css::uno::Reference< css::frame::XFrame2 > DocumentFrame(); + + + css::uno::Reference< css::frame::XDispatchProviderInterceptor > + CreateNewInterceptor(); + + void ClearInterceptorInternally(); + + void LoadDocInFrame( bool bPluginMode ); +public: + + + // the instance to which we belong + static HINSTANCE m_hInstance; + + HWND GetEditWindowParentHandle() const + { + return m_hWndxWinParent; + } + + void SetContainerWindowHandle(HWND hWndxWinCont) + { + m_hWndxWinCont = hWndxWinCont; + } + + DocumentHolder( + const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess ); + + ~DocumentHolder() override; + + // Methods for inplace activation + + + BOOL isActive() const; + void DisableInplaceActivation(BOOL); + HRESULT InPlaceActivate(LPOLECLIENTSITE,BOOL); + void InPlaceDeactivate(); + HRESULT UIActivate(); + void UIDeactivate(); + BOOL InPlaceMenuCreate(); + BOOL InPlaceMenuDestroy(); + + static void OpenIntoWindow(); + static BOOL Undo(); + + // further methods + + void SetDocument( + const css::uno::Reference< css::frame::XModel >& xDoc, + bool bLink = false + ); + + bool ExecuteSuspendCloseFrame(); + + void DisconnectFrameDocument( bool bComplete = false ); + void CloseDocument(); + void CloseFrame(); + void ClearInterceptor(); + void FreeOffice(); + + void resizeWin( const SIZEL& rNewSize ); + + void setTitle(const OUString& aDocumentName); + OUString getTitle() const { return m_aDocumentNamePart; } + + void setContainerName(const OUString& aContainerName); + OUString getContainerName() const { return m_aContainerName; } + void OnPosRectChanged(LPRECT lpRect) const; + void show(); + + bool HasFrame() { return m_xFrame.is(); } + bool IsLink() { return m_bLink; } + + /** hides the document window, even in case of an external container + * side managed window. + */ + + void hide(); + + IDispatch* GetIDispatch(); + + HRESULT GetDocumentBorder( RECT *pRect ); + // HRESULT SetVisArea( const RECTL *pRect ); + // HRESULT GetVisArea( RECTL *pRect ); + HRESULT SetExtent( const SIZEL *pSize ); + HRESULT GetExtent( SIZEL *pSize ); + // sets extension on the hatchwindow + HRESULT SetContRects(LPCRECT pRect); + HRESULT SetObjectRects(LPCRECT aRect, LPCRECT aClip); + + HWND GetTopMostWinHandle() const + { + return m_hWndxWinParent; + } + + css::uno::Reference< css::frame::XModel > + GetDocument() const + { + return m_xDocument; + } + + // XEventListener + virtual void SAL_CALL + disposing( const css::lang::EventObject& aSource ) override; + + // XCloseListener + virtual void SAL_CALL + queryClosing( + const css::lang::EventObject& aSource, + sal_Bool bGetsOwnership + ) override; + + virtual void SAL_CALL + notifyClosing( + const css::lang::EventObject& aSource + ) override; + + // XTerminateListener + virtual void SAL_CALL + queryTermination( + const css::lang::EventObject& aSource + ) override; + + virtual void SAL_CALL + notifyTermination( + const css::lang::EventObject& aSource + ) override; + + + // XModifyListener + virtual void SAL_CALL + modified( + const css::lang::EventObject& aEvent + ) override; + + // XDockingAreaAcceptor + + virtual css::uno::Reference< + css::awt::XWindow> SAL_CALL + getContainerWindow( + ) override; + + virtual sal_Bool SAL_CALL + requestDockingAreaSpace( + const css::awt::Rectangle& RequestedSpace + ) override; + + virtual void SAL_CALL + setDockingAreaSpace( + const css::awt::Rectangle& BorderSpace + ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/embeddoc.hxx b/embedserv/source/inc/embeddoc.hxx new file mode 100644 index 000000000..488b142bc --- /dev/null +++ b/embedserv/source/inc/embeddoc.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_EMBEDDOC_HXX +#define INCLUDED_EMBEDSERV_SOURCE_INC_EMBEDDOC_HXX + +#include "common.h" +#include <oleidl.h> +#include <objidl.h> + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.h> +#include <unordered_map> + +#include "embeddocaccess.hxx" +#include "docholder.hxx" + +typedef std::unordered_map< DWORD, IAdviseSink* > AdviseSinkHashMap; + +class GDIMetaFile; +class CIIAObj; + +class EmbedDocument_Impl + : public IPersistStorage, + public IDataObject, + public IOleObject, + public IOleInPlaceObject, + public IPersistFile, + public IDispatch, + public IExternalConnection +{ +protected: + css::uno::Sequence< css::beans::PropertyValue > + fillArgsForLoading_Impl( css::uno::Reference< css::io::XInputStream > const & xStream, + DWORD nStreamMode, + LPCOLESTR pFilePath = nullptr ); + css::uno::Sequence< css::beans::PropertyValue > + fillArgsForStoring_Impl( css::uno::Reference< css::io::XOutputStream > const & xStream ); + + HRESULT SaveTo_Impl( IStorage* pStg ); + + sal_uInt64 getMetaFileHandle_Impl( bool isEnhMeta ); + +public: + EmbedDocument_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& smgr, + const GUID* guid ); + virtual ~EmbedDocument_Impl(); + + /* IUnknown methods */ + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj) override; + STDMETHOD_(ULONG, AddRef)() override; + STDMETHOD_(ULONG, Release)() override; + + /* IPersistMethod */ + STDMETHOD(GetClassID)(CLSID *pClassID) override; + + /* IPersistStorage methods */ + STDMETHOD(IsDirty) () override; + STDMETHOD(InitNew) ( IStorage *pStg ) override; + STDMETHOD(Load) ( IStorage* pStr ) override; + STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad ) override; + STDMETHOD(SaveCompleted) ( IStorage *pStgNew ) override; + STDMETHOD(HandsOffStorage) (void) override; + + /* IDataObject methods */ + STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ) override; + STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ) override; + STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc ) override; + STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut ) override; + STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease ) override; + STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc ) override; + STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection ) override; + STDMETHOD(DUnadvise) ( DWORD dwConnection ) override; + STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise ) override; + + /* IOleObject methods */ + STDMETHOD(SetClientSite) ( IOleClientSite* pSite ) override; + STDMETHOD(GetClientSite) ( IOleClientSite** pSite ) override; + STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj ) override; + STDMETHOD(Close) ( DWORD dwSaveOption) override; + STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk ) override; + STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk ) override; + STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved ) override; + STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject ) override; + STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect ) override; + STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb ) override; + STDMETHOD(Update) () override; + STDMETHOD(IsUpToDate) () override; + STDMETHOD(GetUserClassID) ( CLSID *pClsid ) override; + STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType ) override; + STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ) override; + STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ) override; + STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection ) override; + STDMETHOD(Unadvise) ( DWORD dwConnection ) override; + STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise ) override; + STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus ) override; + STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal ) override; + + /* IOleInPlaceObject methods */ + STDMETHOD(GetWindow)(HWND *) override; + STDMETHOD(ContextSensitiveHelp)(BOOL) override; + STDMETHOD(InPlaceDeactivate)() override; + STDMETHOD(UIDeactivate)() override; + STDMETHOD(SetObjectRects)(LPCRECT, LPCRECT) override; + STDMETHOD(ReactivateAndUndo)() override; + + /* IPersistFile methods */ + STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode ) override; + STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember ) override; + STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName ) override; + STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName ) override; + + /* IDispatch methods */ + STDMETHOD(GetTypeInfoCount) ( unsigned int FAR* pctinfo ) override; + STDMETHOD(GetTypeInfo) ( unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo ) override; + STDMETHOD(GetIDsOfNames) ( REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId ) override; + STDMETHOD(Invoke) ( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr ) override; + + /* IExternalConnection methods */ + virtual DWORD STDMETHODCALLTYPE AddConnection( DWORD extconn, DWORD reserved) override; + virtual DWORD STDMETHODCALLTYPE ReleaseConnection( DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses) override; + + // c++ - methods + + void notify( bool bDataChanged = true ); + HRESULT SaveObject(); + HRESULT ShowObject(); + GUID GetGUID() const { return m_guid; } + HRESULT OLENotifyClosing(); + + void Deactivate(); + HRESULT OLENotifyDeactivation(); + +protected: + oslInterlockedCount m_refCount; + + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + + DocumentHolder* m_pDocHolder; + OUString m_aFileName; + + CComPtr< IStorage > m_pMasterStorage; + CComPtr< IStream > m_pOwnStream; + CComPtr< IStream > m_pExtStream; + GUID m_guid; + + bool m_bIsDirty; + + CComPtr< IOleClientSite > m_pClientSite; + CComPtr< IDataAdviseHolder > m_pDAdviseHolder; + + AdviseSinkHashMap m_aAdviseHashMap; + DWORD m_nAdviseNum; + + ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOwnAccess; + + bool m_bIsInVerbHandling; +}; + +class BooleanGuard_Impl +{ + bool& m_bValue; + +public: + BooleanGuard_Impl( bool& bValue ) + : m_bValue( bValue ) + { + m_bValue = true; + } + + ~BooleanGuard_Impl() + { + m_bValue = false; + } +}; + +#endif // INCLUDED_EMBEDSERV_SOURCE_INC_EMBEDDOC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/embeddocaccess.hxx b/embedserv/source/inc/embeddocaccess.hxx new file mode 100644 index 000000000..8b03900af --- /dev/null +++ b/embedserv/source/inc/embeddocaccess.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_EMBEDDOCACCESS_HXX +#define INCLUDED_EMBEDSERV_SOURCE_INC_EMBEDDOCACCESS_HXX + +#define OLESERV_SAVEOBJECT 1 +#define OLESERV_CLOSE 2 +#define OLESERV_NOTIFY 3 +#define OLESERV_NOTIFYCLOSING 4 +#define OLESERV_SHOWOBJECT 5 +#define OLESERV_DEACTIVATE 6 + +#include <oleidl.h> +#if defined __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wall" +#pragma clang diagnostic ignored "-Wextra" +#pragma clang diagnostic ignored "-Wmicrosoft" +#pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#endif +#include <atldbcli.h> +#if defined __clang__ +#pragma clang diagnostic pop +#endif +#include <cppuhelper/weak.hxx> + +class EmbedDocument_Impl; +struct LockedEmbedDocument_Impl +{ +private: + EmbedDocument_Impl* m_pEmbedDocument; + +public: + LockedEmbedDocument_Impl(); + LockedEmbedDocument_Impl( EmbedDocument_Impl* pEmbedDocument ); + LockedEmbedDocument_Impl( const LockedEmbedDocument_Impl& aDocLock ); + + ~LockedEmbedDocument_Impl(); + + LockedEmbedDocument_Impl& operator=( const LockedEmbedDocument_Impl& aDocLock ); + + EmbedDocument_Impl* GetEmbedDocument() { return m_pEmbedDocument; } + + void ExecuteMethod( sal_Int16 nId ); +}; + +class EmbeddedDocumentInstanceAccess_Impl : public ::cppu::OWeakObject +{ + ::osl::Mutex m_aMutex; + EmbedDocument_Impl* m_pEmbedDocument; + + public: + EmbeddedDocumentInstanceAccess_Impl( EmbedDocument_Impl* pDoc ) + : m_pEmbedDocument( pDoc ) + {} + + LockedEmbedDocument_Impl GetEmbedDocument(); + void ClearEmbedDocument(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/embservconst.h b/embedserv/source/inc/embservconst.h new file mode 100644 index 000000000..aca7c8e49 --- /dev/null +++ b/embedserv/source/inc/embservconst.h @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_EMBSERVCONST_H +#define INCLUDED_EMBEDSERV_SOURCE_INC_EMBSERVCONST_H + +#include <guiddef.h> + +#include <comphelper/classids.hxx> + +#define SUPPORTED_FACTORIES_NUM 10 + +extern "C" const GUID DECLSPEC_SELECTANY OID_WriterTextServer = { SO3_SW_OLE_EMBED_CLASSID_60 }; +extern "C" const GUID DECLSPEC_SELECTANY OID_WriterOASISTextServer = { SO3_SW_OLE_EMBED_CLASSID_8 }; + +extern "C" const GUID DECLSPEC_SELECTANY OID_CalcServer = { SO3_SC_OLE_EMBED_CLASSID_60 }; +extern "C" const GUID DECLSPEC_SELECTANY OID_CalcOASISServer = { SO3_SC_OLE_EMBED_CLASSID_8 }; + +extern "C" const GUID DECLSPEC_SELECTANY OID_DrawingServer = { SO3_SDRAW_OLE_EMBED_CLASSID_60 }; +extern "C" const GUID DECLSPEC_SELECTANY OID_DrawingOASISServer = { SO3_SDRAW_OLE_EMBED_CLASSID_8 }; + +extern "C" const GUID DECLSPEC_SELECTANY OID_PresentationServer = { SO3_SIMPRESS_OLE_EMBED_CLASSID_60 }; +extern "C" const GUID DECLSPEC_SELECTANY OID_PresentationOASISServer = { SO3_SIMPRESS_OLE_EMBED_CLASSID_8 }; + +extern "C" const GUID DECLSPEC_SELECTANY OID_MathServer = { SO3_SM_OLE_EMBED_CLASSID_60 }; +extern "C" const GUID DECLSPEC_SELECTANY OID_MathOASISServer = { SO3_SM_OLE_EMBED_CLASSID_8 }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/iipaobj.hxx b/embedserv/source/inc/iipaobj.hxx new file mode 100644 index 000000000..8bcc04688 --- /dev/null +++ b/embedserv/source/inc/iipaobj.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_IIPAOBJ_HXX +#define INCLUDED_EMBEDSERV_SOURCE_INC_IIPAOBJ_HXX + +#include "stdafx.h" +#include <oleidl.h> + +#include <osl/interlck.h> +#include <rtl/ref.hxx> +class EmbedDocument_Impl; +class DocumentHolder; + +class CIIAObj + : public IOleInPlaceActiveObject +{ + +public: + + CIIAObj( DocumentHolder * ); + virtual ~CIIAObj(); + + /* IUnknown methods */ + STDMETHODIMP QueryInterface(REFIID, LPVOID FAR * ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + /* IOleInPlaceActiveObject methods */ + STDMETHODIMP GetWindow(HWND *) override; + STDMETHODIMP ContextSensitiveHelp(BOOL) override; + STDMETHODIMP TranslateAccelerator(LPMSG); + STDMETHODIMP OnFrameWindowActivate(BOOL) override; + STDMETHODIMP OnDocWindowActivate(BOOL) override; + STDMETHODIMP ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW + , BOOL) override; + STDMETHODIMP EnableModeless(BOOL) override; + + +private: + + oslInterlockedCount m_refCount; + ::rtl::Reference< DocumentHolder > m_rDocHolder; +}; + + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/intercept.hxx b/embedserv/source/inc/intercept.hxx new file mode 100644 index 000000000..ab3fb63ca --- /dev/null +++ b/embedserv/source/inc/intercept.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_INTERCEPT_HXX +#define INCLUDED_EMBEDSERV_SOURCE_INC_INTERCEPT_HXX + +#include <osl/mutex.hxx> +#include <cppuhelper/implbase.hxx> +#include <comphelper/interfacecontainer2.hxx> +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/frame/XInterceptorInfo.hpp> +#include <com/sun/star/frame/XDispatch.hpp> + +#include <rtl/ref.hxx> +#include "embeddocaccess.hxx" + + +class StatusChangeListenerContainer; +class EmbedDocument_Impl; +class DocumentHolder; + +class Interceptor + : public ::cppu::WeakImplHelper< + css::frame::XDispatchProviderInterceptor, + css::frame::XInterceptorInfo, + css::frame::XDispatch> +{ +public: + + Interceptor( + const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess, + DocumentHolder* pDocH, + bool bLink ); + + ~Interceptor() override; + + void DisconnectDocHolder(); + + void generateFeatureStateEvent(); + + // overwritten to release the statuslistener. + + + // XComponent + /// @throws css::uno::RuntimeException + virtual void + addEventListener( + const css::uno::Reference< css::lang::XEventListener >& xListener ); + + /// @throws css::uno::RuntimeException + virtual void + removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ); + + /// @throws css::uno::RuntimeException + void + dispose(); + + + //XDispatch + virtual void SAL_CALL + dispatch( + const css::util::URL& URL, + const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) override; + + virtual void SAL_CALL + addStatusListener( + const css::uno::Reference< css::frame::XStatusListener >& Control, + const css::util::URL& URL ) override; + + virtual void SAL_CALL + removeStatusListener( + const css::uno::Reference< css::frame::XStatusListener >& Control, + const css::util::URL& URL ) override; + + //XInterceptorInfo + virtual css::uno::Sequence< OUString > + SAL_CALL getInterceptedURLs( ) override; + + + //XDispatchProvider ( inherited by XDispatchProviderInterceptor ) + virtual css::uno::Reference< + css::frame::XDispatch > SAL_CALL + queryDispatch( + const css::util::URL& URL, + const OUString& TargetFrameName, + sal_Int32 SearchFlags ) override; + + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL + queryDispatches( + const css::uno::Sequence< + css::frame::DispatchDescriptor >& Requests ) override; + + + //XDispatchProviderInterceptor + virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL + getSlaveDispatchProvider( ) override; + + virtual void SAL_CALL + setSlaveDispatchProvider( + const css::uno::Reference< css::frame::XDispatchProvider >& NewDispatchProvider ) override; + + virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL + getMasterDispatchProvider( ) override; + + virtual void SAL_CALL + setMasterDispatchProvider( + const css::uno::Reference< css::frame::XDispatchProvider >& NewSupplier ) override; + + +private: + + osl::Mutex m_aMutex; + + ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOleAccess; + + css::uno::WeakReference< css::uno::XInterface > m_xDocHLocker; + DocumentHolder* m_pDocH; + + css::uno::Reference< css::frame::XDispatchProvider > m_xSlaveDispatchProvider; + + css::uno::Reference< css::frame::XDispatchProvider > m_xMasterDispatchProvider; + + static css::uno::Sequence< OUString > m_aInterceptedURL; + + comphelper::OInterfaceContainerHelper2* m_pDisposeEventListeners; + StatusChangeListenerContainer* m_pStatCL; + + bool m_bLink; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/servprov.hxx b/embedserv/source/inc/servprov.hxx new file mode 100644 index 000000000..6d1d887da --- /dev/null +++ b/embedserv/source/inc/servprov.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_SERVPROV_HXX +#define INCLUDED_EMBEDSERV_SOURCE_INC_SERVPROV_HXX + +#include "common.h" +#include <oleidl.h> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase.hxx> + + +class EmbedProviderFactory_Impl; + +class EmbedServer_Impl: public cppu::WeakImplHelper<css::lang::XServiceInfo> +{ +public: + EmbedServer_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory > &xFactory ); + virtual ~EmbedServer_Impl() override; + + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + +protected: + + CComPtr< EmbedProviderFactory_Impl > m_pOLEFactories[ SUPPORTED_FACTORIES_NUM ]; + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; +}; + +class EmbedProviderFactory_Impl : public IClassFactory +{ +public: + + EmbedProviderFactory_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, const GUID* pGuid); + virtual ~EmbedProviderFactory_Impl(); + + bool registerClass(); + bool deregisterClass(); + + /* IUnknown methods */ + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj) override; + STDMETHOD_(ULONG, AddRef)() override; + STDMETHOD_(ULONG, Release)() override; + + /* IClassFactory methods */ + STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv) override; + STDMETHOD(LockServer)(int fLock) override; + +protected: + + oslInterlockedCount m_refCount; + GUID m_guid; + DWORD m_factoryHandle; + + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/stdafx.h b/embedserv/source/inc/stdafx.h new file mode 100644 index 000000000..9ec4fffca --- /dev/null +++ b/embedserv/source/inc/stdafx.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#if !defined(AFX_STDAFX_H_) +#define AFX_STDAFX_H_ + +#define STRICT +#define _ATL_APARTMENT_THREADED +// #define _ATL_STATIC_REGISTRY + +#ifdef _MSC_VER +#if defined __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wall" +#pragma clang diagnostic ignored "-Wattributes" +#pragma clang diagnostic ignored "-Wdelete-incomplete" +#pragma clang diagnostic ignored "-Wdynamic-class-memaccess" +#pragma clang diagnostic ignored "-Wextra" +#pragma clang diagnostic ignored "-Wint-to-pointer-cast" +#pragma clang diagnostic ignored "-Winvalid-noreturn" +#pragma clang diagnostic ignored "-Wmicrosoft" +#pragma clang diagnostic ignored "-Wnon-pod-varargs" +#pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#pragma clang diagnostic ignored "-Wnonportable-include-path" +#pragma clang diagnostic ignored "-Wsequence-point" +#pragma clang diagnostic ignored "-Wtypename-missing" +#endif +#endif +#include <atlbase.h> +#if defined max +#undef max +#endif +#if defined min +#undef min +#endif +//You may derive a class from CComModule and use it if you want to override +//something, but do not change the name of _Module +extern CComModule _Module; +#include <atlcom.h> +#include <atlctl.h> + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#ifdef _MSC_VER +#if defined __clang__ +#pragma clang diagnostic pop +#endif +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/inc/syswinwrapper.hxx b/embedserv/source/inc/syswinwrapper.hxx new file mode 100644 index 000000000..f255058bf --- /dev/null +++ b/embedserv/source/inc/syswinwrapper.hxx @@ -0,0 +1,176 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMBEDSERV_SOURCE_INC_SYSWINWRAPPER_HXX +#define INCLUDED_EMBEDSERV_SOURCE_INC_SYSWINWRAPPER_HXX + +#if !defined WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include <windows.h> + +/** + ** CWindow: Our basic window class. + **/ + + +class DocumentHolder; + + +namespace winwrap { + + + void TransformRect(LPRECT rect,HWND pWnd,HWND pWndClipTo); + + + LRESULT APIENTRY HatchWndProc( + HWND hWnd, UINT iMsg + , WPARAM wParam, LPARAM lParam); + + + BOOL HatchWindowRegister(HINSTANCE hInst); + + class CWindow + { + protected: + HINSTANCE m_hInst; //Task instance + HWND m_hWnd; //Window handle of the window + + public: + //Standard Class Functions + CWindow(HINSTANCE); + ~CWindow(); + + //Just returns members. No need to modify + HWND Window(); + HINSTANCE Instance(); + }; + + + class Tracker { + public: + // Constructors + Tracker(); + Tracker(LPCRECT lpSrcRect, UINT nStyle); + + // Style Flags + enum StyleFlags + { + solidLine = 1, dottedLine = 2, hatchedBorder = 4, + resizeInside = 8, resizeOutside = 16, hatchInside = 32, + }; + + // Hit-Test codes + enum TrackerHit + { + hitNothing = -1, + hitTopLeft = 0, hitTopRight = 1, + hitBottomRight = 2, hitBottomLeft = 3, + hitTop = 4, hitRight = 5, hitBottom = 6, + hitLeft = 7, hitMiddle = 8 + }; + + // Attributes + UINT m_nStyle; // current state + RECT m_rect; // current position (always in pixels) + SIZE m_sizeMin; // minimum X and Y size during track operation + int m_nHandleSize; // size of resize handles (default from WIN.INI) + + // Operations + void Draw(HDC hDC) const; + void GetTrueRect(LPRECT lpTrueRect) const; + BOOL SetCursor(HWND hWnd,UINT nHitTest) const; + BOOL Track(HWND hWnd,POINT point,BOOL bAllowInvert = FALSE, + HWND hWndClipTo = nullptr); +// BOOL TrackRubberBand(HWND hWnd,POINT point,BOOL bAllowInvert = TRUE); + int HitTest(POINT point) const; + int NormalizeHit(int nHandle) const; + + // Overridables + virtual void DrawTrackerRect( + LPRECT lpRect, HWND hWndClipTo, + HDC hDC, HWND hWnd); + virtual void AdjustRect(int nHandle, LPRECT lpRect); + virtual void OnChangedRect(const RECT& rectOld); + virtual UINT GetHandleMask() const; + +// Implementation + public: + virtual ~Tracker(); + +protected: + BOOL m_bAllowInvert; // flag passed to Track or TrackRubberBand + RECT m_rectLast; + SIZE m_sizeLast; + BOOL m_bErase; // TRUE if DrawTrackerRect is called for erasing + BOOL m_bFinalErase; // TRUE if DragTrackerRect called for final erase + + // implementation helpers + int HitTestHandles(POINT point) const; + void GetHandleRect(int nHandle,RECT* pHandleRect) const; + void GetModifyPointers( + int nHandle,int**ppx, int**ppy, int* px, int*py); + virtual int GetHandleSize(LPRECT lpRect = nullptr) const; + BOOL TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo); + void Construct(); + }; + + +//Width of the border +#define HATCHWIN_BORDERWIDTHDEFAULT 4 + + + class CHatchWin : public CWindow + { + friend LRESULT APIENTRY HatchWndProc(HWND, UINT, WPARAM, LPARAM); + + public: + + const DocumentHolder* m_pDocHolder; + Tracker m_aTracker; + + int m_dBorder; + int m_dBorderOrg; + WORD m_uID; + HWND m_hWndParent; + HWND m_hWndKid; + HWND m_hWndAssociate; + RECT m_rcPos; + RECT m_rcClip; + + public: + CHatchWin(HINSTANCE,const DocumentHolder*); + ~CHatchWin(); + + BOOL Init(HWND, WORD, HWND); + + HWND HwndAssociateSet(HWND); + HWND HwndAssociateGet(); + + void RectsSet(LPRECT, LPRECT); + void ChildSet(HWND); + void ShowHatch(BOOL); + void SetTrans(); + }; + +} + +#endif // INCLUDED_EMBEDSERV_SOURCE_INC_SYSWINWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |