Update to m13
[ooovba.git] / applied_patches / 0512-calc-dp-hide-list-menu-bugfix.diff
blob30fece80076a78a8a216edb42fb910689cb8588c
1 diff --git sc/inc/attrib.hxx sc/inc/attrib.hxx
2 index 22e7d27..88e353b 100644
3 --- sc/inc/attrib.hxx
4 +++ sc/inc/attrib.hxx
5 @@ -106,6 +106,7 @@ public:
7 BOOL HasAutoFilter() const { return ( GetValue() & SC_MF_AUTO ) != 0; }
8 BOOL HasButton() const { return ( GetValue() & SC_MF_BUTTON ) != 0; }
9 + bool HasDPTable() const { return ( GetValue() & SC_MF_DP_TABLE ) != 0; }
11 BOOL IsScenario() const { return ( GetValue() & SC_MF_SCENARIO ) != 0; }
13 diff --git sc/inc/dpobject.hxx sc/inc/dpobject.hxx
14 index 503c531..b361472 100644
15 --- sc/inc/dpobject.hxx
16 +++ sc/inc/dpobject.hxx
17 @@ -319,6 +319,11 @@ public:
19 ScSimpleSharedString& GetSharedString();
21 + void FreeTable(ScDPObject* pDPObj);
22 + SC_DLLPUBLIC bool InsertNewTable(ScDPObject* pDPObj);
24 + bool HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
26 ScDPCacheCell* getCacheCellFromPool(const ScDPCacheCell& rCell);
27 void clearCacheCellPool();
29 diff --git sc/source/core/data/documen8.cxx sc/source/core/data/documen8.cxx
30 index bbcb513..e6f15fd 100644
31 --- sc/source/core/data/documen8.cxx
32 +++ sc/source/core/data/documen8.cxx
33 @@ -95,6 +95,7 @@
34 #include "sc.hrc"
35 #include "charthelper.hxx"
36 #include "macromgr.hxx"
37 +#include "dpobject.hxx"
39 #define GET_SCALEVALUE(set,id) ((const SfxUInt16Item&)(set.Get( id ))).GetValue()
41 @@ -712,8 +713,13 @@ BOOL ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
42 // skip everything left of rSpellPos:
43 while ( pCell && nRow == rSpellPos.Row() && nCol < rSpellPos.Col() )
44 pCell = aIter.GetNext( nCol, nRow );
45 - while ( pCell )
47 + for (; pCell; pCell = aIter.GetNext(nCol, nRow))
49 + if (pDPCollection && pDPCollection->HasDPTable(nCol, nRow, nTab))
50 + // Don't spell check within datapilot table.
51 + continue;
53 CellType eType = pCell->GetCellType();
54 if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
56 @@ -798,8 +804,6 @@ BOOL ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
58 if ( ++nCellCount >= SPELL_MAXCELLS ) // seen enough cells?
59 break;
61 - pCell = aIter.GetNext( nCol, nRow );
64 if ( pCell )
65 diff --git sc/source/core/data/dpobject.cxx sc/source/core/data/dpobject.cxx
66 index eddb200..a403571 100644
67 --- sc/source/core/data/dpobject.cxx
68 +++ sc/source/core/data/dpobject.cxx
69 @@ -542,6 +542,9 @@ void ScDPObject::Output()
71 // aOutRange is always the range that was last output to the document
72 aOutRange = pOutput->GetOutputRange();
73 + const ScAddress& s = aOutRange.aStart;
74 + const ScAddress& e = aOutRange.aEnd;
75 + pDoc->ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), SC_MF_DP_TABLE);
78 const ScRange ScDPObject::GetOutputRangeByType( sal_Int32 nType )
79 @@ -2489,7 +2492,7 @@ void ScDPCollection::WriteRefsTo( ScDPCollection& r ) const
81 ScDPObject* pDestObj = new ScDPObject( *pSourceObj );
82 pDestObj->SetAlive(TRUE);
83 - if ( !r.Insert(pDestObj) )
84 + if ( !r.InsertNewTable(pDestObj) )
86 DBG_ERROR("cannot insert DPObject");
87 DELETEZ( pDestObj );
88 @@ -2524,6 +2527,39 @@ ScSimpleSharedString& ScDPCollection::GetSharedString()
89 return maSharedString;
92 +void ScDPCollection::FreeTable(ScDPObject* pDPObj)
94 + const ScRange& rOutRange = pDPObj->GetOutRange();
95 + const ScAddress& s = rOutRange.aStart;
96 + const ScAddress& e = rOutRange.aEnd;
97 + pDoc->RemoveFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), SC_MF_DP_TABLE);
98 + Free(pDPObj);
101 +bool ScDPCollection::InsertNewTable(ScDPObject* pDPObj)
103 + bool bSuccess = Insert(pDPObj);
104 + if (bSuccess)
106 + const ScRange& rOutRange = pDPObj->GetOutRange();
107 + const ScAddress& s = rOutRange.aStart;
108 + const ScAddress& e = rOutRange.aEnd;
109 + pDoc->ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), SC_MF_DP_TABLE);
111 + return bSuccess;
114 +bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
116 + const ScMergeFlagAttr* pMergeAttr = static_cast<const ScMergeFlagAttr*>(
117 + pDoc->GetAttr(nCol, nRow, nTab, ATTR_MERGE_FLAG));
119 + if (!pMergeAttr)
120 + return false;
122 + return pMergeAttr->HasDPTable();
125 ScDPCacheCell* ScDPCollection::getCacheCellFromPool(const ScDPCacheCell& rCell)
127 ScDPCacheCell aCell(rCell);
128 diff --git sc/source/core/data/dpoutput.cxx sc/source/core/data/dpoutput.cxx
129 index 431cf47..edb3c48 100644
130 --- sc/source/core/data/dpoutput.cxx
131 +++ sc/source/core/data/dpoutput.cxx
132 @@ -690,7 +690,7 @@ void ScDPOutput::FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rC
133 nMergeFlag |= SC_MF_BUTTON_POPUP;
134 if (bHasHiddenMember)
135 nMergeFlag |= SC_MF_HIDDEN_MEMBER;
136 - pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr(nMergeFlag) );
137 + pDoc->ApplyFlagsTab(nCol, nRow, nCol, nRow, nTab, nMergeFlag);
139 lcl_SetStyleById( pDoc,nTab, nCol,nRow, nCol,nRow, STR_PIVOT_STYLE_FIELDNAME );
141 @@ -698,7 +698,7 @@ void ScDPOutput::FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rC
142 void lcl_DoFilterButton( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab )
144 pDoc->SetString( nCol, nRow, nTab, ScGlobal::GetRscString(STR_CELL_FILTER) );
145 - pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr(SC_MF_BUTTON) );
146 + pDoc->ApplyFlagsTab(nCol, nRow, nCol, nRow, nTab, SC_MF_BUTTON);
149 void ScDPOutput::CalcSizes()
150 diff --git sc/source/core/data/dpoutputgeometry.cxx sc/source/core/data/dpoutputgeometry.cxx
151 index 4d6996b..8eb552a 100644
152 --- sc/source/core/data/dpoutputgeometry.cxx
153 +++ sc/source/core/data/dpoutputgeometry.cxx
154 @@ -128,7 +128,10 @@ void ScDPOutputGeometry::getRowFieldPositions(vector<ScAddress>& rAddrs) const
155 else if (mbShowFilter)
156 nCurRow += 2;
158 - nCurRow += static_cast<SCROW>(mnColumnFields);
159 + if (mnColumnFields)
160 + nCurRow += static_cast<SCROW>(mnColumnFields);
161 + else
162 + ++nCurRow;
164 SCROW nRow = nCurRow;
165 SCTAB nTab = maOutRange.aStart.Tab();
166 @@ -164,6 +167,7 @@ ScDPOutputGeometry::FieldType ScDPOutputGeometry::getFieldButtonType(const ScAdd
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();
174 @@ -192,6 +196,9 @@ ScDPOutputGeometry::FieldType ScDPOutputGeometry::getFieldButtonType(const ScAdd
175 nCurRow += static_cast<SCROW>(mnColumnFields);
178 + if (bExtraTitleRow)
179 + ++nCurRow;
181 if (mnRowFields)
183 SCCOL nColStart = maOutRange.aStart.Col();
184 diff --git sc/source/core/data/pivot2.cxx sc/source/core/data/pivot2.cxx
185 index 924a5cd..ab8a699 100644
186 --- sc/source/core/data/pivot2.cxx
187 +++ sc/source/core/data/pivot2.cxx
188 @@ -158,12 +158,7 @@ void ScPivot::SetJustifyRight(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2
190 void ScPivot::SetButton(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
192 - if (pDoc->pTab[nDestTab])
194 - ScPatternAttr aPattern( pDoc->GetPool() );
195 - aPattern.GetItemSet().Put( ScMergeFlagAttr(SC_MF_BUTTON) );
196 - pDoc->pTab[nDestTab]->ApplyPatternArea(nCol1, nRow1, nCol2, nRow2, aPattern);
198 + pDoc->ApplyFlagsTab(nCol1, nRow1, nCol2, nRow2, nDestTab, SC_MF_BUTTON);
201 void ScPivot::SetStyle(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nId)
202 diff --git sc/source/filter/excel/xipivot.cxx sc/source/filter/excel/xipivot.cxx
203 index f225c67..fd85060 100644
204 --- sc/source/filter/excel/xipivot.cxx
205 +++ sc/source/filter/excel/xipivot.cxx
206 @@ -1396,7 +1396,7 @@ void XclImpPivotTable::Convert()
207 pDPObj->SetAlive( TRUE );
208 pDPObj->SetHeaderLayout( maPTViewEx9Info.mnGridLayout == 0 );
210 - GetDoc().GetDPCollection()->Insert( pDPObj );
211 + GetDoc().GetDPCollection()->InsertNewTable(pDPObj);
212 mpDPObj = pDPObj;
214 ApplyMergeFlags(aOutRange, aSaveData);
215 @@ -1439,10 +1439,8 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
216 if (rSaveData.HasInvisibleMember(aName))
217 nMFlag |= SC_MF_HIDDEN_MEMBER;
219 - ScMergeFlagAttr aAttr(nMFlag);
220 - rDoc.ApplyAttr(itr->Col(), itr->Row(), itr->Tab(), aAttr);
221 - ScMergeFlagAttr aAttr2(SC_MF_AUTO);
222 - rDoc.ApplyAttr(itr->Col()+1, itr->Row(), itr->Tab(), aAttr2);
223 + rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
224 + rDoc.ApplyFlagsTab(itr->Col()+1, itr->Row(), itr->Col()+1, itr->Row(), itr->Tab(), SC_MF_AUTO);
227 vector<ScAddress> aColBtns;
228 @@ -1456,8 +1454,7 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
229 rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
230 if (rSaveData.HasInvisibleMember(aName))
231 nMFlag |= SC_MF_HIDDEN_MEMBER;
232 - ScMergeFlagAttr aAttr(nMFlag);
233 - rDoc.ApplyAttr(itr->Col(), itr->Row(), itr->Tab(), aAttr);
234 + rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
237 vector<ScAddress> aRowBtns;
238 @@ -1471,14 +1468,12 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
239 rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
240 if (rSaveData.HasInvisibleMember(aName))
241 nMFlag |= SC_MF_HIDDEN_MEMBER;
242 - ScMergeFlagAttr aAttr(nMFlag);
243 - rDoc.ApplyAttr(itr->Col(), itr->Row(), itr->Tab(), aAttr);
244 + rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
246 if (bDataLayout)
248 --itr; // move back to the last row field position.
249 - ScMergeFlagAttr aAttr(SC_MF_BUTTON);
250 - rDoc.ApplyAttr(itr->Col()+1, itr->Row(), itr->Tab(), aAttr);
251 + rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), SC_MF_BUTTON);
255 diff --git sc/source/filter/xml/xmldpimp.cxx sc/source/filter/xml/xmldpimp.cxx
256 index 3214942..de4c7ca 100644
257 --- sc/source/filter/xml/xmldpimp.cxx
258 +++ sc/source/filter/xml/xmldpimp.cxx
259 @@ -299,8 +299,7 @@ void ScXMLDataPilotTableContext::SetButtons()
260 if (maHiddenMemberFields.count(aCellStr))
261 nMFlag |= SC_MF_HIDDEN_MEMBER;
263 - ScMergeFlagAttr aAttr(nMFlag);
264 - pDoc->ApplyAttr( aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), aAttr );
265 + pDoc->ApplyFlagsTab(aScAddress.Col(), aScAddress.Row(), aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), nMFlag);
269 @@ -449,7 +448,7 @@ void ScXMLDataPilotTableContext::EndElement()
271 ScDPCollection* pDPCollection = pDoc->GetDPCollection();
272 pDPObject->SetAlive(sal_True);
273 - pDPCollection->Insert(pDPObject);
274 + pDPCollection->InsertNewTable(pDPObject);
276 SetButtons();
278 diff --git sc/source/ui/docshell/dbdocfun.cxx sc/source/ui/docshell/dbdocfun.cxx
279 index 96c2ccd..c5b3670 100644
280 --- sc/source/ui/docshell/dbdocfun.cxx
281 +++ sc/source/ui/docshell/dbdocfun.cxx
282 @@ -1233,7 +1233,7 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
283 aRange.aEnd.Col(), aRange.aEnd.Row(),
284 nTab, SC_MF_AUTO );
286 - pDoc->GetDPCollection()->Free( pOldObj ); // object is deleted here
287 + pDoc->GetDPCollection()->FreeTable( pOldObj ); // object is deleted here
289 rDocShell.PostPaintGridAll(); //! only necessary parts
290 rDocShell.PostPaint( aRange.aStart.Col(), aRange.aStart.Row(), nTab,
291 @@ -1277,7 +1277,7 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
293 pDestObj = new ScDPObject( *pNewObj );
294 pDestObj->SetAlive(TRUE);
295 - if ( !pDoc->GetDPCollection()->Insert(pDestObj) )
296 + if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) )
298 DBG_ERROR("cannot insert DPObject");
299 DELETEZ( pDestObj );
300 diff --git sc/source/ui/undo/undodat.cxx sc/source/ui/undo/undodat.cxx
301 index 15d6c76..89c0fbe 100644
302 --- sc/source/ui/undo/undodat.cxx
303 +++ sc/source/ui/undo/undodat.cxx
304 @@ -1879,7 +1879,7 @@ void __EXPORT ScUndoDataPilot::Undo()
305 else
307 // delete inserted object
308 - pDoc->GetDPCollection()->Free(pDocObj);
309 + pDoc->GetDPCollection()->FreeTable(pDocObj);
313 @@ -1889,7 +1889,7 @@ void __EXPORT ScUndoDataPilot::Undo()
315 ScDPObject* pDestObj = new ScDPObject( *pOldDPObject );
316 pDestObj->SetAlive(TRUE);
317 - if ( !pDoc->GetDPCollection()->Insert(pDestObj) )
318 + if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) )
320 DBG_ERROR("cannot insert DPObject");
321 DELETEZ( pDestObj );