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