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 SwGrfFmtColl;
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 ); /// Not allowed.
45 : SwOLEObj();
46 :
47 : void SetNode( SwOLENode* pNode );
48 :
49 : public:
50 : SwOLEObj( const svt::EmbeddedObjectRef& pObj );
51 : SwOLEObj( const OUString &rName, sal_Int64 nAspect );
52 : ~SwOLEObj();
53 :
54 : bool UnloadObject();
55 : static bool UnloadObject( ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject > xObj,
56 : const SwDoc* pDoc,
57 : sal_Int64 nAspect );
58 :
59 : OUString GetDescription();
60 :
61 : const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > GetOleRef();
62 : svt::EmbeddedObjectRef& GetObject();
63 64 : OUString GetCurrentPersistName() const { return aName; }
64 : OUString GetStyleString();
65 : bool IsOleRef() const; ///< To avoid unnecessary loading of object.
66 : };
67 :
68 : // SwOLENode
69 :
70 : class SW_DLLPUBLIC SwOLENode: public SwNoTxtNode
71 : {
72 : friend class SwNodes;
73 : mutable SwOLEObj aOLEObj;
74 : Graphic* pGraphic;
75 : OUString sChartTblName; ///< with chart objects: name of referenced table.
76 : bool bOLESizeInvalid; /**< Should be considered at SwDoc::PrtOLENotify
77 : (e.g. copied). Is not persistent. */
78 :
79 : SwEmbedObjectLink* mpObjectLink;
80 : OUString maLinkURL;
81 :
82 : SwOLENode( const SwNodeIndex &rWhere,
83 : const svt::EmbeddedObjectRef&,
84 : SwGrfFmtColl *pGrfColl,
85 : SwAttrSet* pAutoAttr = 0 );
86 :
87 : SwOLENode( const SwNodeIndex &rWhere,
88 : const OUString &rName,
89 : sal_Int64 nAspect,
90 : SwGrfFmtColl *pGrfColl,
91 : SwAttrSet* pAutoAttr = 0 );
92 :
93 : /// aOLEObj has a private Copy-Ctor. We need one too:
94 : SwOLENode( const SwOLENode & );
95 :
96 : using SwNoTxtNode::GetGraphic;
97 :
98 : public:
99 2 : const SwOLEObj& GetOLEObj() const { return aOLEObj; }
100 6545 : SwOLEObj& GetOLEObj() { return aOLEObj; }
101 : virtual ~SwOLENode();
102 :
103 : virtual SwCntntNode *SplitCntntNode( const SwPosition & ) SAL_OVERRIDE;
104 :
105 : /// Is in ndcopy.cxx.
106 : virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const SAL_OVERRIDE;
107 :
108 : virtual Size GetTwipSize() const SAL_OVERRIDE;
109 :
110 : const Graphic* GetGraphic();
111 :
112 : void GetNewReplacement();
113 :
114 : virtual bool SavePersistentData() SAL_OVERRIDE;
115 : virtual bool RestorePersistentData() SAL_OVERRIDE;
116 :
117 : bool IsInGlobalDocSection() const;
118 : bool IsOLEObjectDeleted() const;
119 :
120 3322 : bool IsOLESizeInvalid() const { return bOLESizeInvalid; }
121 580 : void SetOLESizeInvalid( bool b ){ bOLESizeInvalid = b; }
122 :
123 186 : sal_Int64 GetAspect() const { return aOLEObj.GetObject().GetViewAspect(); }
124 38 : void SetAspect( sal_Int64 nAspect) { aOLEObj.GetObject().SetViewAspect( nAspect ); }
125 :
126 : /** Remove OLE-object from "memory".
127 : inline void Unload() { aOLEObj.Unload(); } */
128 40 : OUString GetDescription() const { return aOLEObj.GetDescription(); }
129 :
130 : bool UpdateLinkURL_Impl();
131 : void BreakFileLink_Impl();
132 : void DisconnectFileLink_Impl();
133 :
134 : void CheckFileLink_Impl();
135 :
136 : // #i99665#
137 : bool IsChart() const;
138 :
139 664 : OUString GetChartTblName() const { return sChartTblName; }
140 38 : void SetChartTblName( const OUString& rNm ) { sChartTblName = rNm; }
141 : };
142 :
143 : /// Inline methods from Node.hxx
144 15216 : inline SwOLENode *SwNode::GetOLENode()
145 : {
146 15216 : return ND_OLENODE == nNodeType ? (SwOLENode*)this : 0;
147 : }
148 :
149 291 : inline const SwOLENode *SwNode::GetOLENode() const
150 : {
151 291 : return ND_OLENODE == nNodeType ? (const SwOLENode*)this : 0;
152 : }
153 :
154 : #endif // _ INCLUDED_SW_INC_NDOLE_HXX
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|