Line data Source code
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 :
10 :
11 : #include "cachedattraccess.hxx"
12 : #include "document.hxx"
13 :
14 578 : ScXMLCachedRowAttrAccess::Cache::Cache() :
15 578 : mnTab(-1), mnRow1(-1), mnRow2(-1), mbValue(false) {}
16 :
17 8388810 : bool ScXMLCachedRowAttrAccess::Cache::hasCache(sal_Int32 nTab, sal_Int32 nRow) const
18 : {
19 8388810 : return mnTab == nTab && mnRow1 <= nRow && nRow <= mnRow2;
20 : }
21 :
22 289 : ScXMLCachedRowAttrAccess::ScXMLCachedRowAttrAccess(ScDocument* pDoc) :
23 289 : mpDoc(pDoc) {}
24 :
25 4194405 : bool ScXMLCachedRowAttrAccess::rowHidden(sal_Int32 nTab, sal_Int32 nRow)
26 : {
27 4194405 : if (!maHidden.hasCache(nTab, nRow))
28 : {
29 : SCROW nRow1, nRow2;
30 : maHidden.mbValue = mpDoc->RowHidden(
31 4194405 : static_cast<SCROW>(nRow), static_cast<SCTAB>(nTab), &nRow1, &nRow2);
32 4194405 : maHidden.mnRow1 = static_cast<sal_Int32>(nRow1);
33 4194405 : maHidden.mnRow2 = static_cast<sal_Int32>(nRow2);
34 : }
35 4194405 : return maHidden.mbValue;
36 : }
37 :
38 4194405 : bool ScXMLCachedRowAttrAccess::rowFiltered(sal_Int32 nTab, sal_Int32 nRow)
39 : {
40 4194405 : if (!maFiltered.hasCache(nTab, nRow))
41 : {
42 : SCROW nRow1, nRow2;
43 : maFiltered.mbValue = mpDoc->RowFiltered(
44 4194405 : static_cast<SCROW>(nRow), static_cast<SCTAB>(nTab), &nRow1, &nRow2);
45 4194405 : maFiltered.mnRow1 = static_cast<sal_Int32>(nRow1);
46 4194405 : maFiltered.mnRow2 = static_cast<sal_Int32>(nRow2);
47 : }
48 4194405 : return maFiltered.mbValue;
49 : }
50 :
51 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|