android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / inc / ndole.hxx
blob5caa29ab43bf68fd2c000e0e8e028ca3fe14490e
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 .
19 #ifndef INCLUDED_SW_INC_NDOLE_HXX
20 #define INCLUDED_SW_INC_NDOLE_HXX
22 #include "ndnotxt.hxx"
23 #include <svtools/embedhlp.hxx>
24 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
25 #include <rtl/ref.hxx>
27 class SwGrfFormatColl;
28 class SwDoc;
29 class SwOLENode;
30 class SwOLEListener_Impl;
31 namespace sfx2 { class SvBaseLink; }
32 class DeflateData;
34 class SW_DLLPUBLIC SwOLEObj
36 friend class SwOLENode;
38 const SwOLENode* m_pOLENode;
39 rtl::Reference<SwOLEListener_Impl> m_xListener;
41 /** Either ref or name are known. If only name is known, ref is obtained
42 on demand by GetOleRef() from Sfx. */
43 svt::EmbeddedObjectRef m_xOLERef;
44 OUString m_aName;
46 // eventually buffered data if it is a chart OLE
47 drawinglayer::primitive2d::Primitive2DContainer m_aPrimitive2DSequence;
48 basegfx::B2DRange m_aRange;
49 sal_uInt32 m_nGraphicVersion;
50 std::unique_ptr<DeflateData> m_pDeflateData;
52 SwOLEObj( const SwOLEObj& rObj ) = delete;
54 void SetNode( SwOLENode* pNode );
56 DECL_LINK(IsProtectedHdl, LinkParamNone*, bool);
58 public:
59 SwOLEObj( const svt::EmbeddedObjectRef& pObj );
60 SwOLEObj( OUString aName, sal_Int64 nAspect );
61 ~SwOLEObj() COVERITY_NOEXCEPT_FALSE;
63 bool UnloadObject();
64 static bool UnloadObject( css::uno::Reference< css::embed::XEmbeddedObject > const & xObj,
65 const SwDoc* pDoc,
66 sal_Int64 nAspect );
68 OUString GetDescription();
70 css::uno::Reference < css::embed::XEmbeddedObject > const & GetOleRef();
71 svt::EmbeddedObjectRef& GetObject();
72 const OUString& GetCurrentPersistName() const { return m_aName; }
73 OUString GetStyleString();
74 bool IsOleRef() const; ///< To avoid unnecessary loading of object.
75 bool IsProtected() const;
77 // try to get OLE visualization in form of a Primitive2DSequence
78 // and the corresponding B2DRange. This data may be locally buffered
79 drawinglayer::primitive2d::Primitive2DContainer const & tryToGetChartContentAsPrimitive2DSequence(
80 basegfx::B2DRange& rRange,
81 bool bSynchron);
82 void resetBufferedData();
84 void dumpAsXml(xmlTextWriterPtr pWriter) const;
87 // SwOLENode
89 class SW_DLLPUBLIC SwOLENode final: public SwNoTextNode
91 friend class SwNodes;
92 mutable SwOLEObj maOLEObj;
93 OUString msChartTableName; ///< with chart objects: name of referenced table.
94 bool mbOLESizeInvalid; /**< Should be considered at SwDoc::PrtOLENotify
95 (e.g. copied). Is not persistent. */
97 sfx2::SvBaseLink* mpObjectLink;
98 OUString maLinkURL;
100 SwOLENode( SwNode& rWhere,
101 const svt::EmbeddedObjectRef&,
102 SwGrfFormatColl *pGrfColl,
103 SwAttrSet const * pAutoAttr );
105 SwOLENode( SwNode& rWhere,
106 const OUString &rName,
107 sal_Int64 nAspect,
108 SwGrfFormatColl *pGrfColl,
109 SwAttrSet const * pAutoAttr );
111 SwOLENode( const SwOLENode & ) = delete;
113 using SwNoTextNode::GetGraphic;
115 public:
116 const SwOLEObj& GetOLEObj() const { return maOLEObj; }
117 SwOLEObj& GetOLEObj() { return maOLEObj; }
118 virtual ~SwOLENode() override;
120 /// Is in ndcopy.cxx.
121 virtual SwContentNode* MakeCopy(SwDoc&, SwNode& rWhere, bool bNewFrames) const override;
123 virtual Size GetTwipSize() const override;
125 const Graphic* GetGraphic();
127 void GetNewReplacement();
129 virtual bool SavePersistentData() override;
130 virtual bool RestorePersistentData() override;
132 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
134 bool IsInGlobalDocSection() const;
135 bool IsOLEObjectDeleted() const;
137 bool IsOLESizeInvalid() const { return mbOLESizeInvalid; }
138 void SetOLESizeInvalid( bool b ){ mbOLESizeInvalid = b; }
140 sal_Int64 GetAspect() const { return maOLEObj.GetObject().GetViewAspect(); }
141 void SetAspect( sal_Int64 nAspect) { maOLEObj.GetObject().SetViewAspect( nAspect ); }
143 /** Remove OLE-object from "memory".
144 inline void Unload() { aOLEObj.Unload(); } */
145 OUString GetDescription() const { return maOLEObj.GetDescription(); }
147 bool UpdateLinkURL_Impl();
148 void BreakFileLink_Impl();
149 void DisconnectFileLink_Impl();
151 void CheckFileLink_Impl();
153 // #i99665#
154 bool IsChart() const;
156 const OUString& GetChartTableName() const { return msChartTableName; }
157 void SetChartTableName( const OUString& rNm ) { msChartTableName = rNm; }
160 // react on visual change (invalidate)
161 void SetChanged();
164 /// Inline methods from Node.hxx
165 inline SwOLENode *SwNode::GetOLENode()
167 return SwNodeType::Ole == m_nNodeType ? static_cast<SwOLENode*>(this) : nullptr;
170 inline const SwOLENode *SwNode::GetOLENode() const
172 return SwNodeType::Ole == m_nNodeType ? static_cast<const SwOLENode*>(this) : nullptr;
175 namespace sw
177 class DocumentSettingManager;
180 class PurgeGuard
182 private:
183 ::sw::DocumentSettingManager &m_rManager;
184 bool m_bOrigPurgeOle;
185 public:
186 PurgeGuard(const SwDoc& rDoc);
187 ~PurgeGuard() COVERITY_NOEXCEPT_FALSE;
190 #endif // _ INCLUDED_SW_INC_NDOLE_HXX
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */