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 SC_XMLCONVERTER_HXX 25 #define SC_XMLCONVERTER_HXX 26 27 #include "global.hxx" 28 #include "detfunc.hxx" 29 #include "detdata.hxx" 30 #include <rtl/ustrbuf.hxx> 31 #include <com/sun/star/frame/XModel.hpp> 32 #include <com/sun/star/sheet/ConditionOperator.hpp> 33 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> 34 #include <com/sun/star/sheet/GeneralFunction.hpp> 35 #include <com/sun/star/sheet/ValidationType.hpp> 36 #include <com/sun/star/util/DateTime.hpp> 37 38 class ScDocument; 39 class DateTime; 40 class SvXMLUnitConverter; 41 42 43 //___________________________________________________________________ 44 45 class ScXMLConverter 46 { 47 public: ScXMLConverter()48 inline ScXMLConverter() {} ~ScXMLConverter()49 inline ~ScXMLConverter() {} 50 51 // helper methods 52 static ScDocument* GetScDocument( 53 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel ); 54 55 // IMPORT: GeneralFunction / ScSubTotalFunc 56 static ::com::sun::star::sheet::GeneralFunction 57 GetFunctionFromString( 58 const ::rtl::OUString& rString ); 59 static ScSubTotalFunc GetSubTotalFuncFromString( 60 const ::rtl::OUString& rString ); 61 62 // EXPORT: GeneralFunction / ScSubTotalFunc 63 static void GetStringFromFunction( 64 ::rtl::OUString& rString, 65 const ::com::sun::star::sheet::GeneralFunction eFunction, 66 sal_Bool bAppendStr = sal_False ); 67 static void GetStringFromFunction( 68 ::rtl::OUString& rString, 69 const ScSubTotalFunc eFunction, 70 sal_Bool bAppendStr = sal_False ); 71 72 // IMPORT: DataPilotFieldOrientation 73 static ::com::sun::star::sheet::DataPilotFieldOrientation 74 GetOrientationFromString( 75 const ::rtl::OUString& rString ); 76 77 // EXPORT: DataPilotFieldOrientation 78 static void GetStringFromOrientation( 79 ::rtl::OUString& rString, 80 const ::com::sun::star::sheet::DataPilotFieldOrientation eOrientation, 81 sal_Bool bAppendStr = sal_False ); 82 83 // IMPORT: Detective 84 static ScDetectiveObjType 85 GetDetObjTypeFromString( 86 const ::rtl::OUString& rString ); 87 static sal_Bool GetDetOpTypeFromString( 88 ScDetOpType& rDetOpType, 89 const ::rtl::OUString& rString ); 90 91 // EXPORT: Detective 92 static void GetStringFromDetObjType( 93 ::rtl::OUString& rString, 94 const ScDetectiveObjType eObjType, 95 sal_Bool bAppendStr = sal_False ); 96 static void GetStringFromDetOpType( 97 ::rtl::OUString& rString, 98 const ScDetOpType eOpType, 99 sal_Bool bAppendStr = sal_False ); 100 101 // IMPORT: Formulas 102 static void ParseFormula( 103 ::rtl::OUString& sFormula, 104 const sal_Bool bIsFormula = sal_True); 105 // EXPORT: Core Date Time 106 static void ConvertDateTimeToString(const DateTime& aDateTime, rtl::OUStringBuffer& sDate); 107 //UNUSED2008-05 // IMPORT: Core Date Time 108 //UNUSED2008-05 static void ConvertStringToDateTime(const rtl::OUString& sDate, DateTime& aDateTime, SvXMLUnitConverter* pUnitConverter); 109 110 static void ConvertCoreToAPIDateTime(const DateTime& aDateTime, com::sun::star::util::DateTime& rDateTime); 111 112 static void ConvertAPIToCoreDateTime(const com::sun::star::util::DateTime& aDateTime, DateTime& rDateTime); 113 }; 114 115 // ============================================================================ 116 117 enum ScXMLConditionToken 118 { 119 XML_COND_INVALID, /// Token not recognized. 120 XML_COND_AND, /// The 'and' token. 121 XML_COND_CELLCONTENT, /// The 'cell-content' token. 122 XML_COND_ISBETWEEN, /// The 'cell-content-is-between' token. 123 XML_COND_ISNOTBETWEEN, /// The 'cell-content-is-not-between' token. 124 XML_COND_ISWHOLENUMBER, /// The 'cell-content-is-whole-number' token. 125 XML_COND_ISDECIMALNUMBER, /// The 'cell-content-is-decimal-number' token. 126 XML_COND_ISDATE, /// The 'cell-content-is-date' token. 127 XML_COND_ISTIME, /// The 'cell-content-is-time' token. 128 XML_COND_ISINLIST, /// The 'cell-content-is-in-list' token. 129 XML_COND_TEXTLENGTH, /// The 'cell-content-text-length' token. 130 XML_COND_TEXTLENGTH_ISBETWEEN, /// The 'cell-content-text-length-is-between' token. 131 XML_COND_TEXTLENGTH_ISNOTBETWEEN, /// The 'cell-content-text-length-is-not-between' token. 132 XML_COND_ISTRUEFORMULA /// The 'is-true-formula' token. 133 }; 134 135 // ---------------------------------------------------------------------------- 136 137 /** Result of an attempt to parse a single condition in a 'condition' attribute 138 value of e.g. conditional formatting or data validation. 139 */ 140 struct ScXMLConditionParseResult 141 { 142 ScXMLConditionToken meToken; /// The leading condition token. 143 ::com::sun::star::sheet::ValidationType 144 meValidation; /// A data validation type if existing. 145 ::com::sun::star::sheet::ConditionOperator 146 meOperator; /// A comparison operator if existing. 147 ::rtl::OUString maOperand1; /// First operand of the token or comparison value. 148 ::rtl::OUString maOperand2; /// Second operand of 'between' conditions. 149 sal_Int32 mnEndIndex; /// Index of first character following the condition. 150 }; 151 152 // ---------------------------------------------------------------------------- 153 154 class ScXMLConditionHelper 155 { 156 public: 157 /** Parses the next condition in a 'condition' attribute value of e.g. 158 conditional formatting or data validation. 159 */ 160 static void parseCondition( 161 ScXMLConditionParseResult& rParseResult, 162 const ::rtl::OUString& rAttribute, 163 sal_Int32 nStartIndex ); 164 165 private: 166 ScXMLConditionHelper(); 167 ~ScXMLConditionHelper(); 168 }; 169 170 // ============================================================================ 171 172 #endif 173 174