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