fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / vba / vbacondition.cxx
blob060d33d8821c6163ea3265a40c947309f4474cf8
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/table/XCellRange.hpp>
24 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
26 using namespace ::ooo::vba;
27 using namespace ::com::sun::star;
29 const sal_Int32 ISFORMULA = 98765432;
31 template< typename Ifc1 >
32 ScVbaCondition< Ifc1 >::ScVbaCondition( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetCondition >& _xSheetCondition ) : ScVbaCondition_BASE( xParent, xContext ), mxSheetCondition( _xSheetCondition )
34 mxAddressable.set( xParent, uno::UNO_QUERY_THROW );
37 template< typename Ifc1 >
38 sheet::ConditionOperator
39 ScVbaCondition< Ifc1 >::retrieveAPIOperator( const uno::Any& _aOperator) throw ( script::BasicErrorException )
41 sheet::ConditionOperator aRetAPIOperator = sheet::ConditionOperator_NONE;
42 sal_Int32 nOperator = 0;
43 if ( (_aOperator >>= nOperator ) )
45 switch(nOperator)
47 case excel::XlFormatConditionOperator::xlBetween:
48 aRetAPIOperator = sheet::ConditionOperator_BETWEEN;
49 break;
50 case excel::XlFormatConditionOperator::xlNotBetween:
51 aRetAPIOperator = sheet::ConditionOperator_NOT_BETWEEN;
52 break;
53 case excel::XlFormatConditionOperator::xlEqual:
54 aRetAPIOperator = sheet::ConditionOperator_EQUAL;
55 break;
56 case excel::XlFormatConditionOperator::xlNotEqual:
57 aRetAPIOperator = sheet::ConditionOperator_NOT_EQUAL;
58 break;
59 case excel::XlFormatConditionOperator::xlGreater:
60 aRetAPIOperator = sheet::ConditionOperator_GREATER;
61 break;
62 case excel::XlFormatConditionOperator::xlLess:
63 aRetAPIOperator = sheet::ConditionOperator_LESS;
64 break;
65 case excel::XlFormatConditionOperator::xlGreaterEqual:
66 aRetAPIOperator = sheet::ConditionOperator_GREATER_EQUAL;
67 break;
68 case excel::XlFormatConditionOperator::xlLessEqual:
69 aRetAPIOperator = sheet::ConditionOperator_LESS_EQUAL;
70 break;
71 default:
72 aRetAPIOperator = sheet::ConditionOperator_NONE;
73 break;
76 return aRetAPIOperator;
79 template< typename Ifc1 >
80 OUString
81 ScVbaCondition< Ifc1 >::Formula1( ) throw ( script::BasicErrorException, uno::RuntimeException )
83 return mxSheetCondition->getFormula1();
86 template< typename Ifc1 >
87 OUString
88 ScVbaCondition< Ifc1 >::Formula2( ) throw ( script::BasicErrorException, uno::RuntimeException )
90 return mxSheetCondition->getFormula2();
93 template< typename Ifc1 >
94 void
95 ScVbaCondition< Ifc1 >::setFormula1( const uno::Any& _aFormula1) throw ( script::BasicErrorException )
97 OUString sFormula;
98 if ( (_aFormula1 >>= sFormula ))
100 mxSheetCondition->setFormula1( sFormula );
101 table::CellRangeAddress aCellRangeAddress = mxAddressable->getRangeAddress();
102 table::CellAddress aCellAddress( aCellRangeAddress.Sheet, aCellRangeAddress.StartColumn, aCellRangeAddress.StartRow );
103 mxSheetCondition->setSourcePosition(aCellAddress);
107 template< typename Ifc1 >
108 void
109 ScVbaCondition< Ifc1 >::setFormula2( const uno::Any& _aFormula2) throw ( script::BasicErrorException )
111 OUString sFormula2;
112 // #TODO surely this can't be right?
113 // ( from helperapi/impl/.../calc/ConditionImpl.java
114 if ( (_aFormula2 >>= sFormula2 ))
115 mxSheetCondition->setFormula1(sFormula2);
118 template< typename Ifc1 >
119 sal_Int32
120 ScVbaCondition< Ifc1 >::Operator(bool _bIncludeFormulaValue) throw ( script::BasicErrorException )
122 sal_Int32 retvalue = -1;
123 sheet::ConditionOperator aConditionalOperator = mxSheetCondition->getOperator();
124 switch (aConditionalOperator)
126 case sheet::ConditionOperator_EQUAL:
127 retvalue = excel::XlFormatConditionOperator::xlEqual;
128 break;
129 case sheet::ConditionOperator_NOT_EQUAL:
130 retvalue = excel::XlFormatConditionOperator::xlNotEqual;
131 break;
132 case sheet::ConditionOperator_GREATER:
133 retvalue = excel::XlFormatConditionOperator::xlGreater;
134 break;
135 case sheet::ConditionOperator_GREATER_EQUAL:
136 retvalue = excel::XlFormatConditionOperator::xlGreaterEqual;
137 break;
138 case sheet::ConditionOperator_LESS:
139 retvalue = excel::XlFormatConditionOperator::xlLess;
140 break;
141 case sheet::ConditionOperator_LESS_EQUAL:
142 retvalue = excel::XlFormatConditionOperator::xlLessEqual;
143 break;
144 case sheet::ConditionOperator_BETWEEN:
145 retvalue = excel::XlFormatConditionOperator::xlBetween;
146 break;
147 case sheet::ConditionOperator_NOT_BETWEEN:
148 retvalue = excel::XlFormatConditionOperator::xlNotBetween;
149 break;
150 case sheet::ConditionOperator_FORMULA:
151 if (_bIncludeFormulaValue)
153 //#FIXME huh what's this all about
154 // from helperapi/impl/.../calc/ConditionImpl
155 retvalue = ISFORMULA;
156 break;
158 case sheet::ConditionOperator_NONE:
159 default:
160 DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString("Operator not supported"));
161 break;
163 return retvalue;
166 template class ScVbaCondition< excel::XFormatCondition >;
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */