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

Generated by: LCOV version 1.10