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
25using namespace ::ooo::vba;
26using namespace ::com::sun::star;
27
30lcl_getScVbaFormatConditionsPtr( const uno::Reference< excel::XFormatConditions >& xFormatConditions )
31{
32 ScVbaFormatConditions* pFormatConditions = static_cast< ScVbaFormatConditions* >( xFormatConditions.get() );
33 if ( !pFormatConditions )
34 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
35 return pFormatConditions;
36}
37
38ScVbaFormatCondition::ScVbaFormatCondition( const uno::Reference< XHelperInterface >& xParent,
39 const uno::Reference< uno::XComponentContext > & xContext,
40 const uno::Reference< sheet::XSheetConditionalEntry >& _xSheetConditionalEntry,
41 const uno::Reference< excel::XStyle >& _xStyle,
42 const uno::Reference< excel::XFormatConditions >& _xFormatConditions,
43 const uno::Reference< css::beans::XPropertySet >& _xPropertySet )
44 : ScVbaFormatCondition_BASE( xParent, xContext,
45 uno::Reference< sheet::XSheetCondition >( _xSheetConditionalEntry, css::uno::UNO_QUERY_THROW ) ),
46 moFormatConditions( _xFormatConditions ), mxStyle( _xStyle ), mxParentRangePropertySet( _xPropertySet )
47{
49
50 msStyleName = mxStyle->getName();
51}
52
53void SAL_CALL
55{
57 pFormatConditions->removeFormatCondition(msStyleName, true);
59}
60
61void SAL_CALL
62ScVbaFormatCondition::Modify( ::sal_Int32 _nType, const uno::Any& _aOperator, const uno::Any& _aFormula1, const uno::Any& _aFormula2 )
63{
64 try
65 {
67 pFormatConditions->removeFormatCondition(msStyleName, false);
68 pFormatConditions->Add(_nType, _aOperator, _aFormula1, _aFormula2, mxStyle);
69 }
70 catch (const uno::Exception&)
71 {
72 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
73 }
74}
75
76uno::Reference< excel::XInterior > SAL_CALL
78{
79 return mxStyle->Interior();
80}
81
82uno::Reference< excel::XFont > SAL_CALL
84{
85 return mxStyle->Font();
86}
87uno::Any SAL_CALL
89{ return mxStyle->Borders( Index );
90}
91
92sheet::ConditionOperator
93ScVbaFormatCondition::retrieveAPIType(sal_Int32 _nVBAType, const uno::Reference< sheet::XSheetCondition >& _xSheetCondition )
94{
95 sheet::ConditionOperator aAPIType = sheet::ConditionOperator_NONE;
96 switch (_nVBAType)
97 {
98 case excel::XlFormatConditionType::xlExpression:
99 aAPIType = sheet::ConditionOperator_FORMULA;
100 break;
101 case excel::XlFormatConditionType::xlCellValue:
102 if ( _xSheetCondition.is() && (_xSheetCondition->getOperator() == sheet::ConditionOperator_FORMULA ) )
103 aAPIType = sheet::ConditionOperator_NONE;
104 break;
105 default:
106 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
107 }
108 return aAPIType;
109}
110
111::sal_Int32 SAL_CALL
113{
114 sal_Int32 nReturnType = 0;
115 if ( mxSheetCondition->getOperator() == sheet::ConditionOperator_FORMULA)
116 nReturnType = excel::XlFormatConditionType::xlExpression;
117 else
118 nReturnType = excel::XlFormatConditionType::xlCellValue;
119 return nReturnType;
120}
121
122::sal_Int32 SAL_CALL
124{
126}
127
128void
130{
131 try
132 {
134 }
135 catch (uno::Exception& )
136 {
137 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
138 }
139}
140
141OUString
143{
144 return "ScVbaFormatCondition";
145}
146
147uno::Sequence< OUString >
149{
150 static uno::Sequence< OUString > const aServiceNames
151 {
152 "ooo.vba.excel.FormatCondition"
153 };
154 return aServiceNames;
155}
156
157/* 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
ScVbaFormatCondition(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::sheet::XSheetConditionalEntry > &_xSheetConditionalEntry, const css::uno::Reference< ov::excel::XStyle > &, const css::uno::Reference< ov::excel::XFormatConditions > &_xFormatConditions, const css::uno::Reference< css::beans::XPropertySet > &_xPropertySet)
css::uno::Reference< ov::excel::XStyle > mxStyle
css::uno::Reference< css::sheet::XSheetConditionalEntries > mxSheetConditionalEntries
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
#define SC_UNONAME_CONDFMT
Definition: unonames.hxx:205
static ScVbaFormatConditions * lcl_getScVbaFormatConditionsPtr(const uno::Reference< excel::XFormatConditions > &xFormatConditions)