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
, ImportType eImportType
) :
46 maOutRange(rOutRange
),
51 meImportType(eImportType
),
52 mbShowFilter(bShowFilter
)
56 ScDPOutputGeometry::~ScDPOutputGeometry()
60 void ScDPOutputGeometry::setRowFieldCount(sal_uInt32 nCount
)
65 void ScDPOutputGeometry::setColumnFieldCount(sal_uInt32 nCount
)
67 mnColumnFields
= nCount
;
70 void ScDPOutputGeometry::setPageFieldCount(sal_uInt32 nCount
)
72 mnPageFields
= nCount
;
75 void ScDPOutputGeometry::setDataFieldCount(sal_uInt32 nCount
)
77 mnDataFields
= nCount
;
80 void ScDPOutputGeometry::getColumnFieldPositions(vector
<ScAddress
>& rAddrs
) const
82 vector
<ScAddress
> aAddrs
;
89 bool bDataLayout
= mnDataFields
> 1;
91 SCROW nCurRow
= maOutRange
.aStart
.Row();
95 SCROW nRowStart
= maOutRange
.aStart
.Row() + mbShowFilter
;
96 SCROW nRowEnd
= nRowStart
+ static_cast<SCCOL
>(mnPageFields
-1);
97 nCurRow
= nRowEnd
+ 2;
99 else if (mbShowFilter
)
102 SCROW nRow
= nCurRow
;
103 SCTAB nTab
= maOutRange
.aStart
.Tab();
104 SCCOL nColStart
= maOutRange
.aStart
.Col() + mnRowFields
+ bDataLayout
;
105 SCCOL nColEnd
= nColStart
+ static_cast<SCCOL
>(mnColumnFields
-1);
107 for (SCCOL nCol
= nColStart
; nCol
<= nColEnd
; ++nCol
)
108 aAddrs
.push_back(ScAddress(nCol
, nRow
, nTab
));
112 void ScDPOutputGeometry::getRowFieldPositions(vector
<ScAddress
>& rAddrs
) const
114 vector
<ScAddress
> aAddrs
;
121 SCROW nRow
= getRowFieldHeaderRow();
122 SCTAB nTab
= maOutRange
.aStart
.Tab();
123 SCCOL nColStart
= maOutRange
.aStart
.Col();
124 SCCOL nColEnd
= nColStart
+ static_cast<SCCOL
>(mnRowFields
-1);
126 for (SCCOL nCol
= nColStart
; nCol
<= nColEnd
; ++nCol
)
127 aAddrs
.push_back(ScAddress(nCol
, nRow
, nTab
));
131 void ScDPOutputGeometry::getPageFieldPositions(vector
<ScAddress
>& rAddrs
) const
133 vector
<ScAddress
> aAddrs
;
140 SCTAB nTab
= maOutRange
.aStart
.Tab();
141 SCCOL nCol
= maOutRange
.aStart
.Col();
143 SCROW nRowStart
= maOutRange
.aStart
.Row() + mbShowFilter
;
144 SCROW nRowEnd
= nRowStart
+ static_cast<SCCOL
>(mnPageFields
-1);
146 for (SCROW nRow
= nRowStart
; nRow
<= nRowEnd
; ++nRow
)
147 aAddrs
.push_back(ScAddress(nCol
, nRow
, nTab
));
151 SCROW
ScDPOutputGeometry::getRowFieldHeaderRow() const
153 SCROW nCurRow
= maOutRange
.aStart
.Row();
157 SCROW nRowStart
= maOutRange
.aStart
.Row() + mbShowFilter
;
158 SCROW nRowEnd
= nRowStart
+ static_cast<SCCOL
>(mnPageFields
-1);
159 nCurRow
= nRowEnd
+ 2;
161 else if (mbShowFilter
)
165 nCurRow
+= static_cast<SCROW
>(mnColumnFields
);
166 else if (mnRowFields
)
172 ScDPOutputGeometry::FieldType
ScDPOutputGeometry::getFieldButtonType(const ScAddress
& rPos
) const
174 // We will ignore the table position for now.
176 bool bExtraTitleRow
= (mnColumnFields
== 0 && meImportType
== ScDPOutputGeometry::XLS
);
177 bool bDataLayout
= mnDataFields
> 1;
179 SCROW nCurRow
= maOutRange
.aStart
.Row();
183 SCCOL nCol
= maOutRange
.aStart
.Col();
184 SCROW nRowStart
= maOutRange
.aStart
.Row() + mbShowFilter
;
185 SCROW nRowEnd
= nRowStart
+ static_cast<SCCOL
>(mnPageFields
-1);
186 if (rPos
.Col() == nCol
&& nRowStart
<= rPos
.Row() && rPos
.Row() <= nRowEnd
)
189 nCurRow
= nRowEnd
+ 2;
191 else if (mbShowFilter
)
196 SCROW nRow
= nCurRow
;
197 SCCOL nColStart
= maOutRange
.aStart
.Col() + mnRowFields
+ bDataLayout
;
198 SCCOL nColEnd
= nColStart
+ static_cast<SCCOL
>(mnColumnFields
-1);
199 if (rPos
.Row() == nRow
&& nColStart
<= rPos
.Col() && rPos
.Col() <= nColEnd
)
202 nCurRow
+= static_cast<SCROW
>(mnColumnFields
);
210 SCCOL nColStart
= maOutRange
.aStart
.Col();
211 SCCOL nColEnd
= nColStart
+ static_cast<SCCOL
>(mnRowFields
-1);
212 if (rPos
.Row() == nCurRow
&& nColStart
<= rPos
.Col() && rPos
.Col() <= nColEnd
)