24#include <com/sun/star/container/XNameContainer.hpp>
25#include <osl/diagnose.h>
37 bool operator()(
const ValueRange& rLHS,
const ValueRange& rRHS )
const
39 return rLHS.mnLast < rRHS.mnFirst;
48 ValueRangeVector::iterator aBeg =
maRanges.begin();
49 ValueRangeVector::iterator aEnd =
maRanges.end();
50 ValueRangeVector::iterator aIt = ::std::lower_bound( aBeg, aEnd, rRange, ValueRangeComp() );
52 if( (aIt != aEnd) && aIt->contains( rRange ) )
return;
54 if( (aIt != aBeg) && ((aIt - 1)->mnLast + 1 == rRange.
mnFirst) ) --aIt;
56 if( (aIt != aEnd) && aIt->intersects( rRange ) )
59 aIt->mnFirst = ::std::min( aIt->mnFirst, rRange.
mnFirst );
61 ValueRangeVector::iterator aNext = aIt + 1;
62 while( (aNext != aEnd) && aNext->intersects( rRange ) ) ++aNext;
64 aIt->mnLast = ::std::max( (aNext - 1)->mnLast, rRange.
mnLast );
76 const Reference< XNameAccess >& rxNameAccess,
const OUString& rSuggestedName,
79 OSL_ENSURE( rxNameAccess.is(),
"ContainerHelper::getUnusedName - missing XNameAccess interface" );
81 OUString aNewName = rSuggestedName;
83 while( rxNameAccess->hasByName( aNewName ) )
84 aNewName = rSuggestedName + OUStringChar(cSeparator) + OUString::number(
nIndex++ );
89 const Reference< XNameContainer >& rxNameContainer,
90 const OUString& rName,
const Any& rObject )
92 OSL_ENSURE( rxNameContainer.is(),
"ContainerHelper::insertByName - missing XNameContainer interface" );
96 if( rxNameContainer->hasByName( rName ) )
97 rxNameContainer->replaceByName( rName, rObject );
99 rxNameContainer->insertByName( rName, rObject );
105 OSL_ENSURE( bRet,
"ContainerHelper::insertByName - cannot insert object" );
110 const Reference< XNameContainer >& rxNameContainer,
111 const OUString& rSuggestedName,
sal_Unicode cSeparator,
114 OSL_ENSURE( rxNameContainer.is(),
"ContainerHelper::insertByUnusedName - missing XNameContainer interface" );
117 OUString aNewName =
getUnusedName( rxNameContainer, rSuggestedName, cSeparator );
static bool insertByName(const css::uno::Reference< css::container::XNameContainer > &rxNameContainer, const OUString &rName, const css::uno::Any &rObject)
Inserts an object into a name container.
static OUString getUnusedName(const css::uno::Reference< css::container::XNameAccess > &rxNameAccess, const OUString &rSuggestedName, sal_Unicode cSeparator)
Returns a name that is not used in the passed name container.
static OUString insertByUnusedName(const css::uno::Reference< css::container::XNameContainer > &rxNameContainer, const OUString &rSuggestedName, sal_Unicode cSeparator, const css::uno::Any &rObject)
Inserts an object into a name container.
void insert(const ValueRange &rRange)
Inserts the passed value range into the range list.
ValueRangeVector maRanges
A range of signed 32-bit integer values.