LCOV - code coverage report
Current view: top level - sw/source/core/text - atrhndl.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 11 0.0 %
Date: 2014-04-14 Functions: 0 6 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_TEXT_ATRHNDL_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_TEXT_ATRHNDL_HXX
      22             : 
      23             : #define INITIAL_NUM_ATTR 3
      24             : #define NUM_ATTRIBUTE_STACKS 44
      25             : 
      26             : #include <txatbase.hxx>
      27             : #include <swfntcch.hxx>
      28             : 
      29             : class SwAttrSet;
      30             : class IDocumentSettingAccess;
      31             : class SwViewShell;
      32             : class SfxPoolItem;
      33             : extern const sal_uInt8 StackPos[];
      34             : 
      35             : /*************************************************************************
      36             :  *                      class SwAttrHandler
      37             :  *
      38             :  * Used by Attribute Iterators to organize attributes on stacks to
      39             :  * find the valid attribute in each category
      40             :  *************************************************************************/
      41             : 
      42             : class SwAttrHandler
      43             : {
      44             : private:
      45             : 
      46             :     /*************************************************************************
      47             :      *                      class SwAttrStack
      48             :      *
      49             :      * Container for SwTxtAttr Objects
      50             :      *************************************************************************/
      51             : 
      52             :     class SwAttrStack
      53             :     {
      54             :     private:
      55             :         SwTxtAttr* pInitialArray[ INITIAL_NUM_ATTR ];
      56             :         SwTxtAttr** pArray;
      57             :         sal_uInt16 nCount; // number of elements on stack
      58             :         sal_uInt16 nSize;    // number of positions in Array
      59             : 
      60             :     public:
      61             :         // Ctor, Dtor
      62             :         inline SwAttrStack();
      63           0 :         inline ~SwAttrStack() {
      64           0 :             if ( nSize > INITIAL_NUM_ATTR ) delete [] pArray; }
      65             : 
      66             :         // reset stack
      67           0 :         inline void Reset() { nCount = 0; };
      68             : 
      69             :         // insert on top
      70           0 :         inline void Push( const SwTxtAttr& rAttr ) { Insert( rAttr, nCount ); };
      71             :         // insert at specified position, take care for not inserting behind
      72             :         // the value returned by Count()
      73             :         void Insert( const SwTxtAttr& rAttr, const sal_uInt16 nPos );
      74             : 
      75             :         // remove specified attribute
      76             :         void Remove( const SwTxtAttr& rAttr );
      77             : 
      78             :         // get attribute from top if exists, otherwise 0
      79             :         const SwTxtAttr* Top() const;
      80             : 
      81             :         // number of elements on stack
      82           0 :         inline sal_uInt16 Count() const { return nCount; };
      83             : 
      84             :         // returns position of rAttr on Stack if found, otherwise USHRT_MAX
      85             :         // can be used for Remove of an attribute
      86             :         sal_uInt16 Pos( const SwTxtAttr& rAttr ) const;
      87             :     };
      88             : 
      89             :     SwAttrStack aAttrStack[ NUM_ATTRIBUTE_STACKS ]; // stack collection
      90             :     const SfxPoolItem* pDefaultArray[ NUM_DEFAULT_VALUES ];
      91             :     const IDocumentSettingAccess* mpIDocumentSettingAccess;
      92             :     const SwViewShell* mpShell;
      93             : 
      94             :     // This is the base font for the paragraph. It is stored in order to have
      95             :     // a template, if we have to restart the attribute evaluation
      96             :     SwFont* pFnt;
      97             : 
      98             :     bool bVertLayout;
      99             : 
     100             :     // change font according to pool item
     101             :     void FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush );
     102             : 
     103             :     // push attribute to specified stack, returns true, if attribute has
     104             :     // been pushed on top of stack (important for stacks containing different
     105             :     // attributes with different priority and redlining)
     106             :     bool Push( const SwTxtAttr& rAttr, const SfxPoolItem& rItem );
     107             : 
     108             :     // apply top attribute on stack to font
     109             :     void ActivateTop( SwFont& rFnt, sal_uInt16 nStackPos );
     110             : 
     111             : public:
     112             :     // Ctor
     113             :     SwAttrHandler();
     114             :     ~SwAttrHandler();
     115             : 
     116             :     // set default attributes to values in rAttrSet or from cache
     117             :     void Init( const SwAttrSet& rAttrSet,
     118             :                const IDocumentSettingAccess& rIDocumentSettingAccess,
     119             :                const SwViewShell* pShell );
     120             :     void Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAttrSet,
     121             :                const IDocumentSettingAccess& rIDocumentSettingAccess,
     122             :                const SwViewShell* pShell, SwFont& rFnt,
     123             :                bool bVertLayout );
     124             : 
     125             :     // remove everything from internal stacks, keep default data
     126             :     void Reset( );
     127             : 
     128             :     // insert specified attribute and change font
     129             :     void PushAndChg( const SwTxtAttr& rAttr, SwFont& rFnt );
     130             : 
     131             :     // remove specified attribute and reset font
     132             :     void PopAndChg( const SwTxtAttr& rAttr, SwFont& rFnt );
     133             :     void Pop( const SwTxtAttr& rAttr );
     134             : 
     135             :     // apply script dependent attributes
     136             :     // void ChangeScript( SwFont& rFnt, const sal_uInt8 nScr );
     137             : 
     138             :     // returns the default value for stack nStack
     139             :     inline const SfxPoolItem& GetDefault( const sal_uInt16 nAttribID ) const;
     140             :     // do not call these if you only used the small init function
     141             :     inline void ResetFont( SwFont& rFnt ) const;
     142             :     inline const SwFont* GetFont() const;
     143             : 
     144             :     void GetDefaultAscentAndHeight(SwViewShell* pShell,
     145             :                                    OutputDevice& rOut,
     146             :                                    sal_uInt16& nAscent,
     147             :                                    sal_uInt16& nHeight) const;
     148             : };
     149             : 
     150             : inline const SfxPoolItem& SwAttrHandler::GetDefault( const sal_uInt16 nAttribID ) const
     151             : {
     152             :     OSL_ENSURE( nAttribID < RES_TXTATR_END,
     153             :             "this attrib does not ex."
     154             :             );
     155             :     OSL_ENSURE( pDefaultArray[ StackPos[ nAttribID ] ], "array not initialized" );
     156             :     return *pDefaultArray[ StackPos[ nAttribID ] ];
     157             : }
     158             : 
     159           0 : inline void SwAttrHandler::ResetFont( SwFont& rFnt ) const
     160             : {
     161             :     OSL_ENSURE( pFnt, "ResetFont without a font" );
     162           0 :     if ( pFnt )
     163           0 :         rFnt = *pFnt;
     164           0 : };
     165             : 
     166           0 : inline const SwFont* SwAttrHandler::GetFont() const
     167             : {
     168           0 :     return pFnt;
     169             : };
     170             : 
     171             : #endif
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10