summaryrefslogtreecommitdiff
path: root/include/formula
diff options
context:
space:
mode:
Diffstat (limited to 'include/formula')
-rw-r--r--include/formula/tokenarray.hxx106
1 files changed, 106 insertions, 0 deletions
diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx
index eb04f041abd8..eed55d089921 100644
--- a/include/formula/tokenarray.hxx
+++ b/include/formula/tokenarray.hxx
@@ -136,6 +136,97 @@ public:
}
};
+class FORMULA_DLLPUBLIC FormulaTokenArrayReferencesIterator
+{
+private:
+ FormulaToken** maIter;
+ FormulaToken** maEnd;
+
+ void nextReference()
+ {
+ while (maIter != maEnd)
+ {
+ switch ((*maIter)->GetType())
+ {
+ case svSingleRef:
+ case svDoubleRef:
+ case svExternalSingleRef:
+ case svExternalDoubleRef:
+ return;
+ default:
+ ++maIter;
+ }
+ }
+ }
+
+ enum class Dummy { Flag };
+
+ FormulaTokenArrayReferencesIterator(const FormulaTokenArrayStandardRange& rRange, Dummy) :
+ maIter(rRange.end()),
+ maEnd(rRange.end())
+ {
+ }
+
+public:
+ FormulaTokenArrayReferencesIterator(const FormulaTokenArrayStandardRange& rRange) :
+ maIter(rRange.begin()),
+ maEnd(rRange.end())
+ {
+ nextReference();
+ }
+
+ FormulaTokenArrayReferencesIterator operator++(int)
+ {
+ FormulaTokenArrayReferencesIterator result(*this);
+ operator++();
+ return result;
+ }
+
+ FormulaTokenArrayReferencesIterator operator++()
+ {
+ assert(maIter != maEnd);
+ ++maIter;
+ nextReference();
+ return *this;
+ }
+
+ FormulaToken* operator*() const
+ {
+ return *maIter;
+ }
+
+ bool operator==(const FormulaTokenArrayReferencesIterator& rhs) const
+ {
+ return maIter == rhs.maIter;
+ }
+
+ bool operator!=(const FormulaTokenArrayReferencesIterator& rhs) const
+ {
+ return !operator==(rhs);
+ }
+
+ static FormulaTokenArrayReferencesIterator endOf(const FormulaTokenArrayStandardRange& rRange)
+ {
+ return FormulaTokenArrayReferencesIterator(rRange, Dummy::Flag);
+ }
+};
+
+class FORMULA_DLLPUBLIC FormulaTokenArrayReferencesRange
+{
+private:
+ const FormulaTokenArray& mrFTA;
+
+public:
+ FormulaTokenArrayReferencesRange(const FormulaTokenArray& rFTA) :
+ mrFTA(rFTA)
+ {
+ }
+
+ FormulaTokenArrayReferencesIterator begin();
+
+ FormulaTokenArrayReferencesIterator end();
+};
+
class FORMULA_DLLPUBLIC FormulaTokenArray
{
protected:
@@ -284,6 +375,11 @@ public:
return FormulaTokenArrayStandardRange(pRPN, nRPN);
}
+ FormulaTokenArrayReferencesRange References() const
+ {
+ return FormulaTokenArrayReferencesRange(*this);
+ }
+
sal_uInt16 GetLen() const { return nLen; }
sal_uInt16 GetCodeLen() const { return nRPN; }
FormulaError GetCodeError() const { return nError; }
@@ -401,6 +497,16 @@ inline OpCode FormulaTokenArray::GetOuterFuncOpCode()
return ocNone;
}
+inline FormulaTokenArrayReferencesIterator FormulaTokenArrayReferencesRange::begin()
+{
+ return FormulaTokenArrayReferencesIterator(mrFTA.Tokens());
+}
+
+inline FormulaTokenArrayReferencesIterator FormulaTokenArrayReferencesRange::end()
+{
+ return FormulaTokenArrayReferencesIterator::endOf(mrFTA.Tokens());
+}
+
class FORMULA_DLLPUBLIC FormulaTokenIterator
{
struct Item