20#include <com/sun/star/uno/XInterface.hpp>
21#include <com/sun/star/container/XIndexAccess.hpp>
22#include <com/sun/star/container/XChild.hpp>
26#include <osl/diagnose.h>
34 :m_xStartingPoint(
std::move(xStartingPoint))
36 OSL_ENSURE(
m_xStartingPoint.is(),
"IndexAccessIterator::IndexAccessIterator : no starting point !");
52 bool bHasMoreToSearch =
true;
53 bool bFoundSomething =
false;
54 while (!bFoundSomething && bHasMoreToSearch)
60 bFoundSomething =
true;
65 css::uno::Reference< css::container::XIndexAccess> xContainerAccess(xSearchLoop, css::uno::UNO_QUERY);
66 if (xContainerAccess.is() && xContainerAccess->getCount() &&
ShouldStepInto(xContainerAccess))
68 css::uno::Any aElement(xContainerAccess->getByIndex(0));
69 xSearchLoop = *o3tl::doAccess<css::uno::Reference<css::uno::XInterface>>(aElement);
70 bCheckingStartingPoint =
false;
78 css::uno::Reference< css::container::XChild> xChild(xSearchLoop, css::uno::UNO_QUERY);
79 OSL_ENSURE(xChild.is(),
"IndexAccessIterator::Next : a content has no appropriate interface !");
81 css::uno::Reference< css::uno::XInterface> xParent( xChild->getParent());
82 xContainerAccess.set(xParent, css::uno::UNO_QUERY);
83 OSL_ENSURE(xContainerAccess.is(),
"IndexAccessIterator::Next : a content has an invalid parent !");
89 if (nOldSearchChildIndex < xContainerAccess->getCount() - 1)
91 ++nOldSearchChildIndex;
93 css::uno::Any aElement(xContainerAccess->getByIndex(nOldSearchChildIndex));
94 xSearchLoop = *o3tl::doAccess<css::uno::Reference<css::uno::XInterface>>(aElement);
95 bCheckingStartingPoint =
false;
102 xSearchLoop = xParent;
103 bCheckingStartingPoint =
false;
108 bHasMoreToSearch =
false;
112 if (bHasMoreToSearch)
117 bFoundSomething =
true;
120 if (bCheckingStartingPoint)
121 bHasMoreToSearch =
false;
122 bAlreadyCheckedCurrent =
true;
127 if (!bFoundSomething)
129 OSL_ENSURE(
m_arrChildIndizies.empty(),
"IndexAccessIterator::Next : items left on stack ! how this ?");
virtual bool ShouldStepInto(const css::uno::Reference< css::uno::XInterface > &) const
::std::vector< sal_Int32 > m_arrChildIndizies
css::uno::Reference< css::uno::XInterface > m_xStartingPoint
css::uno::Reference< css::uno::XInterface > m_xCurrentObject
virtual bool ShouldHandleElement(const css::uno::Reference< css::uno::XInterface > &)
virtual void Invalidate()
css::uno::Reference< css::uno::XInterface > const & Next()
virtual ~IndexAccessIterator()
IndexAccessIterator(css::uno::Reference< css::uno::XInterface > xStartingPoint)