Resolves tdf#142513 - Order of ZoomIn and ZoomOut at Print Preview
[LibreOffice.git] / sw / inc / ndole.hxx
blob9603ce4f44405f5a42e09f561cee513d1a4640fe
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 class SwEmbedObjectLink;
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 std::unique_ptr<DeflateData> m_pDeflateData;
51 SwOLEObj( const SwOLEObj& rObj ) = delete;
53 void SetNode( SwOLENode* pNode );
55 public:
56 SwOLEObj( const svt::EmbeddedObjectRef& pObj );
57 SwOLEObj( const OUString &rName, sal_Int64 nAspect );
58 ~SwOLEObj() COVERITY_NOEXCEPT_FALSE;
60 bool UnloadObject();
61 static bool UnloadObject( css::uno::Reference< css::embed::XEmbeddedObject > const & xObj,
62 const SwDoc* pDoc,
63 sal_Int64 nAspect );
65 OUString GetDescription();
67 css::uno::Reference < css::embed::XEmbeddedObject > const & GetOleRef();
68 svt::EmbeddedObjectRef& GetObject();
69 const OUString& GetCurrentPersistName() const { return m_aName; }
70 OUString GetStyleString();
71 bool IsOleRef() const; ///< To avoid unnecessary loading of object.
73 // try to get OLE visualization in form of a Primitive2DSequence
74 // and the corresponding B2DRange. This data may be locally buffered
75 drawinglayer::primitive2d::Primitive2DContainer const & tryToGetChartContentAsPrimitive2DSequence(
76 basegfx::B2DRange& rRange,
77 bool bSynchron);
78 void resetBufferedData();
80 void dumpAsXml(xmlTextWriterPtr pWriter) const;
83 // SwOLENode
85 class SW_DLLPUBLIC SwOLENode final: public SwNoTextNode
87 friend class SwNodes;
88 mutable SwOLEObj maOLEObj;
89 OUString msChartTableName; ///< with chart objects: name of referenced table.
90 bool mbOLESizeInvalid; /**< Should be considered at SwDoc::PrtOLENotify
91 (e.g. copied). Is not persistent. */
93 SwEmbedObjectLink* mpObjectLink;
94 OUString maLinkURL;
96 SwOLENode( const SwNodeIndex &rWhere,
97 const svt::EmbeddedObjectRef&,
98 SwGrfFormatColl *pGrfColl,
99 SwAttrSet const * pAutoAttr );
101 SwOLENode( const SwNodeIndex &rWhere,
102 const OUString &rName,
103 sal_Int64 nAspect,
104 SwGrfFormatColl *pGrfColl,
105 SwAttrSet const * pAutoAttr );
107 SwOLENode( const SwOLENode & ) = delete;
109 using SwNoTextNode::GetGraphic;
111 public:
112 const SwOLEObj& GetOLEObj() const { return maOLEObj; }
113 SwOLEObj& GetOLEObj() { return maOLEObj; }
114 virtual ~SwOLENode() override;
116 /// Is in ndcopy.cxx.
117 virtual SwContentNode* MakeCopy(SwDoc&, const SwNodeIndex&, bool bNewFrames) const override;
119 virtual Size GetTwipSize() const override;
121 const Graphic* GetGraphic();
123 void GetNewReplacement();
125 virtual bool SavePersistentData() override;
126 virtual bool RestorePersistentData() override;
128 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
130 bool IsInGlobalDocSection() const;
131 bool IsOLEObjectDeleted() const;
133 bool IsOLESizeInvalid() const { return mbOLESizeInvalid; }
134 void SetOLESizeInvalid( bool b ){ mbOLESizeInvalid = b; }
136 sal_Int64 GetAspect() const { return maOLEObj.GetObject().GetViewAspect(); }
137 void SetAspect( sal_Int64 nAspect) { maOLEObj.GetObject().SetViewAspect( nAspect ); }
139 /** Remove OLE-object from "memory".
140 inline void Unload() { aOLEObj.Unload(); } */
141 OUString GetDescription() const { return maOLEObj.GetDescription(); }
143 bool UpdateLinkURL_Impl();
144 void BreakFileLink_Impl();
145 void DisconnectFileLink_Impl();
147 void CheckFileLink_Impl();
149 // #i99665#
150 bool IsChart() const;
152 const OUString& GetChartTableName() const { return msChartTableName; }
153 void SetChartTableName( const OUString& rNm ) { msChartTableName = rNm; }
156 // react on visual change (invalidate)
157 void SetChanged();
160 /// Inline methods from Node.hxx
161 inline SwOLENode *SwNode::GetOLENode()
163 return SwNodeType::Ole == m_nNodeType ? static_cast<SwOLENode*>(this) : nullptr;
166 inline const SwOLENode *SwNode::GetOLENode() const
168 return SwNodeType::Ole == m_nNodeType ? static_cast<const SwOLENode*>(this) : nullptr;
171 namespace sw
173 class DocumentSettingManager;
176 class PurgeGuard
178 private:
179 ::sw::DocumentSettingManager &m_rManager;
180 bool m_bOrigPurgeOle;
181 public:
182 PurgeGuard(const SwDoc& rDoc);
183 ~PurgeGuard() COVERITY_NOEXCEPT_FALSE;
186 #endif // _ INCLUDED_SW_INC_NDOLE_HXX
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */