merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / ndgrf.hxx
blobfcef33fdba741fdf30b9ec90bb0b605b1b793f76
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ndgrf.hxx,v $
10 * $Revision: 1.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _NDGRF_HXX
31 #define _NDGRF_HXX
32 #include <sfx2/lnkbase.hxx>
33 #include <goodies/grfmgr.hxx>
34 #include <ndnotxt.hxx>
35 // --> OD, MAV 2005-08-17 #i53025#
36 #include <com/sun/star/embed/XStorage.hpp>
37 // <--
38 // --> OD 2007-03-28 #i73788#
39 #include <boost/shared_ptr.hpp>
40 #include <boost/weak_ptr.hpp>
41 class SwAsyncRetrieveInputStreamThreadConsumer;
42 // <--
44 class SwGrfFmtColl;
45 class SwDoc;
46 class GraphicAttr;
47 class SvStorage;
48 // --------------------
49 // SwGrfNode
50 // --------------------
51 class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
53 friend class SwNodes;
55 GraphicObject aGrfObj;
56 ::sfx2::SvBaseLinkRef refLink; // falls Grafik nur als Link, dann Pointer gesetzt
57 Size nGrfSize;
58 // String aStrmName; // SW3: Name des Storage-Streams fuer Embedded
59 String aNewStrmName; // SW3/XML: new stream name (either SW3 stream
60 // name or package url)
61 String aLowResGrf; // HTML: LowRes Grafik (Ersatzdarstellung bis
62 // die normale (HighRes) geladen ist.
63 BOOL bTransparentFlagValid :1;
64 BOOL bInSwapIn :1;
66 BOOL bGrafikArrived :1;
67 BOOL bChgTwipSize :1;
68 BOOL bChgTwipSizeFromPixel :1;
69 BOOL bLoadLowResGrf :1;
70 BOOL bFrameInPaint :1; //Um Start-/EndActions im Paint (ueber
71 //SwapIn zu verhindern.
72 BOOL bScaleImageMap :1; //Image-Map in SetTwipSize skalieren
74 // --> OD 2007-01-19 #i73788#
75 boost::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
76 bool mbLinkedInputStreamReady;
77 com::sun::star::uno::Reference<com::sun::star::io::XInputStream> mxInputStream;
78 sal_Bool mbIsStreamReadOnly;
79 // <--
81 SwGrfNode( const SwNodeIndex& rWhere,
82 const String& rGrfName, const String& rFltName,
83 const Graphic* pGraphic,
84 SwGrfFmtColl* pGrfColl,
85 SwAttrSet* pAutoAttr = 0 );
86 // Ctor fuer Einlesen (SW/G) ohne Grafik
87 SwGrfNode( const SwNodeIndex& rWhere,
88 const String& rGrfName, const String& rFltName,
89 SwGrfFmtColl* pGrfColl,
90 SwAttrSet* pAutoAttr = 0 );
91 SwGrfNode( const SwNodeIndex& rWhere,
92 const GraphicObject& rGrfObj,
93 SwGrfFmtColl* pGrfColl,
94 SwAttrSet* pAutoAttr = 0 );
96 void InsertLink( const String& rGrfName, const String& rFltName );
97 BOOL ImportGraphic( SvStream& rStrm );
98 BOOL HasStreamName() const { return aGrfObj.HasUserData(); }
99 // --> OD 2005-05-04 #i48434# - adjust return type and rename method to
100 // indicate that its an private one.
101 // --> OD 2005-08-17 #i53025#
102 // embedded graphic stream couldn't be inside a 3.1 - 5.2 storage any more.
103 // Thus, return value isn't needed any more.
104 void _GetStreamStorageNames( String& rStrmName, String& rStgName ) const;
105 // <--
106 void DelStreamName();
107 DECL_LINK( SwapGraphic, GraphicObject* );
109 /** helper method to determine stream for the embedded graphic.
111 OD 2005-05-04 #i48434#
112 Important note: caller of this method has to handle the thrown exceptions
113 OD, MAV 2005-08-17 #i53025#
114 Storage, which should contain the stream of the embedded graphic, is
115 provided via parameter. Otherwise the returned stream will be closed
116 after the the method returns, because its parent stream is closed and deleted.
117 Proposed name of embedded graphic stream is also provided by parameter.
119 @author OD
121 @param _refPics
122 input parameter - reference to storage, which should contain the
123 embedded graphic stream.
125 @param _aStrmName
126 input parameter - proposed name of the embedded graphic stream.
128 @return SvStream*
129 new created stream of the embedded graphic, which has to be destroyed
130 after its usage. Could be NULL, if the stream isn't found.
132 SvStream* _GetStreamForEmbedGrf(
133 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
134 String& _aStrmName ) const;
136 /** helper method to get a substorage of the document storage for readonly access.
138 OD, MAV 2005-08-17 #i53025#
139 A substorage with the specified name will be opened readonly. If the provided
140 name is empty the root storage will be returned.
142 @param _aStgName
143 input parameter - name of substorage. Can be empty.
145 @return XStorage
146 reference to substorage or the root storage
148 ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > _GetDocSubstorageOrRoot(
149 const String& aStgName ) const;
151 public:
152 virtual ~SwGrfNode();
153 const Graphic& GetGrf() const { return aGrfObj.GetGraphic(); }
154 const GraphicObject& GetGrfObj() const { return aGrfObj; }
155 GraphicObject& GetGrfObj() { return aGrfObj; }
157 virtual SwCntntNode *SplitCntntNode( const SwPosition & );
159 virtual Size GetTwipSize() const;
160 #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
161 void SetTwipSize( const Size& rSz );
163 BOOL IsTransparent() const;
165 inline BOOL IsAnimated() const { return aGrfObj.IsAnimated(); }
167 inline BOOL IsChgTwipSize() const { return bChgTwipSize; }
168 inline BOOL IsChgTwipSizeFromPixel() const { return bChgTwipSizeFromPixel; }
169 inline void SetChgTwipSize( BOOL b, BOOL bFromPx=FALSE ) { bChgTwipSize = b; bChgTwipSizeFromPixel = bFromPx; }
171 inline BOOL IsGrafikArrived() const { return bGrafikArrived; }
172 inline void SetGrafikArrived( BOOL b ) { bGrafikArrived = b; }
174 inline BOOL IsFrameInPaint() const { return bFrameInPaint; }
175 inline void SetFrameInPaint( BOOL b ) { bFrameInPaint = b; }
177 inline BOOL IsScaleImageMap() const { return bScaleImageMap; }
178 inline void SetScaleImageMap( BOOL b ) { bScaleImageMap = b; }
179 #endif
180 // steht in ndcopy.cxx
181 virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const;
182 #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
184 // erneutes Einlesen, falls Graphic nicht Ok ist. Die
185 // aktuelle wird durch die neue ersetzt.
186 BOOL ReRead( const String& rGrfName, const String& rFltName,
187 const Graphic* pGraphic = 0,
188 const GraphicObject* pGrfObj = 0,
189 BOOL bModify = TRUE );
190 // Laden der Grafik unmittelbar vor der Anzeige
191 short SwapIn( BOOL bWaitForData = FALSE );
192 // Entfernen der Grafik, um Speicher freizugeben
193 short SwapOut();
194 // Zugriff auf den Storage-Streamnamen
195 void SetStreamName( const String& r ) { aGrfObj.SetUserData( r ); }
196 void SetNewStreamName( const String& r ) { aNewStrmName = r; }
197 // is this node selected by any shell?
198 BOOL IsSelected() const;
199 #endif
201 // Der Grafik sagen, dass sich der Node im Undobereich befindet
202 virtual BOOL SavePersistentData();
203 virtual BOOL RestorePersistentData();
205 #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
206 // Abfrage der Link-Daten
207 BOOL IsGrfLink() const { return refLink.Is(); }
208 inline BOOL IsLinkedFile() const;
209 inline BOOL IsLinkedDDE() const;
210 ::sfx2::SvBaseLinkRef GetLink() const { return refLink; }
211 BOOL GetFileFilterNms( String* pFileNm, String* pFilterNm ) const;
212 void ReleaseLink();
214 // Prioritaet beim Laden der Grafik setzen. Geht nur, wenn der Link
215 // ein FileObject gesetzt hat
216 void SetTransferPriority( USHORT nPrio );
218 // Skalieren einer Image-Map: Die Image-Map wird um den Faktor
219 // zwischen Grafik-Groesse und Rahmen-Groesse vergroessert/verkleinert
220 void ScaleImageMap();
222 // returns the with our graphic attributes filled Graphic-Attr-Structure
223 GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrm* pFrm ) const;
225 #endif
226 // --> OD 2007-01-18 #i73788#
227 boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer();
228 bool IsLinkedInputStreamReady() const;
229 void TriggerAsyncRetrieveInputStream();
230 void ApplyInputStream(
231 com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
232 const sal_Bool bIsStreamReadOnly );
233 void UpdateLinkWithInputStream();
234 // <--
235 // --> OD 2008-07-21 #i90395#
236 bool IsAsyncRetrieveInputStreamPossible() const;
237 // <--
241 // ----------------------------------------------------------------------
242 // Inline Metoden aus Node.hxx - erst hier ist der TxtNode bekannt !!
243 inline SwGrfNode *SwNode::GetGrfNode()
245 return ND_GRFNODE == nNodeType ? (SwGrfNode*)this : 0;
247 inline const SwGrfNode *SwNode::GetGrfNode() const
249 return ND_GRFNODE == nNodeType ? (const SwGrfNode*)this : 0;
252 #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
253 inline BOOL SwGrfNode::IsLinkedFile() const
255 return refLink.Is() && OBJECT_CLIENT_GRF == refLink->GetObjType();
257 inline BOOL SwGrfNode::IsLinkedDDE() const
259 return refLink.Is() && OBJECT_CLIENT_DDE == refLink->GetObjType();
261 #endif
264 #endif