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

Generated by: LCOV version 1.11