1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _XMLOFF_XMLNUMFE_HXX 29 #define _XMLOFF_XMLNUMFE_HXX 30 31 #include "sal/config.h" 32 #include "xmloff/dllapi.h" 33 #include "sal/types.h" 34 #include <com/sun/star/util/XNumberFormatsSupplier.hpp> 35 #include <com/sun/star/uno/Sequence.h> 36 #include <rtl/ustrbuf.hxx> 37 38 #define XML_WRITTENNUMBERSTYLES "WrittenNumberStyles" 39 40 class Color; 41 class LocaleDataWrapper; 42 class CharClass; 43 class SvXMLExport; 44 class SvXMLNamespaceMap; 45 class SvXMLAttributeList; 46 class SvNumberFormatter; 47 class SvNumberformat; 48 class SvXMLNumUsedList_Impl; 49 class SvXMLEmbeddedTextEntryArr; 50 51 class XMLOFF_DLLPUBLIC SvXMLNumFmtExport 52 { 53 private: 54 SvXMLExport& rExport; 55 ::rtl::OUString sPrefix; 56 SvNumberFormatter* pFormatter; 57 ::rtl::OUStringBuffer sTextContent; 58 SvXMLNumUsedList_Impl* pUsedList; 59 CharClass* pCharClass; 60 LocaleDataWrapper* pLocaleData; 61 62 SAL_DLLPRIVATE void AddCalendarAttr_Impl( const ::rtl::OUString& rCalendar ); 63 SAL_DLLPRIVATE void AddStyleAttr_Impl( sal_Bool bLong ); 64 SAL_DLLPRIVATE void AddTextualAttr_Impl( sal_Bool bText ); 65 SAL_DLLPRIVATE void AddLanguageAttr_Impl( sal_Int32 nLang ); 66 67 SAL_DLLPRIVATE void AddToTextElement_Impl( const ::rtl::OUString& rString ); 68 SAL_DLLPRIVATE void FinishTextElement_Impl(); 69 70 SAL_DLLPRIVATE void WriteColorElement_Impl( const Color& rColor ); 71 SAL_DLLPRIVATE void WriteNumberElement_Impl( sal_Int32 nDecimals, sal_Int32 nInteger, 72 const ::rtl::OUString& rDashStr, sal_Bool bVarDecimals, 73 sal_Bool bGrouping, sal_Int32 nTrailingThousands, 74 const SvXMLEmbeddedTextEntryArr& rEmbeddedEntries ); 75 SAL_DLLPRIVATE void WriteScientificElement_Impl( sal_Int32 nDecimals, sal_Int32 nInteger, 76 sal_Bool bGrouping, sal_Int32 nExp ); 77 SAL_DLLPRIVATE void WriteFractionElement_Impl( sal_Int32 nInteger, sal_Bool bGrouping, 78 sal_Int32 nNumerator, sal_Int32 nDenominator ); 79 SAL_DLLPRIVATE void WriteCurrencyElement_Impl( const ::rtl::OUString& rString, 80 const ::rtl::OUString& rExt ); 81 SAL_DLLPRIVATE void WriteBooleanElement_Impl(); 82 SAL_DLLPRIVATE void WriteTextContentElement_Impl(); 83 SAL_DLLPRIVATE void WriteDayElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 84 SAL_DLLPRIVATE void WriteMonthElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong, sal_Bool bText ); 85 SAL_DLLPRIVATE void WriteYearElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 86 SAL_DLLPRIVATE void WriteEraElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 87 SAL_DLLPRIVATE void WriteDayOfWeekElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 88 SAL_DLLPRIVATE void WriteWeekElement_Impl( const ::rtl::OUString& rCalendar ); 89 SAL_DLLPRIVATE void WriteQuarterElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 90 SAL_DLLPRIVATE void WriteHoursElement_Impl( sal_Bool bLong ); 91 SAL_DLLPRIVATE void WriteMinutesElement_Impl( sal_Bool bLong ); 92 SAL_DLLPRIVATE void WriteSecondsElement_Impl( sal_Bool bLong, sal_uInt16 nDecimals ); 93 SAL_DLLPRIVATE void WriteAMPMElement_Impl(); 94 SAL_DLLPRIVATE void WriteMapElement_Impl( sal_Int32 nOp, double fLimit, 95 sal_Int32 nKey, sal_Int32 nPart ); 96 97 SAL_DLLPRIVATE sal_Bool WriteTextWithCurrency_Impl( const ::rtl::OUString& rString, 98 const ::com::sun::star::lang::Locale& rLocale ); 99 SAL_DLLPRIVATE void ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt32 nKey, 100 sal_uInt16 nPart, sal_Bool bDefPart ); 101 102 SAL_DLLPRIVATE void ExportFormat_Impl( const SvNumberformat& rFormat, sal_uInt32 nKey ); 103 104 public: 105 SvXMLNumFmtExport( SvXMLExport& rExport, 106 const ::com::sun::star::uno::Reference< 107 ::com::sun::star::util::XNumberFormatsSupplier >& rSupp ); 108 SvXMLNumFmtExport( SvXMLExport& rExport, 109 const ::com::sun::star::uno::Reference< 110 ::com::sun::star::util::XNumberFormatsSupplier >& rSupp, 111 const rtl::OUString& rPrefix ); 112 113 virtual ~SvXMLNumFmtExport(); 114 115 // core API 116 void Export( sal_Bool bIsAutoStyle); 117 118 // mark number format as used 119 void SetUsed( sal_uInt32 nKey ); 120 121 // get the style name that was generated for a key 122 ::rtl::OUString GetStyleName( sal_uInt32 nKey ); 123 124 void GetWasUsed(com::sun::star::uno::Sequence<sal_Int32>& rWasUsed); 125 void SetWasUsed(const com::sun::star::uno::Sequence<sal_Int32>& rWasUsed); 126 127 128 129 // two methods to allow the field import/export to treat system languages 130 // properly: 131 132 /// obtain number format with system languange for a given key 133 sal_uInt32 ForceSystemLanguage( sal_uInt32 nKey ); 134 135 /// determine whether number format uses system language 136 bool IsSystemLanguage( sal_uInt32 nKey ); 137 }; 138 139 #endif 140 141