merge the formfield patch from ooo-build
[ooovba.git] / sc / source / filter / xml / XMLConverter.hxx
blob29ccd833d829d0dabb01f86092d477133ed7f075
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLConverter.hxx,v $
10 * $Revision: 1.15.32.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_XMLCONVERTER_HXX
32 #define SC_XMLCONVERTER_HXX
34 #include "global.hxx"
35 #include "detfunc.hxx"
36 #include "detdata.hxx"
37 #include <rtl/ustrbuf.hxx>
38 #include <com/sun/star/frame/XModel.hpp>
39 #include <com/sun/star/sheet/ConditionOperator.hpp>
40 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
41 #include <com/sun/star/sheet/GeneralFunction.hpp>
42 #include <com/sun/star/sheet/ValidationType.hpp>
43 #include <com/sun/star/util/DateTime.hpp>
45 class ScDocument;
46 class DateTime;
47 class SvXMLUnitConverter;
50 //___________________________________________________________________
52 class ScXMLConverter
54 public:
55 inline ScXMLConverter() {}
56 inline ~ScXMLConverter() {}
58 // helper methods
59 static ScDocument* GetScDocument(
60 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel );
62 // IMPORT: GeneralFunction / ScSubTotalFunc
63 static ::com::sun::star::sheet::GeneralFunction
64 GetFunctionFromString(
65 const ::rtl::OUString& rString );
66 static ScSubTotalFunc GetSubTotalFuncFromString(
67 const ::rtl::OUString& rString );
69 // EXPORT: GeneralFunction / ScSubTotalFunc
70 static void GetStringFromFunction(
71 ::rtl::OUString& rString,
72 const ::com::sun::star::sheet::GeneralFunction eFunction,
73 sal_Bool bAppendStr = sal_False );
74 static void GetStringFromFunction(
75 ::rtl::OUString& rString,
76 const ScSubTotalFunc eFunction,
77 sal_Bool bAppendStr = sal_False );
79 // IMPORT: DataPilotFieldOrientation
80 static ::com::sun::star::sheet::DataPilotFieldOrientation
81 GetOrientationFromString(
82 const ::rtl::OUString& rString );
84 // EXPORT: DataPilotFieldOrientation
85 static void GetStringFromOrientation(
86 ::rtl::OUString& rString,
87 const ::com::sun::star::sheet::DataPilotFieldOrientation eOrientation,
88 sal_Bool bAppendStr = sal_False );
90 // IMPORT: Detective
91 static ScDetectiveObjType
92 GetDetObjTypeFromString(
93 const ::rtl::OUString& rString );
94 static sal_Bool GetDetOpTypeFromString(
95 ScDetOpType& rDetOpType,
96 const ::rtl::OUString& rString );
98 // EXPORT: Detective
99 static void GetStringFromDetObjType(
100 ::rtl::OUString& rString,
101 const ScDetectiveObjType eObjType,
102 sal_Bool bAppendStr = sal_False );
103 static void GetStringFromDetOpType(
104 ::rtl::OUString& rString,
105 const ScDetOpType eOpType,
106 sal_Bool bAppendStr = sal_False );
108 // IMPORT: Formulas
109 static void ParseFormula(
110 ::rtl::OUString& sFormula,
111 const sal_Bool bIsFormula = sal_True);
112 // EXPORT: Core Date Time
113 static void ConvertDateTimeToString(const DateTime& aDateTime, rtl::OUStringBuffer& sDate);
114 //UNUSED2008-05 // IMPORT: Core Date Time
115 //UNUSED2008-05 static void ConvertStringToDateTime(const rtl::OUString& sDate, DateTime& aDateTime, SvXMLUnitConverter* pUnitConverter);
117 static void ConvertCoreToAPIDateTime(const DateTime& aDateTime, com::sun::star::util::DateTime& rDateTime);
119 static void ConvertAPIToCoreDateTime(const com::sun::star::util::DateTime& aDateTime, DateTime& rDateTime);
122 // ============================================================================
124 enum ScXMLConditionToken
126 XML_COND_INVALID, /// Token not recognized.
127 XML_COND_AND, /// The 'and' token.
128 XML_COND_CELLCONTENT, /// The 'cell-content' token.
129 XML_COND_ISBETWEEN, /// The 'cell-content-is-between' token.
130 XML_COND_ISNOTBETWEEN, /// The 'cell-content-is-not-between' token.
131 XML_COND_ISWHOLENUMBER, /// The 'cell-content-is-whole-number' token.
132 XML_COND_ISDECIMALNUMBER, /// The 'cell-content-is-decimal-number' token.
133 XML_COND_ISDATE, /// The 'cell-content-is-date' token.
134 XML_COND_ISTIME, /// The 'cell-content-is-time' token.
135 XML_COND_ISINLIST, /// The 'cell-content-is-in-list' token.
136 XML_COND_TEXTLENGTH, /// The 'cell-content-text-length' token.
137 XML_COND_TEXTLENGTH_ISBETWEEN, /// The 'cell-content-text-length-is-between' token.
138 XML_COND_TEXTLENGTH_ISNOTBETWEEN, /// The 'cell-content-text-length-is-not-between' token.
139 XML_COND_ISTRUEFORMULA /// The 'is-true-formula' token.
142 // ----------------------------------------------------------------------------
144 /** Result of an attempt to parse a single condition in a 'condition' attribute
145 value of e.g. conditional formatting or data validation.
147 struct ScXMLConditionParseResult
149 ScXMLConditionToken meToken; /// The leading condition token.
150 ::com::sun::star::sheet::ValidationType
151 meValidation; /// A data validation type if existing.
152 ::com::sun::star::sheet::ConditionOperator
153 meOperator; /// A comparison operator if existing.
154 ::rtl::OUString maOperand1; /// First operand of the token or comparison value.
155 ::rtl::OUString maOperand2; /// Second operand of 'between' conditions.
156 sal_Int32 mnEndIndex; /// Index of first character following the condition.
159 // ----------------------------------------------------------------------------
161 class ScXMLConditionHelper
163 public:
164 /** Parses the next condition in a 'condition' attribute value of e.g.
165 conditional formatting or data validation.
167 static void parseCondition(
168 ScXMLConditionParseResult& rParseResult,
169 const ::rtl::OUString& rAttribute,
170 sal_Int32 nStartIndex );
172 private:
173 ScXMLConditionHelper();
174 ~ScXMLConditionHelper();
177 // ============================================================================
179 #endif