2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* $RCSfile: rangeutl.cxx,v $
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* $Revision: 1.5 $
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-08 18:48:58 $
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2005-09-08 17:48:58 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifdef PCH
|
|
|
|
#include "core_pch.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
// INCLUDE ---------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
|
|
|
|
#include "rangeutl.hxx"
|
|
|
|
#include "document.hxx"
|
|
|
|
#include "global.hxx"
|
|
|
|
#include "dbcolect.hxx"
|
|
|
|
#include "rangenam.hxx"
|
|
|
|
#include "scresid.hxx"
|
|
|
|
#include "globstr.hrc"
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScRangeUtil::MakeArea( const String& rAreaStr,
|
|
|
|
ScArea& rArea,
|
|
|
|
ScDocument* pDoc,
|
2004-06-04 09:38:52 +00:00
|
|
|
SCTAB nTab ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
// Eingabe in rAreaStr: "$Tabelle1.$A1:$D17"
|
|
|
|
|
|
|
|
BOOL nSuccess = FALSE;
|
|
|
|
USHORT nPointPos = rAreaStr.Search('.');
|
|
|
|
USHORT nColonPos = rAreaStr.Search(':');
|
|
|
|
String aStrArea( rAreaStr );
|
2004-06-04 09:38:52 +00:00
|
|
|
ScRefAddress startPos;
|
|
|
|
ScRefAddress endPos;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( nColonPos == STRING_NOTFOUND )
|
|
|
|
if ( nPointPos != STRING_NOTFOUND )
|
|
|
|
{
|
|
|
|
aStrArea += ':';
|
|
|
|
aStrArea += rAreaStr.Copy( nPointPos+1 ); // '.' nicht mitkopieren
|
|
|
|
}
|
|
|
|
|
|
|
|
nSuccess = ConvertDoubleRef( pDoc, aStrArea, nTab, startPos, endPos );
|
|
|
|
|
|
|
|
if ( nSuccess )
|
2004-06-04 09:38:52 +00:00
|
|
|
rArea = ScArea( startPos.Tab(),
|
|
|
|
startPos.Col(), startPos.Row(),
|
|
|
|
endPos.Col(), endPos.Row() );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
return nSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScRangeUtil::CutPosString( const String& theAreaStr,
|
|
|
|
String& thePosStr ) const
|
|
|
|
{
|
|
|
|
String aPosStr;
|
|
|
|
USHORT nColonPos = theAreaStr.Search(':');
|
|
|
|
|
|
|
|
if ( nColonPos != STRING_NOTFOUND )
|
|
|
|
aPosStr = theAreaStr.Copy( 0, nColonPos ); // ':' nicht mitkopieren
|
|
|
|
else
|
|
|
|
aPosStr = theAreaStr;
|
|
|
|
|
|
|
|
thePosStr = aPosStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScRangeUtil::IsAbsTabArea( const String& rAreaStr,
|
|
|
|
ScDocument* pDoc,
|
|
|
|
ScArea*** pppAreas,
|
2000-11-03 14:56:03 +00:00
|
|
|
USHORT* pAreaCount,
|
|
|
|
BOOL bAcceptCellRef ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( pDoc, "Kein Dokument uebergeben!" );
|
|
|
|
if ( !pDoc )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Erwartet wird ein String der Form
|
|
|
|
* "$Tabelle1.$A$1:$Tabelle3.$D$17"
|
2000-11-03 14:56:03 +00:00
|
|
|
* Wenn bAcceptCellRef == TRUE ist, wird auch ein String der Form
|
|
|
|
* "$Tabelle1.$A$1"
|
|
|
|
* akzeptiert.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
|
|
|
* als Ergebnis wird ein ScArea-Array angelegt,
|
|
|
|
* welches ueber ppAreas bekannt gegeben wird und auch
|
|
|
|
* wieder geloescht werden muss!
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL bStrOk = FALSE;
|
2000-11-03 14:56:03 +00:00
|
|
|
String aTempAreaStr(rAreaStr);
|
2000-09-18 23:16:46 +00:00
|
|
|
String aStartPosStr;
|
|
|
|
String aEndPosStr;
|
|
|
|
|
2000-11-03 14:56:03 +00:00
|
|
|
if ( STRING_NOTFOUND == aTempAreaStr.Search(':') )
|
|
|
|
{
|
|
|
|
aTempAreaStr.Append(':');
|
|
|
|
aTempAreaStr.Append(rAreaStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nColonPos = aTempAreaStr.Search(':');
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( STRING_NOTFOUND != nColonPos
|
2000-11-03 14:56:03 +00:00
|
|
|
&& STRING_NOTFOUND != aTempAreaStr.Search('.') )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:38:52 +00:00
|
|
|
ScRefAddress aStartPos;
|
|
|
|
ScRefAddress aEndPos;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-11-03 14:56:03 +00:00
|
|
|
aStartPosStr = aTempAreaStr.Copy( 0, nColonPos );
|
|
|
|
aEndPosStr = aTempAreaStr.Copy( nColonPos+1, STRING_LEN );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( ConvertSingleRef( pDoc, aStartPosStr, 0, aStartPos ) )
|
|
|
|
{
|
2004-06-04 09:38:52 +00:00
|
|
|
if ( ConvertSingleRef( pDoc, aEndPosStr, aStartPos.Tab(), aEndPos ) )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
aStartPos.SetRelCol( FALSE );
|
|
|
|
aStartPos.SetRelRow( FALSE );
|
|
|
|
aStartPos.SetRelTab( FALSE );
|
|
|
|
aEndPos.SetRelCol( FALSE );
|
|
|
|
aEndPos.SetRelRow( FALSE );
|
|
|
|
aEndPos.SetRelTab( FALSE );
|
|
|
|
|
|
|
|
bStrOk = TRUE;
|
|
|
|
|
|
|
|
if ( pppAreas && pAreaCount ) // Array zurueckgegeben?
|
|
|
|
{
|
2004-06-04 09:38:52 +00:00
|
|
|
SCTAB nStartTab = aStartPos.Tab();
|
|
|
|
SCTAB nEndTab = aEndPos.Tab();
|
|
|
|
USHORT nTabCount = static_cast<USHORT>(nEndTab-nStartTab+1);
|
2000-09-18 23:16:46 +00:00
|
|
|
ScArea** theAreas = new ScArea*[nTabCount];
|
2004-06-04 09:38:52 +00:00
|
|
|
SCTAB nTab = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
USHORT i = 0;
|
2004-06-04 09:38:52 +00:00
|
|
|
ScArea theArea( 0, aStartPos.Col(), aStartPos.Row(),
|
|
|
|
aEndPos.Col(), aEndPos.Row() );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
nTab = nStartTab;
|
|
|
|
for ( i=0; i<nTabCount; i++ )
|
|
|
|
{
|
|
|
|
theAreas[i] = new ScArea( theArea );
|
|
|
|
theAreas[i]->nTab = nTab;
|
|
|
|
nTab++;
|
|
|
|
}
|
|
|
|
*pppAreas = theAreas;
|
|
|
|
*pAreaCount = nTabCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bStrOk;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScRangeUtil::IsAbsArea( const String& rAreaStr,
|
|
|
|
ScDocument* pDoc,
|
2004-06-04 09:38:52 +00:00
|
|
|
SCTAB nTab,
|
2000-09-18 23:16:46 +00:00
|
|
|
String* pCompleteStr,
|
2004-06-04 09:38:52 +00:00
|
|
|
ScRefAddress* pStartPos,
|
|
|
|
ScRefAddress* pEndPos ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
BOOL bIsAbsArea = FALSE;
|
2004-06-04 09:38:52 +00:00
|
|
|
ScRefAddress startPos;
|
|
|
|
ScRefAddress endPos;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
bIsAbsArea = ConvertDoubleRef( pDoc, rAreaStr, nTab, startPos, endPos );
|
|
|
|
|
|
|
|
if ( bIsAbsArea )
|
|
|
|
{
|
|
|
|
startPos.SetRelCol( FALSE );
|
|
|
|
startPos.SetRelRow( FALSE );
|
|
|
|
startPos.SetRelTab( FALSE );
|
|
|
|
endPos .SetRelCol( FALSE );
|
|
|
|
endPos .SetRelRow( FALSE );
|
|
|
|
endPos .SetRelTab( FALSE );
|
|
|
|
|
|
|
|
if ( pCompleteStr )
|
|
|
|
{
|
|
|
|
*pCompleteStr = startPos.GetRefString( pDoc, MAXTAB+1 );
|
|
|
|
*pCompleteStr += ':';
|
|
|
|
*pCompleteStr += endPos .GetRefString( pDoc, nTab );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pStartPos && pEndPos )
|
|
|
|
{
|
|
|
|
*pStartPos = startPos;
|
|
|
|
*pEndPos = endPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bIsAbsArea;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScRangeUtil::IsAbsPos( const String& rPosStr,
|
|
|
|
ScDocument* pDoc,
|
2004-06-04 09:38:52 +00:00
|
|
|
SCTAB nTab,
|
2000-09-18 23:16:46 +00:00
|
|
|
String* pCompleteStr,
|
2004-06-04 09:38:52 +00:00
|
|
|
ScRefAddress* pPosTripel ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
BOOL bIsAbsPos = FALSE;
|
2004-06-04 09:38:52 +00:00
|
|
|
ScRefAddress thePos;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
bIsAbsPos = ConvertSingleRef( pDoc, rPosStr, nTab, thePos );
|
|
|
|
|
|
|
|
thePos.SetRelCol( FALSE );
|
|
|
|
thePos.SetRelRow( FALSE );
|
|
|
|
thePos.SetRelTab( FALSE );
|
|
|
|
|
|
|
|
if ( bIsAbsPos )
|
|
|
|
{
|
|
|
|
if ( pPosTripel )
|
|
|
|
*pPosTripel = thePos;
|
|
|
|
if ( pCompleteStr )
|
|
|
|
*pCompleteStr = thePos.GetRefString( pDoc, MAXTAB+1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return bIsAbsPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScRangeUtil::MakeRangeFromName (
|
|
|
|
const String& rName,
|
|
|
|
ScDocument* pDoc,
|
2004-06-04 09:38:52 +00:00
|
|
|
SCTAB nCurTab,
|
2000-09-18 23:16:46 +00:00
|
|
|
ScRange& rRange,
|
|
|
|
RutlNameScope eScope
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
BOOL bResult=FALSE;
|
|
|
|
ScRangeUtil aRangeUtil;
|
2004-06-04 09:38:52 +00:00
|
|
|
SCTAB nTab;
|
|
|
|
SCCOL nColStart;
|
|
|
|
SCCOL nColEnd;
|
|
|
|
SCROW nRowStart;
|
|
|
|
SCROW nRowEnd;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if( eScope==RUTL_NAMES )
|
|
|
|
{
|
|
|
|
ScRangeName& rRangeNames = *(pDoc->GetRangeName());
|
|
|
|
USHORT nAt = 0;
|
|
|
|
|
|
|
|
if ( rRangeNames.SearchName( rName, nAt ) )
|
|
|
|
{
|
|
|
|
ScRangeData* pData = rRangeNames[nAt];
|
|
|
|
String aStrArea;
|
2004-06-04 09:38:52 +00:00
|
|
|
ScRefAddress aStartPos;
|
|
|
|
ScRefAddress aEndPos;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
pData->GetSymbol( aStrArea );
|
|
|
|
|
|
|
|
if ( IsAbsArea( aStrArea, pDoc, nCurTab,
|
|
|
|
NULL, &aStartPos, &aEndPos ) )
|
|
|
|
{
|
2004-06-04 09:38:52 +00:00
|
|
|
nTab = aStartPos.Tab();
|
|
|
|
nColStart = aStartPos.Col();
|
|
|
|
nRowStart = aStartPos.Row();
|
|
|
|
nColEnd = aEndPos.Col();
|
|
|
|
nRowEnd = aEndPos.Row();
|
2000-09-18 23:16:46 +00:00
|
|
|
bResult = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CutPosString( aStrArea, aStrArea );
|
|
|
|
|
|
|
|
if ( IsAbsPos( aStrArea, pDoc, nCurTab,
|
|
|
|
NULL, &aStartPos ) )
|
|
|
|
{
|
2004-06-04 09:38:52 +00:00
|
|
|
nTab = aStartPos.Tab();
|
|
|
|
nColStart = nColEnd = aStartPos.Col();
|
|
|
|
nRowStart = nRowEnd = aStartPos.Row();
|
2000-09-18 23:16:46 +00:00
|
|
|
bResult = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( eScope==RUTL_DBASE )
|
|
|
|
{
|
|
|
|
ScDBCollection& rDbNames = *(pDoc->GetDBCollection());
|
|
|
|
USHORT nAt = 0;
|
|
|
|
|
|
|
|
if ( rDbNames.SearchName( rName, nAt ) )
|
|
|
|
{
|
|
|
|
ScDBData* pData = rDbNames[nAt];
|
|
|
|
|
|
|
|
pData->GetArea( nTab, nColStart, nRowStart,
|
|
|
|
nColEnd, nRowEnd );
|
|
|
|
bResult = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "ScRangeUtil::MakeRangeFromName" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bResult )
|
|
|
|
{
|
|
|
|
rRange = ScRange( nColStart, nRowStart, nTab, nColEnd, nRowEnd, nTab );
|
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
2004-06-04 09:38:52 +00:00
|
|
|
ScArea::ScArea( SCTAB tab,
|
|
|
|
SCCOL colStart, SCROW rowStart,
|
|
|
|
SCCOL colEnd, SCROW rowEnd ) :
|
2000-09-18 23:16:46 +00:00
|
|
|
nTab ( tab ),
|
|
|
|
nColStart( colStart ), nRowStart( rowStart ),
|
|
|
|
nColEnd ( colEnd ), nRowEnd ( rowEnd )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScArea::ScArea( const ScArea& r ) :
|
|
|
|
nTab ( r.nTab ),
|
|
|
|
nColStart( r.nColStart ), nRowStart( r.nRowStart ),
|
|
|
|
nColEnd ( r.nColEnd ), nRowEnd ( r.nRowEnd )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScArea::Clear()
|
|
|
|
{
|
2004-06-04 09:38:52 +00:00
|
|
|
nTab = 0;
|
|
|
|
nColStart = nColEnd = 0;
|
|
|
|
nRowStart = nRowEnd = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScArea& ScArea::operator=( const ScArea& r )
|
|
|
|
{
|
|
|
|
nTab = r.nTab;
|
|
|
|
nColStart = r.nColStart;
|
|
|
|
nRowStart = r.nRowStart;
|
|
|
|
nColEnd = r.nColEnd;
|
|
|
|
nRowEnd = r.nRowEnd;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScArea::operator==( const ScArea& r ) const
|
|
|
|
{
|
|
|
|
return ( (nTab == r.nTab)
|
|
|
|
&& (nColStart == r.nColStart)
|
|
|
|
&& (nRowStart == r.nRowStart)
|
|
|
|
&& (nColEnd == r.nColEnd)
|
|
|
|
&& (nRowEnd == r.nRowEnd) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SvStream& operator>> ( SvStream& rStream, ScArea& rArea )
|
|
|
|
{
|
2004-06-04 09:38:52 +00:00
|
|
|
#if SC_ROWLIMIT_STREAM_ACCESS
|
|
|
|
#error address types changed!
|
2000-09-18 23:16:46 +00:00
|
|
|
rStream >> rArea.nTab;
|
|
|
|
rStream >> rArea.nColStart;
|
|
|
|
rStream >> rArea.nRowStart;
|
|
|
|
rStream >> rArea.nColEnd;
|
|
|
|
rStream >> rArea.nRowEnd;
|
2004-06-04 09:38:52 +00:00
|
|
|
#endif // SC_ROWLIMIT_STREAM_ACCESS
|
2000-09-18 23:16:46 +00:00
|
|
|
return rStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SvStream& operator<< ( SvStream& rStream, const ScArea& rArea )
|
|
|
|
{
|
2004-06-04 09:38:52 +00:00
|
|
|
#if SC_ROWLIMIT_STREAM_ACCESS
|
|
|
|
#error address types changed!
|
2000-09-18 23:16:46 +00:00
|
|
|
rStream << rArea.nTab;
|
|
|
|
rStream << rArea.nColStart;
|
|
|
|
rStream << rArea.nRowStart;
|
|
|
|
rStream << rArea.nColEnd;
|
|
|
|
rStream << rArea.nRowEnd;
|
2004-06-04 09:38:52 +00:00
|
|
|
#endif // SC_ROWLIMIT_STREAM_ACCESS
|
2000-09-18 23:16:46 +00:00
|
|
|
return rStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScArea::GetString( String& rStr, BOOL bAbsolute, ScDocument* pDoc ) const
|
|
|
|
{
|
|
|
|
ScRange aRange( ScAddress( nColStart, nRowStart, nTab ),
|
|
|
|
ScAddress( nColEnd, nRowEnd, nTab ) );
|
|
|
|
USHORT nFlags = bAbsolute ? SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE : 0;
|
|
|
|
|
|
|
|
aRange.Format( rStr, nFlags, pDoc );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) :
|
|
|
|
aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) )
|
|
|
|
{
|
|
|
|
pRangeName = pDoc->GetRangeName();
|
|
|
|
pDBCollection = pDoc->GetDBCollection();
|
|
|
|
nPos = 0;
|
|
|
|
bFirstPass = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL ScAreaNameIterator::Next( String& rName, ScRange& rRange )
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if ( bFirstPass ) // erst Bereichsnamen
|
|
|
|
{
|
|
|
|
if ( pRangeName && nPos < pRangeName->GetCount() )
|
|
|
|
{
|
|
|
|
ScRangeData* pData = (*pRangeName)[nPos++];
|
|
|
|
if ( pData && pData->IsReference(rRange) )
|
|
|
|
{
|
|
|
|
rName = pData->GetName();
|
|
|
|
return TRUE; // gefunden
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bFirstPass = FALSE;
|
|
|
|
nPos = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bFirstPass ) // dann DB-Bereiche
|
|
|
|
{
|
|
|
|
if ( pDBCollection && nPos < pDBCollection->GetCount() )
|
|
|
|
{
|
|
|
|
ScDBData* pData = (*pDBCollection)[nPos++];
|
|
|
|
if (pData && pData->GetName() != aStrNoName)
|
|
|
|
{
|
|
|
|
pData->GetArea( rRange );
|
|
|
|
rName = pData->GetName();
|
|
|
|
return TRUE; // gefunden
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE; // gibt nichts mehr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|