LCOV - code coverage report
Current view: top level - sw/inc - ndgrf.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 29 34 85.3 %
Date: 2014-11-03 Functions: 20 25 80.0 %
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             :     /** adjust return type and rename method to
      76             :        indicate that its an private one. */
      77             : 
      78             :     void DelStreamName();
      79             :     DECL_LINK( SwapGraphic, GraphicObject* );
      80             : 
      81             :     /** helper method to determine stream for the embedded graphic.
      82             : 
      83             :         Important note: caller of this method has to handle the thrown exceptions
      84             :         Storage, which should contain the stream of the embedded graphic, is
      85             :         provided via parameter. Otherwise the returned stream will be closed
      86             :         after the method returns, because its parent stream is closed and deleted.
      87             :         Proposed name of embedded graphic stream is also provided by parameter.
      88             : 
      89             :         @author OD
      90             : 
      91             :         @param _refPics
      92             :         input parameter - reference to storage, which should contain the
      93             :         embedded graphic stream.
      94             : 
      95             :         @param rStrmName
      96             :         input parameter - proposed name of the embedded graphic stream.
      97             : 
      98             :         @return SvStream*
      99             :         new created stream of the embedded graphic, which has to be destroyed
     100             :         after its usage. Could be NULL, if the stream isn't found.
     101             :     */
     102             :     SvStream* _GetStreamForEmbedGrf(
     103             :             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
     104             :             const OUString& rStreamName ) const;
     105             : 
     106             :     /** helper method to get a substorage of the document storage for readonly access.
     107             : 
     108             :         A substorage with the specified name will be opened readonly. If the provided
     109             :         name is empty the root storage will be returned.
     110             : 
     111             :         @param _aStgName
     112             :         input parameter - name of substorage. Can be empty.
     113             : 
     114             :         @return XStorage
     115             :         reference to substorage or the root storage
     116             :     */
     117             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > _GetDocSubstorageOrRoot(
     118             :                                                 const OUString& aStgName ) const;
     119             : 
     120             :     /// allow reaction on change of content of GraphicObject, so always call
     121             :     /// when GraphicObject content changes
     122             :     void onGraphicChanged();
     123             : 
     124             : public:
     125             :     virtual ~SwGrfNode();
     126         582 :     const Graphic&          GetGrf() const      { return maGrfObj.GetGraphic(); }
     127         718 :     const GraphicObject&    GetGrfObj() const   { return maGrfObj; }
     128             :     const GraphicObject* GetReplacementGrfObj() const;
     129             :     virtual SwCntntNode *SplitCntntNode( const SwPosition & ) SAL_OVERRIDE;
     130             : 
     131             :     /// isolated only way to set GraphicObject to allow more actions when doing so
     132             :     void SetGraphic(const Graphic& rGraphic, const OUString& rLink);
     133             : 
     134             :     /// wrappers for non-const calls at GraphicObject
     135         162 :     void ReleaseGraphicFromCache() { maGrfObj.ReleaseFromCache(); }
     136           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); }
     137           0 :     void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); }
     138             : 
     139             :     virtual Size GetTwipSize() const SAL_OVERRIDE;
     140             :     void SetTwipSize( const Size& rSz );
     141             : 
     142             :     bool IsTransparent() const;
     143             : 
     144        2813 :     bool IsAnimated() const              { return maGrfObj.IsAnimated(); }
     145             : 
     146           0 :     bool IsChgTwipSize() const           { return bChgTwipSize; }
     147          28 :     bool IsChgTwipSizeFromPixel() const  { return bChgTwipSizeFromPixel; }
     148         758 :     void SetChgTwipSize( bool b, bool bFromPx=false )
     149             :     {
     150         758 :         bChgTwipSize = b;
     151         758 :         bChgTwipSizeFromPixel = bFromPx;
     152         758 :     }
     153             : 
     154           0 :     bool IsGraphicArrived() const        { return bGraphicArrived; }
     155          28 :     void SetGraphicArrived( bool b )     { bGraphicArrived = b; }
     156             : 
     157          28 :     bool IsFrameInPaint() const          { return bFrameInPaint; }
     158         372 :     void SetFrameInPaint( bool b )       { bFrameInPaint = b; }
     159             : 
     160         942 :     bool IsScaleImageMap() const         { return bScaleImageMap; }
     161           0 :     void SetScaleImageMap( bool b )      { bScaleImageMap = b; }
     162             : 
     163             :     /// in ndcopy.cxx
     164             :     virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const SAL_OVERRIDE;
     165             : 
     166             :     /** Re-read in case graphic was not OK. The current one
     167             :        gets replaced by the new one. */
     168             :     bool ReRead( const OUString& rGrfName, const OUString& rFltName,
     169             :                  const Graphic* pGraphic = 0,
     170             :                  const GraphicObject* pGrfObj = 0,
     171             :                  bool bModify = true );
     172             :     /// Loading of graphic immediately before displaying.
     173             :     bool SwapIn( bool bWaitForData = false );
     174             :     /// Remove graphic in order to free memory.
     175             :     bool SwapOut();
     176        1114 :     bool HasEmbeddedStreamName() const { return maGrfObj.HasUserData(); }
     177             :     /// applying new stream name for embedded graphic - needed as saving the document might change this stream name
     178           2 :     void ApplyNewEmbeddedStreamName(const OUString& r)
     179             :     {
     180           2 :         maGrfObj.SetUserData(r);
     181           2 :     }
     182             :     /// Is this node selected by any shell?
     183             :     bool IsSelected() const;
     184             : 
     185             :     /// Communicate to graphic that node is in Undo-range.
     186             :     virtual bool SavePersistentData() SAL_OVERRIDE;
     187             :     virtual bool RestorePersistentData() SAL_OVERRIDE;
     188             : 
     189             :     /// Query link-data.
     190         126 :     bool IsGrfLink() const                  { return refLink.Is(); }
     191             :     bool IsLinkedFile() const;
     192             :     bool IsLinkedDDE() const;
     193          40 :     ::sfx2::SvBaseLinkRef GetLink() const    { return refLink; }
     194             :     bool GetFileFilterNms( OUString* pFileNm, OUString* pFilterNm ) const;
     195             :     void ReleaseLink();
     196             : 
     197             :     /** Scale an image-map: the image-map becomes zoomed in / out by
     198             :        factor between graphic-size and border-size. */
     199             :     void ScaleImageMap();
     200             : 
     201             :     /// Returns the with our graphic attributes filled Graphic-Attr-Structure.
     202             :     GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrm* pFrm ) const;
     203             : 
     204           8 :     boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer() { return mpThreadConsumer;}
     205         184 :     bool IsLinkedInputStreamReady() const { return mbLinkedInputStreamReady;}
     206             :     void TriggerAsyncRetrieveInputStream();
     207             :     void ApplyInputStream(
     208             :         com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
     209             :         const bool bIsStreamReadOnly );
     210             :     void UpdateLinkWithInputStream();
     211             :     bool IsAsyncRetrieveInputStreamPossible() const;
     212             : };
     213             : 
     214             : // Inline methods from Node.hxx - it is only now that we know TxtNode!!
     215        7382 : inline       SwGrfNode   *SwNode::GetGrfNode()
     216             : {
     217        7382 :      return ND_GRFNODE == nNodeType ? (SwGrfNode*)this : 0;
     218             : }
     219             : 
     220        4784 : inline const SwGrfNode   *SwNode::GetGrfNode() const
     221             : {
     222        4784 :      return ND_GRFNODE == nNodeType ? (const SwGrfNode*)this : 0;
     223             : }
     224             : 
     225         590 : inline bool SwGrfNode::IsLinkedFile() const
     226             : {
     227         590 :     return refLink.Is() && OBJECT_CLIENT_GRF == refLink->GetObjType();
     228             : }
     229             : 
     230         278 : inline bool SwGrfNode::IsLinkedDDE() const
     231             : {
     232         278 :     return refLink.Is() && OBJECT_CLIENT_DDE == refLink->GetObjType();
     233             : }
     234             : 
     235             : #endif
     236             : 
     237             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10