LCOV - code coverage report
Current view: top level - sw/inc - ndgrf.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 26 84.6 %
Date: 2015-06-13 12:38:46 Functions: 16 20 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 SwGrfFormatColl;
      31             : class SwDoc;
      32             : class GraphicAttr;
      33             : class SotStorage;
      34             : 
      35             : // SwGrfNode
      36             : class SW_DLLPUBLIC SwGrfNode: public SwNoTextNode
      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 bFrameInPaint          :1; ///< To avoid Start-/EndActions in Paint via SwapIn.
      50             :     bool bScaleImageMap         :1; ///< Scale image map in SetTwipSize.
      51             : 
      52             :     boost::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
      53             :     bool mbLinkedInputStreamReady;
      54             :     com::sun::star::uno::Reference<com::sun::star::io::XInputStream> mxInputStream;
      55             :     bool mbIsStreamReadOnly;
      56             : 
      57             :     SwGrfNode( const SwNodeIndex& rWhere,
      58             :                const OUString& rGrfName, const OUString& rFltName,
      59             :                const Graphic* pGraphic,
      60             :                SwGrfFormatColl* pGrfColl,
      61             :                SwAttrSet* pAutoAttr = 0 );
      62             :     ///< Ctor for reading (SW/G) without graphics.
      63             :     SwGrfNode( const SwNodeIndex& rWhere,
      64             :                const OUString& rGrfName, const OUString& rFltName,
      65             :                SwGrfFormatColl* pGrfColl,
      66             :                SwAttrSet* pAutoAttr = 0 );
      67             :     SwGrfNode( const SwNodeIndex& rWhere,
      68             :                const GraphicObject& rGrfObj,
      69             :                SwGrfFormatColl* pGrfColl,
      70             :                SwAttrSet* pAutoAttr = 0 );
      71             : 
      72             :     void InsertLink( const OUString& rGrfName, const OUString& rFltName );
      73             :     bool ImportGraphic( SvStream& rStrm );
      74             :     /** adjust return type and rename method to
      75             :        indicate that its an private one. */
      76             : 
      77             :     void DelStreamName();
      78             :     DECL_LINK( SwapGraphic, GraphicObject* );
      79             : 
      80             :     /** helper method to determine stream for the embedded graphic.
      81             : 
      82             :         Important note: caller of this method has to handle the thrown exceptions
      83             :         Storage, which should contain the stream of the embedded graphic, is
      84             :         provided via parameter. Otherwise the returned stream will be closed
      85             :         after the method returns, because its parent stream is closed and deleted.
      86             :         Proposed name of embedded graphic stream is also provided by parameter.
      87             : 
      88             :         @author OD
      89             : 
      90             :         @param _refPics
      91             :         input parameter - reference to storage, which should contain the
      92             :         embedded graphic stream.
      93             : 
      94             :         @param rStrmName
      95             :         input parameter - proposed name of the embedded graphic stream.
      96             : 
      97             :         @return SvStream*
      98             :         new created stream of the embedded graphic, which has to be destroyed
      99             :         after its usage. Could be NULL, if the stream isn't found.
     100             :     */
     101             :     SvStream* _GetStreamForEmbedGrf(
     102             :             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
     103             :             const OUString& rStreamName ) const;
     104             : 
     105             :     /** helper method to get a substorage of the document storage for readonly access.
     106             : 
     107             :         A substorage with the specified name will be opened readonly. If the provided
     108             :         name is empty the root storage will be returned.
     109             : 
     110             :         @param _aStgName
     111             :         input parameter - name of substorage. Can be empty.
     112             : 
     113             :         @return XStorage
     114             :         reference to substorage or the root storage
     115             :     */
     116             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > _GetDocSubstorageOrRoot(
     117             :                                                 const OUString& aStgName ) const;
     118             : 
     119             :     /// allow reaction on change of content of GraphicObject, so always call
     120             :     /// when GraphicObject content changes
     121             :     void onGraphicChanged();
     122             : 
     123             : public:
     124             :     virtual ~SwGrfNode();
     125             :     const Graphic&          GetGrf(bool bWait = false) const;
     126             :     const GraphicObject&    GetGrfObj(bool bWait = false) const;
     127             :     const GraphicObject* GetReplacementGrfObj() const;
     128             :     virtual SwContentNode *SplitContentNode( const SwPosition & ) SAL_OVERRIDE;
     129             : 
     130             :     /// isolated only way to set GraphicObject to allow more actions when doing so
     131             :     void SetGraphic(const Graphic& rGraphic, const OUString& rLink);
     132             : 
     133             :     /// wrappers for non-const calls at GraphicObject
     134           0 :     void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0, const GraphicAttr* pAttr = NULL, GraphicManagerDrawFlags nFlags = GraphicManagerDrawFlags::STANDARD, OutputDevice* pFirstFrameOutDev = NULL) { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pAttr, nFlags, pFirstFrameOutDev); }
     135           0 :     void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); }
     136             : 
     137             :     virtual Size GetTwipSize() const SAL_OVERRIDE;
     138             :     void SetTwipSize( const Size& rSz );
     139             : 
     140             :     bool IsTransparent() const;
     141             : 
     142        1688 :     bool IsAnimated() const              { return maGrfObj.IsAnimated(); }
     143             : 
     144           2 :     bool IsChgTwipSize() const           { return bChgTwipSize; }
     145         478 :     void SetChgTwipSize( bool b)
     146             :     {
     147         478 :         bChgTwipSize = b;
     148         478 :     }
     149             : 
     150           0 :     bool IsGraphicArrived() const        { return bGraphicArrived; }
     151          34 :     void SetGraphicArrived( bool b )     { bGraphicArrived = b; }
     152             : 
     153          34 :     bool IsFrameInPaint() const          { return bFrameInPaint; }
     154         202 :     void SetFrameInPaint( bool b )       { bFrameInPaint = b; }
     155             : 
     156         813 :     bool IsScaleImageMap() const         { return bScaleImageMap; }
     157           0 :     void SetScaleImageMap( bool b )      { bScaleImageMap = b; }
     158             : 
     159             :     /// in ndcopy.cxx
     160             :     virtual SwContentNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const SAL_OVERRIDE;
     161             : 
     162             :     /** Re-read in case graphic was not OK. The current one
     163             :        gets replaced by the new one. */
     164             :     bool ReRead( const OUString& rGrfName, const OUString& rFltName,
     165             :                  const Graphic* pGraphic = 0,
     166             :                  const GraphicObject* pGrfObj = 0,
     167             :                  bool bModify = true );
     168             : private:
     169             :     /// Loading of graphic immediately before displaying.
     170             :     bool SwapIn( bool bWaitForData = false );
     171             :     /// Remove graphic in order to free memory.
     172             :     bool SwapOut();
     173             : 
     174             : public:
     175          95 :     bool HasEmbeddedStreamName() const { return maGrfObj.HasUserData(); }
     176             : 
     177             :     /// Is this node selected by any shell?
     178             :     bool IsSelected() const;
     179             : 
     180             :     /// Communicate to graphic that node is in Undo-range.
     181             :     virtual bool SavePersistentData() SAL_OVERRIDE;
     182             :     virtual bool RestorePersistentData() SAL_OVERRIDE;
     183             : 
     184             :     /// Query link-data.
     185         104 :     bool IsGrfLink() const                  { return refLink.Is(); }
     186             :     bool IsLinkedFile() const;
     187             :     bool IsLinkedDDE() const;
     188           5 :     ::sfx2::SvBaseLinkRef GetLink() const    { return refLink; }
     189             :     bool GetFileFilterNms( OUString* pFileNm, OUString* pFilterNm ) const;
     190             :     void ReleaseLink();
     191             : 
     192             :     /** Scale an image-map: the image-map becomes zoomed in / out by
     193             :        factor between graphic-size and border-size. */
     194             :     void ScaleImageMap();
     195             : 
     196             :     /// Returns the with our graphic attributes filled Graphic-Attr-Structure.
     197             :     GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrm* pFrm ) const;
     198             : 
     199           4 :     boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer() { return mpThreadConsumer;}
     200          95 :     bool IsLinkedInputStreamReady() const { return mbLinkedInputStreamReady;}
     201             :     void TriggerAsyncRetrieveInputStream();
     202             :     void ApplyInputStream(
     203             :         com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
     204             :         const bool bIsStreamReadOnly );
     205             :     void UpdateLinkWithInputStream();
     206             :     bool IsAsyncRetrieveInputStreamPossible() const;
     207             : };
     208             : 
     209             : // Inline methods from Node.hxx - it is only now that we know TextNode!!
     210        4209 : inline       SwGrfNode   *SwNode::GetGrfNode()
     211             : {
     212        4209 :      return ND_GRFNODE == nNodeType ? static_cast<SwGrfNode*>(this) : 0;
     213             : }
     214             : 
     215        2487 : inline const SwGrfNode   *SwNode::GetGrfNode() const
     216             : {
     217        2487 :      return ND_GRFNODE == nNodeType ? static_cast<const SwGrfNode*>(this) : 0;
     218             : }
     219             : 
     220         319 : inline bool SwGrfNode::IsLinkedFile() const
     221             : {
     222         319 :     return refLink.Is() && OBJECT_CLIENT_GRF == refLink->GetObjType();
     223             : }
     224             : 
     225         177 : inline bool SwGrfNode::IsLinkedDDE() const
     226             : {
     227         177 :     return refLink.Is() && OBJECT_CLIENT_DDE == refLink->GetObjType();
     228             : }
     229             : 
     230             : #endif
     231             : 
     232             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11