Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/embeddedobj/source/msole/olecomponent.hxx
Line
Count
Source
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
20
#pragma once
21
22
#include <com/sun/star/uno/Sequence.hxx>
23
#include <com/sun/star/uno/Reference.hxx>
24
#include <com/sun/star/lang/XComponent.hpp>
25
#include <com/sun/star/util/XCloseable.hpp>
26
#include <com/sun/star/datatransfer/XTransferable.hpp>
27
#include <com/sun/star/embed/VerbDescriptor.hpp>
28
#include <com/sun/star/awt/Size.hpp>
29
#include <com/sun/star/lang/XUnoTunnel.hpp>
30
#include <cppuhelper/implbase.hxx>
31
#include <com/sun/star/util/XModifiable.hpp>
32
#include <com/sun/star/uno/XComponentContext.hpp>
33
#include <rtl/ref.hxx>
34
35
namespace comphelper {
36
    class OMultiTypeInterfaceContainerHelper2;
37
}
38
39
class OleWrapperClientSite;
40
class OleWrapperAdviseSink;
41
class OleEmbeddedObject;
42
class OleComponentNative_Impl;
43
44
class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css::lang::XComponent,
45
                                                    css::lang::XUnoTunnel, css::util::XModifiable,
46
                                                    css::datatransfer::XTransferable >
47
{
48
    ::osl::Mutex m_aMutex;
49
    comphelper::OMultiTypeInterfaceContainerHelper2* m_pInterfaceContainer;
50
51
    bool m_bDisposed;
52
    bool m_bModified;
53
    std::unique_ptr<OleComponentNative_Impl> m_pNativeImpl;
54
55
    OleEmbeddedObject* m_pUnoOleObject;
56
    OleWrapperClientSite* m_pOleWrapClientSite;
57
    OleWrapperAdviseSink* m_pImplAdviseSink;
58
59
    css::uno::Sequence< css::embed::VerbDescriptor > m_aVerbList;
60
    css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavors;
61
62
    css::uno::Reference< css::uno::XComponentContext > m_xContext;
63
64
    bool m_bOleInitialized;
65
66
    // specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object )
67
    // such objects report the dirty state wrongly sometimes and do not allow to store them any time
68
    bool m_bWorkaroundActive;
69
70
    void InitializeObject_Impl();
71
72
    OUString getTempURL() const;
73
74
    void RetrieveObjectDataFlavors_Impl();
75
    void Dispose();
76
77
78
public:
79
    OleComponent( const css::uno::Reference< css::uno::XComponentContext >& xContext,
80
                  OleEmbeddedObject* pOleObj );
81
82
    virtual ~OleComponent() override;
83
84
    OleComponent* createEmbeddedCopyOfLink();
85
86
    void disconnectEmbeddedObject();
87
88
    static css::awt::Size CalculateWithFactor( const css::awt::Size& aSize,
89
                                                            const css::awt::Size& aMultiplier,
90
                                                            const css::awt::Size& aDivisor );
91
92
    css::awt::Size CalculateTheRealSize( const css::awt::Size& aContSize, bool bUpdate );
93
94
    // ==== Initialization ==================================================
95
    void LoadEmbeddedObject( const OUString& aTempURL );
96
    void CreateObjectFromClipboard();
97
    void CreateNewEmbeddedObject( const css::uno::Sequence< sal_Int8 >& aSeqCLSID );
98
    static void CreateObjectFromData(
99
                        const css::uno::Reference< css::datatransfer::XTransferable >& xTransfer );
100
    void CreateObjectFromFile( const OUString& aFileName );
101
    void CreateLinkFromFile( const OUString& aFileName );
102
    void InitEmbeddedCopyOfLink( rtl::Reference<OleComponent> const & pOleLinkComponent );
103
104
105
    void RunObject(); // switch OLE object to running state
106
    void CloseObject(); // switch OLE object to loaded state
107
108
    css::uno::Sequence< css::embed::VerbDescriptor > GetVerbList();
109
110
    void ExecuteVerb( sal_Int32 nVerbID );
111
    void SetHostName( const OUString& aEmbDocName );
112
    void SetExtent( const css::awt::Size& aVisAreaSize, sal_Int64 nAspect );
113
114
    css::awt::Size GetExtent( sal_Int64 nAspect );
115
    css::awt::Size GetCachedExtent( sal_Int64 nAspect );
116
    css::awt::Size GetRecommendedExtent( sal_Int64 nAspect );
117
118
    sal_Int64 GetMiscStatus( sal_Int64 nAspect );
119
120
    css::uno::Sequence< sal_Int8 > GetCLSID();
121
122
0
    bool IsWorkaroundActive() const { return m_bWorkaroundActive; }
123
    bool IsDirty();
124
125
    void StoreOwnTmpIfNecessary();
126
127
    bool SaveObject_Impl();
128
    bool OnShowWindow_Impl( bool bShow );
129
    void OnViewChange_Impl( sal_uInt32 dwAspect );
130
    void OnClose_Impl();
131
132
    // XCloseable
133
    virtual void SAL_CALL close( sal_Bool DeliverOwnership ) override;
134
    virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override;
135
    virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override;
136
137
    // XTransferable
138
    virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
139
    virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors(  ) override;
140
    virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
141
142
    // XComponent
143
    virtual void SAL_CALL dispose() override;
144
    virtual void SAL_CALL addEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) override;
145
    virtual void SAL_CALL removeEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) override;
146
147
    // XUnoTunnel
148
    virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
149
150
    // XModifiable
151
    virtual sal_Bool SAL_CALL isModified() override;
152
    virtual void SAL_CALL setModified( sal_Bool bModified ) override;
153
    virtual void SAL_CALL addModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener ) override;
154
    virtual void SAL_CALL removeModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener) override;
155
};
156
157
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */