LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/inc - ndgrf.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 27 81.5 %
Date: 2013-07-09 Functions: 18 23 78.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 _NDGRF_HXX
      21             : #define _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             :     String aNewStrmName;                 /**< SW3/XML: new stream name (either SW3 stream
      45             :                                          // name or package url) */
      46             :     String aLowResGrf;                   ///< HTML: LowRes graphics (substitute until regular HighRes graphics is loaded).
      47             :     sal_Bool bTransparentFlagValid  :1;
      48             :     sal_Bool bInSwapIn              :1;
      49             : 
      50             :     sal_Bool bGrafikArrived         :1;
      51             :     sal_Bool bChgTwipSize           :1;
      52             :     sal_Bool bChgTwipSizeFromPixel  :1;
      53             :     sal_Bool bLoadLowResGrf         :1;
      54             :     sal_Bool bFrameInPaint          :1; ///< To avoid Start-/EndActions in Paint via SwapIn.
      55             :     sal_Bool bScaleImageMap         :1; ///< Scale image map in SetTwipSize.
      56             : 
      57             :     boost::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
      58             :     bool mbLinkedInputStreamReady;
      59             :     com::sun::star::uno::Reference<com::sun::star::io::XInputStream> mxInputStream;
      60             :     sal_Bool mbIsStreamReadOnly;
      61             : 
      62             :     SwGrfNode( const SwNodeIndex& rWhere,
      63             :                const String& rGrfName, const String& rFltName,
      64             :                const Graphic* pGraphic,
      65             :                SwGrfFmtColl* pGrfColl,
      66             :                SwAttrSet* pAutoAttr = 0 );
      67             :     ///< Ctor for reading (SW/G) without graphics.
      68             :     SwGrfNode( const SwNodeIndex& rWhere,
      69             :                const String& rGrfName, const String& rFltName,
      70             :                SwGrfFmtColl* pGrfColl,
      71             :                SwAttrSet* pAutoAttr = 0 );
      72             :     SwGrfNode( const SwNodeIndex& rWhere,
      73             :                const GraphicObject& rGrfObj,
      74             :                SwGrfFmtColl* pGrfColl,
      75             :                SwAttrSet* pAutoAttr = 0 );
      76             : 
      77             :     void InsertLink( const String& rGrfName, const String& rFltName );
      78             :     sal_Bool ImportGraphic( SvStream& rStrm );
      79          64 :     sal_Bool HasStreamName() const { return maGrfObj.HasUserData(); }
      80             :     /** adjust return type and rename method to
      81             :        indicate that its an private one. */
      82             : 
      83             :     /** embedded graphic stream couldn't be inside a 3.1 - 5.2 storage any more.
      84             :        Thus, return value isn't needed any more. */
      85             :     void _GetStreamStorageNames( String& rStrmName, String& rStgName ) const;
      86             : 
      87             :     void DelStreamName();
      88             :     DECL_LINK( SwapGraphic, GraphicObject* );
      89             : 
      90             :     /** helper method to determine stream for the embedded graphic.
      91             : 
      92             :         Important note: caller of this method has to handle the thrown exceptions
      93             :         Storage, which should contain the stream of the embedded graphic, is
      94             :         provided via parameter. Otherwise the returned stream will be closed
      95             :         after the method returns, because its parent stream is closed and deleted.
      96             :         Proposed name of embedded graphic stream is also provided by parameter.
      97             : 
      98             :         @author OD
      99             : 
     100             :         @param _refPics
     101             :         input parameter - reference to storage, which should contain the
     102             :         embedded graphic stream.
     103             : 
     104             :         @param _aStrmName
     105             :         input parameter - proposed name of the embedded graphic stream.
     106             : 
     107             :         @return SvStream*
     108             :         new created stream of the embedded graphic, which has to be destroyed
     109             :         after its usage. Could be NULL, if the stream isn't found.
     110             :     */
     111             :     SvStream* _GetStreamForEmbedGrf(
     112             :             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
     113             :             String& _aStrmName ) const;
     114             : 
     115             :     /** helper method to get a substorage of the document storage for readonly access.
     116             : 
     117             :         A substorage with the specified name will be opened readonly. If the provided
     118             :         name is empty the root storage will be returned.
     119             : 
     120             :         @param _aStgName
     121             :         input parameter - name of substorage. Can be empty.
     122             : 
     123             :         @return XStorage
     124             :         reference to substorage or the root storage
     125             :     */
     126             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > _GetDocSubstorageOrRoot(
     127             :                                                 const String& aStgName ) const;
     128             : 
     129             : public:
     130             :     virtual ~SwGrfNode();
     131          89 :     const Graphic&          GetGrf() const      { return maGrfObj.GetGraphic(); }
     132          67 :     const GraphicObject&    GetGrfObj() const   { return maGrfObj; }
     133             :     const GraphicObject* GetReplacementGrfObj() const;
     134             :     virtual SwCntntNode *SplitCntntNode( const SwPosition & );
     135             : 
     136             :     /// isolated only way to set GraphicObject to allow more actions when doing so
     137             :     void SetGraphic(const Graphic& rGraphic, const String& rLink);
     138             : 
     139             :     /// wrappers for non-const calls at GraphicObject
     140          24 :     void ReleaseGraphicFromCache() { maGrfObj.ReleaseFromCache(); }
     141           1 :     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); }
     142           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); }
     143           0 :     void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); }
     144             : 
     145             :     /// allow reaction on change of content of GraphicObject, so always call
     146             :     /// when GraphicObject content changes
     147             :     void onGraphicChanged();
     148             : 
     149             :     virtual Size GetTwipSize() const;
     150             : #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     151             :     void SetTwipSize( const Size& rSz );
     152             : 
     153             :     sal_Bool IsTransparent() const;
     154             : 
     155         141 :     inline sal_Bool IsAnimated() const              { return maGrfObj.IsAnimated(); }
     156             : 
     157           0 :     inline sal_Bool IsChgTwipSize() const           { return bChgTwipSize; }
     158          14 :     inline sal_Bool IsChgTwipSizeFromPixel() const  { return bChgTwipSizeFromPixel; }
     159          33 :     inline void SetChgTwipSize( sal_Bool b, sal_Bool bFromPx=sal_False )        { bChgTwipSize = b; bChgTwipSizeFromPixel = bFromPx; }
     160             : 
     161           0 :     inline sal_Bool IsGrafikArrived() const         { return bGrafikArrived; }
     162          14 :     inline void SetGrafikArrived( sal_Bool b )      { bGrafikArrived = b; }
     163             : 
     164          14 :     inline sal_Bool IsFrameInPaint() const          { return bFrameInPaint; }
     165          74 :     inline void SetFrameInPaint( sal_Bool b )       { bFrameInPaint = b; }
     166             : 
     167          87 :     inline sal_Bool IsScaleImageMap() const         { return bScaleImageMap; }
     168           0 :     inline void SetScaleImageMap( sal_Bool b )      { bScaleImageMap = b; }
     169             : #endif
     170             :         /// in ndcopy.cxx
     171             :     virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const;
     172             : #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     173             : 
     174             :     /** Re-read in case graphic was not OK. The current one
     175             :        gets replaced by the new one. */
     176             :     sal_Bool ReRead( const String& rGrfName, const String& rFltName,
     177             :                  const Graphic* pGraphic = 0,
     178             :                  const GraphicObject* pGrfObj = 0,
     179             :                  sal_Bool bModify = sal_True );
     180             :     /// Loading of graphic immediately before displaying.
     181             :     short SwapIn( sal_Bool bWaitForData = sal_False );
     182             :     /// Remove graphic in order to free memory.
     183             :     short SwapOut();
     184             :     /// Access to storage stream-name.
     185             :     void SetStreamName( const String& r ) { maGrfObj.SetUserData( r ); }
     186             :     void SetNewStreamName( const String& r ) { aNewStrmName = r; }
     187             :     /// Is this node selected by any shell?
     188             :     sal_Bool IsSelected() const;
     189             : #endif
     190             : 
     191             :     /// Communicate to graphic that node is in Undo-range.
     192             :     virtual sal_Bool SavePersistentData();
     193             :     virtual sal_Bool RestorePersistentData();
     194             : 
     195             : #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     196             : 
     197             :     /// Query link-data.
     198           8 :     bool IsGrfLink() const                  { return refLink.Is(); }
     199             :     inline bool IsLinkedFile() const;
     200             :     inline bool IsLinkedDDE() const;
     201          25 :     ::sfx2::SvBaseLinkRef GetLink() const    { return refLink; }
     202             :     bool GetFileFilterNms( String* pFileNm, String* pFilterNm ) const;
     203             :     void ReleaseLink();
     204             : 
     205             :     /** Scale an image-map: the image-map becomes zoomed in / out by
     206             :        factor between graphic-size and border-size. */
     207             :     void ScaleImageMap();
     208             : 
     209             :     /// Returns the with our graphic attributes filled Graphic-Attr-Structure.
     210             :     GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrm* pFrm ) const;
     211             : 
     212             : #endif
     213             :     boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer();
     214             :     bool IsLinkedInputStreamReady() const;
     215             :     void TriggerAsyncRetrieveInputStream();
     216             :     void ApplyInputStream(
     217             :         com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
     218             :         const sal_Bool bIsStreamReadOnly );
     219             :     void UpdateLinkWithInputStream();
     220             :     bool IsAsyncRetrieveInputStreamPossible() const;
     221             : };
     222             : 
     223             : 
     224             : // Inline methods from Node.hxx - it is only now that we know TxtNode!!
     225         691 : inline       SwGrfNode   *SwNode::GetGrfNode()
     226             : {
     227         691 :      return ND_GRFNODE == nNodeType ? (SwGrfNode*)this : 0;
     228             : }
     229         780 : inline const SwGrfNode   *SwNode::GetGrfNode() const
     230             : {
     231         780 :      return ND_GRFNODE == nNodeType ? (const SwGrfNode*)this : 0;
     232             : }
     233             : 
     234             : #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     235         105 : inline bool SwGrfNode::IsLinkedFile() const
     236             : {
     237         105 :     return refLink.Is() && OBJECT_CLIENT_GRF == refLink->GetObjType();
     238             : }
     239           2 : inline bool SwGrfNode::IsLinkedDDE() const
     240             : {
     241           2 :     return refLink.Is() && OBJECT_CLIENT_DDE == refLink->GetObjType();
     242             : }
     243             : #endif
     244             : 
     245             : #endif
     246             : 
     247             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10