1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef OOX_XLS_NUMBERFORMATSBUFFER_HXX 25*b1cdbd2cSJim Jagielski #define OOX_XLS_NUMBERFORMATSBUFFER_HXX 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/Locale.hpp> 28*b1cdbd2cSJim Jagielski #include "oox/xls/workbookhelper.hxx" 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielski namespace com { namespace sun { namespace star { 31*b1cdbd2cSJim Jagielski namespace util { class XNumberFormats; } 32*b1cdbd2cSJim Jagielski } } } 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski namespace oox { class PropertyMap; } 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski namespace oox { 37*b1cdbd2cSJim Jagielski namespace xls { 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski // ============================================================================ 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski struct NumFmtModel 42*b1cdbd2cSJim Jagielski { 43*b1cdbd2cSJim Jagielski ::com::sun::star::lang::Locale maLocale; 44*b1cdbd2cSJim Jagielski ::rtl::OUString maFmtCode; 45*b1cdbd2cSJim Jagielski sal_Int16 mnPredefId; 46*b1cdbd2cSJim Jagielski 47*b1cdbd2cSJim Jagielski explicit NumFmtModel(); 48*b1cdbd2cSJim Jagielski }; 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski // ---------------------------------------------------------------------------- 51*b1cdbd2cSJim Jagielski 52*b1cdbd2cSJim Jagielski /** Contains all API number format attributes. */ 53*b1cdbd2cSJim Jagielski struct ApiNumFmtData 54*b1cdbd2cSJim Jagielski { 55*b1cdbd2cSJim Jagielski sal_Int32 mnIndex; /// API number format index. 56*b1cdbd2cSJim Jagielski 57*b1cdbd2cSJim Jagielski explicit ApiNumFmtData(); 58*b1cdbd2cSJim Jagielski }; 59*b1cdbd2cSJim Jagielski 60*b1cdbd2cSJim Jagielski // ---------------------------------------------------------------------------- 61*b1cdbd2cSJim Jagielski 62*b1cdbd2cSJim Jagielski /** Contains all data for a number format code. */ 63*b1cdbd2cSJim Jagielski class NumberFormat : public WorkbookHelper 64*b1cdbd2cSJim Jagielski { 65*b1cdbd2cSJim Jagielski public: 66*b1cdbd2cSJim Jagielski explicit NumberFormat( const WorkbookHelper& rHelper ); 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski /** Sets the passed format code. */ 69*b1cdbd2cSJim Jagielski void setFormatCode( const ::rtl::OUString& rFmtCode ); 70*b1cdbd2cSJim Jagielski /** Sets the passed format code, encoded in UTF-8. */ 71*b1cdbd2cSJim Jagielski void setFormatCode( 72*b1cdbd2cSJim Jagielski const ::com::sun::star::lang::Locale& rLocale, 73*b1cdbd2cSJim Jagielski const sal_Char* pcFmtCode ); 74*b1cdbd2cSJim Jagielski /** Sets the passed predefined format code identifier. */ 75*b1cdbd2cSJim Jagielski void setPredefinedId( 76*b1cdbd2cSJim Jagielski const ::com::sun::star::lang::Locale& rLocale, 77*b1cdbd2cSJim Jagielski sal_Int16 nPredefId ); 78*b1cdbd2cSJim Jagielski 79*b1cdbd2cSJim Jagielski /** Final processing after import of all style settings. Returns the API format index. */ 80*b1cdbd2cSJim Jagielski sal_Int32 finalizeImport( 81*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& rxNumFmts, 82*b1cdbd2cSJim Jagielski const ::com::sun::star::lang::Locale& rFromLocale ); 83*b1cdbd2cSJim Jagielski 84*b1cdbd2cSJim Jagielski /** Writes the number format to the passed property map. */ 85*b1cdbd2cSJim Jagielski void writeToPropertyMap( PropertyMap& rPropMap ) const; 86*b1cdbd2cSJim Jagielski 87*b1cdbd2cSJim Jagielski private: 88*b1cdbd2cSJim Jagielski NumFmtModel maModel; 89*b1cdbd2cSJim Jagielski ApiNumFmtData maApiData; 90*b1cdbd2cSJim Jagielski }; 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski typedef ::boost::shared_ptr< NumberFormat > NumberFormatRef; 93*b1cdbd2cSJim Jagielski 94*b1cdbd2cSJim Jagielski // ============================================================================ 95*b1cdbd2cSJim Jagielski 96*b1cdbd2cSJim Jagielski class NumberFormatsBuffer : public WorkbookHelper 97*b1cdbd2cSJim Jagielski { 98*b1cdbd2cSJim Jagielski public: 99*b1cdbd2cSJim Jagielski explicit NumberFormatsBuffer( const WorkbookHelper& rHelper ); 100*b1cdbd2cSJim Jagielski 101*b1cdbd2cSJim Jagielski /** Inserts a new number format. */ 102*b1cdbd2cSJim Jagielski NumberFormatRef createNumFmt( sal_Int32 nNumFmtId, const ::rtl::OUString& rFmtCode ); 103*b1cdbd2cSJim Jagielski 104*b1cdbd2cSJim Jagielski /** Inserts a new number format code. */ 105*b1cdbd2cSJim Jagielski NumberFormatRef importNumFmt( const AttributeList& rAttribs ); 106*b1cdbd2cSJim Jagielski /** Inserts a new number format code from a NUMFMT record. */ 107*b1cdbd2cSJim Jagielski void importNumFmt( SequenceInputStream& rStrm ); 108*b1cdbd2cSJim Jagielski /** Inserts a new number format code from a FORMAT record. */ 109*b1cdbd2cSJim Jagielski void importFormat( BiffInputStream& rStrm ); 110*b1cdbd2cSJim Jagielski 111*b1cdbd2cSJim Jagielski /** Final processing after import of all style settings. */ 112*b1cdbd2cSJim Jagielski void finalizeImport(); 113*b1cdbd2cSJim Jagielski 114*b1cdbd2cSJim Jagielski /** Writes the specified number format to the passed property map. */ 115*b1cdbd2cSJim Jagielski void writeToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const; 116*b1cdbd2cSJim Jagielski 117*b1cdbd2cSJim Jagielski private: 118*b1cdbd2cSJim Jagielski /** Inserts built-in number formats for the current system language. */ 119*b1cdbd2cSJim Jagielski void insertBuiltinFormats(); 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski private: 122*b1cdbd2cSJim Jagielski typedef RefMap< sal_Int32, NumberFormat > NumberFormatMap; 123*b1cdbd2cSJim Jagielski 124*b1cdbd2cSJim Jagielski NumberFormatMap maNumFmts; /// List of number formats. 125*b1cdbd2cSJim Jagielski ::rtl::OUString maLocaleStr; /// Current office locale. 126*b1cdbd2cSJim Jagielski sal_Int32 mnNextBiffIndex; /// Format id counter for BIFF2-BIFF4. 127*b1cdbd2cSJim Jagielski }; 128*b1cdbd2cSJim Jagielski 129*b1cdbd2cSJim Jagielski // ============================================================================ 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim Jagielski } // namespace xls 132*b1cdbd2cSJim Jagielski } // namespace oox 133*b1cdbd2cSJim Jagielski 134*b1cdbd2cSJim Jagielski #endif 135