24#include <ooo/vba/office/MsoHyperlinkType.hpp>
38bool lclContains(
const ScRangeList& rScOuter,
const uno::Reference< excel::XRange >& rxInner )
42 throw uno::RuntimeException(
"Empty range objects" );
44 for(
size_t nIndex = 0, nCount = rScInner.
size(); nIndex < nCount; ++nIndex )
45 if( !rScOuter.
Contains( rScInner[ nIndex ] ) )
51struct EqualAnchorFunctor
53 uno::Reference< excel::XRange > mxAnchorRange;
54 uno::Reference< msforms::XShape > mxAnchorShape;
57 explicit EqualAnchorFunctor(
const uno::Reference< excel::XHyperlink >& rxHlink );
59 bool operator()(
const uno::Reference< excel::XHyperlink >& rxHlink )
const;
62EqualAnchorFunctor::EqualAnchorFunctor(
const uno::Reference< excel::XHyperlink >& rxHlink ) :
67 case office::MsoHyperlinkType::msoHyperlinkRange:
68 mxAnchorRange.set( rxHlink->getRange(), uno::UNO_SET_THROW );
70 case office::MsoHyperlinkType::msoHyperlinkShape:
71 case office::MsoHyperlinkType::msoHyperlinkInlineShape:
72 mxAnchorShape.set( rxHlink->getShape(), uno::UNO_SET_THROW );
75 throw uno::RuntimeException();
79bool EqualAnchorFunctor::operator()(
const uno::Reference< excel::XHyperlink >& rxHlink )
const
81 sal_Int32
nType = rxHlink->getType();
87 case office::MsoHyperlinkType::msoHyperlinkRange:
89 uno::Reference< excel::XRange > xAnchorRange( rxHlink->getRange(), uno::UNO_SET_THROW );
92 return (rScRanges1.
size() == 1) && (rScRanges2.
size() == 1) && (rScRanges1[ 0 ] == rScRanges2[ 0 ]);
94 case office::MsoHyperlinkType::msoHyperlinkShape:
95 case office::MsoHyperlinkType::msoHyperlinkInlineShape:
97 uno::Reference< msforms::XShape > xAnchorShape( rxHlink->getShape(), uno::UNO_SET_THROW );
98 return xAnchorShape.get() == mxAnchorShape.get();
101 throw uno::RuntimeException();
122 void insertHyperlink(
const uno::Reference< excel::XHyperlink >& rxHlink );
125 virtual sal_Int32 SAL_CALL
getCount()
override;
147 uno::Reference< excel::XHyperlink > xHlink( rxSheetContainer->getByIndex(
nIndex ), uno::UNO_QUERY_THROW );
148 uno::Reference< excel::XRange > xHlinkRange( xHlink->getRange(), uno::UNO_SET_THROW );
149 if( lclContains( rScRanges, xHlinkRange ) )
156 HyperlinkVector::iterator aIt = ::std::find_if(
maHlinks.begin(),
maHlinks.end(), EqualAnchorFunctor( rxHlink ) );
165 return static_cast< sal_Int32
>(
maHlinks.size() );
172 throw lang::IndexOutOfBoundsException();
197 const uno::Reference< uno::XComponentContext >& rxContext ) :
198 detail::ScVbaHlinkContainerMember( new
detail::ScVbaHlinkContainer ),
204 const uno::Reference< uno::XComponentContext >& rxContext,
208 mxSheetHlinks( rxSheetHlinks )
228 if( mxSheetHlinks.is() )
229 return mxSheetHlinks->Add( rAnchor, rAddress, rSubAddress, rScreenTip, rTextToDisplay );
232 uno::Reference< XHelperInterface > xAnchor( rAnchor, uno::UNO_QUERY_THROW );
237 xAnchor,
mxContext, rAddress, rSubAddress, rScreenTip, rTextToDisplay ) );
248 throw uno::RuntimeException();
bool Contains(const ScRange &) const
Represents a collection of hyperlinks of a worksheet or of a range.
virtual css::uno::Any createCollectionObject(const css::uno::Any &rSource) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
ScVbaHyperlinks(const css::uno::Reference< ov::XHelperInterface > &rxParent, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual css::uno::Reference< ov::excel::XHyperlink > SAL_CALL Add(const css::uno::Any &rAnchor, const css::uno::Any &rAddress, const css::uno::Any &rSubAddress, const css::uno::Any &rScreenTip, const css::uno::Any &rTextToDisplay) override
virtual css::uno::Type SAL_CALL getElementType() override
virtual ~ScVbaHyperlinks() override
virtual void SAL_CALL Delete() override
const ScRangeList & getScRangeList()
css::uno::Type const & get()
virtual uno::Type SAL_CALL getElementType() override
void insertHyperlink(const uno::Reference< excel::XHyperlink > &rxHlink)
Inserts the passed hyperlink into the collection.
virtual sal_Int32 SAL_CALL getCount() override
virtual sal_Bool SAL_CALL hasElements() override
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
::std::vector< uno::Reference< excel::XHyperlink > > HyperlinkVector
bool getType(BSTR name, Type &type)
~ScVbaHlinkContainerMember()
ScVbaHlinkContainerMember(ScVbaHlinkContainer *pContainer)
#define VBAHELPER_IMPL_XHELPERINTERFACE(classname, servicename)