LCOV - code coverage report
Current view: top level - sw/inc - ndgrf.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 24 87.5 %
Date: 2012-08-25 Functions: 17 20 85.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 12 66.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef _NDGRF_HXX
      29                 :            : #define _NDGRF_HXX
      30                 :            : #include <sfx2/lnkbase.hxx>
      31                 :            : #include <svtools/grfmgr.hxx>
      32                 :            : #include <ndnotxt.hxx>
      33                 :            : #include <com/sun/star/embed/XStorage.hpp>
      34                 :            : #include <boost/shared_ptr.hpp>
      35                 :            : #include <boost/weak_ptr.hpp>
      36                 :            : class SwAsyncRetrieveInputStreamThreadConsumer;
      37                 :            : 
      38                 :            : class SwGrfFmtColl;
      39                 :            : class SwDoc;
      40                 :            : class GraphicAttr;
      41                 :            : class SvStorage;
      42                 :            : 
      43                 :            : // SwGrfNode
      44                 :            : class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
      45                 :            : {
      46                 :            :     friend class SwNodes;
      47                 :            : 
      48                 :            :     GraphicObject aGrfObj;
      49                 :            :     ::sfx2::SvBaseLinkRef refLink;       // If graphics only as link then pointer is set.
      50                 :            :     Size nGrfSize;
      51                 :            :     String aNewStrmName;        // SW3/XML: new stream name (either SW3 stream
      52                 :            :                                 // name or package url)
      53                 :            :     String aLowResGrf;          // HTML: LowRes graphics (substitute until regular HighRes graphics is loaded).
      54                 :            :     sal_Bool bTransparentFlagValid  :1;
      55                 :            :     sal_Bool bInSwapIn              :1;
      56                 :            : 
      57                 :            :     sal_Bool bGrafikArrived         :1;
      58                 :            :     sal_Bool bChgTwipSize           :1;
      59                 :            :     sal_Bool bChgTwipSizeFromPixel  :1;
      60                 :            :     sal_Bool bLoadLowResGrf         :1;
      61                 :            :     sal_Bool bFrameInPaint          :1; // To avoid Start-/EndActions in Paint via SwapIn.
      62                 :            :     sal_Bool bScaleImageMap         :1; // Scale image map in SetTwipSize.
      63                 :            : 
      64                 :            :     boost::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
      65                 :            :     bool mbLinkedInputStreamReady;
      66                 :            :     com::sun::star::uno::Reference<com::sun::star::io::XInputStream> mxInputStream;
      67                 :            :     sal_Bool mbIsStreamReadOnly;
      68                 :            : 
      69                 :            :     SwGrfNode( const SwNodeIndex& rWhere,
      70                 :            :                const String& rGrfName, const String& rFltName,
      71                 :            :                const Graphic* pGraphic,
      72                 :            :                SwGrfFmtColl* pGrfColl,
      73                 :            :                SwAttrSet* pAutoAttr = 0 );
      74                 :            :     // Ctor for reading (SW/G) without graphics.
      75                 :            :     SwGrfNode( const SwNodeIndex& rWhere,
      76                 :            :                const String& rGrfName, const String& rFltName,
      77                 :            :                SwGrfFmtColl* pGrfColl,
      78                 :            :                SwAttrSet* pAutoAttr = 0 );
      79                 :            :     SwGrfNode( const SwNodeIndex& rWhere,
      80                 :            :                const GraphicObject& rGrfObj,
      81                 :            :                SwGrfFmtColl* pGrfColl,
      82                 :            :                SwAttrSet* pAutoAttr = 0 );
      83                 :            : 
      84                 :            :     void InsertLink( const String& rGrfName, const String& rFltName );
      85                 :            :     sal_Bool ImportGraphic( SvStream& rStrm );
      86                 :        104 :     sal_Bool HasStreamName() const { return aGrfObj.HasUserData(); }
      87                 :            :     // adjust return type and rename method to
      88                 :            :     // indicate that its an private one.
      89                 :            : 
      90                 :            :     // embedded graphic stream couldn't be inside a 3.1 - 5.2 storage any more.
      91                 :            :     // Thus, return value isn't needed any more.
      92                 :            :     void _GetStreamStorageNames( String& rStrmName, String& rStgName ) const;
      93                 :            : 
      94                 :            :     void DelStreamName();
      95                 :            :     DECL_LINK( SwapGraphic, GraphicObject* );
      96                 :            : 
      97                 :            :     /** helper method to determine stream for the embedded graphic.
      98                 :            : 
      99                 :            :         Important note: caller of this method has to handle the thrown exceptions
     100                 :            :         Storage, which should contain the stream of the embedded graphic, is
     101                 :            :         provided via parameter. Otherwise the returned stream will be closed
     102                 :            :         after the the method returns, because its parent stream is closed and deleted.
     103                 :            :         Proposed name of embedded graphic stream is also provided by parameter.
     104                 :            : 
     105                 :            :         @author OD
     106                 :            : 
     107                 :            :         @param _refPics
     108                 :            :         input parameter - reference to storage, which should contain the
     109                 :            :         embedded graphic stream.
     110                 :            : 
     111                 :            :         @param _aStrmName
     112                 :            :         input parameter - proposed name of the embedded graphic stream.
     113                 :            : 
     114                 :            :         @return SvStream*
     115                 :            :         new created stream of the embedded graphic, which has to be destroyed
     116                 :            :         after its usage. Could be NULL, if the stream isn't found.
     117                 :            :     */
     118                 :            :     SvStream* _GetStreamForEmbedGrf(
     119                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
     120                 :            :             String& _aStrmName ) const;
     121                 :            : 
     122                 :            :     /** helper method to get a substorage of the document storage for readonly access.
     123                 :            : 
     124                 :            :         A substorage with the specified name will be opened readonly. If the provided
     125                 :            :         name is empty the root storage will be returned.
     126                 :            : 
     127                 :            :         @param _aStgName
     128                 :            :         input parameter - name of substorage. Can be empty.
     129                 :            : 
     130                 :            :         @return XStorage
     131                 :            :         reference to substorage or the root storage
     132                 :            :     */
     133                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > _GetDocSubstorageOrRoot(
     134                 :            :                                                 const String& aStgName ) const;
     135                 :            : 
     136                 :            : public:
     137                 :            :     virtual ~SwGrfNode();
     138                 :         27 :     const Graphic&          GetGrf() const      { return aGrfObj.GetGraphic(); }
     139                 :         16 :     const GraphicObject&    GetGrfObj() const   { return aGrfObj; }
     140                 :        140 :           GraphicObject&    GetGrfObj()         { return aGrfObj; }
     141                 :            : 
     142                 :            :     virtual SwCntntNode *SplitCntntNode( const SwPosition & );
     143                 :            : 
     144                 :            :     virtual Size GetTwipSize() const;
     145                 :            : #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     146                 :            :     void SetTwipSize( const Size& rSz );
     147                 :            : 
     148                 :            :     sal_Bool IsTransparent() const;
     149                 :            : 
     150                 :        197 :     inline sal_Bool IsAnimated() const              { return aGrfObj.IsAnimated(); }
     151                 :            : 
     152                 :          0 :     inline sal_Bool IsChgTwipSize() const           { return bChgTwipSize; }
     153                 :         28 :     inline sal_Bool IsChgTwipSizeFromPixel() const  { return bChgTwipSizeFromPixel; }
     154                 :         41 :     inline void SetChgTwipSize( sal_Bool b, sal_Bool bFromPx=sal_False )        { bChgTwipSize = b; bChgTwipSizeFromPixel = bFromPx; }
     155                 :            : 
     156                 :          0 :     inline sal_Bool IsGrafikArrived() const         { return bGrafikArrived; }
     157                 :         28 :     inline void SetGrafikArrived( sal_Bool b )      { bGrafikArrived = b; }
     158                 :            : 
     159                 :         28 :     inline sal_Bool IsFrameInPaint() const          { return bFrameInPaint; }
     160                 :        120 :     inline void SetFrameInPaint( sal_Bool b )       { bFrameInPaint = b; }
     161                 :            : 
     162                 :        153 :     inline sal_Bool IsScaleImageMap() const         { return bScaleImageMap; }
     163                 :          0 :     inline void SetScaleImageMap( sal_Bool b )      { bScaleImageMap = b; }
     164                 :            : #endif
     165                 :            :         // in ndcopy.cxx
     166                 :            :     virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const;
     167                 :            : #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     168                 :            : 
     169                 :            :     // Re-read in case graphic was not OK. The current one
     170                 :            :     // gets replaced by the new one.
     171                 :            :     sal_Bool ReRead( const String& rGrfName, const String& rFltName,
     172                 :            :                  const Graphic* pGraphic = 0,
     173                 :            :                  const GraphicObject* pGrfObj = 0,
     174                 :            :                  sal_Bool bModify = sal_True );
     175                 :            :     // Loading of graphic immediately before displaying.
     176                 :            :     short SwapIn( sal_Bool bWaitForData = sal_False );
     177                 :            :     // Remove graphic in order to free memory.
     178                 :            :     short SwapOut();
     179                 :            :     // Access to storage stream-name.
     180                 :            :     void SetStreamName( const String& r ) { aGrfObj.SetUserData( r ); }
     181                 :            :     void SetNewStreamName( const String& r ) { aNewStrmName = r; }
     182                 :            :     // Is this node selected by any shell?
     183                 :            :     sal_Bool IsSelected() const;
     184                 :            : #endif
     185                 :            : 
     186                 :            :     // Communicate to graphic that node is in Undo-range.
     187                 :            :     virtual sal_Bool SavePersistentData();
     188                 :            :     virtual sal_Bool RestorePersistentData();
     189                 :            : 
     190                 :            : #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     191                 :            : 
     192                 :            :     // Query link-data.
     193                 :         16 :     sal_Bool IsGrfLink() const                  { return refLink.Is(); }
     194                 :            :     inline sal_Bool IsLinkedFile() const;
     195                 :            :     inline sal_Bool IsLinkedDDE() const;
     196                 :         34 :     ::sfx2::SvBaseLinkRef GetLink() const    { return refLink; }
     197                 :            :     sal_Bool GetFileFilterNms( String* pFileNm, String* pFilterNm ) const;
     198                 :            :     void ReleaseLink();
     199                 :            : 
     200                 :            :     // Scale an image-map: the image-map becomes zoomed in / out by
     201                 :            :     // factor between graphic-size and border-size.
     202                 :            :     void ScaleImageMap();
     203                 :            : 
     204                 :            :     // Returns the with our graphic attributes filled Graphic-Attr-Structure.
     205                 :            :     GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrm* pFrm ) const;
     206                 :            : 
     207                 :            : #endif
     208                 :            :     boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer();
     209                 :            :     bool IsLinkedInputStreamReady() const;
     210                 :            :     void TriggerAsyncRetrieveInputStream();
     211                 :            :     void ApplyInputStream(
     212                 :            :         com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
     213                 :            :         const sal_Bool bIsStreamReadOnly );
     214                 :            :     void UpdateLinkWithInputStream();
     215                 :            :     bool IsAsyncRetrieveInputStreamPossible() const;
     216                 :            : };
     217                 :            : 
     218                 :            : 
     219                 :            : // Inline methods from Node.hxx - it is only now that we know TxtNode!!
     220                 :       1290 : inline       SwGrfNode   *SwNode::GetGrfNode()
     221                 :            : {
     222         [ +  + ]:       1290 :      return ND_GRFNODE == nNodeType ? (SwGrfNode*)this : 0;
     223                 :            : }
     224                 :       2108 : inline const SwGrfNode   *SwNode::GetGrfNode() const
     225                 :            : {
     226         [ +  + ]:       2108 :      return ND_GRFNODE == nNodeType ? (const SwGrfNode*)this : 0;
     227                 :            : }
     228                 :            : 
     229                 :            : #ifndef _FESHVIEW_ONLY_INLINE_NEEDED
     230                 :        163 : inline sal_Bool SwGrfNode::IsLinkedFile() const
     231                 :            : {
     232 [ +  + ][ +  - ]:        163 :     return refLink.Is() && OBJECT_CLIENT_GRF == refLink->GetObjType();
     233                 :            : }
     234                 :          3 : inline sal_Bool SwGrfNode::IsLinkedDDE() const
     235                 :            : {
     236 [ -  + ][ #  # ]:          3 :     return refLink.Is() && OBJECT_CLIENT_DDE == refLink->GetObjType();
     237                 :            : }
     238                 :            : #endif
     239                 :            : 
     240                 :            : #endif
     241                 :            : 
     242                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10