1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: autonamecache.cxx,v $
10 * $Revision: 1.4.128.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <unotools/transliterationwrapper.hxx>
40 #include "autonamecache.hxx"
41 #include "dociter.hxx"
43 #include "queryparam.hxx"
45 // -----------------------------------------------------------------------
47 ScAutoNameCache::ScAutoNameCache( ScDocument
* pD
) :
49 nCurrentTab( 0 ) // doesn't matter - aNames is empty
53 ScAutoNameCache::~ScAutoNameCache()
57 const ScAutoNameAddresses
& ScAutoNameCache::GetNameOccurences( const String
& rName
, SCTAB nTab
)
59 if ( nTab
!= nCurrentTab
)
61 // the lists are valid only for one sheet, so they are cleared when another sheet is used
66 ScAutoNameHashMap::const_iterator aFound
= aNames
.find( rName
);
67 if ( aFound
!= aNames
.end() )
68 return aFound
->second
; // already initialized
70 ScAutoNameAddresses
& rAddresses
= aNames
[rName
];
72 ScCellIterator
aIter( pDoc
, ScRange( 0, 0, nCurrentTab
, MAXCOL
, MAXROW
, nCurrentTab
) );
73 for ( ScBaseCell
* pCell
= aIter
.GetFirst(); pCell
; pCell
= aIter
.GetNext() )
75 // don't check code length here, always use the stored result
76 // (AutoCalc is disabled during CompileXML)
78 if ( pCell
->HasStringData() )
81 CellType eType
= pCell
->GetCellType();
85 ((ScStringCell
*)pCell
)->GetString( aStr
);
87 case CELLTYPE_FORMULA
:
88 ((ScFormulaCell
*)pCell
)->GetString( aStr
);
91 ((ScEditCell
*)pCell
)->GetString( aStr
);
96 case CELLTYPE_SYMBOLS
:
98 case CELLTYPE_DESTROYED
:
100 ; // nothing, prevent compiler warning
103 if ( ScGlobal::GetpTransliteration()->isEqual( aStr
, rName
) )
105 rAddresses
.push_back( ScAddress( aIter
.GetCol(), aIter
.GetRow(), aIter
.GetTab() ) );