LibreOffice Module sc (master) 1
frmbase.cxx
Go to the documentation of this file.
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 * 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 .
18 */
19
20#include <formel.hxx>
21
22#include <osl/diagnose.h>
23
25: XclImpRoot( rRoot )
26{
27}
28
30{
31}
32
33void ScRangeListTabs::Append( const ScAddress& aSRD, SCTAB nTab )
34{
35 ScAddress a = aSRD;
36 ScDocument& rDoc = GetRoot().GetDoc();
37
38 if (a.Tab() > MAXTAB)
39 a.SetTab(MAXTAB);
40
41 if (a.Col() > rDoc.MaxCol())
42 a.SetCol(rDoc.MaxCol());
43
44 if (a.Row() > rDoc.MaxRow())
45 a.SetRow(rDoc.MaxRow());
46
47 if( nTab == SCTAB_MAX)
48 return;
49 if( nTab < 0)
50 nTab = a.Tab();
51
52 if (nTab < 0 || MAXTAB < nTab)
53 return;
54
55 TabRangeType::iterator itr = m_TabRanges.find(nTab);
56 if (itr == m_TabRanges.end())
57 {
58 // No entry for this table yet. Insert a new one.
59 std::pair<TabRangeType::iterator, bool> r =
60 m_TabRanges.insert(std::make_pair(nTab, RangeListType()));
61
62 if (!r.second)
63 // Insertion failed.
64 return;
65
66 itr = r.first;
67 }
68 itr->second.push_back(ScRange(a.Col(),a.Row(),a.Tab()));
69}
70
71void ScRangeListTabs::Append( const ScRange& aCRD, SCTAB nTab )
72{
73 ScRange a = aCRD;
74 ScDocument& rDoc = GetRoot().GetDoc();
75
76 // ignore 3D ranges
77 if (a.aStart.Tab() != a.aEnd.Tab())
78 return;
79
80 if (a.aStart.Tab() > MAXTAB)
81 a.aStart.SetTab(MAXTAB);
82 else if (a.aStart.Tab() < 0)
83 a.aStart.SetTab(0);
84
85 if (a.aStart.Col() > rDoc.MaxCol())
86 a.aStart.SetCol(rDoc.MaxCol());
87 else if (a.aStart.Col() < 0)
88 a.aStart.SetCol(0);
89
90 if (a.aStart.Row() > rDoc.MaxRow())
91 a.aStart.SetRow(rDoc.MaxRow());
92 else if (a.aStart.Row() < 0)
93 a.aStart.SetRow(0);
94
95 if (a.aEnd.Col() > rDoc.MaxCol())
96 a.aEnd.SetCol(rDoc.MaxCol());
97 else if (a.aEnd.Col() < 0)
98 a.aEnd.SetCol(0);
99
100 if (a.aEnd.Row() > rDoc.MaxRow())
101 a.aEnd.SetRow(rDoc.MaxRow());
102 else if (a.aEnd.Row() < 0)
103 a.aEnd.SetRow(0);
104
105 if( nTab == SCTAB_MAX)
106 return;
107
108 if( nTab < -1)
109 nTab = a.aStart.Tab();
110
111 if (nTab < 0 || MAXTAB < nTab)
112 return;
113
114 TabRangeType::iterator itr = m_TabRanges.find(nTab);
115 if (itr == m_TabRanges.end())
116 {
117 // No entry for this table yet. Insert a new one.
118 std::pair<TabRangeType::iterator, bool> r =
119 m_TabRanges.insert(std::make_pair(nTab, RangeListType()));
120
121 if (!r.second)
122 // Insertion failed.
123 return;
124
125 itr = r.first;
126 }
127 itr->second.push_back(a);
128}
131{
132 OSL_ENSURE( ValidTab(n), "-ScRangeListTabs::First(): Good bye!" );
133
134 TabRangeType::iterator itr = m_TabRanges.find(n);
135 if (itr == m_TabRanges.end())
136 // No range list exists for this table.
137 return nullptr;
138
139 const RangeListType& rList = itr->second;
140 maItrCur = rList.begin();
141 maItrCurEnd = rList.end();
142 return rList.empty() ? nullptr : &(*maItrCur);
143}
144
146{
147 ++maItrCur;
148 if (maItrCur == maItrCurEnd)
149 return nullptr;
150
151 return &(*maItrCur);
152}
153
155 aPool(rSPool),
156 aEingPos( 0, 0, 0 )
157{
158}
159
161{
162}
163
165{
166 aPool.Reset();
167 aStack.Reset();
168}
169
171 ConverterBase(rSPool)
172{
173}
174
176{
177}
178
180{
182 aEingPos = rEingPos;
183}
184
186{
188 aEingPos.Set( 0, 0, 0 );
189}
190
192 ConverterBase(rSPool),
193 aIn( rStr ),
194 nBytesLeft( 0 )
195{
196}
197
199{
200}
201
203{
205 nBytesLeft = 0;
206 aEingPos = rEingPos;
207}
208
209/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
const SCTAB MAXTAB
Definition: address.hxx:70
const SCTAB SCTAB_MAX
Definition: address.hxx:57
ScAddress aEingPos
Definition: formel.hxx:81
void Reset()
Definition: frmbase.cxx:164
ConverterBase(svl::SharedStringPool &rSPool)
Definition: frmbase.cxx:154
TokenPool aPool
Definition: formel.hxx:79
TokenStack aStack
Definition: formel.hxx:80
virtual ~ConverterBase()
Definition: frmbase.cxx:160
ExcelConverterBase(svl::SharedStringPool &rSPool)
Definition: frmbase.cxx:170
virtual ~ExcelConverterBase() override
Definition: frmbase.cxx:175
virtual ~LotusConverterBase() override
Definition: frmbase.cxx:198
LotusConverterBase(SvStream &rStr, svl::SharedStringPool &rSPool)
Definition: frmbase.cxx:191
sal_Int32 nBytesLeft
Definition: formel.hxx:109
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: address.hxx:403
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
::std::vector< ScRange > RangeListType
Definition: formel.hxx:57
void Append(const ScAddress &aSRD, SCTAB nTab)
Definition: frmbase.cxx:33
RangeListType::const_iterator maItrCurEnd
Definition: formel.hxx:61
const ScRange * First(SCTAB nTab)
Definition: frmbase.cxx:130
const ScRange * Next()
Definition: frmbase.cxx:145
ScRangeListTabs(const XclImpRoot &rRoot)
Definition: frmbase.cxx:24
RangeListType::const_iterator maItrCur
Definition: formel.hxx:60
TabRangeType m_TabRanges
Definition: formel.hxx:59
void Reset()
Definition: tokstack.cxx:675
void Reset()
Definition: tokstack.hxx:328
Access to global data from other classes.
Definition: xiroot.hxx:129
const XclImpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xiroot.hxx:134
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
sal_Int64 n
uno_Any a
sal_Int16 SCTAB
Definition: types.hxx:22