1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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"
45 ScDPOutputGeometry::ScDPOutputGeometry(const ScRange
& rOutRange
, bool bShowFilter
) :
46 maOutRange(rOutRange
),
51 mbShowFilter(bShowFilter
)
55 ScDPOutputGeometry::~ScDPOutputGeometry()
59 void ScDPOutputGeometry::setRowFieldCount(sal_uInt32 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
;
88 bool bDataLayout
= mnDataFields
> 1;
90 SCROW nCurRow
= maOutRange
.aStart
.Row();
94 SCROW nRowStart
= maOutRange
.aStart
.Row() + mbShowFilter
;
95 SCROW nRowEnd
= nRowStart
+ static_cast<SCCOL
>(mnPageFields
-1);
96 nCurRow
= nRowEnd
+ 2;
98 else if (mbShowFilter
)
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
));
111 void ScDPOutputGeometry::getRowFieldPositions(vector
<ScAddress
>& rAddrs
) const
113 vector
<ScAddress
> aAddrs
;
120 SCROW nCurRow
= maOutRange
.aStart
.Row();
124 SCROW nRowStart
= maOutRange
.aStart
.Row() + mbShowFilter
;
125 SCROW nRowEnd
= nRowStart
+ static_cast<SCCOL
>(mnPageFields
-1);
126 nCurRow
= nRowEnd
+ 2;
128 else if (mbShowFilter
)
131 nCurRow
+= static_cast<SCROW
>(mnColumnFields
);
133 SCROW nRow
= nCurRow
;
134 SCTAB nTab
= maOutRange
.aStart
.Tab();
135 SCCOL nColStart
= maOutRange
.aStart
.Col();
136 SCCOL nColEnd
= nColStart
+ static_cast<SCCOL
>(mnRowFields
-1);
138 for (SCCOL nCol
= nColStart
; nCol
<= nColEnd
; ++nCol
)
139 aAddrs
.push_back(ScAddress(nCol
, nRow
, nTab
));
143 void ScDPOutputGeometry::getPageFieldPositions(vector
<ScAddress
>& rAddrs
) const
145 vector
<ScAddress
> aAddrs
;
152 SCTAB nTab
= maOutRange
.aStart
.Tab();
153 SCCOL nCol
= maOutRange
.aStart
.Col();
155 SCROW nRowStart
= maOutRange
.aStart
.Row() + mbShowFilter
;
156 SCROW nRowEnd
= nRowStart
+ static_cast<SCCOL
>(mnPageFields
-1);
158 for (SCROW nRow
= nRowStart
; nRow
<= nRowEnd
; ++nRow
)
159 aAddrs
.push_back(ScAddress(nCol
, nRow
, nTab
));
163 ScDPOutputGeometry::FieldType
ScDPOutputGeometry::getFieldButtonType(const ScAddress
& rPos
) const
165 // We will ignore the table position for now.
167 bool bDataLayout
= mnDataFields
> 1;
169 SCROW nCurRow
= maOutRange
.aStart
.Row();
173 SCCOL nCol
= maOutRange
.aStart
.Col();
174 SCROW nRowStart
= maOutRange
.aStart
.Row() + mbShowFilter
;
175 SCROW nRowEnd
= nRowStart
+ static_cast<SCCOL
>(mnPageFields
-1);
176 if (rPos
.Col() == nCol
&& nRowStart
<= rPos
.Row() && rPos
.Row() <= nRowEnd
)
179 nCurRow
= nRowEnd
+ 2;
181 else if (mbShowFilter
)
186 SCROW nRow
= nCurRow
;
187 SCCOL nColStart
= maOutRange
.aStart
.Col() + mnRowFields
+ bDataLayout
;
188 SCCOL nColEnd
= nColStart
+ static_cast<SCCOL
>(mnColumnFields
-1);
189 if (rPos
.Row() == nRow
&& nColStart
<= rPos
.Col() && rPos
.Col() <= nColEnd
)
192 nCurRow
+= static_cast<SCROW
>(mnColumnFields
);
197 SCCOL nColStart
= maOutRange
.aStart
.Col();
198 SCCOL nColEnd
= nColStart
+ static_cast<SCCOL
>(mnRowFields
-1);
199 if (rPos
.Row() == nCurRow
&& nColStart
<= rPos
.Col() && rPos
.Col() <= nColEnd
)