tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / vba / vbacondition.cxx
blobc22eff9bf5fa99be9828679e3bc2d2c687a29c22
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "vbacondition.hxx"
21 #include <ooo/vba/excel/XlFormatConditionOperator.hpp>
22 #include <ooo/vba/excel/XFormatCondition.hpp>
23 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
24 #include <com/sun/star/sheet/XSheetCondition.hpp>
25 #include <basic/sberrors.hxx>
26 #include <utility>
28 using namespace ::ooo::vba;
29 using namespace ::com::sun::star;
31 const sal_Int32 ISFORMULA = 98765432;
33 template <typename... Ifc>
34 ScVbaCondition<Ifc...>::ScVbaCondition(const uno::Reference<XHelperInterface>& xParent,
35 const uno::Reference<uno::XComponentContext>& xContext,
36 uno::Reference<sheet::XSheetCondition> _xSheetCondition)
37 : ScVbaCondition_BASE(xParent, xContext)
38 , mxSheetCondition(std::move(_xSheetCondition))
40 mxAddressable.set(xParent, uno::UNO_QUERY_THROW);
43 template <typename... Ifc>
44 sheet::ConditionOperator ScVbaCondition<Ifc...>::retrieveAPIOperator(const uno::Any& _aOperator)
46 sheet::ConditionOperator aRetAPIOperator = sheet::ConditionOperator_NONE;
47 sal_Int32 nOperator = 0;
48 if (_aOperator >>= nOperator)
50 switch (nOperator)
52 case excel::XlFormatConditionOperator::xlBetween:
53 aRetAPIOperator = sheet::ConditionOperator_BETWEEN;
54 break;
55 case excel::XlFormatConditionOperator::xlNotBetween:
56 aRetAPIOperator = sheet::ConditionOperator_NOT_BETWEEN;
57 break;
58 case excel::XlFormatConditionOperator::xlEqual:
59 aRetAPIOperator = sheet::ConditionOperator_EQUAL;
60 break;
61 case excel::XlFormatConditionOperator::xlNotEqual:
62 aRetAPIOperator = sheet::ConditionOperator_NOT_EQUAL;
63 break;
64 case excel::XlFormatConditionOperator::xlGreater:
65 aRetAPIOperator = sheet::ConditionOperator_GREATER;
66 break;
67 case excel::XlFormatConditionOperator::xlLess:
68 aRetAPIOperator = sheet::ConditionOperator_LESS;
69 break;
70 case excel::XlFormatConditionOperator::xlGreaterEqual:
71 aRetAPIOperator = sheet::ConditionOperator_GREATER_EQUAL;
72 break;
73 case excel::XlFormatConditionOperator::xlLessEqual:
74 aRetAPIOperator = sheet::ConditionOperator_LESS_EQUAL;
75 break;
76 default:
77 aRetAPIOperator = sheet::ConditionOperator_NONE;
78 break;
81 return aRetAPIOperator;
84 template <typename... Ifc> OUString ScVbaCondition<Ifc...>::Formula1()
86 return mxSheetCondition->getFormula1();
89 template <typename... Ifc> OUString ScVbaCondition<Ifc...>::Formula2()
91 return mxSheetCondition->getFormula2();
94 template <typename... Ifc> sal_Int32 ScVbaCondition<Ifc...>::Operator(bool _bIncludeFormulaValue)
96 sal_Int32 retvalue = -1;
97 sheet::ConditionOperator aConditionalOperator = mxSheetCondition->getOperator();
98 switch (aConditionalOperator)
100 case sheet::ConditionOperator_EQUAL:
101 retvalue = excel::XlFormatConditionOperator::xlEqual;
102 break;
103 case sheet::ConditionOperator_NOT_EQUAL:
104 retvalue = excel::XlFormatConditionOperator::xlNotEqual;
105 break;
106 case sheet::ConditionOperator_GREATER:
107 retvalue = excel::XlFormatConditionOperator::xlGreater;
108 break;
109 case sheet::ConditionOperator_GREATER_EQUAL:
110 retvalue = excel::XlFormatConditionOperator::xlGreaterEqual;
111 break;
112 case sheet::ConditionOperator_LESS:
113 retvalue = excel::XlFormatConditionOperator::xlLess;
114 break;
115 case sheet::ConditionOperator_LESS_EQUAL:
116 retvalue = excel::XlFormatConditionOperator::xlLessEqual;
117 break;
118 case sheet::ConditionOperator_BETWEEN:
119 retvalue = excel::XlFormatConditionOperator::xlBetween;
120 break;
121 case sheet::ConditionOperator_NOT_BETWEEN:
122 retvalue = excel::XlFormatConditionOperator::xlNotBetween;
123 break;
124 case sheet::ConditionOperator_FORMULA:
125 if (_bIncludeFormulaValue)
127 //#FIXME huh what's this all about
128 // from helperapi/impl/.../calc/ConditionImpl
129 retvalue = ISFORMULA;
130 break;
132 [[fallthrough]]; //TODO ???
133 case sheet::ConditionOperator_NONE:
134 default:
135 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, u"Operator not supported");
136 break;
138 return retvalue;
141 template class ScVbaCondition<excel::XFormatCondition>;
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */