xref: /aoo42x/main/sw/inc/ndgrf.hxx (revision ddde725d)
11d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
31d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
41d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
51d2dbeb0SAndrew Rist  * distributed with this work for additional information
61d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
71d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
81d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
91d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
101d2dbeb0SAndrew Rist  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
121d2dbeb0SAndrew Rist  *
131d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
141d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
151d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
171d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
181d2dbeb0SAndrew Rist  * under the License.
191d2dbeb0SAndrew Rist  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _NDGRF_HXX
24cdf0e10cSrcweir #define _NDGRF_HXX
25cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
26cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
27cdf0e10cSrcweir #include <ndnotxt.hxx>
28cdf0e10cSrcweir // --> OD, MAV 2005-08-17 #i53025#
29cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
30cdf0e10cSrcweir // <--
31cdf0e10cSrcweir // --> OD 2007-03-28 #i73788#
32cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
33cdf0e10cSrcweir #include <boost/weak_ptr.hpp>
34cdf0e10cSrcweir class SwAsyncRetrieveInputStreamThreadConsumer;
35cdf0e10cSrcweir // <--
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class SwGrfFmtColl;
38cdf0e10cSrcweir class SwDoc;
39cdf0e10cSrcweir class GraphicAttr;
40cdf0e10cSrcweir class SvStorage;
41cdf0e10cSrcweir // --------------------
42cdf0e10cSrcweir // SwGrfNode
43cdf0e10cSrcweir // --------------------
44cdf0e10cSrcweir class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	friend class SwNodes;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 	GraphicObject aGrfObj;
49*ddde725dSArmin Le Grand 	GraphicObject* mpReplacementGraphic;
50cdf0e10cSrcweir     ::sfx2::SvBaseLinkRef refLink;       // falls Grafik nur als Link, dann Pointer gesetzt
51cdf0e10cSrcweir 	Size nGrfSize;
52cdf0e10cSrcweir //	String aStrmName;			// SW3: Name des Storage-Streams fuer Embedded
53cdf0e10cSrcweir 	String aNewStrmName;		// SW3/XML: new stream name (either SW3 stream
54cdf0e10cSrcweir 								// name or package url)
55cdf0e10cSrcweir 	String aLowResGrf;			// HTML: LowRes Grafik (Ersatzdarstellung bis
56cdf0e10cSrcweir 								// 		die normale (HighRes) geladen ist.
57cdf0e10cSrcweir 	sal_Bool bTransparentFlagValid	:1;
58cdf0e10cSrcweir 	sal_Bool bInSwapIn				:1;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	sal_Bool bGrafikArrived			:1;
61cdf0e10cSrcweir 	sal_Bool bChgTwipSize			:1;
62cdf0e10cSrcweir 	sal_Bool bChgTwipSizeFromPixel	:1;
63cdf0e10cSrcweir 	sal_Bool bLoadLowResGrf			:1;
64cdf0e10cSrcweir 	sal_Bool bFrameInPaint			:1;	//Um Start-/EndActions im Paint (ueber
65cdf0e10cSrcweir 									//SwapIn zu verhindern.
66cdf0e10cSrcweir 	sal_Bool bScaleImageMap	 		:1; //Image-Map in SetTwipSize skalieren
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     // --> OD 2007-01-19 #i73788#
69cdf0e10cSrcweir     boost::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
70cdf0e10cSrcweir     bool mbLinkedInputStreamReady;
71cdf0e10cSrcweir     com::sun::star::uno::Reference<com::sun::star::io::XInputStream> mxInputStream;
72cdf0e10cSrcweir     sal_Bool mbIsStreamReadOnly;
73cdf0e10cSrcweir     // <--
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	SwGrfNode( const SwNodeIndex& rWhere,
76cdf0e10cSrcweir 			   const String& rGrfName, const String& rFltName,
77cdf0e10cSrcweir 			   const Graphic* pGraphic,
78cdf0e10cSrcweir 			   SwGrfFmtColl* pGrfColl,
79cdf0e10cSrcweir 			   SwAttrSet* pAutoAttr = 0 );
80cdf0e10cSrcweir 	// Ctor fuer Einlesen (SW/G) ohne Grafik
81cdf0e10cSrcweir 	SwGrfNode( const SwNodeIndex& rWhere,
82cdf0e10cSrcweir 			   const String& rGrfName, const String& rFltName,
83cdf0e10cSrcweir 			   SwGrfFmtColl* pGrfColl,
84cdf0e10cSrcweir 			   SwAttrSet* pAutoAttr = 0 );
85cdf0e10cSrcweir 	SwGrfNode( const SwNodeIndex& rWhere,
86cdf0e10cSrcweir 			   const GraphicObject& rGrfObj,
87cdf0e10cSrcweir 			   SwGrfFmtColl* pGrfColl,
88cdf0e10cSrcweir 			   SwAttrSet* pAutoAttr = 0 );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	void InsertLink( const String& rGrfName, const String& rFltName );
91cdf0e10cSrcweir 	sal_Bool ImportGraphic( SvStream& rStrm );
92cdf0e10cSrcweir 	sal_Bool HasStreamName() const { return aGrfObj.HasUserData(); }
93cdf0e10cSrcweir     // --> OD 2005-05-04 #i48434# - adjust return type and rename method to
94cdf0e10cSrcweir     // indicate that its an private one.
95cdf0e10cSrcweir     // --> OD 2005-08-17 #i53025#
96cdf0e10cSrcweir     // embedded graphic stream couldn't be inside a 3.1 - 5.2 storage any more.
97cdf0e10cSrcweir     // Thus, return value isn't needed any more.
98cdf0e10cSrcweir     void _GetStreamStorageNames( String& rStrmName, String& rStgName ) const;
99cdf0e10cSrcweir     // <--
100cdf0e10cSrcweir 	void DelStreamName();
101cdf0e10cSrcweir 	DECL_LINK( SwapGraphic, GraphicObject* );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     /** helper method to determine stream for the embedded graphic.
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         OD 2005-05-04 #i48434#
106cdf0e10cSrcweir         Important note: caller of this method has to handle the thrown exceptions
107cdf0e10cSrcweir         OD, MAV 2005-08-17 #i53025#
108cdf0e10cSrcweir         Storage, which should contain the stream of the embedded graphic, is
109cdf0e10cSrcweir         provided via parameter. Otherwise the returned stream will be closed
110cdf0e10cSrcweir         after the the method returns, because its parent stream is closed and deleted.
111cdf0e10cSrcweir         Proposed name of embedded graphic stream is also provided by parameter.
112cdf0e10cSrcweir 
113cdf0e10cSrcweir         @author OD
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         @param _refPics
116cdf0e10cSrcweir         input parameter - reference to storage, which should contain the
117cdf0e10cSrcweir         embedded graphic stream.
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         @param _aStrmName
120cdf0e10cSrcweir         input parameter - proposed name of the embedded graphic stream.
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         @return SvStream*
123cdf0e10cSrcweir         new created stream of the embedded graphic, which has to be destroyed
124cdf0e10cSrcweir         after its usage. Could be NULL, if the stream isn't found.
125cdf0e10cSrcweir     */
126cdf0e10cSrcweir     SvStream* _GetStreamForEmbedGrf(
127cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
128cdf0e10cSrcweir             String& _aStrmName ) const;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     /** helper method to get a substorage of the document storage for readonly access.
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         OD, MAV 2005-08-17 #i53025#
133cdf0e10cSrcweir         A substorage with the specified name will be opened readonly. If the provided
134cdf0e10cSrcweir         name is empty the root storage will be returned.
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         @param _aStgName
137cdf0e10cSrcweir         input parameter - name of substorage. Can be empty.
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         @return XStorage
140cdf0e10cSrcweir         reference to substorage or the root storage
141cdf0e10cSrcweir     */
142cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > _GetDocSubstorageOrRoot(
143cdf0e10cSrcweir                                                 const String& aStgName ) const;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir public:
146cdf0e10cSrcweir 	virtual ~SwGrfNode();
147cdf0e10cSrcweir 	const Graphic& 			GetGrf() const  	{ return aGrfObj.GetGraphic(); }
148cdf0e10cSrcweir 	const GraphicObject&	GetGrfObj() const  	{ return aGrfObj; }
149cdf0e10cSrcweir 		  GraphicObject&	GetGrfObj() 		{ return aGrfObj; }
150*ddde725dSArmin Le Grand     const GraphicObject* GetReplacementGrfObj() const;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     virtual SwCntntNode *SplitCntntNode( const SwPosition & );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	virtual Size GetTwipSize() const;
155cdf0e10cSrcweir #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
156cdf0e10cSrcweir 	void SetTwipSize( const Size& rSz );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	sal_Bool IsTransparent() const;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	inline sal_Bool IsAnimated() const				{ return aGrfObj.IsAnimated(); }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	inline sal_Bool IsChgTwipSize() const			{ return bChgTwipSize; }
163cdf0e10cSrcweir 	inline sal_Bool IsChgTwipSizeFromPixel() const	{ return bChgTwipSizeFromPixel; }
164cdf0e10cSrcweir 	inline void SetChgTwipSize( sal_Bool b, sal_Bool bFromPx=sal_False ) 		{ bChgTwipSize = b; bChgTwipSizeFromPixel = bFromPx; }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	inline sal_Bool IsGrafikArrived() const			{ return bGrafikArrived; }
167cdf0e10cSrcweir 	inline void SetGrafikArrived( sal_Bool b ) 		{ bGrafikArrived = b; }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	inline sal_Bool IsFrameInPaint() const			{ return bFrameInPaint; }
170cdf0e10cSrcweir 	inline void SetFrameInPaint( sal_Bool b )		{ bFrameInPaint = b; }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	inline sal_Bool IsScaleImageMap() const			{ return bScaleImageMap; }
173cdf0e10cSrcweir 	inline void SetScaleImageMap( sal_Bool b )		{ bScaleImageMap = b; }
174cdf0e10cSrcweir #endif
175cdf0e10cSrcweir 		// steht in ndcopy.cxx
176cdf0e10cSrcweir 	virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const;
177cdf0e10cSrcweir #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     // erneutes Einlesen, falls Graphic nicht Ok ist. Die
180cdf0e10cSrcweir     // aktuelle wird durch die neue ersetzt.
181cdf0e10cSrcweir 	sal_Bool ReRead( const String& rGrfName, const String& rFltName,
182cdf0e10cSrcweir                  const Graphic* pGraphic = 0,
183cdf0e10cSrcweir                  const GraphicObject* pGrfObj = 0,
184cdf0e10cSrcweir                  sal_Bool bModify = sal_True );
185cdf0e10cSrcweir     // Laden der Grafik unmittelbar vor der Anzeige
186cdf0e10cSrcweir 	short SwapIn( sal_Bool bWaitForData = sal_False );
187cdf0e10cSrcweir 		// Entfernen der Grafik, um Speicher freizugeben
188cdf0e10cSrcweir 	short SwapOut();
189cdf0e10cSrcweir 		// Zugriff auf den Storage-Streamnamen
190cdf0e10cSrcweir 	void SetStreamName( const String& r ) { aGrfObj.SetUserData( r ); }
191cdf0e10cSrcweir 	void SetNewStreamName( const String& r ) { aNewStrmName = r; }
192cdf0e10cSrcweir 	// is this node selected by any shell?
193cdf0e10cSrcweir 	sal_Bool IsSelected() const;
194cdf0e10cSrcweir #endif
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 		// Der Grafik sagen, dass sich der Node im Undobereich befindet
197cdf0e10cSrcweir 	virtual sal_Bool SavePersistentData();
198cdf0e10cSrcweir 	virtual sal_Bool RestorePersistentData();
199cdf0e10cSrcweir 
200cdf0e10cSrcweir #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
201cdf0e10cSrcweir 		// Abfrage der Link-Daten
202cdf0e10cSrcweir 	sal_Bool IsGrfLink() const 					{ return refLink.Is(); }
203cdf0e10cSrcweir 	inline sal_Bool IsLinkedFile() const;
204cdf0e10cSrcweir 	inline sal_Bool IsLinkedDDE() const;
205cdf0e10cSrcweir     ::sfx2::SvBaseLinkRef GetLink() const    { return refLink; }
206cdf0e10cSrcweir 	sal_Bool GetFileFilterNms( String* pFileNm, String* pFilterNm ) const;
207cdf0e10cSrcweir 	void ReleaseLink();
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	// Skalieren einer Image-Map: Die Image-Map wird um den Faktor
210cdf0e10cSrcweir 	// zwischen Grafik-Groesse und Rahmen-Groesse vergroessert/verkleinert
211cdf0e10cSrcweir 	void ScaleImageMap();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	// returns the with our graphic attributes filled Graphic-Attr-Structure
214cdf0e10cSrcweir 	GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrm* pFrm ) const;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir #endif
217cdf0e10cSrcweir     // --> OD 2007-01-18 #i73788#
218cdf0e10cSrcweir     boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer();
219cdf0e10cSrcweir     bool IsLinkedInputStreamReady() const;
220cdf0e10cSrcweir     void TriggerAsyncRetrieveInputStream();
221cdf0e10cSrcweir     void ApplyInputStream(
222cdf0e10cSrcweir         com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
223cdf0e10cSrcweir         const sal_Bool bIsStreamReadOnly );
224cdf0e10cSrcweir     void UpdateLinkWithInputStream();
225cdf0e10cSrcweir     // <--
226cdf0e10cSrcweir     // --> OD 2008-07-21 #i90395#
227cdf0e10cSrcweir     bool IsAsyncRetrieveInputStreamPossible() const;
228cdf0e10cSrcweir     // <--
229cdf0e10cSrcweir };
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 
232cdf0e10cSrcweir // ----------------------------------------------------------------------
233cdf0e10cSrcweir // Inline Metoden aus Node.hxx - erst hier ist der TxtNode bekannt !!
234cdf0e10cSrcweir inline       SwGrfNode	 *SwNode::GetGrfNode()
235cdf0e10cSrcweir {
236cdf0e10cSrcweir 	 return ND_GRFNODE == nNodeType ? (SwGrfNode*)this : 0;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir inline const SwGrfNode   *SwNode::GetGrfNode() const
239cdf0e10cSrcweir {
240cdf0e10cSrcweir 	 return ND_GRFNODE == nNodeType ? (const SwGrfNode*)this : 0;
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
244cdf0e10cSrcweir inline sal_Bool SwGrfNode::IsLinkedFile() const
245cdf0e10cSrcweir {
246cdf0e10cSrcweir 	return refLink.Is() && OBJECT_CLIENT_GRF == refLink->GetObjType();
247cdf0e10cSrcweir }
248cdf0e10cSrcweir inline sal_Bool SwGrfNode::IsLinkedDDE() const
249cdf0e10cSrcweir {
250cdf0e10cSrcweir 	return refLink.Is() && OBJECT_CLIENT_DDE == refLink->GetObjType();
251cdf0e10cSrcweir }
252cdf0e10cSrcweir #endif
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 
255cdf0e10cSrcweir #endif
256