1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _XMLOFF_XMLNUMFE_HXX 25 #define _XMLOFF_XMLNUMFE_HXX 26 27 #include "sal/config.h" 28 #include "xmloff/dllapi.h" 29 #include "sal/types.h" 30 #include <com/sun/star/util/XNumberFormatsSupplier.hpp> 31 #include <com/sun/star/uno/Sequence.h> 32 #include <rtl/ustrbuf.hxx> 33 34 #define XML_WRITTENNUMBERSTYLES "WrittenNumberStyles" 35 36 class Color; 37 class LocaleDataWrapper; 38 class CharClass; 39 class SvXMLExport; 40 class SvXMLNamespaceMap; 41 class SvXMLAttributeList; 42 class SvNumberFormatter; 43 class SvNumberformat; 44 class SvXMLNumUsedList_Impl; 45 class SvXMLEmbeddedTextEntryArr; 46 47 class XMLOFF_DLLPUBLIC SvXMLNumFmtExport 48 { 49 private: 50 SvXMLExport& rExport; 51 ::rtl::OUString sPrefix; 52 SvNumberFormatter* pFormatter; 53 ::rtl::OUStringBuffer sTextContent; 54 SvXMLNumUsedList_Impl* pUsedList; 55 CharClass* pCharClass; 56 LocaleDataWrapper* pLocaleData; 57 58 SAL_DLLPRIVATE void AddCalendarAttr_Impl( const ::rtl::OUString& rCalendar ); 59 SAL_DLLPRIVATE void AddStyleAttr_Impl( sal_Bool bLong ); 60 SAL_DLLPRIVATE void AddTextualAttr_Impl( sal_Bool bText ); 61 SAL_DLLPRIVATE void AddLanguageAttr_Impl( sal_Int32 nLang ); 62 63 SAL_DLLPRIVATE void AddToTextElement_Impl( const ::rtl::OUString& rString ); 64 SAL_DLLPRIVATE void FinishTextElement_Impl(); 65 66 SAL_DLLPRIVATE void WriteColorElement_Impl( const Color& rColor ); 67 SAL_DLLPRIVATE void WriteNumberElement_Impl( sal_Int32 nDecimals, sal_Int32 nInteger, 68 const ::rtl::OUString& rDashStr, sal_Bool bVarDecimals, 69 sal_Bool bGrouping, sal_Int32 nTrailingThousands, 70 const SvXMLEmbeddedTextEntryArr& rEmbeddedEntries ); 71 SAL_DLLPRIVATE void WriteScientificElement_Impl( sal_Int32 nDecimals, sal_Int32 nInteger, 72 sal_Bool bGrouping, sal_Int32 nExp ); 73 SAL_DLLPRIVATE void WriteFractionElement_Impl( sal_Int32 nInteger, sal_Bool bGrouping, 74 sal_Int32 nNumerator, sal_Int32 nDenominator ); 75 SAL_DLLPRIVATE void WriteCurrencyElement_Impl( const ::rtl::OUString& rString, 76 const ::rtl::OUString& rExt ); 77 SAL_DLLPRIVATE void WriteBooleanElement_Impl(); 78 SAL_DLLPRIVATE void WriteTextContentElement_Impl(); 79 SAL_DLLPRIVATE void WriteDayElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 80 SAL_DLLPRIVATE void WriteMonthElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong, sal_Bool bText ); 81 SAL_DLLPRIVATE void WriteYearElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 82 SAL_DLLPRIVATE void WriteEraElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 83 SAL_DLLPRIVATE void WriteDayOfWeekElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 84 SAL_DLLPRIVATE void WriteWeekElement_Impl( const ::rtl::OUString& rCalendar ); 85 SAL_DLLPRIVATE void WriteQuarterElement_Impl( const ::rtl::OUString& rCalendar, sal_Bool bLong ); 86 SAL_DLLPRIVATE void WriteHoursElement_Impl( sal_Bool bLong ); 87 SAL_DLLPRIVATE void WriteMinutesElement_Impl( sal_Bool bLong ); 88 SAL_DLLPRIVATE void WriteSecondsElement_Impl( sal_Bool bLong, sal_uInt16 nDecimals ); 89 SAL_DLLPRIVATE void WriteAMPMElement_Impl(); 90 SAL_DLLPRIVATE void WriteMapElement_Impl( sal_Int32 nOp, double fLimit, 91 sal_Int32 nKey, sal_Int32 nPart ); 92 93 SAL_DLLPRIVATE sal_Bool WriteTextWithCurrency_Impl( const ::rtl::OUString& rString, 94 const ::com::sun::star::lang::Locale& rLocale ); 95 SAL_DLLPRIVATE void ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt32 nKey, 96 sal_uInt16 nPart, sal_Bool bDefPart ); 97 98 SAL_DLLPRIVATE void ExportFormat_Impl( const SvNumberformat& rFormat, sal_uInt32 nKey ); 99 100 public: 101 SvXMLNumFmtExport( SvXMLExport& rExport, 102 const ::com::sun::star::uno::Reference< 103 ::com::sun::star::util::XNumberFormatsSupplier >& rSupp ); 104 SvXMLNumFmtExport( SvXMLExport& rExport, 105 const ::com::sun::star::uno::Reference< 106 ::com::sun::star::util::XNumberFormatsSupplier >& rSupp, 107 const rtl::OUString& rPrefix ); 108 109 virtual ~SvXMLNumFmtExport(); 110 111 // core API 112 void Export( sal_Bool bIsAutoStyle); 113 114 // mark number format as used 115 void SetUsed( sal_uInt32 nKey ); 116 117 // get the style name that was generated for a key 118 ::rtl::OUString GetStyleName( sal_uInt32 nKey ); 119 120 void GetWasUsed(com::sun::star::uno::Sequence<sal_Int32>& rWasUsed); 121 void SetWasUsed(const com::sun::star::uno::Sequence<sal_Int32>& rWasUsed); 122 123 124 125 // two methods to allow the field import/export to treat system languages 126 // properly: 127 128 /// obtain number format with system languange for a given key 129 sal_uInt32 ForceSystemLanguage( sal_uInt32 nKey ); 130 131 /// determine whether number format uses system language 132 bool IsSystemLanguage( sal_uInt32 nKey ); 133 }; 134 135 #endif 136 137