20#include <ooo/vba/excel/XRange.hpp>
21#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
26#include <unonames.hxx>
43 for (sal_Int32
i =
nCount - 1;
i >= 0;
i--)
45 uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry(
mxSheetConditionalEntries->getByIndex(
i), uno::UNO_QUERY_THROW );
46 pStyles->
Delete(xSheetConditionalEntry->getStyleName());
51 catch (uno::Exception& )
63static 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 )
65 uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry;
66 aObject >>= xSheetConditionalEntry;
68 uno::Reference< excel::XStyle > xStyle( xStyles->Item(
uno::Any( xSheetConditionalEntry->getStyleName() ),
uno::Any() ), uno::UNO_QUERY_THROW );
69 uno::Reference< excel::XFormatCondition > xCondition =
new ScVbaFormatCondition( xRangeParent, xContext, xSheetConditionalEntry, xStyle, xFormatConditions, xRangeProps );
83 uno::Reference<container::XIndexAccess > m_xIndexAccess;
84 uno::Reference<excel::XRange > m_xParentRange;
85 uno::Reference<uno::XComponentContext >
m_xContext;
86 uno::Reference<excel::XStyles > m_xStyles;
87 uno::Reference<excel::XFormatConditions > m_xParentCollection;
88 uno::Reference<beans::XPropertySet >
m_xProps;
92 EnumWrapper(
const uno::Reference< container::XIndexAccess >& xIndexAccess,
const uno::Reference<excel::XRange >& xRange,
const uno::Reference<uno::XComponentContext >& xContext,
const uno::Reference<excel::XStyles >& xStyles,
const uno::Reference< excel::XFormatConditions >& xCollection,
const uno::Reference<beans::XPropertySet >& xProps ) : m_xIndexAccess( xIndexAccess ), m_xParentRange( xRange ),
m_xContext( xContext ), m_xStyles( xStyles ), m_xParentCollection( xCollection ),
m_xProps( xProps ),
nIndex( 0 ) {}
93 virtual sal_Bool SAL_CALL hasMoreElements( )
override
95 return ( nIndex < m_xIndexAccess->getCount() );
98 virtual uno::Any SAL_CALL nextElement( )
override
102 if ( nIndex < m_xIndexAccess->getCount() )
103 return xSheetConditionToFormatCondition( uno::Reference< XHelperInterface >( m_xParentRange, uno::UNO_QUERY_THROW ), m_xContext, m_xStyles, m_xParentCollection, m_xProps, m_xIndexAccess->getByIndex( nIndex++ ) );
105 catch (
const container::NoSuchElementException&)
109 catch (
const lang::WrappedTargetException&)
113 catch (
const uno::RuntimeException&)
117 catch (
const uno::Exception& e)
120 throw css::lang::WrappedTargetException(
121 "wrapped Exception " + e.Message,
122 css::uno::Reference<css::uno::XInterface>(), a);
124 throw container::NoSuchElementException();
130uno::Reference< excel::XFormatCondition > SAL_CALL
133 return Add( _nType, _aOperator, _aFormula1, _aFormula2, uno::Reference< excel::XStyle >() );
136uno::Reference< excel::XFormatCondition >
146 uno::Reference< excel::XStyle > xStyle( _xStyle );
147 uno::Reference< excel::XFormatCondition > xFormatCondition;
158 sStyleName = xStyle->getName();
161 std::vector< beans::PropertyValue > aPropertyValueVector;
165 if ( aType == sheet::ConditionOperator_FORMULA)
166 aValue <<= sheet::ConditionOperator_FORMULA;
170 beans::PropertyValue aProperty(
"Operator", 0, aValue, beans::PropertyState_DIRECT_VALUE );
171 aPropertyValueVector.push_back( aProperty );
175 beans::PropertyValue aProp(
"Formula1", 0,
uno::Any(
getA1Formula( _aFormula1 ) ), beans::PropertyState_DIRECT_VALUE );
176 aPropertyValueVector.push_back( aProp );
180 beans::PropertyValue aProp(
"Formula2", 0,
uno::Any(
getA1Formula( _aFormula2 ) ), beans::PropertyState_DIRECT_VALUE );
181 aPropertyValueVector.push_back( aProp );
183 aProperty.Name =
"StyleName";
184 aProperty.Value <<= sStyleName;
189 uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry(
mxSheetConditionalEntries->getByIndex(i), uno::UNO_QUERY_THROW );
190 if (xSheetConditionalEntry->getStyleName() == sStyleName)
194 return xFormatCondition;
198 catch (uno::Exception& )
201 DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, {} );
202 return xFormatCondition;
205uno::Reference< container::XEnumeration > SAL_CALL
218 catch (uno::Exception& )
240 uno::Sequence< OUString > sCellStyleNames = pStyles->
getStyleNames();
241 return ContainerUtilities::getUniqueName(sCellStyleNames,
"Excel_CondFormat",
u"_");
250 for (sal_Int32
i = 0;
i < nElems;
i++)
252 uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry(
mxSheetConditionalEntries->getByIndex(
i), uno::UNO_QUERY_THROW );
253 if (_sStyleName == xSheetConditionalEntry->getStyleName())
261 pStyles->
Delete( _sStyleName );
267 catch (
const uno::Exception&)
276 return "ScVbaFormatConditions";
279uno::Sequence< OUString >
284 "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
#define SC_UNONAME_CONDFMT
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE