LibreOffice Module sc (master)  1
formulaiter.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <formulaiter.hxx>
21 
22 #include <formulacell.hxx>
23 #include <tokenarray.hxx>
24 #include <formula/token.hxx>
25 #include <token.hxx>
26 
27 using namespace formula;
28 
30  mrDoc(rDoc),
31  maIter(*pCell->GetCode()),
32  aPos(pCell->aPos)
33 {
34 }
35 
36 static bool lcl_ScDetectiveRefIter_SkipRef( const ScDocument& rDoc, formula::FormulaToken* p, const ScAddress& rPos )
37 {
38  ScSingleRefData& rRef1 = *p->GetSingleRef();
39  ScAddress aAbs1 = rRef1.toAbs(rDoc, rPos);
40  if (!rDoc.ValidAddress(aAbs1))
41  return true;
42  if ( p->GetType() == svDoubleRef || p->GetType() == svExternalDoubleRef )
43  {
44  ScSingleRefData& rRef2 = p->GetDoubleRef()->Ref2;
45  ScAddress aAbs2 = rRef2.toAbs(rDoc, rPos);
46  if (!rDoc.ValidAddress(aAbs2))
47  return true;
48  }
49  return false;
50 }
51 
53 {
54  bool bRet = false;
56  if( p )
57  {
58  SingleDoubleRefProvider aProv( *p );
59  rRange.aStart = aProv.Ref1.toAbs(mrDoc, aPos);
60  rRange.aEnd = aProv.Ref2.toAbs(mrDoc, aPos);
61  bRet = true;
62  }
63 
64  return bRet;
65 }
66 
68 {
70  while (p && lcl_ScDetectiveRefIter_SkipRef(mrDoc, p, aPos))
71  {
73  }
74  return p;
75 }
76 
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const ScSingleRefData & Ref2
Definition: token.hxx:446
ScAddress aStart
Definition: address.hxx:500
Single reference (one address) into the sheet.
Definition: refdata.hxx:30
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Definition: refdata.cxx:193
const ScDocument & mrDoc
Definition: formulaiter.hxx:35
ScAddress aEnd
Definition: address.hxx:501
const ScSingleRefData & Ref1
Definition: token.hxx:445
virtual const ScSingleRefData * GetSingleRef() const
static bool lcl_ScDetectiveRefIter_SkipRef(const ScDocument &rDoc, formula::FormulaToken *p, const ScAddress &rPos)
Definition: formulaiter.cxx:36
virtual const ScComplexRefData * GetDoubleRef() const
ScDetectiveRefIter(const ScDocument &rDoc, ScFormulaCell *pCell)
Definition: formulaiter.cxx:29
ScSingleRefData Ref2
Definition: refdata.hxx:126
svExternalDoubleRef
bool ValidAddress(const ScAddress &rAddress) const
Definition: document.hxx:880
svDoubleRef
formula::FormulaTokenArrayPlainIterator maIter
Definition: formulaiter.hxx:36
bool GetNextRef(ScRange &rRange)
Definition: formulaiter.cxx:52
AnnotationVector::iterator maIter
void * p
formula::FormulaToken * GetNextRefToken()
Definition: formulaiter.cxx:67
StackVar GetType() const