Lines 48-53
Link Here
|
48 |
#include "drawview.hxx" |
48 |
#include "drawview.hxx" |
49 |
#include "globstr.hrc" |
49 |
#include "globstr.hrc" |
50 |
#include <avmedia/mediawindow.hxx> |
50 |
#include <avmedia/mediawindow.hxx> |
|
|
51 |
#include "scmod.hxx" |
52 |
#include "dbcolect.hxx" |
53 |
#include "inputhdl.hxx" |
54 |
#include <editeng/editview.hxx> |
55 |
#include "inputwin.hxx" |
51 |
|
56 |
|
52 |
//------------------------------------------------------------------------ |
57 |
//------------------------------------------------------------------------ |
53 |
|
58 |
|
Lines 131-136
Link Here
|
131 |
pDrView->InsertObjectSafe( pObj, *pDrView->GetSdrPageView() ); |
136 |
pDrView->InsertObjectSafe( pObj, *pDrView->GetSdrPageView() ); |
132 |
} |
137 |
} |
133 |
|
138 |
|
|
|
139 |
//------------------------------------------------------------------------ |
134 |
|
140 |
|
|
|
141 |
sal_Bool lcl_UseSubTotal(ScTabViewShell* pViewSh, ScRangeList* pRangeList) |
142 |
{ |
143 |
sal_Bool bSubTotal(sal_False); |
144 |
|
145 |
ScDocument* pDoc = pViewSh->GetViewData()->GetDocument(); |
146 |
sal_Int32 nRangeCount (pRangeList->Count()); |
147 |
sal_Int32 nRangeIndex (0); |
148 |
while (!bSubTotal && nRangeIndex < nRangeCount) |
149 |
{ |
150 |
const ScRange* pRange = pRangeList->GetObject( nRangeIndex ); |
151 |
if( pRange ) |
152 |
{ |
153 |
SCTAB nTabEnd(pRange->aEnd.Tab()); |
154 |
SCTAB nTab(pRange->aStart.Tab()); |
155 |
while (!bSubTotal && nTab <= nTabEnd) |
156 |
{ |
157 |
SCROW nRowEnd(pRange->aEnd.Row()); |
158 |
SCROW nRow(pRange->aStart.Row()); |
159 |
while (!bSubTotal && nRow <= nRowEnd) |
160 |
{ |
161 |
if (pDoc->RowFiltered(nRow, nTab)) |
162 |
bSubTotal = sal_True; |
163 |
else |
164 |
++nRow; |
165 |
} |
166 |
++nTab; |
167 |
} |
168 |
} |
169 |
++nRangeIndex; |
170 |
} |
135 |
|
171 |
|
|
|
172 |
ScDBCollection* pDBCollection = pDoc->GetDBCollection(); |
173 |
sal_uInt16 nDBCount (pDBCollection->GetCount()); |
174 |
sal_uInt16 nDBIndex (0); |
175 |
while (!bSubTotal && nDBIndex < nDBCount) |
176 |
{ |
177 |
ScDBData* pDB = (*pDBCollection)[nDBIndex]; |
178 |
if (pDB && pDB->HasAutoFilter()) |
179 |
{ |
180 |
nRangeIndex = 0; |
181 |
while (!bSubTotal && nRangeIndex < nRangeCount) |
182 |
{ |
183 |
const ScRange* pRange = pRangeList->GetObject( nRangeIndex ); |
184 |
if( pRange ) |
185 |
{ |
186 |
ScRange aDBArea; |
187 |
pDB->GetArea(aDBArea); |
188 |
if (aDBArea.Intersects(*pRange)) |
189 |
bSubTotal = sal_True; |
190 |
} |
191 |
++nRangeIndex; |
192 |
} |
193 |
} |
194 |
++nDBIndex; |
195 |
} |
196 |
|
197 |
return bSubTotal; |
198 |
} |
136 |
|
199 |
|
|
|
200 |
//---------------------------------------------------------------------------- |
201 |
|
202 |
void ScTabViewShell::InputAutoSum( bool bFromInputWindow ) |
203 |
{ |
204 |
const ScMarkData& rMark = GetViewData()->GetMarkData(); |
205 |
if ( rMark.IsMarked() || rMark.IsMultiMarked() ) |
206 |
{ |
207 |
ScRangeList aMarkRangeList; |
208 |
rMark.FillRangeListWithMarks( &aMarkRangeList, sal_False ); |
209 |
ScDocument* pDoc = GetViewData()->GetDocument(); |
210 |
|
211 |
// check if one of the marked ranges is empty |
212 |
bool bEmpty = false; |
213 |
const sal_uLong nCount = aMarkRangeList.Count(); |
214 |
for ( sal_uLong i = 0; i < nCount; ++i ) |
215 |
{ |
216 |
const ScRange aRange( *aMarkRangeList.GetObject( i ) ); |
217 |
if ( pDoc->IsBlockEmpty( aRange.aStart.Tab(), |
218 |
aRange.aStart.Col(), aRange.aStart.Row(), |
219 |
aRange.aEnd.Col(), aRange.aEnd.Row() ) ) |
220 |
{ |
221 |
bEmpty = true; |
222 |
break; |
223 |
} |
224 |
} |
225 |
|
226 |
if ( bEmpty ) |
227 |
{ |
228 |
ScRangeList aRangeList; |
229 |
const sal_Bool bDataFound = GetAutoSumArea( aRangeList ); |
230 |
if ( bDataFound ) |
231 |
{ |
232 |
const sal_Bool bSubTotal( lcl_UseSubTotal( this, &aRangeList ) ); |
233 |
EnterAutoSum( aRangeList, bSubTotal ); // Block mit Summen fuellen |
234 |
} |
235 |
} |
236 |
else |
237 |
{ |
238 |
const sal_Bool bSubTotal( lcl_UseSubTotal( this, &aMarkRangeList ) ); |
239 |
for ( sal_uLong i = 0; i < nCount; ++i ) |
240 |
{ |
241 |
const ScRange aRange( *aMarkRangeList.GetObject( i ) ); |
242 |
const bool bSetCursor = ( i == nCount - 1 ? true : false ); |
243 |
const bool bContinue = ( i != 0 ? true : false ); |
244 |
if ( !AutoSum( aRange, bSubTotal, bSetCursor, bContinue ) ) |
245 |
{ |
246 |
MarkRange( aRange, sal_False, sal_False ); |
247 |
SetCursor( aRange.aEnd.Col(), aRange.aEnd.Row() ); |
248 |
ScInputHandler* pHdl = GetInputHandler(); |
249 |
if ( pHdl ) |
250 |
{ |
251 |
const ScRangeList aRangeList; |
252 |
const String aFormula = GetAutoSumFormula( aRangeList, bSubTotal ); |
253 |
ScInputWindow *pInputWin = pHdl->GetInputWindow(); |
254 |
if ( pInputWin ) |
255 |
pInputWin->SetFuncString( aFormula ); |
256 |
else if ( !bFromInputWindow ) |
257 |
EnterData( GetViewData()->GetCurX(), GetViewData()->GetCurY(), |
258 |
GetViewData()->GetTabNo(), aFormula ); |
259 |
} |
260 |
break; |
261 |
} |
262 |
} |
263 |
} |
264 |
} |
265 |
else |
266 |
{ |
267 |
ScRangeList aRangeList; |
268 |
const sal_Bool bDataFound = GetAutoSumArea( aRangeList ); |
269 |
const sal_Bool bSubTotal( lcl_UseSubTotal( this, &aRangeList ) ); |
270 |
const String aFormula = GetAutoSumFormula( aRangeList, bSubTotal ); |
271 |
ScInputHandler* pHdl = GetInputHandler(); |
272 |
|
273 |
if ( pHdl ) |
274 |
{ |
275 |
ScInputWindow *pInputWin = pHdl->GetInputWindow(); |
276 |
if ( pInputWin ) |
277 |
pInputWin->SetFuncString( aFormula ); |
278 |
else if ( !bFromInputWindow ) |
279 |
EnterData( GetViewData()->GetCurX(), GetViewData()->GetCurY(), |
280 |
GetViewData()->GetTabNo(), aFormula ); |
281 |
} |
282 |
|
283 |
if ( bDataFound ) |
284 |
{ |
285 |
if ( pHdl && SC_MOD()->IsEditMode() ) |
286 |
{ |
287 |
pHdl->InitRangeFinder( aFormula ); |
288 |
|
289 |
//! SetSelection am InputHandler ??? |
290 |
//! bSelIsRef setzen ??? |
291 |
const xub_StrLen nOpen = aFormula.Search('('); |
292 |
const xub_StrLen nLen = aFormula.Len(); |
293 |
if ( nOpen != STRING_NOTFOUND && nLen > nOpen ) |
294 |
{ |
295 |
sal_uInt8 nAdd(1); |
296 |
if (bSubTotal) |
297 |
nAdd = 3; |
298 |
ESelection aSel(0,nOpen+nAdd,0,nLen-1); |
299 |
EditView* pTableView = pHdl->GetTableView(); |
300 |
if (pTableView) |
301 |
pTableView->SetSelection(aSel); |
302 |
EditView* pTopView = pHdl->GetTopView(); |
303 |
if (pTopView) |
304 |
pTopView->SetSelection(aSel); |
305 |
} |
306 |
} |
307 |
} |
308 |
} |
309 |
} |