1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SVX_SVDOOLE2_HXX
21 #define INCLUDED_SVX_SVDOOLE2_HXX
24 #include <svx/svdorect.hxx>
25 #include <svx/svxdllapi.h>
26 #include <sfx2/linkmgr.hxx>
28 #include <com/sun/star/uno/Reference.h>
30 namespace com
{ namespace sun
{ namespace star
{
32 namespace awt
{ class XWindow
; }
34 namespace datatransfer
{ class XTransferable
; }
36 namespace embed
{ class XEmbeddedObject
; }
38 namespace frame
{ class XModel
; }
42 namespace svt
{ class EmbeddedObjectRef
; }
46 class SVX_DLLPUBLIC SdrOle2Obj
: public SdrRectObj
49 std::unique_ptr
<SdrOle2ObjImpl
> mpImpl
;
52 SVX_DLLPRIVATE
void Connect_Impl();
53 SVX_DLLPRIVATE
void Disconnect_Impl();
54 SVX_DLLPRIVATE
void Reconnect_Impl();
55 SVX_DLLPRIVATE
void AddListeners_Impl();
56 SVX_DLLPRIVATE
void RemoveListeners_Impl();
57 SVX_DLLPRIVATE
void GetObjRef_Impl();
59 // #i118485# helper added
60 SVX_DLLPRIVATE SdrObject
* createSdrGrafObjReplacement(bool bAddText
) const;
61 SVX_DLLPRIVATE
void ImpSetVisAreaSize();
64 virtual sdr::contact::ViewContact
* CreateObjectSpecificViewContact() override
;
65 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties() override
;
68 OUString
GetStyleString();
70 SdrOle2Obj( bool bFrame_
= false );
71 SdrOle2Obj( const svt::EmbeddedObjectRef
& rNewObjRef
, const OUString
& rNewObjName
, const tools::Rectangle
& rNewRect
);
72 virtual ~SdrOle2Obj() override
;
74 const svt::EmbeddedObjectRef
& getEmbeddedObjectRef() const;
76 sal_Int64
GetAspect() const;
77 bool isInplaceActive() const;
78 bool isUiActive() const;
79 void SetAspect( sal_Int64 nAspect
);
81 // An OLE graphic object can contain a StarView graphic,
82 // which will be displayed if the OLE object is empty.
83 void SetGraphic(const Graphic
& rGrf
);
85 const Graphic
* GetGraphic() const;
86 void GetNewReplacement();
88 // The original size of the object (size of the icon for iconified object)
89 // no conversion is done if no target mode is provided
90 Size
GetOrigObjSize( MapMode
* pTargetMapMode
= nullptr ) const;
92 // #i118524# Allow suppress SetVisAreaSize in changing methods when call
93 // comes from OLE client
94 void setSuppressSetVisAreaSize( bool bNew
);
96 // OLE object has got a separate PersistName member now;
97 // !!! use ::SetPersistName( ... ) only, if you know what you do !!!
98 const OUString
& GetPersistName() const;
99 void SetPersistName( const OUString
& rPersistName
);
101 // One can add an application name to a SdrOle2Obj, which can be queried for
102 // later on (SD needs this for presentation objects).
103 void SetProgName( const OUString
& rName
);
104 const OUString
& GetProgName() const;
105 bool IsEmpty() const;
107 void SetObjRef(const css::uno::Reference
< css::embed::XEmbeddedObject
>& rNewObjRef
);
108 css::uno::Reference
< css::embed::XEmbeddedObject
> GetObjRef() const;
110 SVX_DLLPRIVATE
css::uno::Reference
< css::embed::XEmbeddedObject
> GetObjRef_NoInit() const;
112 void AbandonObject();
114 virtual void SetPage(SdrPage
* pNewPage
) override
;
115 virtual void SetModel(SdrModel
* pModel
) override
;
117 /** Change the IsClosedObj attribute
120 Whether the OLE object is closed, i.e. has opaque background
122 void SetClosedObj( bool bIsClosed
);
125 virtual SdrObject
* getFullDragClone() const override
;
127 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const override
;
128 virtual sal_uInt16
GetObjIdentifier() const override
;
129 virtual OUString
TakeObjNameSingul() const override
;
130 virtual OUString
TakeObjNamePlural() const override
;
132 virtual SdrOle2Obj
* Clone() const override
;
134 SdrOle2Obj
& assignFrom(const SdrOle2Obj
& rObj
);
135 SdrOle2Obj
& operator=(const SdrOle2Obj
& rObj
);
137 virtual void NbcMove(const Size
& rSize
) override
;
138 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
139 virtual void NbcSetSnapRect(const tools::Rectangle
& rRect
) override
;
140 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
141 virtual void SetGeoData(const SdrObjGeoData
& rGeo
) override
;
143 static bool CanUnloadRunningObj( const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
,
145 static bool Unload( const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
, sal_Int64 nAspect
);
151 css::uno::Reference
< css::frame::XModel
> getXModel() const;
153 bool IsChart() const;
154 bool IsReal3DChart() const;
157 bool UpdateLinkURL_Impl();
158 void BreakFileLink_Impl();
159 void DisconnectFileLink_Impl();
160 void CheckFileLink_Impl();
162 // allows to transfer the graphics to the object helper
163 void SetGraphicToObj( const Graphic
& aGraphic
, const OUString
& aMediaType
);
164 void SetGraphicToObj( const css::uno::Reference
< css::io::XInputStream
>& xGrStream
,
165 const OUString
& aMediaType
);
167 css::uno::Reference
< css::frame::XModel
> GetParentXModel() const;
168 bool CalculateNewScaling( Fraction
& aScaleWidth
, Fraction
& aScaleHeight
, Size
& aObjAreaSize
);
169 bool AddOwnLightClient();
171 // handy to get the empty replacement graphic without accessing all the old stuff
172 static Graphic
GetEmptyOLEReplacementGraphic();
174 void SetWindow(const css::uno::Reference
< css::awt::XWindow
>& _xWindow
);
176 // #i118485# missing converter added
177 virtual SdrObject
* DoConvertToPolyObj(bool bBezier
, bool bAddText
) const override
;
180 class SVX_DLLPUBLIC SdrEmbedObjectLink
: public sfx2::SvBaseLink
185 explicit SdrEmbedObjectLink(SdrOle2Obj
* pObj
);
186 virtual ~SdrEmbedObjectLink() override
;
188 virtual void Closed() override
;
189 virtual ::sfx2::SvBaseLink::UpdateResult
DataChanged(
190 const OUString
& rMimeType
, const css::uno::Any
& rValue
) override
;
192 bool Connect() { return GetRealObject() != nullptr; }
195 #endif // INCLUDED_SVX_SVDOOLE2_HXX
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */