20#include <ooo/vba/excel/XRange.hpp>
21#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
27#include <unonames.hxx>
44 for (sal_Int32
i =
nCount - 1;
i >= 0;
i--)
46 uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry(
mxSheetConditionalEntries->getByIndex(
i), uno::UNO_QUERY_THROW );
47 pStyles->
Delete(xSheetConditionalEntry->getStyleName());
52 catch (uno::Exception& )
64static uno::Any xSheetConditionToFormatCondition(
const uno::Reference< XHelperInterface >& xRangeParent,
const uno::Reference< uno::XComponentContext >& xContext,
const uno::Reference< excel::XStyles >& xStyles,
const uno::Reference< excel::XFormatConditions >& xFormatConditions,
const uno::Reference< beans::XPropertySet >& xRangeProps,
const uno::Any& aObject )
66 uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry;
67 aObject >>= xSheetConditionalEntry;
69 uno::Reference< excel::XStyle > xStyle( xStyles->Item(
uno::Any( xSheetConditionalEntry->getStyleName() ),
uno::Any() ), uno::UNO_QUERY_THROW );
70 uno::Reference< excel::XFormatCondition > xCondition =
new ScVbaFormatCondition( xRangeParent, xContext, xSheetConditionalEntry, xStyle, xFormatConditions, xRangeProps );
84 uno::Reference<container::XIndexAccess > m_xIndexAccess;
85 uno::Reference<excel::XRange > m_xParentRange;
86 uno::Reference<uno::XComponentContext >
m_xContext;
87 uno::Reference<excel::XStyles > m_xStyles;
88 uno::Reference<excel::XFormatConditions > m_xParentCollection;
89 uno::Reference<beans::XPropertySet >
m_xProps;
93 EnumWrapper( uno::Reference< container::XIndexAccess > xIndexAccess, uno::Reference<excel::XRange > xRange, uno::Reference<uno::XComponentContext > xContext, uno::Reference<excel::XStyles > xStyles, uno::Reference< excel::XFormatConditions > xCollection, uno::Reference<beans::XPropertySet > xProps ) : m_xIndexAccess(
std::move( xIndexAccess )), m_xParentRange(
std::move( xRange )),
m_xContext(
std::move( xContext )), m_xStyles(
std::move( xStyles )), m_xParentCollection(
std::move( xCollection )),
m_xProps(
std::move( xProps )),
nIndex( 0 ) {}
94 virtual sal_Bool SAL_CALL hasMoreElements( )
override
96 return ( nIndex < m_xIndexAccess->getCount() );
99 virtual uno::Any SAL_CALL nextElement( )
override
103 if ( nIndex < m_xIndexAccess->getCount() )
104 return xSheetConditionToFormatCondition( uno::Reference< XHelperInterface >( m_xParentRange, uno::UNO_QUERY_THROW ), m_xContext, m_xStyles, m_xParentCollection, m_xProps, m_xIndexAccess->getByIndex( nIndex++ ) );
106 catch (
const container::NoSuchElementException&)
110 catch (
const lang::WrappedTargetException&)
114 catch (
const uno::RuntimeException&)
118 catch (
const uno::Exception& e)
121 throw css::lang::WrappedTargetException(
122 "wrapped Exception " + e.Message,
123 css::uno::Reference<css::uno::XInterface>(), a);
125 throw container::NoSuchElementException();
131uno::Reference< excel::XFormatCondition > SAL_CALL
134 return Add( _nType, _aOperator, _aFormula1, _aFormula2, uno::Reference< excel::XStyle >() );
137uno::Reference< excel::XFormatCondition >
147 uno::Reference< excel::XStyle > xStyle( _xStyle );
148 uno::Reference< excel::XFormatCondition > xFormatCondition;
159 sStyleName = xStyle->getName();
162 std::vector< beans::PropertyValue > aPropertyValueVector;
166 if ( aType == sheet::ConditionOperator_FORMULA)
167 aValue <<= sheet::ConditionOperator_FORMULA;
171 beans::PropertyValue aProperty(
"Operator", 0, aValue, beans::PropertyState_DIRECT_VALUE );
172 aPropertyValueVector.push_back( aProperty );
176 beans::PropertyValue aProp(
"Formula1", 0,
uno::Any(
getA1Formula( _aFormula1 ) ), beans::PropertyState_DIRECT_VALUE );
177 aPropertyValueVector.push_back( aProp );
181 beans::PropertyValue aProp(
"Formula2", 0,
uno::Any(
getA1Formula( _aFormula2 ) ), beans::PropertyState_DIRECT_VALUE );
182 aPropertyValueVector.push_back( aProp );
184 aProperty.Name =
"StyleName";
185 aProperty.Value <<= sStyleName;
190 uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry(
mxSheetConditionalEntries->getByIndex(i), uno::UNO_QUERY_THROW );
191 if (xSheetConditionalEntry->getStyleName() == sStyleName)
195 return xFormatCondition;
199 catch (uno::Exception& )
202 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
203 return xFormatCondition;
206uno::Reference< container::XEnumeration > SAL_CALL
219 catch (uno::Exception& )
241 uno::Sequence< OUString > sCellStyleNames = pStyles->
getStyleNames();
242 return ContainerUtilities::getUniqueName(sCellStyleNames,
"Excel_CondFormat",
u"_");
251 for (sal_Int32
i = 0;
i < nElems;
i++)
253 uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry(
mxSheetConditionalEntries->getByIndex(
i), uno::UNO_QUERY_THROW );
254 if (_sStyleName == xSheetConditionalEntry->getStyleName())
262 pStyles->
Delete( _sStyleName );
268 catch (
const uno::Exception&)
277 return "ScVbaFormatConditions";
280uno::Sequence< OUString >
285 "ooo.vba.excel.FormatConditions"
Reference< XComponentContext > m_xContext
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
static css::sheet::ConditionOperator retrieveAPIOperator(const css::uno::Any &_aOperator)
css::uno::Sequence< OUString > getStyleNames()
void Delete(const OUString &_sStyleName)
css::uno::Type const & get()
Sequence< OUString > aServiceNames
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Any SAL_CALL getCaughtException()
#define ERRCODE_BASIC_BAD_PARAMETER
#define ERRCODE_BASIC_METHOD_FAILED
constexpr OUStringLiteral SC_UNONAME_CONDFMT
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE