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