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 48*172c67b2SArmin Le Grand GraphicObject maGrfObj; 49ddde725dSArmin 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 ); 92*172c67b2SArmin Le Grand sal_Bool HasStreamName() const { return maGrfObj.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(); 147*172c67b2SArmin Le Grand const Graphic& GetGrf() const { return maGrfObj.GetGraphic(); } 148*172c67b2SArmin Le Grand const GraphicObject& GetGrfObj() const { return maGrfObj; } 149ddde725dSArmin Le Grand const GraphicObject* GetReplacementGrfObj() const; 150cdf0e10cSrcweir virtual SwCntntNode *SplitCntntNode( const SwPosition & ); 151cdf0e10cSrcweir 152*172c67b2SArmin Le Grand /// isolated only way to set GraphicObject to allow more actions when doing so 153*172c67b2SArmin Le Grand void SetGraphic(const Graphic& rGraphic, const String& rLink); 154*172c67b2SArmin Le Grand 155*172c67b2SArmin Le Grand /// wrappers for non-const calls at GraphicObject 156*172c67b2SArmin Le Grand void ReleaseGraphicFromCache() { maGrfObj.ReleaseFromCache(); } 157*172c67b2SArmin Le Grand void DrawGraphicWithPDFHandling(OutputDevice& rOutDev, const Point& rPt, const Size& rSz, const GraphicAttr* pGrfAttr = NULL, const sal_uLong nFlags = GRFMGR_DRAW_STANDARD) { maGrfObj.DrawWithPDFHandling(rOutDev, rPt, rSz, pGrfAttr, nFlags); } 158*172c67b2SArmin Le Grand void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0, const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD, OutputDevice* pFirstFrameOutDev = NULL) { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pAttr, nFlags, pFirstFrameOutDev); } 159*172c67b2SArmin Le Grand void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); } 160*172c67b2SArmin Le Grand 161*172c67b2SArmin Le Grand /// allow reaction on change of content of GraphicObject, so always call 162*172c67b2SArmin Le Grand /// when GraphicObject content changes 163*172c67b2SArmin Le Grand void onGraphicChanged(); 164*172c67b2SArmin Le Grand 165*172c67b2SArmin Le Grand virtual Size GetTwipSize() const; 166cdf0e10cSrcweir #ifndef _FESHVIEW_ONLY_INLINE_NEEDED 167cdf0e10cSrcweir void SetTwipSize( const Size& rSz ); 168cdf0e10cSrcweir 169cdf0e10cSrcweir sal_Bool IsTransparent() const; 170cdf0e10cSrcweir 171*172c67b2SArmin Le Grand inline sal_Bool IsAnimated() const { return maGrfObj.IsAnimated(); } 172cdf0e10cSrcweir 173cdf0e10cSrcweir inline sal_Bool IsChgTwipSize() const { return bChgTwipSize; } 174cdf0e10cSrcweir inline sal_Bool IsChgTwipSizeFromPixel() const { return bChgTwipSizeFromPixel; } 175cdf0e10cSrcweir inline void SetChgTwipSize( sal_Bool b, sal_Bool bFromPx=sal_False ) { bChgTwipSize = b; bChgTwipSizeFromPixel = bFromPx; } 176cdf0e10cSrcweir 177cdf0e10cSrcweir inline sal_Bool IsGrafikArrived() const { return bGrafikArrived; } 178cdf0e10cSrcweir inline void SetGrafikArrived( sal_Bool b ) { bGrafikArrived = b; } 179cdf0e10cSrcweir 180cdf0e10cSrcweir inline sal_Bool IsFrameInPaint() const { return bFrameInPaint; } 181cdf0e10cSrcweir inline void SetFrameInPaint( sal_Bool b ) { bFrameInPaint = b; } 182cdf0e10cSrcweir 183cdf0e10cSrcweir inline sal_Bool IsScaleImageMap() const { return bScaleImageMap; } 184cdf0e10cSrcweir inline void SetScaleImageMap( sal_Bool b ) { bScaleImageMap = b; } 185cdf0e10cSrcweir #endif 186cdf0e10cSrcweir // steht in ndcopy.cxx 187cdf0e10cSrcweir virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const; 188cdf0e10cSrcweir #ifndef _FESHVIEW_ONLY_INLINE_NEEDED 189cdf0e10cSrcweir 190cdf0e10cSrcweir // erneutes Einlesen, falls Graphic nicht Ok ist. Die 191cdf0e10cSrcweir // aktuelle wird durch die neue ersetzt. 192cdf0e10cSrcweir sal_Bool ReRead( const String& rGrfName, const String& rFltName, 193cdf0e10cSrcweir const Graphic* pGraphic = 0, 194cdf0e10cSrcweir const GraphicObject* pGrfObj = 0, 195cdf0e10cSrcweir sal_Bool bModify = sal_True ); 196cdf0e10cSrcweir // Laden der Grafik unmittelbar vor der Anzeige 197cdf0e10cSrcweir short SwapIn( sal_Bool bWaitForData = sal_False ); 198cdf0e10cSrcweir // Entfernen der Grafik, um Speicher freizugeben 199cdf0e10cSrcweir short SwapOut(); 200cdf0e10cSrcweir // Zugriff auf den Storage-Streamnamen 201*172c67b2SArmin Le Grand void SetStreamName( const String& r ) { maGrfObj.SetUserData( r ); } 202cdf0e10cSrcweir void SetNewStreamName( const String& r ) { aNewStrmName = r; } 203cdf0e10cSrcweir // is this node selected by any shell? 204cdf0e10cSrcweir sal_Bool IsSelected() const; 205cdf0e10cSrcweir #endif 206cdf0e10cSrcweir 207cdf0e10cSrcweir // Der Grafik sagen, dass sich der Node im Undobereich befindet 208cdf0e10cSrcweir virtual sal_Bool SavePersistentData(); 209cdf0e10cSrcweir virtual sal_Bool RestorePersistentData(); 210cdf0e10cSrcweir 211cdf0e10cSrcweir #ifndef _FESHVIEW_ONLY_INLINE_NEEDED 212cdf0e10cSrcweir // Abfrage der Link-Daten 213cdf0e10cSrcweir sal_Bool IsGrfLink() const { return refLink.Is(); } 214cdf0e10cSrcweir inline sal_Bool IsLinkedFile() const; 215cdf0e10cSrcweir inline sal_Bool IsLinkedDDE() const; 216cdf0e10cSrcweir ::sfx2::SvBaseLinkRef GetLink() const { return refLink; } 217cdf0e10cSrcweir sal_Bool GetFileFilterNms( String* pFileNm, String* pFilterNm ) const; 218cdf0e10cSrcweir void ReleaseLink(); 219cdf0e10cSrcweir 220cdf0e10cSrcweir // Skalieren einer Image-Map: Die Image-Map wird um den Faktor 221cdf0e10cSrcweir // zwischen Grafik-Groesse und Rahmen-Groesse vergroessert/verkleinert 222cdf0e10cSrcweir void ScaleImageMap(); 223cdf0e10cSrcweir 224cdf0e10cSrcweir // returns the with our graphic attributes filled Graphic-Attr-Structure 225cdf0e10cSrcweir GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrm* pFrm ) const; 226cdf0e10cSrcweir 227cdf0e10cSrcweir #endif 228cdf0e10cSrcweir // --> OD 2007-01-18 #i73788# 229cdf0e10cSrcweir boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer(); 230cdf0e10cSrcweir bool IsLinkedInputStreamReady() const; 231cdf0e10cSrcweir void TriggerAsyncRetrieveInputStream(); 232cdf0e10cSrcweir void ApplyInputStream( 233cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream, 234cdf0e10cSrcweir const sal_Bool bIsStreamReadOnly ); 235cdf0e10cSrcweir void UpdateLinkWithInputStream(); 236cdf0e10cSrcweir // <-- 237cdf0e10cSrcweir // --> OD 2008-07-21 #i90395# 238cdf0e10cSrcweir bool IsAsyncRetrieveInputStreamPossible() const; 239cdf0e10cSrcweir // <-- 240cdf0e10cSrcweir }; 241cdf0e10cSrcweir 242cdf0e10cSrcweir 243cdf0e10cSrcweir // ---------------------------------------------------------------------- 244cdf0e10cSrcweir // Inline Metoden aus Node.hxx - erst hier ist der TxtNode bekannt !! 245cdf0e10cSrcweir inline SwGrfNode *SwNode::GetGrfNode() 246cdf0e10cSrcweir { 247cdf0e10cSrcweir return ND_GRFNODE == nNodeType ? (SwGrfNode*)this : 0; 248cdf0e10cSrcweir } 249cdf0e10cSrcweir inline const SwGrfNode *SwNode::GetGrfNode() const 250cdf0e10cSrcweir { 251cdf0e10cSrcweir return ND_GRFNODE == nNodeType ? (const SwGrfNode*)this : 0; 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir #ifndef _FESHVIEW_ONLY_INLINE_NEEDED 255cdf0e10cSrcweir inline sal_Bool SwGrfNode::IsLinkedFile() const 256cdf0e10cSrcweir { 257cdf0e10cSrcweir return refLink.Is() && OBJECT_CLIENT_GRF == refLink->GetObjType(); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir inline sal_Bool SwGrfNode::IsLinkedDDE() const 260cdf0e10cSrcweir { 261cdf0e10cSrcweir return refLink.Is() && OBJECT_CLIENT_DDE == refLink->GetObjType(); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir #endif 264cdf0e10cSrcweir 265cdf0e10cSrcweir 266cdf0e10cSrcweir #endif 267