Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLCONVERTER_HXX
21 : #define INCLUDED_SC_SOURCE_FILTER_XML_XMLCONVERTER_HXX
22 :
23 : #include "global.hxx"
24 : #include "detfunc.hxx"
25 : #include "detdata.hxx"
26 : #include <rtl/ustrbuf.hxx>
27 : #include <com/sun/star/frame/XModel.hpp>
28 : #include <com/sun/star/sheet/ConditionOperator.hpp>
29 : #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
30 : #include <com/sun/star/sheet/GeneralFunction.hpp>
31 : #include <com/sun/star/sheet/ValidationType.hpp>
32 : #include <com/sun/star/util/DateTime.hpp>
33 :
34 : class ScDocument;
35 : class DateTime;
36 :
37 : class ScXMLConverter
38 : {
39 : public:
40 : inline ScXMLConverter() {}
41 : inline ~ScXMLConverter() {}
42 :
43 : // helper methods
44 : static ScDocument* GetScDocument(
45 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel );
46 :
47 : // IMPORT: GeneralFunction / ScSubTotalFunc
48 : static ::com::sun::star::sheet::GeneralFunction
49 : GetFunctionFromString(
50 : const OUString& rString );
51 : static ScSubTotalFunc GetSubTotalFuncFromString(
52 : const OUString& rString );
53 :
54 : // EXPORT: GeneralFunction / ScSubTotalFunc
55 : static void GetStringFromFunction(
56 : OUString& rString,
57 : const ::com::sun::star::sheet::GeneralFunction eFunction,
58 : bool bAppendStr = false );
59 : static void GetStringFromFunction(
60 : OUString& rString,
61 : const ScSubTotalFunc eFunction,
62 : bool bAppendStr = false );
63 :
64 : // IMPORT: DataPilotFieldOrientation
65 : static ::com::sun::star::sheet::DataPilotFieldOrientation
66 : GetOrientationFromString(
67 : const OUString& rString );
68 :
69 : // EXPORT: DataPilotFieldOrientation
70 : static void GetStringFromOrientation(
71 : OUString& rString,
72 : const ::com::sun::star::sheet::DataPilotFieldOrientation eOrientation,
73 : bool bAppendStr = false );
74 :
75 : // IMPORT: Detective
76 : static ScDetectiveObjType
77 : GetDetObjTypeFromString(
78 : const OUString& rString );
79 : static bool GetDetOpTypeFromString(
80 : ScDetOpType& rDetOpType,
81 : const OUString& rString );
82 :
83 : // EXPORT: Detective
84 : static void GetStringFromDetObjType(
85 : OUString& rString,
86 : const ScDetectiveObjType eObjType,
87 : bool bAppendStr = false );
88 : static void GetStringFromDetOpType(
89 : OUString& rString,
90 : const ScDetOpType eOpType,
91 : bool bAppendStr = false );
92 :
93 : // IMPORT: Formulas
94 : static void ParseFormula(
95 : OUString& sFormula,
96 : const bool bIsFormula = true);
97 : // EXPORT: Core Date Time
98 : static void ConvertDateTimeToString(const DateTime& aDateTime, OUStringBuffer& sDate);
99 :
100 : };
101 :
102 : enum ScXMLConditionToken
103 : {
104 : XML_COND_INVALID, /// Token not recognized.
105 : XML_COND_AND, /// The 'and' token.
106 : XML_COND_CELLCONTENT, /// The 'cell-content' token.
107 : XML_COND_ISBETWEEN, /// The 'cell-content-is-between' token.
108 : XML_COND_ISNOTBETWEEN, /// The 'cell-content-is-not-between' token.
109 : XML_COND_ISWHOLENUMBER, /// The 'cell-content-is-whole-number' token.
110 : XML_COND_ISDECIMALNUMBER, /// The 'cell-content-is-decimal-number' token.
111 : XML_COND_ISDATE, /// The 'cell-content-is-date' token.
112 : XML_COND_ISTIME, /// The 'cell-content-is-time' token.
113 : XML_COND_ISINLIST, /// The 'cell-content-is-in-list' token.
114 : XML_COND_TEXTLENGTH, /// The 'cell-content-text-length' token.
115 : XML_COND_TEXTLENGTH_ISBETWEEN, /// The 'cell-content-text-length-is-between' token.
116 : XML_COND_TEXTLENGTH_ISNOTBETWEEN, /// The 'cell-content-text-length-is-not-between' token.
117 : XML_COND_ISTRUEFORMULA /// The 'is-true-formula' token.
118 : };
119 :
120 : /** Result of an attempt to parse a single condition in a 'condition' attribute
121 : value of e.g. conditional formatting or data validation.
122 : */
123 78 : struct ScXMLConditionParseResult
124 : {
125 : ScXMLConditionToken meToken; /// The leading condition token.
126 : ::com::sun::star::sheet::ValidationType
127 : meValidation; /// A data validation type if existing.
128 : ::com::sun::star::sheet::ConditionOperator
129 : meOperator; /// A comparison operator if existing.
130 : OUString maOperand1; /// First operand of the token or comparison value.
131 : OUString maOperand2; /// Second operand of 'between' conditions.
132 : sal_Int32 mnEndIndex; /// Index of first character following the condition.
133 : };
134 :
135 : namespace ScXMLConditionHelper
136 : {
137 : /** Parses the next condition in a 'condition' attribute value of e.g.
138 : conditional formatting or data validation.
139 : */
140 : void parseCondition(
141 : ScXMLConditionParseResult& rParseResult,
142 : const OUString& rAttribute,
143 : sal_Int32 nStartIndex );
144 :
145 : OUString getExpression(const sal_Unicode*& rpcString, const sal_Unicode* pcEnd, sal_Unicode cEndChar );
146 : }
147 :
148 : #endif
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|