LCOV - code coverage report
Current view: top level - sw/inc - ndgrf.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 24 29 82.8 %
Date: 2014-04-11 Functions: 17 22 77.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SW_INC_NDGRF_HXX
      21             : #define INCLUDED_SW_INC_NDGRF_HXX
      22             : #include <sfx2/lnkbase.hxx>
      23             : #include <svtools/grfmgr.hxx>
      24             : #include <ndnotxt.hxx>
      25             : #include <com/sun/star/embed/XStorage.hpp>
      26             : #include <boost/shared_ptr.hpp>
      27             : #include <boost/weak_ptr.hpp>
      28             : class SwAsyncRetrieveInputStreamThreadConsumer;
      29             : 
      30             : class SwGrfFmtColl;
      31             : class SwDoc;
      32             : class GraphicAttr;
      33             : class SvStorage;
      34             : 
      35             : // SwGrfNode
      36             : class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
      37             : {
      38             :     friend class SwNodes;
      39             : 
      40             :     GraphicObject maGrfObj;
      41             :     GraphicObject *mpReplacementGraphic;
      42             :     ::sfx2::SvBaseLinkRef refLink;       ///< If graphics only as link then pointer is set.
      43             :     Size nGrfSize;
      44             :     OUString aLowResGrf;                   ///< HTML: LowRes graphics (substitute until regular HighRes graphics is loaded).
      45             :     bool bInSwapIn              :1;
      46             : 
      47             :     bool bGraphicArrived        :1;
      48             :     bool bChgTwipSize           :1;
      49             :     bool bChgTwipSizeFromPixel  :1;
      50             :     bool bFrameInPaint          :1; ///< To avoid Start-/EndActions in Paint via SwapIn.
      51             :     bool bScaleImageMap         :1; ///< Scale image map in SetTwipSize.
      52             : 
      53             :     boost::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
      54             :     bool mbLinkedInputStreamReady;
      55             :     com::sun::star::uno::Reference<com::sun::star::io::XInputStream> mxInputStream;
      56             :     bool mbIsStreamReadOnly;
      57             : 
      58             :     SwGrfNode( const SwNodeIndex& rWhere,
      59             :                const OUString& rGrfName, const OUString& rFltName,
      60             :                const Graphic* pGraphic,
      61             :                SwGrfFmtColl* pGrfColl,
      62             :                SwAttrSet* pAutoAttr = 0 );
      63             :     ///< Ctor for reading (SW/G) without graphics.
      64             :     SwGrfNode( const SwNodeIndex& rWhere,
      65             :                const OUString& rGrfName, const OUString& rFltName,
      66             :                SwGrfFmtColl* pGrfColl,
      67             :                SwAttrSet* pAutoAttr = 0 );
      68             :     SwGrfNode( const SwNodeIndex& rWhere,
      69             :                const GraphicObject& rGrfObj,
      70             :                SwGrfFmtColl* pGrfColl,
      71             :                SwAttrSet* pAutoAttr = 0 );
      72             : 
      73             :     void InsertLink( const OUString& rGrfName, const OUString& rFltName );
      74             :     bool ImportGraphic( SvStream& rStrm );
      75         315 :     bool HasStreamName() const { return maGrfObj.HasUserData(); }
      76             :     /** adjust return type and rename method to
      77             :        indicate that its an private one. */
      78             : 
      79             :     void DelStreamName();
      80             :     DECL_LINK( SwapGraphic, GraphicObject* );
      81             : 
      82             :     /** helper method to determine stream for the embedded graphic.
      83             : 
      84             :         Important note: caller of this method has to handle the thrown exceptions
      85             :         Storage, which should contain the stream of the embedded graphic, is
      86             :         provided via parameter. Otherwise the returned stream will be closed
      87             :         after the method returns, because its parent stream is closed and deleted.
      88             :         Proposed name of embedded graphic stream is also provided by parameter.
      89             : 
      90             :         @author OD
      91             : 
      92             :         @param _refPics
      93             :         input parameter - reference to storage, which should contain the
      94             :         embedded graphic stream.
      95             : 
      96             :         @param rStrmName
      97             :         input parameter - proposed name of the embedded graphic stream.
      98             : 
      99             :         @return SvStream*
     100             :         new created stream of the embedded graphic, which has to be destroyed
     101             :         after its usage. Could be NULL, if the stream isn't found.
     102             :     */
     103             :     SvStream* _GetStreamForEmbedGrf(
     104             :             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
     105             :             const OUString& rStreamName ) const;
     106             : 
     107             :     /** helper method to get a substorage of the document storage for readonly access.
     108             : 
     109             :         A substorage with the specified name will be opened readonly. If the provided
     110             :         name is empty the root storage will be returned.
     111             : 
     112             :         @param _aStgName
     113             :         input parameter - name of substorage. Can be empty.
     114             : 
     115             :         @return XStorage
     116             :         reference to substorage or the root storage
     117             :     */
     118             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > _GetDocSubstorageOrRoot(
     119             :                                                 const OUString& aStgName ) const;
     120             : 
     121             : public:
     122             :     virtual ~SwGrfNode();
     123         464 :     const Graphic&          GetGrf() const      { return maGrfObj.GetGraphic(); }
     124         755 :     const GraphicObject&    GetGrfObj() const   { return maGrfObj; }
     125             :     const GraphicObject* GetReplacementGrfObj() const;
     126             :     virtual SwCntntNode *SplitCntntNode( const SwPosition & ) SAL_OVERRIDE;
     127             : 
     128             :     /// isolated only way to set GraphicObject to allow more actions when doing so
     129             :     void SetGraphic(const Graphic& rGraphic, const OUString& rLink);
     130             : 
     131             :     /// wrappers for non-const calls at GraphicObject
     132          79 :     void ReleaseGraphicFromCache() { maGrfObj.ReleaseFromCache(); }
     133           0 :     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); }
     134           0 :     void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); }
     135             : 
     136             :     /// allow reaction on change of content of GraphicObject, so always call
     137             :     /// when GraphicObject content changes
     138             :     void onGraphicChanged();
     139             : 
     140             :     virtual Size GetTwipSize() const SAL_OVERRIDE;
     141             :     void SetTwipSize( const Size& rSz );
     142             : 
     143             :     bool IsTransparent() const;
     144             : 
     145         962 :     bool IsAnimated() const              { return maGrfObj.IsAnimated(); }
     146             : 
     147           0 :     bool IsChgTwipSize() const           { return bChgTwipSize; }
     148          14 :     bool IsChgTwipSizeFromPixel() const  { return bChgTwipSizeFromPixel; }
     149         314 :     void SetChgTwipSize( bool b, bool bFromPx=false )
     150             :     {
     151         314 :         bChgTwipSize = b;
     152         314 :         bChgTwipSizeFromPixel = bFromPx;
     153         314 :     }
     154             : 
     155           0 :     bool IsGraphicArrived() const        { return bGraphicArrived; }
     156          14 :     void SetGraphicArrived( bool b )     { bGraphicArrived = b; }
     157             : 
     158          14 :     bool IsFrameInPaint() const          { return bFrameInPaint; }
     159         148 :     void SetFrameInPaint( bool b )       { bFrameInPaint = b; }
     160             : 
     161         315 :     bool IsScaleImageMap() const         { return bScaleImageMap; }
     162           0 :     void SetScaleImageMap( bool b )      { bScaleImageMap = b; }
     163             : 
     164             :     /// in ndcopy.cxx
     165             :     virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const SAL_OVERRIDE;
     166             : 
     167             :     /** Re-read in case graphic was not OK. The current one
     168             :        gets replaced by the new one. */
     169             :     bool ReRead( const OUString& rGrfName, const OUString& rFltName,
     170             :                  const Graphic* pGraphic = 0,
     171             :                  const GraphicObject* pGrfObj = 0,
     172             :                  bool bModify = true );
     173             :     /// Loading of graphic immediately before displaying.
     174             :     bool SwapIn( bool bWaitForData = false );
     175             :     /// Remove graphic in order to free memory.
     176             :     bool SwapOut();
     177             :     /// Access to storage stream-name.
     178             :     void SetStreamName( const OUString& r ) { maGrfObj.SetUserData( r ); }
     179             :     /// Is this node selected by any shell?
     180             :     bool IsSelected() const;
     181             : 
     182             :     /// Communicate to graphic that node is in Undo-range.
     183             :     virtual bool SavePersistentData() SAL_OVERRIDE;
     184             :     virtual bool RestorePersistentData() SAL_OVERRIDE;
     185             : 
     186             :     /// Query link-data.
     187          55 :     bool IsGrfLink() const                  { return refLink.Is(); }
     188             :     bool IsLinkedFile() const;
     189             :     bool IsLinkedDDE() const;
     190          24 :     ::sfx2::SvBaseLinkRef GetLink() const    { return refLink; }
     191             :     bool GetFileFilterNms( OUString* pFileNm, OUString* pFilterNm ) const;
     192             :     void ReleaseLink();
     193             : 
     194             :     /** Scale an image-map: the image-map becomes zoomed in / out by
     195             :        factor between graphic-size and border-size. */
     196             :     void ScaleImageMap();
     197             : 
     198             :     /// Returns the with our graphic attributes filled Graphic-Attr-Structure.
     199             :     GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrm* pFrm ) const;
     200             : 
     201             :     boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer();
     202             :     bool IsLinkedInputStreamReady() const;
     203             :     void TriggerAsyncRetrieveInputStream();
     204             :     void ApplyInputStream(
     205             :         com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
     206             :         const bool bIsStreamReadOnly );
     207             :     void UpdateLinkWithInputStream();
     208             :     bool IsAsyncRetrieveInputStreamPossible() const;
     209             : };
     210             : 
     211             : // Inline methods from Node.hxx - it is only now that we know TxtNode!!
     212        2876 : inline       SwGrfNode   *SwNode::GetGrfNode()
     213             : {
     214        2876 :      return ND_GRFNODE == nNodeType ? (SwGrfNode*)this : 0;
     215             : }
     216             : 
     217        1772 : inline const SwGrfNode   *SwNode::GetGrfNode() const
     218             : {
     219        1772 :      return ND_GRFNODE == nNodeType ? (const SwGrfNode*)this : 0;
     220             : }
     221             : 
     222         208 : inline bool SwGrfNode::IsLinkedFile() const
     223             : {
     224         208 :     return refLink.Is() && OBJECT_CLIENT_GRF == refLink->GetObjType();
     225             : }
     226             : 
     227          54 : inline bool SwGrfNode::IsLinkedDDE() const
     228             : {
     229          54 :     return refLink.Is() && OBJECT_CLIENT_DDE == refLink->GetObjType();
     230             : }
     231             : 
     232             : #endif
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10