merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0140-sc-dbrange-dynamic-resize.diff
blob3236a7464c107a352a500df392329075d0aa14c7
1 diff --git sc/inc/dbcolect.hxx sc/inc/dbcolect.hxx
2 index eea9076..00ea53b 100644
3 --- sc/inc/dbcolect.hxx
4 +++ sc/inc/dbcolect.hxx
5 @@ -94,6 +94,7 @@ private:
6 ScQueryConnect eQueryConnect[MAXQUERY];
7 BOOL bIsAdvanced; // TRUE if created by advanced filter
8 ScRange aAdvSource; // source range
9 + SCROW nDynamicEndRow;
10 // SubTotalParam
11 BOOL bSubRemoveOnly;
12 BOOL bSubReplace;
13 @@ -141,9 +142,10 @@ public:
14 const String& GetName() const { return aName; }
15 void GetName(String& rName) const { rName = aName; }
16 void SetName(const String& rName) { aName = rName; }
17 - void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const;
18 - SC_DLLPUBLIC void GetArea(ScRange& rRange) const;
19 + void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2, bool bUseDynamicRange = false) const;
20 + SC_DLLPUBLIC void GetArea(ScRange& rRange, bool bUseDynamicRange = false) const;
21 void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
22 + void SetDynamicEndRow(SCROW nRow);
23 void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
24 BOOL IsByRow() const { return bByRow; }
25 void SetByRow(BOOL bByR) { bByRow = bByR; }
26 diff --git sc/inc/document.hxx sc/inc/document.hxx
27 index a92545f..daeb91e 100644
28 --- sc/inc/document.hxx
29 +++ sc/inc/document.hxx
30 @@ -873,7 +873,7 @@ public:
31 bool ShrinkToDataArea(SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow) const;
33 void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
34 - SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld );
35 + SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld ) const;
36 SC_DLLPUBLIC BOOL GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
37 SC_DLLPUBLIC BOOL GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
38 SC_DLLPUBLIC BOOL GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
39 @@ -1392,6 +1392,9 @@ public:
40 SCTAB nTab, ScQueryParam& rQueryParam );
41 void GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab, String& rStr);
43 + /** Update the dynamic end row position of a current data area. */
44 + void UpdateDynamicEndRow(ScDBData& rDBData) const;
46 BOOL GetFilterEntries( SCCOL nCol, SCROW nRow, SCTAB nTab,
47 bool bFilter, TypedScStrCollection& rStrings, bool& rHasDates);
48 SC_DLLPUBLIC BOOL GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
49 diff --git sc/inc/queryparam.hxx sc/inc/queryparam.hxx
50 index bc50237..01ddffb 100644
51 --- sc/inc/queryparam.hxx
52 +++ sc/inc/queryparam.hxx
53 @@ -86,6 +86,8 @@ struct SC_DLLPUBLIC ScQueryParam : public ScQueryParamBase, public ScQueryParamT
54 SCTAB nDestTab;
55 SCCOL nDestCol;
56 SCROW nDestRow;
57 + SCROW nDynamicEndRow;
58 + bool bUseDynamicRange;
60 ScQueryParam();
61 ScQueryParam( const ScQueryParam& r );
62 diff --git sc/inc/table.hxx sc/inc/table.hxx
63 index 3659381..89f505e 100644
64 --- sc/inc/table.hxx
65 +++ sc/inc/table.hxx
66 @@ -379,7 +379,7 @@ public:
67 SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
69 void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
70 - BOOL bIncludeOld );
71 + BOOL bIncludeOld ) const;
73 SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
74 SCCOL nEndCol, SCROW nEndRow, ScDirection eDir );
75 diff --git sc/source/core/data/documen3.cxx sc/source/core/data/documen3.cxx
76 index caeb5b1..396d54c 100644
77 --- sc/source/core/data/documen3.cxx
78 +++ sc/source/core/data/documen3.cxx
79 @@ -1255,6 +1255,18 @@ BOOL ScDocument::HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol,
80 //return FALSE;
83 +void ScDocument::UpdateDynamicEndRow(ScDBData& rDBData) const
85 + SCCOL nCol1, nCol2;
86 + SCROW nRow1, nRow2;
87 + SCTAB nTab;
88 + rDBData.GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
89 + SCCOL nCol1a = nCol1, nCol2a = nCol2;
90 + SCROW nRow1a = nRow1, nRow2a = nRow2;
91 + GetDataArea(nTab, nCol1a, nRow1a, nCol2a, nRow2a, false);
92 + rDBData.SetDynamicEndRow(nRow2a);
96 // GetFilterEntries - Eintraege fuer AutoFilter-Listbox
98 @@ -1267,6 +1279,7 @@ BOOL ScDocument::GetFilterEntries(
99 ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, FALSE); //!??
100 if (pDBData)
102 + UpdateDynamicEndRow(*pDBData);
103 SCTAB nAreaTab;
104 SCCOL nStartCol;
105 SCROW nStartRow;
106 @@ -1278,6 +1291,7 @@ BOOL ScDocument::GetFilterEntries(
108 ScQueryParam aParam;
109 pDBData->GetQueryParam( aParam );
110 + nEndRow = aParam.nDynamicEndRow;
111 rStrings.SetCaseSensitive( aParam.bCaseSens );
113 // return all filter entries, if a filter condition is connected with a boolean OR
114 diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
115 index 3d61f28..187199f 100644
116 --- sc/source/core/data/document.cxx
117 +++ sc/source/core/data/document.cxx
118 @@ -663,7 +663,7 @@ bool ScDocument::ShrinkToDataArea(SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow
119 // zusammenhaengender Bereich
121 void ScDocument::GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
122 - SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld )
123 + SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld ) const
125 if (VALIDTAB(nTab))
126 if (pTab[nTab])
127 diff --git sc/source/core/data/table1.cxx sc/source/core/data/table1.cxx
128 index 15db733..10b8cda 100644
129 --- sc/source/core/data/table1.cxx
130 +++ sc/source/core/data/table1.cxx
131 @@ -680,7 +680,7 @@ BOOL ScTable::GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const
134 void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
135 - BOOL bIncludeOld )
136 + BOOL bIncludeOld ) const
138 BOOL bLeft = FALSE;
139 BOOL bRight = FALSE;
140 diff --git sc/source/core/data/table3.cxx sc/source/core/data/table3.cxx
141 index 986755a..2ecc8c1 100644
142 --- sc/source/core/data/table3.cxx
143 +++ sc/source/core/data/table3.cxx
144 @@ -1617,6 +1617,7 @@ SCSIZE ScTable::Query(ScQueryParam& rParamOrg, BOOL bKeepSub)
145 BOOL* pSpecial = new BOOL[nEntryCount];
146 lcl_PrepareQuery( pDocument, this, aParam, pSpecial );
148 + SCROW nEndRow = aParam.bUseDynamicRange ? aParam.nDynamicEndRow : aParam.nRow2;
149 if (!aParam.bInplace)
151 nOutRow = aParam.nDestRow + nHeader;
152 @@ -1625,7 +1626,7 @@ SCSIZE ScTable::Query(ScQueryParam& rParamOrg, BOOL bKeepSub)
153 aParam.nDestCol, aParam.nDestRow, aParam.nDestTab );
156 - for (SCROW j=aParam.nRow1 + nHeader; j<=aParam.nRow2; j++)
157 + for (SCROW j=aParam.nRow1 + nHeader; j<=nEndRow; j++)
159 BOOL bResult; // Filterergebnis
160 BOOL bValid = ValidQuery(j, aParam, pSpecial);
161 diff --git sc/source/core/tool/dbcolect.cxx sc/source/core/tool/dbcolect.cxx
162 index 4f0e755..5fae4bd 100644
163 --- sc/source/core/tool/dbcolect.cxx
164 +++ sc/source/core/tool/dbcolect.cxx
165 @@ -381,18 +381,20 @@ String ScDBData::GetOperations() const
166 return aVal;
169 -void ScDBData::GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const
170 +void ScDBData::GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2,
171 + bool bUseDynamicRange) const
173 rTab = nTable;
174 rCol1 = nStartCol;
175 rRow1 = nStartRow;
176 rCol2 = nEndCol;
177 - rRow2 = nEndRow;
178 + rRow2 = bUseDynamicRange ? nDynamicEndRow : nEndRow;
181 -void ScDBData::GetArea(ScRange& rRange) const
182 +void ScDBData::GetArea(ScRange& rRange, bool bUseDynamicRange) const
184 - rRange = ScRange( nStartCol,nStartRow,nTable, nEndCol,nEndRow,nTable );
185 + SCROW nNewEndRow = bUseDynamicRange ? nDynamicEndRow : nEndRow;
186 + rRange = ScRange( nStartCol, nStartRow, nTable, nEndCol, nNewEndRow, nTable );
189 void ScDBData::SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
190 @@ -404,6 +406,11 @@ void ScDBData::SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW
191 nEndRow = nRow2;
194 +void ScDBData::SetDynamicEndRow(SCROW nRow)
196 + nDynamicEndRow = nRow;
199 void ScDBData::MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
201 USHORT i;
202 @@ -511,6 +518,7 @@ void ScDBData::GetQueryParam( ScQueryParam& rQueryParam ) const
203 rQueryParam.nDestTab = nQueryDestTab;
204 rQueryParam.nDestCol = nQueryDestCol;
205 rQueryParam.nDestRow = nQueryDestRow;
206 + rQueryParam.nDynamicEndRow = nDynamicEndRow;
208 rQueryParam.Resize( MAXQUERY );
209 for (SCSIZE i=0; i<MAXQUERY; i++)
210 diff --git sc/source/core/tool/queryparam.cxx sc/source/core/tool/queryparam.cxx
211 index d9d477d..0593534 100644
212 --- sc/source/core/tool/queryparam.cxx
213 +++ sc/source/core/tool/queryparam.cxx
214 @@ -177,7 +177,8 @@ ScQueryParam::ScQueryParam() :
215 ScQueryParam::ScQueryParam( const ScQueryParam& r ) :
216 ScQueryParamBase(r),
217 ScQueryParamTable(r),
218 - bDestPers(r.bDestPers), nDestTab(r.nDestTab), nDestCol(r.nDestCol), nDestRow(r.nDestRow)
219 + bDestPers(r.bDestPers), nDestTab(r.nDestTab), nDestCol(r.nDestCol), nDestRow(r.nDestRow),
220 + nDynamicEndRow(r.nDynamicEndRow), bUseDynamicRange(r.bUseDynamicRange)
224 @@ -187,7 +188,9 @@ ScQueryParam::ScQueryParam( const ScDBQueryParamInternal& r ) :
225 bDestPers(true),
226 nDestTab(0),
227 nDestCol(0),
228 - nDestRow(0)
229 + nDestRow(0),
230 + nDynamicEndRow(0),
231 + bUseDynamicRange(false)
235 @@ -221,6 +224,8 @@ void ScQueryParam::ClearDestParams()
236 nDestTab = 0;
237 nDestCol = 0;
238 nDestRow = 0;
239 + nDynamicEndRow = 0;
240 + bUseDynamicRange = false;
243 //------------------------------------------------------------------------
244 @@ -243,6 +248,8 @@ ScQueryParam& ScQueryParam::operator=( const ScQueryParam& r )
245 bDuplicate = r.bDuplicate;
246 bByRow = r.bByRow;
247 bDestPers = r.bDestPers;
248 + nDynamicEndRow = r.nDynamicEndRow;
249 + bUseDynamicRange = r.bUseDynamicRange;
251 maEntries = r.maEntries;
253 @@ -281,7 +288,9 @@ BOOL ScQueryParam::operator==( const ScQueryParam& rOther ) const
254 && (bDestPers == rOther.bDestPers)
255 && (nDestTab == rOther.nDestTab)
256 && (nDestCol == rOther.nDestCol)
257 - && (nDestRow == rOther.nDestRow) )
258 + && (nDestRow == rOther.nDestRow)
259 + && (nDynamicEndRow == rOther.nDynamicEndRow)
260 + && (bUseDynamicRange == rOther.bUseDynamicRange) )
262 bEqual = TRUE;
263 for ( SCSIZE i=0; i<nUsed && bEqual; i++ )
264 @@ -305,6 +314,7 @@ void ScQueryParam::MoveToDest()
265 nCol2 = sal::static_int_cast<SCCOL>( nCol2 + nDifX );
266 nRow2 = sal::static_int_cast<SCROW>( nRow2 + nDifY );
267 nTab = sal::static_int_cast<SCTAB>( nTab + nDifZ );
268 + nDynamicEndRow = sal::static_int_cast<SCROW>( nDynamicEndRow + nDifY );
269 size_t n = maEntries.size();
270 for (size_t i=0; i<n; i++)
271 maEntries[i].nField += nDifX;
272 diff --git sc/source/ui/dbgui/filtdlg.cxx sc/source/ui/dbgui/filtdlg.cxx
273 index 4f56adb..51fe845 100644
274 --- sc/source/ui/dbgui/filtdlg.cxx
275 +++ sc/source/ui/dbgui/filtdlg.cxx
276 @@ -454,7 +454,7 @@ void ScFilterDlg::UpdateValueList( USHORT nList )
277 USHORT nOffset = GetSliderPos();
278 SCTAB nTab = nSrcTab;
279 SCROW nFirstRow = theQueryData.nRow1;
280 - SCROW nLastRow = theQueryData.nRow2;
281 + SCROW nLastRow = theQueryData.bUseDynamicRange ? theQueryData.nDynamicEndRow : theQueryData.nRow2;
282 mbHasDates[nOffset+nList-1] = false;
284 // erstmal ohne die erste Zeile
285 diff --git sc/source/ui/inc/dbfunc.hxx sc/source/ui/inc/dbfunc.hxx
286 index 91834e1..097202b 100644
287 --- sc/source/ui/inc/dbfunc.hxx
288 +++ sc/source/ui/inc/dbfunc.hxx
289 @@ -80,7 +80,7 @@ public:
290 void GotoDBArea( const String& rDBName );
292 // DB-Bereich vom Cursor
293 - ScDBData* GetDBData( BOOL bMarkArea = TRUE, ScGetDBMode eMode = SC_DB_MAKE, bool bShrinkToData = false );
294 + ScDBData* GetDBData( BOOL bMarkArea = TRUE, ScGetDBMode eMode = SC_DB_MAKE, bool bShrinkToData = false, bool bExpandRows = false );
296 void NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList );
298 diff --git sc/source/ui/view/dbfunc.cxx sc/source/ui/view/dbfunc.cxx
299 index 05dce54..e78581a 100644
300 --- sc/source/ui/view/dbfunc.cxx
301 +++ sc/source/ui/view/dbfunc.cxx
302 @@ -107,7 +107,7 @@ void ScDBFunc::GotoDBArea( const String& rDBName )
304 // aktuellen Datenbereich fuer Sortieren / Filtern suchen
306 -ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, bool bShrinkToData )
307 +ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, bool bShrinkToData, bool bExpandRows )
309 ScDocShell* pDocSh = GetViewData()->GetDocShell();
310 ScDBData* pData = NULL;
311 @@ -136,11 +136,20 @@ ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, bool bShrinkToData
312 ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
313 GetViewData()->GetTabNo() ),
314 eMode, FALSE );
315 + if (!pData)
316 + return NULL;
318 - if ( pData && bMark )
319 + if (bExpandRows)
321 + // Dynamically expand rows to include any new data rows that are
322 + // immediately below the original range.
323 + GetViewData()->GetDocument()->UpdateDynamicEndRow(*pData);
326 + if (bMark)
328 ScRange aFound;
329 - pData->GetArea(aFound);
330 + pData->GetArea(aFound, bExpandRows);
331 MarkRange( aFound, FALSE );
333 return pData;
334 diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
335 index 6e0280a..57f1996 100644
336 --- sc/source/ui/view/gridwin.cxx
337 +++ sc/source/ui/view/gridwin.cxx
338 @@ -1276,6 +1276,7 @@ void ScGridWindow::ExecFilter( ULONG nSel,
339 pViewData->GetViewShell()->UpdateInputHandler();
342 + aParam.bUseDynamicRange = true;
343 pViewData->GetView()->Query( aParam, NULL, TRUE );
344 pDBData->SetQueryParam( aParam ); // speichern
346 diff --git sc/source/ui/view/tabvwshc.cxx sc/source/ui/view/tabvwshc.cxx
347 index 968984d..499c2a0 100644
348 --- sc/source/ui/view/tabvwshc.cxx
349 +++ sc/source/ui/view/tabvwshc.cxx
350 @@ -178,8 +178,9 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
351 SCITEM_QUERYDATA,
352 SCITEM_QUERYDATA );
354 - ScDBData* pDBData = GetDBData();
355 + ScDBData* pDBData = GetDBData(true, SC_DB_MAKE, true);
356 pDBData->GetQueryParam( aQueryParam );
357 + aQueryParam.bUseDynamicRange = true;
359 ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
360 ScRange aAdvSource;
361 @@ -203,8 +204,9 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
362 SCITEM_QUERYDATA,
363 SCITEM_QUERYDATA );
365 - ScDBData* pDBData = GetDBData();
366 + ScDBData* pDBData = GetDBData(true, SC_DB_MAKE, true);
367 pDBData->GetQueryParam( aQueryParam );
368 + aQueryParam.bUseDynamicRange = true;
370 aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
371 GetViewData(),