Update to m13
[ooovba.git] / sc / source / core / data / dpoutputgeometry.cxx
blobd570dfc34b48ffb0d98708176d7ad69d5db6b6ed
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmldpimp.cxx,v $
10 * $Revision: 1.27.134.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 "dpoutputgeometry.hxx"
39 #include "address.hxx"
41 #include <vector>
43 using ::std::vector;
45 ScDPOutputGeometry::ScDPOutputGeometry(const ScRange& rOutRange, bool bShowFilter) :
46 maOutRange(rOutRange),
47 mnRowFields(0),
48 mnColumnFields(0),
49 mnPageFields(0),
50 mnDataFields(0),
51 mbShowFilter(bShowFilter)
55 ScDPOutputGeometry::~ScDPOutputGeometry()
59 void ScDPOutputGeometry::setRowFieldCount(sal_uInt32 nCount)
61 mnRowFields = nCount;
64 void ScDPOutputGeometry::setColumnFieldCount(sal_uInt32 nCount)
66 mnColumnFields = nCount;
69 void ScDPOutputGeometry::setPageFieldCount(sal_uInt32 nCount)
71 mnPageFields = nCount;
74 void ScDPOutputGeometry::setDataFieldCount(sal_uInt32 nCount)
76 mnDataFields = nCount;
79 void ScDPOutputGeometry::getColumnFieldPositions(vector<ScAddress>& rAddrs) const
81 vector<ScAddress> aAddrs;
82 if (!mnColumnFields)
84 rAddrs.swap(aAddrs);
85 return;
88 bool bDataLayout = mnDataFields > 1;
90 SCROW nCurRow = maOutRange.aStart.Row();
92 if (mnPageFields)
94 SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
95 SCROW nRowEnd = nRowStart + static_cast<SCCOL>(mnPageFields-1);
96 nCurRow = nRowEnd + 2;
98 else if (mbShowFilter)
99 nCurRow += 2;
101 SCROW nRow = nCurRow;
102 SCTAB nTab = maOutRange.aStart.Tab();
103 SCCOL nColStart = maOutRange.aStart.Col() + mnRowFields + bDataLayout;
104 SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnColumnFields-1);
106 for (SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
107 aAddrs.push_back(ScAddress(nCol, nRow, nTab));
108 rAddrs.swap(aAddrs);
111 void ScDPOutputGeometry::getRowFieldPositions(vector<ScAddress>& rAddrs) const
113 vector<ScAddress> aAddrs;
114 if (!mnRowFields)
116 rAddrs.swap(aAddrs);
117 return;
120 SCROW nCurRow = maOutRange.aStart.Row();
122 if (mnPageFields)
124 SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
125 SCROW nRowEnd = nRowStart + static_cast<SCCOL>(mnPageFields-1);
126 nCurRow = nRowEnd + 2;
128 else if (mbShowFilter)
129 nCurRow += 2;
131 if (mnColumnFields)
132 nCurRow += static_cast<SCROW>(mnColumnFields);
133 else
134 ++nCurRow;
136 SCROW nRow = nCurRow;
137 SCTAB nTab = maOutRange.aStart.Tab();
138 SCCOL nColStart = maOutRange.aStart.Col();
139 SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnRowFields-1);
141 for (SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
142 aAddrs.push_back(ScAddress(nCol, nRow, nTab));
143 rAddrs.swap(aAddrs);
146 void ScDPOutputGeometry::getPageFieldPositions(vector<ScAddress>& rAddrs) const
148 vector<ScAddress> aAddrs;
149 if (!mnPageFields)
151 rAddrs.swap(aAddrs);
152 return;
155 SCTAB nTab = maOutRange.aStart.Tab();
156 SCCOL nCol = maOutRange.aStart.Col();
158 SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
159 SCROW nRowEnd = nRowStart + static_cast<SCCOL>(mnPageFields-1);
161 for (SCROW nRow = nRowStart; nRow <= nRowEnd; ++nRow)
162 aAddrs.push_back(ScAddress(nCol, nRow, nTab));
163 rAddrs.swap(aAddrs);
166 ScDPOutputGeometry::FieldType ScDPOutputGeometry::getFieldButtonType(const ScAddress& rPos) const
168 // We will ignore the table position for now.
170 bool bExtraTitleRow = (mnColumnFields == 0);
171 bool bDataLayout = mnDataFields > 1;
173 SCROW nCurRow = maOutRange.aStart.Row();
175 if (mnPageFields)
177 SCCOL nCol = maOutRange.aStart.Col();
178 SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
179 SCROW nRowEnd = nRowStart + static_cast<SCCOL>(mnPageFields-1);
180 if (rPos.Col() == nCol && nRowStart <= rPos.Row() && rPos.Row() <= nRowEnd)
181 return Page;
183 nCurRow = nRowEnd + 2;
185 else if (mbShowFilter)
186 nCurRow += 2;
188 if (mnColumnFields)
190 SCROW nRow = nCurRow;
191 SCCOL nColStart = maOutRange.aStart.Col() + mnRowFields + bDataLayout;
192 SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnColumnFields-1);
193 if (rPos.Row() == nRow && nColStart <= rPos.Col() && rPos.Col() <= nColEnd)
194 return Column;
196 nCurRow += static_cast<SCROW>(mnColumnFields);
199 if (bExtraTitleRow)
200 ++nCurRow;
202 if (mnRowFields)
204 SCCOL nColStart = maOutRange.aStart.Col();
205 SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnRowFields-1);
206 if (rPos.Row() == nCurRow && nColStart <= rPos.Col() && rPos.Col() <= nColEnd)
207 return Row;
210 return None;