LCOV - code coverage report
Current view: top level - sw/source/core/layout - layhelp.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 22 0.0 %
Date: 2014-04-14 Functions: 0 20 0.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_SOURCE_CORE_LAYOUT_LAYHELP_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_LAYOUT_LAYHELP_HXX
      22             : 
      23             : #include <swrect.hxx>
      24             : #include <vector>
      25             : #include <deque>
      26             : 
      27             : class SwDoc;
      28             : class SwFrm;
      29             : class SwLayoutFrm;
      30             : class SwPageFrm;
      31             : class SwFlyFrm;
      32             : class SwSectionFrm;
      33             : class SwSectionNode;
      34             : class SvStream;
      35             : 
      36             : /*************************************************************************
      37             :  *                      class SwLayCacheImpl
      38             :  * contains the page break information and the text frame positions
      39             :  * of the document (after loading)
      40             :  * and is used inside the constructor of the layout rootframe to
      41             :  * insert content and text frames at the right pages.
      42             :  * For every page of the main text (body content, no footnotes, text frames etc.)
      43             :  * we have the nodeindex of the first content at the page,
      44             :  * the type of content ( table or paragraph )
      45             :  * and if it's not the first part of the table/paragraph,
      46             :  * the row/character-offset inside the table/paragraph.
      47             :  * The text frame positions are stored in the SwPageFlyCache array.
      48             :  *************************************************************************/
      49             : 
      50             : class SwFlyCache;
      51             : typedef boost::ptr_vector<SwFlyCache> SwPageFlyCache;
      52             : 
      53           0 : class SwLayCacheImpl : public std::vector<sal_uLong>
      54             : {
      55             :     std::deque<sal_Int32> aOffset;
      56             :     std::vector<sal_uInt16> aType;
      57             :     SwPageFlyCache aFlyCache;
      58             :     bool bUseFlyCache;
      59             :     void Insert( sal_uInt16 nType, sal_uLong nIndex, sal_Int32 nOffset );
      60             : 
      61             : public:
      62           0 :     SwLayCacheImpl() : bUseFlyCache(false) {}
      63             :     bool Read( SvStream& rStream );
      64             : 
      65           0 :     sal_uLong GetBreakIndex( sal_uInt16 nIdx ) const { return std::vector<sal_uLong>::operator[]( nIdx ); }
      66           0 :     sal_Int32 GetBreakOfst( size_t nIdx ) const { return aOffset[ nIdx ]; }
      67           0 :     sal_uInt16 GetBreakType( sal_uInt16 nIdx ) const { return aType[ nIdx ]; }
      68             : 
      69           0 :     sal_uInt16 GetFlyCount() const { return aFlyCache.size(); }
      70           0 :     SwFlyCache *GetFlyCache( sal_uInt16 nIdx ) { return &aFlyCache[ nIdx ]; }
      71             : 
      72           0 :     bool IsUseFlyCache() const { return bUseFlyCache; }
      73             : };
      74             : 
      75             : /*************************************************************************
      76             :  *                      class SwActualSection
      77             :  * helps to create the sectionframes during the _InsertCnt-function
      78             :  * by controlling nested sections.
      79             :  *************************************************************************/
      80             : 
      81             : class SwActualSection
      82             : {
      83             :     SwActualSection *pUpper;
      84             :     SwSectionFrm    *pSectFrm;
      85             :     SwSectionNode   *pSectNode;
      86             : public:
      87             :     SwActualSection( SwActualSection *pUpper,
      88             :                      SwSectionFrm    *pSect,
      89             :                      SwSectionNode   *pNd );
      90             : 
      91           0 :     SwSectionFrm    *GetSectionFrm()                    { return pSectFrm; }
      92           0 :     void             SetSectionFrm( SwSectionFrm *p )   { pSectFrm = p; }
      93           0 :     SwSectionNode   *GetSectionNode()                   { return pSectNode;}
      94           0 :     SwActualSection *GetUpper()                         { return pUpper; }
      95             : };
      96             : 
      97             : /*************************************************************************
      98             :  *                      class SwLayHelper
      99             :  * helps during the _InsertCnt-function to create new pages.
     100             :  * If there's a layoutcache available, this information is used.
     101             :  *************************************************************************/
     102             : 
     103             : class SwLayHelper
     104             : {
     105             :     SwFrm* &rpFrm;
     106             :     SwFrm* &rpPrv;
     107             :     SwPageFrm* &rpPage;
     108             :     SwLayoutFrm* &rpLay;
     109             :     SwActualSection* &rpActualSection;
     110             :     sal_Bool &rbBreakAfter;
     111             :     SwDoc* pDoc;
     112             :     SwLayCacheImpl* pImpl;
     113             :     sal_uLong nMaxParaPerPage;
     114             :     sal_uLong nParagraphCnt;
     115             :     sal_uLong nStartOfContent;
     116             :     sal_uInt16 nIndex;                      // the index in the page break array
     117             :     sal_uInt16 nFlyIdx;                     // the index in the fly cache array
     118             :     bool bFirst : 1;
     119             :     void _CheckFlyCache( SwPageFrm* pPage );
     120             : public:
     121             :     SwLayHelper( SwDoc *pD, SwFrm* &rpF, SwFrm* &rpP, SwPageFrm* &rpPg,
     122             :             SwLayoutFrm* &rpL, SwActualSection* &rpA, sal_Bool &rBrk,
     123             :             sal_uLong nNodeIndex, bool bCache );
     124             :     ~SwLayHelper();
     125             :     sal_uLong CalcPageCount();
     126             :     bool CheckInsert( sal_uLong nNodeIndex );
     127             : 
     128             :     bool CheckInsertPage();
     129             : 
     130             :     /// Look for fresh text frames at this (new) page and set them to the right
     131             :     /// position, if they are in the fly cache.
     132           0 :     void CheckFlyCache( SwPageFrm* pPage )
     133           0 :     { if( pImpl && nFlyIdx < pImpl->GetFlyCount() ) _CheckFlyCache( pPage ); }
     134             : 
     135             :     /// Look for this text frame and set it to the right position,
     136             :     /// if it's in the fly cache.
     137             :     static bool CheckPageFlyCache( SwPageFrm* &rpPage, SwFlyFrm* pFly );
     138             : };
     139             : 
     140             : /*************************************************************************
     141             :  *                      class SwLayCacheIoImpl
     142             :  * contains the data structures that are required to read and write a
     143             :  * layout cache.
     144             :  *************************************************************************/
     145             : 
     146             : #define SW_LAYCACHE_IO_REC_PAGES    'p'
     147             : #define SW_LAYCACHE_IO_REC_PARA     'P'
     148             : #define SW_LAYCACHE_IO_REC_TABLE    'T'
     149             : #define SW_LAYCACHE_IO_REC_FLY      'F'
     150             : 
     151             : #define SW_LAYCACHE_IO_VERSION_MAJOR    1
     152             : #define SW_LAYCACHE_IO_VERSION_MINOR    1
     153             : 
     154           0 : class SwLayCacheIoImpl
     155             : {
     156             : private:
     157             :     struct RecTypeSize {
     158             :         sal_uInt8 type;
     159             :         sal_uLong size;
     160           0 :         RecTypeSize(sal_uInt8 typ, sal_uLong siz) : type(typ), size(siz) {}
     161             :     };
     162             :     std::vector<RecTypeSize> aRecords;
     163             : 
     164             :     SvStream        *pStream;
     165             : 
     166             :     sal_uLong           nFlagRecEnd;
     167             : 
     168             :     sal_uInt16          nMajorVersion;
     169             :     sal_uInt16          nMinorVersion;
     170             : 
     171             :     bool            bWriteMode : 1;
     172             :     bool            bError : 1;
     173             : 
     174             : public:
     175             :     SwLayCacheIoImpl( SvStream& rStrm, bool bWrtMd );
     176             : 
     177             :     /// Get input or output stream
     178           0 :     SvStream& GetStream() const { return *pStream; }
     179             : 
     180             :     /// Open a record of type "nType"
     181             :     bool OpenRec( sal_uInt8 nType );
     182             : 
     183             :     /// Close a record of type "nType". This skips any unread data that
     184             :     /// remains in the record.
     185             :     bool CloseRec( sal_uInt8 nType );
     186             : 
     187             :     /// Return the number of bytes contained in the current record that
     188             :     /// haven't been read by now.
     189             :     sal_uInt32 BytesLeft();
     190             : 
     191             :     /// Return the current record's type
     192             :     sal_uInt8 Peek();
     193             : 
     194             :     /// Skip the current record
     195             :     void SkipRec();
     196             : 
     197             :     /// Open a flag record for reading. The uppermost four bits are flags,
     198             :     /// while the lowermost are the flag record's size. Flag records cannot
     199             :     /// be nested.
     200             :     sal_uInt8 OpenFlagRec();
     201             : 
     202             :     /// Open flag record for writing;
     203             :     void OpenFlagRec( sal_uInt8 nFlags, sal_uInt8 nLen );
     204             : 
     205             :     /// Close a flag record. Any bytes left are skipped.
     206             :     void CloseFlagRec();
     207             : 
     208           0 :     bool HasError() const { return bError; }
     209             : 
     210           0 :     sal_uInt16 GetMajorVersion() const { return nMajorVersion; }
     211           0 :     sal_uInt16 GetMinorVersion() const { return nMinorVersion; }
     212             : };
     213             : 
     214             : // Stored information about text frames:
     215             : class SwFlyCache : public SwRect // position and size
     216             : {
     217             : public:
     218             :     sal_uLong nOrdNum;      ///< Id to recognize text frames
     219             :     sal_uInt16 nPageNum;    ///< page number
     220           0 :     SwFlyCache( sal_uInt16 nP, sal_uLong nO, long nXL, long nYL, long nWL, long nHL ) :
     221           0 :         SwRect( nXL, nYL, nWL, nHL ), nOrdNum( nO ), nPageNum( nP ){}
     222             : };
     223             : 
     224             : #endif
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10