LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - NumberingManager.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 20 20 100.0 %
Date: 2014-04-11 Functions: 18 18 100.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_NUMBERINGMANAGER_HXX
      21             : #define INCLUDED_NUMBERINGMANAGER_HXX
      22             : 
      23             : #include "PropertyMap.hxx"
      24             : 
      25             : #include <WriterFilterDllApi.hxx>
      26             : #include <dmapper/DomainMapper.hxx>
      27             : #include <resourcemodel/LoggedResources.hxx>
      28             : 
      29             : #include <editeng/numitem.hxx>
      30             : 
      31             : #include <com/sun/star/container/XIndexReplace.hpp>
      32             : #include <com/sun/star/graphic/XGraphic.hpp>
      33             : 
      34             : namespace writerfilter {
      35             : namespace dmapper {
      36             : 
      37             : class DomainMapper;
      38             : class StyleSheetEntry;
      39             : 
      40             : 
      41             : /** Class representing the numbering level properties.
      42             :  */
      43             : class ListLevel : public PropertyMap
      44             : {
      45             :     sal_Int32                                     m_nIStartAt;       //LN_CT_Lvl_start
      46             :     sal_Int32                                     m_nNFC;            //LN_CT_Lvl_numFmt
      47             :     sal_Int32                                     m_nJC;             //LN_JC
      48             :     sal_Int32                                     m_nFLegal;         //LN_FLEGAL
      49             :     sal_Int32                                     m_nFPrev;          //LN_FPREV
      50             :     sal_Int32                                     m_nFPrevSpace;     //LN_FPREVSPACE
      51             :     sal_Int32                                     m_nFWord6;         //LN_FWORD6
      52             :     OUString                               m_sRGBXchNums;     //LN_RGBXCHNUMS
      53             :     sal_Int16                                     m_nXChFollow;      //LN_IXCHFOLLOW
      54             :     OUString                               m_sBulletChar;
      55             :     OUString                               m_sGraphicURL;
      56             :     com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > m_sGraphicBitmap;
      57             :     sal_Int32                                     m_nTabstop;
      58             :     boost::shared_ptr< StyleSheetEntry >          m_pParaStyle;
      59             :     bool                                          m_outline;
      60             : 
      61             : public:
      62             : 
      63             :     typedef boost::shared_ptr< ListLevel > Pointer;
      64             : 
      65       13178 :     ListLevel() :
      66             :         m_nIStartAt(-1)
      67             :         ,m_nNFC(-1)
      68             :         ,m_nJC(-1)
      69             :         ,m_nFLegal(-1)
      70             :         ,m_nFPrev(-1)
      71             :         ,m_nFPrevSpace(-1)
      72             :         ,m_nFWord6(-1)
      73             :         ,m_nXChFollow(SvxNumberFormat::LISTTAB)
      74             :         ,m_nTabstop( 0 )
      75       13178 :         ,m_outline(false)
      76       13178 :         {}
      77             : 
      78       26356 :     virtual ~ListLevel( ){ }
      79             : 
      80             :     // Setters for the import
      81             :     void SetValue( Id nId, sal_Int32 nValue );
      82       12905 :     void SetBulletChar( const OUString& sValue ) { m_sBulletChar = sValue; };
      83          14 :     void SetGraphicURL( const OUString& sValue ) { m_sGraphicURL = sValue; };
      84          32 :     void SetGraphicBitmap( com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > sValue )
      85          32 :         { m_sGraphicBitmap = sValue; }
      86             :     void SetParaStyle( boost::shared_ptr< StyleSheetEntry > pStyle );
      87             :     void AddRGBXchNums( const OUString& sValue ) { m_sRGBXchNums += sValue; };
      88             : 
      89             :     // Getters
      90       13738 :     OUString GetBulletChar( ) { return m_sBulletChar; };
      91       13441 :     boost::shared_ptr< StyleSheetEntry > GetParaStyle( ) { return m_pParaStyle; };
      92       34559 :     bool isOutlineNumbering() const { return m_outline; }
      93             : 
      94             :     // UNO mapping functions
      95             : 
      96             :     // rPrefix and rSuffix are out parameters
      97             :     static sal_Int16 GetParentNumbering( const OUString& sText, sal_Int16 nLevel,
      98             :         OUString& rPrefix, OUString& rSuffix );
      99             : 
     100             :     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
     101             :         GetProperties(  );
     102             : 
     103             :     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue>
     104             :         GetCharStyleProperties( );
     105             : private:
     106             : 
     107             :     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
     108             :         GetLevelProperties(  );
     109             : 
     110             :     void AddParaProperties( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* props );
     111             : };
     112             : 
     113             : /// Represents a numbering picture bullet: an id and a graphic.
     114             : class NumPicBullet
     115             : {
     116             : public:
     117             :     typedef boost::shared_ptr<NumPicBullet> Pointer;
     118             :     NumPicBullet();
     119             :     virtual ~NumPicBullet();
     120             : 
     121             :     void SetId(sal_Int32 nId);
     122             :     sal_Int32 GetId();
     123             :     void SetShape(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape);
     124             :     com::sun::star::uno::Reference<com::sun::star::drawing::XShape> GetShape();
     125             : private:
     126             :     sal_Int32 m_nId;
     127             :     com::sun::star::uno::Reference<com::sun::star::drawing::XShape> m_xShape;
     128             : };
     129             : 
     130             : class AbstractListDef
     131             : {
     132             : private:
     133             :     sal_Int32                            m_nTmpl;
     134             :     OUString                      m_sRGISTD;        //LN_RGISTD
     135             : 
     136             :     // The ID member reflects either the abstractNumId or the numId
     137             :     // depending on the use of the class
     138             :     sal_Int32                            m_nId;
     139             : 
     140             :     // Properties of each level. This can also reflect the overridden
     141             :     // levels of a numbering.
     142             :     ::std::vector< ListLevel::Pointer >  m_aLevels;
     143             : 
     144             :     // Only used during the numberings import
     145             :     ListLevel::Pointer                         m_pCurrentLevel;
     146             : 
     147             :     // The style name linked to.
     148             :     ::rtl::OUString                      m_sNumStyleLink;
     149             : 
     150             : public:
     151             :     typedef boost::shared_ptr< AbstractListDef > Pointer;
     152             : 
     153             :     AbstractListDef( );
     154             :     virtual ~AbstractListDef( );
     155             : 
     156             :     // Setters using during the import
     157        3757 :     void SetId( sal_Int32 nId ) { m_nId = nId; };
     158             :     void SetValue( sal_uInt32 nSprmId, sal_Int32 nValue );
     159             :     void AddRGISTD( const OUString& sValue ) { m_sRGISTD += sValue; };
     160             : 
     161             :     // Accessors
     162       40700 :     sal_Int32             GetId( ) { return m_nId; };
     163             : 
     164        1918 :     sal_Int16             Size( ) { return sal_Int16( m_aLevels.size( ) ); };
     165             :     ListLevel::Pointer    GetLevel( sal_uInt16 nLvl );
     166             :     void                  AddLevel( );
     167             : 
     168      170422 :     ListLevel::Pointer    GetCurrentLevel( ) { return m_pCurrentLevel; };
     169             : 
     170             :     virtual com::sun::star::uno::Sequence<
     171             :         com::sun::star::uno::Sequence<
     172             :             com::sun::star::beans::PropertyValue > > GetPropertyValues( );
     173             : 
     174           4 :     void                  SetNumStyleLink(const OUString& sValue) { m_sNumStyleLink = sValue; };
     175        1927 :     OUString              GetNumStyleLink() { return m_sNumStyleLink; };
     176             : };
     177             : 
     178             : class ListDef : public AbstractListDef
     179             : {
     180             : private:
     181             :     // Pointer to the abstract numbering
     182             :     AbstractListDef::Pointer             m_pAbstractDef;
     183             : 
     184             :     // Cache for the UNO numbering rules
     185             :     uno::Reference< container::XIndexReplace > m_xNumRules;
     186             : 
     187             : public:
     188             :     typedef boost::shared_ptr< ListDef > Pointer;
     189             : 
     190             :     ListDef( );
     191             :     virtual ~ListDef( );
     192             : 
     193             :     // Accessors
     194        1923 :     void SetAbstractDefinition( AbstractListDef::Pointer pAbstract ) { m_pAbstractDef = pAbstract; };
     195           4 :     AbstractListDef::Pointer GetAbstractDefinition( ) { return m_pAbstractDef; };
     196             : 
     197             :     // Mapping functions
     198             :     static OUString GetStyleName( sal_Int32 nId );
     199             : 
     200             :     com::sun::star::uno::Sequence<
     201             :         com::sun::star::uno::Sequence<
     202             :             com::sun::star::beans::PropertyValue > > GetPropertyValues( ) SAL_OVERRIDE;
     203             : 
     204             :     void CreateNumberingRules(
     205             :             DomainMapper& rDMapper,
     206             :             com::sun::star::uno::Reference<
     207             :                 com::sun::star::lang::XMultiServiceFactory> xFactory );
     208             : 
     209             :     ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace >
     210        1166 :             GetNumberingRules( ) { return m_xNumRules; };
     211             : 
     212             : };
     213             : 
     214             : /** This class provides access to the defined numbering styles.
     215             :   */
     216             : class ListsManager :
     217             :     public LoggedProperties,
     218             :     public LoggedTable
     219             : {
     220             : private:
     221             : 
     222             :     DomainMapper&                                       m_rDMapper;
     223             :     com::sun::star::uno::Reference<
     224             :         com::sun::star::lang::XMultiServiceFactory >    m_xFactory;
     225             : 
     226             :     // The numbering entries
     227             :     std::vector< NumPicBullet::Pointer >                m_aNumPicBullets;
     228             :     std::vector< AbstractListDef::Pointer >             m_aAbstractLists;
     229             :     std::vector< ListDef::Pointer >                     m_aLists;
     230             : 
     231             : 
     232             :     // These members are used for import only
     233             :     AbstractListDef::Pointer                            m_pCurrentDefinition;
     234             :     NumPicBullet::Pointer                               m_pCurrentNumPicBullet;
     235             :     bool                                                m_bIsLFOImport;
     236             : 
     237             :     AbstractListDef::Pointer    GetAbstractList( sal_Int32 nId );
     238             : 
     239             :     // Properties
     240             :     virtual void lcl_attribute( Id nName, Value & rVal ) SAL_OVERRIDE;
     241             :     virtual void lcl_sprm(Sprm & sprm) SAL_OVERRIDE;
     242             : 
     243             :     // Table
     244             :     virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) SAL_OVERRIDE;
     245             : 
     246             : public:
     247             : 
     248             :     ListsManager(
     249             :             DomainMapper& rDMapper,
     250             :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory);
     251             :     virtual ~ListsManager();
     252             : 
     253             :     typedef boost::shared_ptr< ListsManager >  Pointer;
     254             : 
     255             :     // Config methods
     256             :     void SetLFOImport( bool bLFOImport ) { m_bIsLFOImport = bLFOImport; };
     257             : 
     258             :     // Numberings accessors
     259             :     AbstractListDef::Pointer GetCurrentDef( ) { return m_pCurrentDefinition; };
     260             : 
     261             :     sal_uInt32              Size() const
     262             :         { return sal_uInt32( m_aLists.size( ) ); };
     263             :     ListDef::Pointer        GetList( sal_Int32 nId );
     264             : 
     265             :     // Mapping methods
     266             :     void CreateNumberingRules( );
     267             : };
     268             : 
     269             : } }
     270             : 
     271             : #endif
     272             : 
     273             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10