fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / data / autonamecache.cxx
blobba261b17b29ae82e094831ebe02e3e2e12e35ae1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <unotools/transliterationwrapper.hxx>
22 #include "autonamecache.hxx"
23 #include "dociter.hxx"
24 #include "queryparam.hxx"
25 #include "formulacell.hxx"
26 #include "cellvalue.hxx"
27 #include "editutil.hxx"
28 #include "document.hxx"
30 ScAutoNameCache::ScAutoNameCache( ScDocument* pD ) :
31 pDoc( pD ),
32 nCurrentTab( 0 ) // doesn't matter - aNames is empty
36 ScAutoNameCache::~ScAutoNameCache()
40 const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const OUString& rName, SCTAB nTab )
42 if ( nTab != nCurrentTab )
44 // the lists are valid only for one sheet, so they are cleared when another sheet is used
45 aNames.clear();
46 nCurrentTab = nTab;
49 ScAutoNameHashMap::const_iterator aFound = aNames.find( rName );
50 if ( aFound != aNames.end() )
51 return aFound->second; // already initialized
53 ScAutoNameAddresses& rAddresses = aNames[rName];
55 ScCellIterator aIter( pDoc, ScRange( 0, 0, nCurrentTab, MAXCOL, MAXROW, nCurrentTab ) );
56 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
58 // don't check code length here, always use the stored result
59 // (AutoCalc is disabled during CompileXML)
60 if (aIter.hasString())
62 OUString aStr;
63 switch (aIter.getType())
65 case CELLTYPE_STRING:
66 aStr = aIter.getString();
67 break;
68 case CELLTYPE_FORMULA:
69 aStr = aIter.getFormulaCell()->GetString().getString();
70 break;
71 case CELLTYPE_EDIT:
73 const EditTextObject* p = aIter.getEditText();
74 if (p)
75 aStr = ScEditUtil::GetMultilineString(*p); // string with line separators between paragraphs
77 break;
78 case CELLTYPE_NONE:
79 case CELLTYPE_VALUE:
80 ; // nothing, prevent compiler warning
81 break;
83 if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rName ) )
85 rAddresses.push_back(aIter.GetPos());
90 return rAddresses;
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */