xref: /AOO41X/main/sw/inc/ndole.hxx (revision 8809db7a87f97847b57a57f4cd2b0104b2b83182)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _NDOLE_HXX
24 #define _NDOLE_HXX
25 
26 #include <ndnotxt.hxx>
27 
28 #include <svtools/embedhlp.hxx>
29 
30 class SwGrfFmtColl;
31 class SwDoc;
32 class SwOLENode;
33 
34 class SwOLEListener_Impl;
35 class SwEmbedObjectLink;
36 class SW_DLLPUBLIC SwOLEObj
37 {
38     friend class SwOLENode;
39 
40     const SwOLENode* pOLENd;
41     SwOLEListener_Impl* pListener;
42 
43     //Entweder Ref oder Name sind bekannt, wenn nur der Name bekannt ist, wird
44     //dir Ref bei Anforderung durch GetOleRef() vom Sfx besorgt.
45     svt::EmbeddedObjectRef xOLERef;
46     String aName;
47 
48     SwOLEObj( const SwOLEObj& rObj );   //nicht erlaubt.
49     SwOLEObj();
50 
51     void SetNode( SwOLENode* pNode );
52 
53 public:
54     SwOLEObj( const svt::EmbeddedObjectRef& pObj );
55     SwOLEObj( const String &rName, sal_Int64 nAspect );
56     ~SwOLEObj();
57 
58     sal_Bool UnloadObject();
59     static sal_Bool UnloadObject( ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject > xObj,
60                                 const SwDoc* pDoc,
61                                 sal_Int64 nAspect );
62 
63     String GetDescription();
64 
65 #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
66     const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > GetOleRef();
67     svt::EmbeddedObjectRef& GetObject();
68     const String& GetCurrentPersistName() const { return aName; }
69     sal_Bool IsOleRef() const;  //Damit das Objekt nicht unnoetig geladen werden muss.
70 #endif
71 };
72 
73 
74 // --------------------
75 // SwOLENode
76 // --------------------
77 
78 class SW_DLLPUBLIC SwOLENode: public SwNoTxtNode
79 {
80     friend class SwNodes;
81     mutable SwOLEObj aOLEObj;
82     Graphic*    pGraphic;
83     String sChartTblName;       // bei Chart Objecten: Name der ref. Tabelle
84     sal_Bool   bOLESizeInvalid;     //Soll beim SwDoc::PrtOLENotify beruecksichtig
85                                 //werden (zum Beispiel kopiert). Ist nicht
86                                 //Persistent.
87 
88     SwEmbedObjectLink*  mpObjectLink;
89     String maLinkURL;
90 
91     SwOLENode(  const SwNodeIndex &rWhere,
92                 const svt::EmbeddedObjectRef&,
93                 SwGrfFmtColl *pGrfColl,
94                 SwAttrSet* pAutoAttr = 0 );
95 
96     SwOLENode(  const SwNodeIndex &rWhere,
97                 const String &rName,
98                 sal_Int64 nAspect,
99                 SwGrfFmtColl *pGrfColl,
100                 SwAttrSet* pAutoAttr = 0 );
101 
102     // aOLEObj besitzt einen privaten Copy-CTOR, wir brauchen auch einen:
103     SwOLENode( const SwOLENode & );
104 
105     using SwNoTxtNode::GetGraphic;
106 
107 public:
108     const SwOLEObj& GetOLEObj() const { return aOLEObj; }
109           SwOLEObj& GetOLEObj()       { return aOLEObj; }
110     ~SwOLENode();
111 
112     virtual SwCntntNode *SplitCntntNode( const SwPosition & );
113         // steht in ndcopy.cxx
114     virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const;
115 
116     virtual Size GetTwipSize() const;
117 
118     Graphic* GetGraphic();
119 
120     Graphic* GetHCGraphic(); // tries to retrieve HighContrast representation if possible
121     void GetNewReplacement();
122 
123     virtual sal_Bool SavePersistentData();
124     virtual sal_Bool RestorePersistentData();
125 
126     sal_Bool IsInGlobalDocSection() const;
127     sal_Bool IsOLEObjectDeleted() const;
128 
129     sal_Bool IsOLESizeInvalid() const   { return bOLESizeInvalid; }
130     void SetOLESizeInvalid( sal_Bool b ){ bOLESizeInvalid = b; }
131 
132     sal_Int64 GetAspect() const { return aOLEObj.GetObject().GetViewAspect(); }
133     void SetAspect( sal_Int64 nAspect) { aOLEObj.GetObject().SetViewAspect( nAspect ); }
134 
135     // OLE-Object aus dem "Speicher" entfernen
136     // inline void Unload() { aOLEObj.Unload(); }
137     String GetDescription() const { return aOLEObj.GetDescription(); }
138 
139     sal_Bool UpdateLinkURL_Impl();
140     void BreakFileLink_Impl();
141     void DisconnectFileLink_Impl();
142 
143     void CheckFileLink_Impl();
144 
145     // --> OD 2009-03-05 #i99665#
146     bool IsChart() const;
147     // <--
148 
149 #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
150     const String& GetChartTblName() const       { return sChartTblName; }
151     void SetChartTblName( const String& rNm )   { sChartTblName = rNm; }
152 #endif
153 };
154 
155 
156 // Inline Metoden aus Node.hxx - erst hier ist der TxtNode bekannt !!
157 inline SwOLENode *SwNode::GetOLENode()
158 {
159      return ND_OLENODE == nNodeType ? (SwOLENode*)this : 0;
160 }
161 inline const SwOLENode *SwNode::GetOLENode() const
162 {
163      return ND_OLENODE == nNodeType ? (const SwOLENode*)this : 0;
164 }
165 
166 #endif  // _NDOLE_HXX
167