Line data Source code
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 : #ifndef INCLUDED_SW_INC_NDOLE_HXX
20 : #define INCLUDED_SW_INC_NDOLE_HXX
21 :
22 : #include <ndnotxt.hxx>
23 :
24 : #include <svtools/embedhlp.hxx>
25 :
26 : class SwGrfFormatColl;
27 : class SwDoc;
28 : class SwOLENode;
29 :
30 : class SwOLEListener_Impl;
31 : class SwEmbedObjectLink;
32 : class SW_DLLPUBLIC SwOLEObj
33 : {
34 : friend class SwOLENode;
35 :
36 : const SwOLENode* pOLENd;
37 : SwOLEListener_Impl* pListener;
38 :
39 : /** Either ref or name are known. If only name is known, ref is obtained
40 : on demand by GetOleRef() from Sfx. */
41 : svt::EmbeddedObjectRef xOLERef;
42 : OUString aName;
43 :
44 : SwOLEObj( const SwOLEObj& rObj ) SAL_DELETED_FUNCTION;
45 :
46 : void SetNode( SwOLENode* pNode );
47 :
48 : public:
49 : SwOLEObj( const svt::EmbeddedObjectRef& pObj );
50 : SwOLEObj( const OUString &rName, sal_Int64 nAspect );
51 : ~SwOLEObj();
52 :
53 : bool UnloadObject();
54 : static bool UnloadObject( ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject > xObj,
55 : const SwDoc* pDoc,
56 : sal_Int64 nAspect );
57 :
58 : OUString GetDescription();
59 :
60 : const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > GetOleRef();
61 : svt::EmbeddedObjectRef& GetObject();
62 34 : OUString GetCurrentPersistName() const { return aName; }
63 : OUString GetStyleString();
64 : bool IsOleRef() const; ///< To avoid unnecessary loading of object.
65 : };
66 :
67 : // SwOLENode
68 :
69 : class SW_DLLPUBLIC SwOLENode: public SwNoTextNode
70 : {
71 : friend class SwNodes;
72 : mutable SwOLEObj aOLEObj;
73 : OUString sChartTableName; ///< with chart objects: name of referenced table.
74 : bool bOLESizeInvalid; /**< Should be considered at SwDoc::PrtOLENotify
75 : (e.g. copied). Is not persistent. */
76 :
77 : SwEmbedObjectLink* mpObjectLink;
78 : OUString maLinkURL;
79 :
80 : SwOLENode( const SwNodeIndex &rWhere,
81 : const svt::EmbeddedObjectRef&,
82 : SwGrfFormatColl *pGrfColl,
83 : SwAttrSet* pAutoAttr = 0 );
84 :
85 : SwOLENode( const SwNodeIndex &rWhere,
86 : const OUString &rName,
87 : sal_Int64 nAspect,
88 : SwGrfFormatColl *pGrfColl,
89 : SwAttrSet* pAutoAttr = 0 );
90 :
91 : SwOLENode( const SwOLENode & ) SAL_DELETED_FUNCTION;
92 :
93 : using SwNoTextNode::GetGraphic;
94 :
95 : public:
96 0 : const SwOLEObj& GetOLEObj() const { return aOLEObj; }
97 3333 : SwOLEObj& GetOLEObj() { return aOLEObj; }
98 : virtual ~SwOLENode();
99 :
100 : virtual SwContentNode *SplitContentNode( const SwPosition & ) SAL_OVERRIDE;
101 :
102 : /// Is in ndcopy.cxx.
103 : virtual SwContentNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const SAL_OVERRIDE;
104 :
105 : virtual Size GetTwipSize() const SAL_OVERRIDE;
106 :
107 : const Graphic* GetGraphic();
108 :
109 : void GetNewReplacement();
110 :
111 : virtual bool SavePersistentData() SAL_OVERRIDE;
112 : virtual bool RestorePersistentData() SAL_OVERRIDE;
113 :
114 : bool IsInGlobalDocSection() const;
115 : bool IsOLEObjectDeleted() const;
116 :
117 1647 : bool IsOLESizeInvalid() const { return bOLESizeInvalid; }
118 310 : void SetOLESizeInvalid( bool b ){ bOLESizeInvalid = b; }
119 :
120 117 : sal_Int64 GetAspect() const { return aOLEObj.GetObject().GetViewAspect(); }
121 29 : void SetAspect( sal_Int64 nAspect) { aOLEObj.GetObject().SetViewAspect( nAspect ); }
122 :
123 : /** Remove OLE-object from "memory".
124 : inline void Unload() { aOLEObj.Unload(); } */
125 29 : OUString GetDescription() const { return aOLEObj.GetDescription(); }
126 :
127 : bool UpdateLinkURL_Impl();
128 : void BreakFileLink_Impl();
129 : void DisconnectFileLink_Impl();
130 :
131 : void CheckFileLink_Impl();
132 :
133 : // #i99665#
134 : bool IsChart() const;
135 :
136 342 : OUString GetChartTableName() const { return sChartTableName; }
137 29 : void SetChartTableName( const OUString& rNm ) { sChartTableName = rNm; }
138 : };
139 :
140 : /// Inline methods from Node.hxx
141 9577 : inline SwOLENode *SwNode::GetOLENode()
142 : {
143 9577 : return ND_OLENODE == nNodeType ? static_cast<SwOLENode*>(this) : 0;
144 : }
145 :
146 148 : inline const SwOLENode *SwNode::GetOLENode() const
147 : {
148 148 : return ND_OLENODE == nNodeType ? static_cast<const SwOLENode*>(this) : 0;
149 : }
150 :
151 : #endif // _ INCLUDED_SW_INC_NDOLE_HXX
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|