1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 #include <detfunc.hxx>
24 #include <detdata.hxx>
25 #include <rtl/ustrbuf.hxx>
26 #include <com/sun/star/sheet/ConditionOperator.hpp>
27 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
28 #include <com/sun/star/sheet/GeneralFunction.hpp>
29 #include <com/sun/star/sheet/ValidationType.hpp>
31 namespace com::sun::star::frame
{ class XModel
; }
35 enum class ScGeneralFunction
;
40 ScXMLConverter() = delete;
43 static ScDocument
* GetScDocument(
44 const css::uno::Reference
< css::frame::XModel
>& xModel
);
46 // IMPORT: GeneralFunction / ScSubTotalFunc
47 static css::sheet::GeneralFunction
48 GetFunctionFromString(
49 std::u16string_view rString
);
50 static ScGeneralFunction
51 GetFunctionFromString2(
52 std::u16string_view rString
);
54 static ScSubTotalFunc
GetSubTotalFuncFromString(
55 std::u16string_view rString
);
57 // EXPORT: GeneralFunctio2 / ScSubTotalFunc
58 static OUString
GetStringFromFunction(
59 const sal_Int16 eFunction
);
60 static OUString
GetStringFromFunction(
61 const ScSubTotalFunc eFunction
);
63 // IMPORT: DataPilotFieldOrientation
64 static css::sheet::DataPilotFieldOrientation
65 GetOrientationFromString(
66 std::u16string_view rString
);
68 // EXPORT: DataPilotFieldOrientation
69 static OUString
GetStringFromOrientation(
70 const css::sheet::DataPilotFieldOrientation eOrientation
);
73 static ScDetectiveObjType
74 GetDetObjTypeFromString(
75 std::u16string_view rString
);
76 static bool GetDetOpTypeFromString(
77 ScDetOpType
& rDetOpType
,
78 std::u16string_view rString
);
81 static OUString
GetStringFromDetObjType(
82 const ScDetectiveObjType eObjType
);
83 static OUString
GetStringFromDetOpType(
84 const ScDetOpType eOpType
);
87 static void ConvertCellRangeAddress(
89 // EXPORT: Core Date Time
90 static void ConvertDateTimeToString(const DateTime
& aDateTime
, OUStringBuffer
& sDate
);
94 enum ScXMLConditionToken
96 XML_COND_INVALID
, /// Token not recognized.
97 XML_COND_AND
, /// The 'and' token.
98 XML_COND_CELLCONTENT
, /// The 'cell-content' token.
99 XML_COND_ISBETWEEN
, /// The 'cell-content-is-between' token.
100 XML_COND_ISNOTBETWEEN
, /// The 'cell-content-is-not-between' token.
101 XML_COND_ISWHOLENUMBER
, /// The 'cell-content-is-whole-number' token.
102 XML_COND_ISDECIMALNUMBER
, /// The 'cell-content-is-decimal-number' token.
103 XML_COND_ISDATE
, /// The 'cell-content-is-date' token.
104 XML_COND_ISTIME
, /// The 'cell-content-is-time' token.
105 XML_COND_ISINLIST
, /// The 'cell-content-is-in-list' token.
106 XML_COND_TEXTLENGTH
, /// The 'cell-content-text-length' token.
107 XML_COND_TEXTLENGTH_ISBETWEEN
, /// The 'cell-content-text-length-is-between' token.
108 XML_COND_TEXTLENGTH_ISNOTBETWEEN
, /// The 'cell-content-text-length-is-not-between' token.
109 XML_COND_ISTRUEFORMULA
/// The 'is-true-formula' token.
112 /** Result of an attempt to parse a single condition in a 'condition' attribute
113 value of e.g. conditional formatting or data validation.
115 struct ScXMLConditionParseResult
117 ScXMLConditionToken meToken
; /// The leading condition token.
118 css::sheet::ValidationType
119 meValidation
; /// A data validation type if existing.
120 css::sheet::ConditionOperator
121 meOperator
; /// A comparison operator if existing.
122 OUString maOperand1
; /// First operand of the token or comparison value.
123 OUString maOperand2
; /// Second operand of 'between' conditions.
124 sal_Int32 mnEndIndex
; /// Index of first character following the condition.
126 ScXMLConditionParseResult()
127 : meToken(XML_COND_INVALID
)
128 , meValidation(css::sheet::ValidationType_ANY
)
129 , meOperator(css::sheet::ConditionOperator_NONE
)
135 namespace ScXMLConditionHelper
137 /** Parses the next condition in a 'condition' attribute value of e.g.
138 conditional formatting or data validation.
141 ScXMLConditionParseResult
& rParseResult
,
142 const OUString
& rAttribute
,
143 sal_Int32 nStartIndex
);
145 OUString
getExpression(const sal_Unicode
*& rpcString
, const sal_Unicode
* pcEnd
, sal_Unicode cEndChar
);
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */