LibreOffice Module sc (master) 1
vbaformatcondition.cxx
Go to the documentation of this file.
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 */
21#include <unonames.hxx>
22#include <ooo/vba/excel/XlFormatConditionType.hpp>
23#include <basic/sberrors.hxx>
24#include <utility>
25
26using namespace ::ooo::vba;
27using namespace ::com::sun::star;
28
31lcl_getScVbaFormatConditionsPtr( const uno::Reference< excel::XFormatConditions >& xFormatConditions )
32{
33 ScVbaFormatConditions* pFormatConditions = static_cast< ScVbaFormatConditions* >( xFormatConditions.get() );
34 if ( !pFormatConditions )
35 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
36 return pFormatConditions;
37}
38
39ScVbaFormatCondition::ScVbaFormatCondition( const uno::Reference< XHelperInterface >& xParent,
40 const uno::Reference< uno::XComponentContext > & xContext,
41 const uno::Reference< sheet::XSheetConditionalEntry >& _xSheetConditionalEntry,
42 uno::Reference< excel::XStyle > _xStyle,
43 uno::Reference< excel::XFormatConditions > _xFormatConditions,
44 uno::Reference< css::beans::XPropertySet > _xPropertySet )
45 : ScVbaFormatCondition_BASE( xParent, xContext,
46 uno::Reference< sheet::XSheetCondition >( _xSheetConditionalEntry, css::uno::UNO_QUERY_THROW ) ),
47 moFormatConditions(std::move( _xFormatConditions )), mxStyle(std::move( _xStyle )), mxParentRangePropertySet(std::move( _xPropertySet ))
48{
50
51 msStyleName = mxStyle->getName();
52}
53
54void SAL_CALL
56{
58 pFormatConditions->removeFormatCondition(msStyleName, true);
60}
61
62void SAL_CALL
63ScVbaFormatCondition::Modify( ::sal_Int32 _nType, const uno::Any& _aOperator, const uno::Any& _aFormula1, const uno::Any& _aFormula2 )
64{
65 try
66 {
68 pFormatConditions->removeFormatCondition(msStyleName, false);
69 pFormatConditions->Add(_nType, _aOperator, _aFormula1, _aFormula2, mxStyle);
70 }
71 catch (const uno::Exception&)
72 {
73 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
74 }
75}
76
77uno::Reference< excel::XInterior > SAL_CALL
79{
80 return mxStyle->Interior();
81}
82
83uno::Reference< excel::XFont > SAL_CALL
85{
86 return mxStyle->Font();
87}
88uno::Any SAL_CALL
90{ return mxStyle->Borders( Index );
91}
92
93sheet::ConditionOperator
94ScVbaFormatCondition::retrieveAPIType(sal_Int32 _nVBAType, const uno::Reference< sheet::XSheetCondition >& _xSheetCondition )
95{
96 sheet::ConditionOperator aAPIType = sheet::ConditionOperator_NONE;
97 switch (_nVBAType)
98 {
99 case excel::XlFormatConditionType::xlExpression:
100 aAPIType = sheet::ConditionOperator_FORMULA;
101 break;
102 case excel::XlFormatConditionType::xlCellValue:
103 if ( _xSheetCondition.is() && (_xSheetCondition->getOperator() == sheet::ConditionOperator_FORMULA ) )
104 aAPIType = sheet::ConditionOperator_NONE;
105 break;
106 default:
107 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
108 }
109 return aAPIType;
110}
111
112::sal_Int32 SAL_CALL
114{
115 sal_Int32 nReturnType = 0;
116 if ( mxSheetCondition->getOperator() == sheet::ConditionOperator_FORMULA)
117 nReturnType = excel::XlFormatConditionType::xlExpression;
118 else
119 nReturnType = excel::XlFormatConditionType::xlCellValue;
120 return nReturnType;
121}
122
123::sal_Int32 SAL_CALL
125{
127}
128
129void
131{
132 try
133 {
135 }
136 catch (uno::Exception& )
137 {
138 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
139 }
140}
141
142OUString
144{
145 return "ScVbaFormatCondition";
146}
147
148uno::Sequence< OUString >
150{
151 static uno::Sequence< OUString > const aServiceNames
152 {
153 "ooo.vba.excel.FormatCondition"
154 };
155 return aServiceNames;
156}
157
158/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
css::uno::Reference< css::sheet::XSheetCondition > mxSheetCondition
virtual sal_Int32 SAL_CALL Operator() override=0
css::uno::Reference< ov::excel::XFormatConditions > moFormatConditions
static css::sheet::ConditionOperator retrieveAPIType(sal_Int32 _nVBAType, const css::uno::Reference< css::sheet::XSheetCondition > &_xSheetCondition)
virtual ::sal_Int32 SAL_CALL Type() override
css::uno::Reference< ov::excel::XStyle > mxStyle
css::uno::Reference< css::sheet::XSheetConditionalEntries > mxSheetConditionalEntries
ScVbaFormatCondition(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::sheet::XSheetConditionalEntry > &_xSheetConditionalEntry, css::uno::Reference< ov::excel::XStyle >, css::uno::Reference< ov::excel::XFormatConditions > _xFormatConditions, css::uno::Reference< css::beans::XPropertySet > _xPropertySet)
virtual css::uno::Reference< ::ooo::vba::excel::XFont > SAL_CALL Font() override
virtual css::uno::Reference< ::ooo::vba::excel::XInterior > SAL_CALL Interior() override
virtual OUString getServiceImplName() override
virtual ::sal_Int32 SAL_CALL Operator() override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual void SAL_CALL Delete() override
virtual void SAL_CALL Modify(::sal_Int32 Type, const css::uno::Any &Operator, const css::uno::Any &Formula1, const css::uno::Any &Formula2) override
css::uno::Reference< css::beans::XPropertySet > mxParentRangePropertySet
virtual css::uno::Any SAL_CALL Borders(const css::uno::Any &Index) override
css::uno::Reference< ov::excel::XFormatCondition > Add(::sal_Int32 Type, const css::uno::Any &Operator, const css::uno::Any &Formula1, const css::uno::Any &Formula2, const css::uno::Reference< ov::excel::XStyle > &_xCalcStyle)
void removeFormatCondition(const OUString &_sStyleName, bool _bRemoveStyle)
const css::uno::Reference< css::sheet::XSheetConditionalEntries > & getSheetConditionalEntries() const
Sequence< OUString > aServiceNames
Reference< XPropertySet > _xPropertySet
Reference
#define ERRCODE_BASIC_METHOD_FAILED
constexpr OUStringLiteral SC_UNONAME_CONDFMT
Definition: unonames.hxx:213
static ScVbaFormatConditions * lcl_getScVbaFormatConditionsPtr(const uno::Reference< excel::XFormatConditions > &xFormatConditions)