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 .
23 #include <svx/svdorect.hxx>
24 #include <svx/svxdllapi.h>
25 #include <sfx2/lnkbase.hxx>
27 #include <com/sun/star/uno/Reference.h>
29 namespace com::sun::star
{
31 namespace awt
{ class XWindow
; }
33 namespace datatransfer
{ class XTransferable
; }
35 namespace embed
{ class XEmbeddedObject
; }
37 namespace frame
{ class XModel
; }
39 namespace io
{ class XInputStream
; }
42 namespace svt
{ class EmbeddedObjectRef
; }
46 class SVXCORE_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 AddListeners_Impl();
55 SVX_DLLPRIVATE
void RemoveListeners_Impl();
56 SVX_DLLPRIVATE
void GetObjRef_Impl();
58 // #i118485# helper added
59 SVX_DLLPRIVATE SdrObjectUniquePtr
createSdrGrafObjReplacement(bool bAddText
) const;
60 SVX_DLLPRIVATE
void ImpSetVisAreaSize();
62 SVX_DLLPRIVATE
void Init();
65 virtual std::unique_ptr
<sdr::contact::ViewContact
> CreateObjectSpecificViewContact() override
;
66 virtual std::unique_ptr
<sdr::properties::BaseProperties
> CreateObjectSpecificProperties() override
;
68 // protected destructor
69 virtual ~SdrOle2Obj() override
;
72 OUString
GetStyleString();
76 bool bFrame_
= false);
78 SdrOle2Obj(SdrModel
& rSdrModel
, SdrOle2Obj
const & rSource
);
81 const svt::EmbeddedObjectRef
& rNewObjRef
,
82 const OUString
& rNewObjName
,
83 const tools::Rectangle
& rNewRect
);
85 const svt::EmbeddedObjectRef
& getEmbeddedObjectRef() const;
87 sal_Int64
GetAspect() const;
88 bool isInplaceActive() const;
89 bool isUiActive() const;
90 void SetAspect( sal_Int64 nAspect
);
92 // An OLE graphic object can contain a StarView graphic,
93 // which will be displayed if the OLE object is empty.
94 void SetGraphic(const Graphic
& rGrf
);
96 const Graphic
* GetGraphic() const;
97 void GetNewReplacement();
99 // The original size of the object (size of the icon for iconified object)
100 // no conversion is done if no target mode is provided
101 Size
GetOrigObjSize( MapMode
const * pTargetMapMode
= nullptr ) const;
103 // #i118524# Allow suppress SetVisAreaSize in changing methods when call
104 // comes from OLE client
105 void setSuppressSetVisAreaSize( bool bNew
);
107 // OLE object has got a separate PersistName member now;
108 // !!! use ::SetPersistName( ... ) only, if you know what you do !!!
109 const OUString
& GetPersistName() const;
110 void SetPersistName( const OUString
& rPersistName
);
112 // One can add an application name to a SdrOle2Obj, which can be queried for
113 // later on (SD needs this for presentation objects).
114 void SetProgName( const OUString
& rName
);
115 const OUString
& GetProgName() const;
116 bool IsEmpty() const;
118 void SetObjRef(const css::uno::Reference
< css::embed::XEmbeddedObject
>& rNewObjRef
);
119 css::uno::Reference
< css::embed::XEmbeddedObject
> const & GetObjRef() const;
121 SVX_DLLPRIVATE
css::uno::Reference
< css::embed::XEmbeddedObject
> const & GetObjRef_NoInit() const;
123 void AbandonObject();
125 // react on model/page change
126 virtual void handlePageChange(SdrPage
* pOldPage
, SdrPage
* pNewPage
) override
;
128 /** Change the IsClosedObj attribute
131 Whether the OLE object is closed, i.e. has opaque background
133 void SetClosedObj( bool bIsClosed
);
136 virtual SdrObjectUniquePtr
getFullDragClone() const override
;
138 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const override
;
139 virtual SdrObjKind
GetObjIdentifier() const override
;
140 virtual OUString
TakeObjNameSingul() const override
;
141 virtual OUString
TakeObjNamePlural() const override
;
143 virtual SdrOle2Obj
* CloneSdrObject(SdrModel
& rTargetModel
) const override
;
145 virtual void NbcMove(const Size
& rSize
) override
;
146 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
147 virtual void NbcSetSnapRect(const tools::Rectangle
& rRect
) override
;
148 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
149 virtual void SetGeoData(const SdrObjGeoData
& rGeo
) override
;
151 static bool CanUnloadRunningObj( const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
,
153 static bool Unload( const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
, sal_Int64 nAspect
);
159 css::uno::Reference
< css::frame::XModel
> getXModel() const;
161 bool IsChart() const;
164 bool UpdateLinkURL_Impl();
165 void BreakFileLink_Impl();
166 void DisconnectFileLink_Impl();
167 void CheckFileLink_Impl();
169 // allows to transfer the graphics to the object helper
170 void SetGraphicToObj( const Graphic
& aGraphic
);
171 void SetGraphicToObj( const css::uno::Reference
< css::io::XInputStream
>& xGrStream
,
172 const OUString
& aMediaType
);
174 css::uno::Reference
< css::frame::XModel
> GetParentXModel() const;
175 bool CalculateNewScaling( Fraction
& aScaleWidth
, Fraction
& aScaleHeight
, Size
& aObjAreaSize
);
176 bool AddOwnLightClient();
178 // handy to get the empty replacement graphic without accessing all the old stuff
179 static Graphic
GetEmptyOLEReplacementGraphic();
181 void SetWindow(const css::uno::Reference
< css::awt::XWindow
>& _xWindow
);
183 // #i118485# missing converter added
184 virtual SdrObjectUniquePtr
DoConvertToPolyObj(bool bBezier
, bool bAddText
) const override
;
187 class SVXCORE_DLLPUBLIC SdrEmbedObjectLink final
: public sfx2::SvBaseLink
192 explicit SdrEmbedObjectLink(SdrOle2Obj
* pObj
);
193 virtual ~SdrEmbedObjectLink() override
;
195 virtual void Closed() override
;
196 virtual ::sfx2::SvBaseLink::UpdateResult
DataChanged(
197 const OUString
& rMimeType
, const css::uno::Any
& rValue
) override
;
199 void Connect() { GetRealObject(); }
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */