LCOV - code coverage report
Current view: top level - sc/source/filter/inc - numberformatsbuffer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef OOX_XLS_NUMBERFORMATSBUFFER_HXX
      30                 :            : #define OOX_XLS_NUMBERFORMATSBUFFER_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/lang/Locale.hpp>
      33                 :            : #include <svl/itemset.hxx>
      34                 :            : #include "workbookhelper.hxx"
      35                 :            : 
      36                 :            : namespace com { namespace sun { namespace star {
      37                 :            :     namespace util { class XNumberFormats; }
      38                 :            : } } }
      39                 :            : 
      40                 :            : namespace oox { class PropertyMap; }
      41                 :            : 
      42                 :            : namespace oox {
      43                 :            : namespace xls {
      44                 :            : 
      45                 :            : // ============================================================================
      46                 :            : 
      47                 :       2016 : struct NumFmtModel
      48                 :            : {
      49                 :            :     ::com::sun::star::lang::Locale maLocale;
      50                 :            :     ::rtl::OUString     maFmtCode;
      51                 :            :     sal_Int16           mnPredefId;
      52                 :            : 
      53                 :            :     explicit            NumFmtModel();
      54                 :            : };
      55                 :            : 
      56                 :            : // ----------------------------------------------------------------------------
      57                 :            : 
      58                 :            : /** Contains all API number format attributes. */
      59                 :            : struct ApiNumFmtData
      60                 :            : {
      61                 :            :     sal_Int32           mnIndex;            /// API number format index.
      62                 :            : 
      63                 :            :     explicit            ApiNumFmtData();
      64                 :            : };
      65                 :            : 
      66                 :            : // ----------------------------------------------------------------------------
      67                 :            : 
      68                 :            : /** Contains all data for a number format code. */
      69         [ -  + ]:       4032 : class NumberFormat : public WorkbookHelper
      70                 :            : {
      71                 :            : public:
      72                 :            :     explicit            NumberFormat( const WorkbookHelper& rHelper );
      73                 :            : 
      74                 :            :     /** Sets the passed format code. */
      75                 :            :     void                setFormatCode( const ::rtl::OUString& rFmtCode );
      76                 :            :     /** Sets the passed format code, encoded in UTF-8. */
      77                 :            :     void                setFormatCode(
      78                 :            :                             const ::com::sun::star::lang::Locale& rLocale,
      79                 :            :                             const sal_Char* pcFmtCode );
      80                 :            :     /** Sets the passed predefined format code identifier. */
      81                 :            :     void                setPredefinedId(
      82                 :            :                             const ::com::sun::star::lang::Locale& rLocale,
      83                 :            :                             sal_Int16 nPredefId );
      84                 :            : 
      85                 :            :     /** Final processing after import of all style settings. Returns the API format index. */
      86                 :            :     sal_Int32           finalizeImport(
      87                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& rxNumFmts,
      88                 :            :                             const ::com::sun::star::lang::Locale& rFromLocale );
      89                 :            :     void                fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const;
      90                 :            :     /** Writes the number format to the passed property map. */
      91                 :            :     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
      92                 :            : 
      93                 :            : private:
      94                 :            :     NumFmtModel         maModel;
      95                 :            :     ApiNumFmtData       maApiData;
      96                 :            : };
      97                 :            : 
      98                 :            : typedef ::boost::shared_ptr< NumberFormat > NumberFormatRef;
      99                 :            : 
     100                 :            : // ============================================================================
     101                 :            : 
     102         [ -  + ]:         24 : class NumberFormatsBuffer : public WorkbookHelper
     103                 :            : {
     104                 :            : public:
     105                 :            :     explicit            NumberFormatsBuffer( const WorkbookHelper& rHelper );
     106                 :            : 
     107                 :            :     /** Inserts a new number format. */
     108                 :            :     NumberFormatRef     createNumFmt( sal_Int32 nNumFmtId, const ::rtl::OUString& rFmtCode );
     109                 :            : 
     110                 :            :     /** Inserts a new number format code. */
     111                 :            :     NumberFormatRef     importNumFmt( const AttributeList& rAttribs );
     112                 :            :     /** Inserts a new number format code from a NUMFMT record. */
     113                 :            :     void                importNumFmt( SequenceInputStream& rStrm );
     114                 :            : 
     115                 :            :     /** Final processing after import of all style settings. */
     116                 :            :     void                finalizeImport();
     117                 :            : 
     118                 :            :     void                fillToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs = false ) const;
     119                 :            : 
     120                 :            :     /** Writes the specified number format to the passed property map. */
     121                 :            :     void                writeToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const;
     122                 :            : 
     123                 :            : private:
     124                 :            :     /** Inserts built-in number formats for the current system language. */
     125                 :            :     void                insertBuiltinFormats();
     126                 :            : 
     127                 :            : private:
     128                 :            :     typedef RefMap< sal_Int32, NumberFormat > NumberFormatMap;
     129                 :            : 
     130                 :            :     NumberFormatMap     maNumFmts;          /// List of number formats.
     131                 :            :     ::rtl::OUString     maLocaleStr;        /// Current office locale.
     132                 :            :     sal_Int32           mnNextBiffIndex;    /// Format id counter for BIFF2-BIFF4.
     133                 :            : };
     134                 :            : 
     135                 :            : // ============================================================================
     136                 :            : 
     137                 :            : } // namespace xls
     138                 :            : } // namespace oox
     139                 :            : 
     140                 :            : #endif
     141                 :            : 
     142                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10