merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0134-sc-overwrite-char-font-attrs.diff
blobc2d0a01c86e0cc8aa3c076cc7af2ca32908bf085
1 --- sc/inc/attarray.hxx.old 2009-04-02 10:45:43.000000000 +0000
2 +++ sc/inc/attarray.hxx 2009-04-06 16:41:49.000000000 +0000
3 @@ -35,6 +35,7 @@
4 #include "attrib.hxx"
6 class ScDocument;
7 +class ScEditDataArray;
8 class ScMarkArray;
9 class ScPatternAttr;
10 class ScStyleSheet;
11 @@ -104,6 +105,9 @@ friend void lcl_IterGetNumberFormat( ULO
12 SCROW nStartRow, SCROW nEndRow,
13 BOOL bLeft, SCCOL nDistRight, BOOL bTop, SCROW nDistBottom );
15 + void RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
16 + const ScPatternAttr* pPattern, ScEditDataArray* pDataArray );
18 public:
19 ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc );
20 ~ScAttrArray();
21 @@ -125,9 +129,11 @@ public:
22 SCROW nStartRow, SCROW nEndRow, BOOL bLeft, SCCOL nDistRight );
24 void SetPattern( SCROW nRow, const ScPatternAttr* pPattern, BOOL bPutToPool = FALSE );
25 - void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern, BOOL bPutToPool = FALSE);
26 + void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern,
27 + BOOL bPutToPool = FALSE, ScEditDataArray* pDataArray = NULL );
28 void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle );
29 - void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache );
30 + void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache,
31 + ScEditDataArray* pDataArray = NULL );
32 void ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
33 const SvxBorderLine* pLine, BOOL bColorOnly );
35 --- sc/inc/cell.hxx.old 2009-04-02 10:45:43.000000000 +0000
36 +++ sc/inc/cell.hxx 2009-04-06 16:41:49.000000000 +0000
37 @@ -34,6 +34,9 @@
38 #include <stddef.h>
40 #include <set>
41 +#include <vector>
42 +#include <boost/shared_ptr.hpp>
44 #include <tools/mempool.hxx>
45 #include <svtools/listener.hxx>
46 #include "global.hxx"
47 @@ -58,6 +61,7 @@ class SvtBroadcaster;
48 class ScCodeArray;
49 class ScProgress;
50 class ScPostIt;
51 +class ScPatternAttr;
53 class ScMultipleReadHeader;
54 class ScMultipleWriteHeader;
55 @@ -285,6 +289,53 @@ public:
56 void GetString( String& rString ) const;
58 const EditTextObject* GetData() const { return pData; }
60 + /** Removes character attribute based on new pattern attributes. */
61 + void RemoveCharAttribs( const ScPatternAttr& rAttr );
62 +};
64 +// ============================================================================
66 +class ScEditDataArray
68 +public:
69 + class Item
70 + {
71 + public:
72 + explicit Item(SCTAB nTab, SCCOL nCol, SCROW nRow,
73 + EditTextObject* pOldData, EditTextObject* pNewData);
74 + ~Item();
76 + const EditTextObject* GetOldData() const;
77 + const EditTextObject* GetNewData() const;
78 + SCTAB GetTab() const;
79 + SCCOL GetCol() const;
80 + SCROW GetRow() const;
82 + private:
83 + Item(); // disabled
85 + private:
86 + ::boost::shared_ptr<EditTextObject> mpOldData;
87 + ::boost::shared_ptr<EditTextObject> mpNewData;
88 + SCTAB mnTab;
89 + SCCOL mnCol;
90 + SCROW mnRow;
92 + };
94 + ScEditDataArray();
95 + ~ScEditDataArray();
97 + void AddItem(SCTAB nTab, SCCOL nCol, SCROW nRow,
98 + EditTextObject* pOldData, EditTextObject* pNewData);
100 + const Item* First();
101 + const Item* Next();
103 +private:
104 + ::std::vector<Item>::const_iterator maIter;
105 + ::std::vector<Item> maArray;
108 // ============================================================================
109 --- sc/inc/column.hxx.old 2009-04-02 10:45:43.000000000 +0000
110 +++ sc/inc/column.hxx 2009-04-06 16:41:49.000000000 +0000
111 @@ -56,6 +56,7 @@ class ScAttrIterator;
112 class ScAttrArray;
113 class ScBaseCell;
114 class ScDocument;
115 +class ScEditDataArray;
116 class ScFormulaCell;
117 class ScMarkData;
118 class ScMultipleReadHeader;
119 @@ -317,7 +318,8 @@ public:
121 void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
122 void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
123 - void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr );
124 + void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
125 + ScEditDataArray* pDataArray = NULL );
126 void SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, BOOL bPutToPool = FALSE );
127 void SetPatternArea( SCROW nStartRow, SCROW nEndRow,
128 const ScPatternAttr& rPatAttr, BOOL bPutToPool = FALSE );
129 @@ -349,7 +351,7 @@ public:
131 void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
133 - SCsROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark );
134 + SCsROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = NULL );
135 void DeleteSelection( USHORT nDelFlag, const ScMarkData& rMark );
137 void ClearSelectionItems( const USHORT* pWhich, const ScMarkData& rMark );
138 --- sc/inc/document.hxx.old 2009-04-06 16:41:49.000000000 +0000
139 +++ sc/inc/document.hxx 2009-04-06 16:41:49.000000000 +0000
140 @@ -369,6 +369,7 @@ private:
141 // kein Broadcast, keine Listener aufbauen waehrend aus einem anderen
142 // Doc (per Filter o.ae.) inserted wird, erst bei CompileAll / CalcAfterLoad
143 BOOL bInsertingFromOtherDoc;
144 + bool bLoadingMedium;
145 BOOL bImportingXML; // special handling of formula text
146 BOOL bXMLFromWrapper; // distinguish ScXMLImportWrapper from external component
147 BOOL bCalcingAfterLoad; // in CalcAfterLoad TRUE
148 @@ -1118,7 +1119,8 @@ public:
149 const ScPatternAttr& rAttr );
150 SC_DLLPUBLIC void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
151 SCCOL nEndCol, SCROW nEndRow,
152 - const ScMarkData& rMark, const ScPatternAttr& rAttr );
153 + const ScMarkData& rMark, const ScPatternAttr& rAttr,
154 + ScEditDataArray* pDataArray = NULL );
155 SC_DLLPUBLIC void ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow,
156 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
157 const ScPatternAttr& rAttr );
158 @@ -1180,7 +1182,8 @@ public:
159 SCCOL nVCol, SCROW nVRow, SCTAB nVTab,
160 const String& sValStr, double& nX);
162 - void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark );
163 + void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark,
164 + ScEditDataArray* pDataArray = NULL );
165 void DeleteSelection( USHORT nDelFlag, const ScMarkData& rMark );
166 void DeleteSelectionTab( SCTAB nTab, USHORT nDelFlag, const ScMarkData& rMark );
168 @@ -1429,6 +1432,8 @@ public:
169 BOOL GetNoSetDirty() const { return bNoSetDirty; }
170 void SetInsertingFromOtherDoc( BOOL bVal ) { bInsertingFromOtherDoc = bVal; }
171 BOOL IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
172 + void SetLoadingMedium( bool bVal );
173 + bool IsLoadingMedium() const;
174 void SetImportingXML( BOOL bVal );
175 BOOL IsImportingXML() const { return bImportingXML; }
176 void SetXMLFromWrapper( BOOL bVal );
177 --- sc/inc/table.hxx.old 2009-04-06 16:41:49.000000000 +0000
178 +++ sc/inc/table.hxx 2009-04-06 16:41:49.000000000 +0000
179 @@ -57,6 +57,7 @@ class ScAutoFormatData;
180 class ScBaseCell;
181 class ScDocument;
182 class ScDrawLayer;
183 +class ScEditDataArray;
184 class ScFormulaCell;
185 class ScOutlineTable;
186 class ScPostIt;
187 @@ -456,7 +457,8 @@ public:
189 void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
190 void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
191 - void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScPatternAttr& rAttr );
192 + void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
193 + const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = NULL );
194 void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr, BOOL bPutToPool = FALSE )
195 { aCol[rPos.Col()].SetPattern( rPos.Row(), rAttr, bPutToPool ); }
196 void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr, BOOL bPutToPool = FALSE );
197 @@ -484,7 +486,7 @@ public:
198 BOOL ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, INT16 nFlags );
199 BOOL RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, INT16 nFlags );
201 - void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark );
202 + void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = NULL );
203 void DeleteSelection( USHORT nDelFlag, const ScMarkData& rMark );
205 void ClearSelectionItems( const USHORT* pWhich, const ScMarkData& rMark );
206 --- sc/source/core/data/attarray.cxx.old 2009-04-02 10:45:01.000000000 +0000
207 +++ sc/source/core/data/attarray.cxx 2009-04-06 16:41:49.000000000 +0000
208 @@ -41,6 +41,7 @@
209 #include <svx/bolnitem.hxx>
210 #include <svx/frmdiritem.hxx>
211 #include <svx/shaditem.hxx>
212 +#include <svx/editobj.hxx>
213 #include <svtools/poolcach.hxx>
214 #include <svx/fontitem.hxx>
215 #include <vcl/fontcvt.hxx>
216 @@ -55,7 +56,7 @@
217 #include "markarr.hxx"
218 #include "rechead.hxx"
219 #include "globstr.hrc"
221 +#include "cell.hxx"
223 #undef DBG_INVALIDATE
224 #define DBGOUTPUT(s) \
225 @@ -299,8 +300,31 @@ void ScAttrArray::SetPattern( SCROW nRow
226 SetPatternArea( nRow, nRow, pPattern, bPutToPool );
229 +void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
230 + const ScPatternAttr* pPattern, ScEditDataArray* pDataArray )
232 + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
234 + ScBaseCell* pCell;
235 + pDocument->GetCell(nCol, nRow, nTab, pCell);
236 + if (pCell && pCell->GetCellType() == CELLTYPE_EDIT)
238 + EditTextObject* pOldData = NULL;
239 + ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
240 + if (pDataArray)
241 + pOldData = pEditCell->GetData()->Clone();
242 + pEditCell->RemoveCharAttribs(*pPattern);
243 + if (pDataArray)
245 + EditTextObject* pNewData = pEditCell->GetData()->Clone();
246 + pDataArray->AddItem(nTab, nCol, nRow, pOldData, pNewData);
252 -void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPatternAttr *pPattern, BOOL bPutToPool )
253 +void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPatternAttr *pPattern,
254 + BOOL bPutToPool, ScEditDataArray* pDataArray )
256 if (ValidRow(nStartRow) && ValidRow(nEndRow))
258 @@ -470,6 +494,13 @@ void ScAttrArray::SetPatternArea(SCROW n
259 pData[nInsert-1].nRow = nStartRow - 1;
260 pData[nInsert].nRow = nEndRow;
261 pData[nInsert].pPattern = pPattern;
263 + // Remove character attributes from these cells if the pattern
264 + // is applied during normal session. We don't want to do this
265 + // while importing document.
266 + if (!pDocument->IsLoadingMedium())
267 + RemoveCellCharAttribs(nStartRow, nEndRow, pPattern ,pDataArray);
269 nCount++;
272 @@ -705,7 +736,7 @@ void ScAttrArray::ApplyLineStyleArea( SC
273 #undef SET_LINE
276 -void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache )
277 +void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray )
279 #ifdef DBG_UTIL
280 TestData();
281 @@ -740,7 +771,7 @@ void ScAttrArray::ApplyCacheArea( SCROW
283 if (nY1 < nStartRow) nY1=nStartRow;
284 if (nY2 > nEndRow) nY2=nEndRow;
285 - SetPatternArea( nY1, nY2, pNewPattern );
286 + SetPatternArea( nY1, nY2, pNewPattern, false, pDataArray );
287 Search( nStart, nPos );
289 else
290 --- sc/source/core/data/cell2.cxx.old 2009-04-02 10:45:01.000000000 +0000
291 +++ sc/source/core/data/cell2.cxx 2009-04-06 16:41:49.000000000 +0000
292 @@ -50,6 +50,8 @@
293 #include "chgtrack.hxx"
294 #include "indexmap.hxx"
295 #include "externalrefmgr.hxx"
296 +#include "scitems.hxx"
297 +#include "patattr.hxx"
299 using namespace formula;
301 @@ -138,6 +140,28 @@ void ScEditCell::GetString( String& rStr
302 rString.Erase();
305 +void ScEditCell::RemoveCharAttribs( const ScPatternAttr& rAttr )
307 + const struct {
308 + USHORT nAttrType;
309 + USHORT nCharType;
310 + } AttrTypeMap[] = {
311 + { ATTR_FONT, EE_CHAR_FONTINFO },
312 + { ATTR_FONT_HEIGHT, EE_CHAR_FONTHEIGHT },
313 + { ATTR_FONT_WEIGHT, EE_CHAR_WEIGHT },
314 + { ATTR_FONT_COLOR, EE_CHAR_COLOR }
315 + };
316 + USHORT nMapCount = sizeof(AttrTypeMap) / sizeof(AttrTypeMap[0]);
318 + const SfxItemSet& rSet = rAttr.GetItemSet();
319 + const SfxPoolItem* pItem;
320 + for (USHORT i = 0; i < nMapCount; ++i)
322 + if ( rSet.GetItemState(AttrTypeMap[i].nAttrType, false, &pItem) == SFX_ITEM_SET )
323 + pData->RemoveCharAttribs(AttrTypeMap[i].nCharType);
327 void ScEditCell::SetTextObject( const EditTextObject* pObject,
328 const SfxItemPool* pFromPool )
330 @@ -173,6 +197,76 @@ void ScEditCell::SetTextObject( const Ed
331 pData = NULL;
334 +ScEditDataArray::ScEditDataArray()
338 +ScEditDataArray::~ScEditDataArray()
342 +void ScEditDataArray::AddItem(SCTAB nTab, SCCOL nCol, SCROW nRow,
343 + EditTextObject* pOldData, EditTextObject* pNewData)
345 + maArray.push_back(Item(nTab, nCol, nRow, pOldData, pNewData));
348 +const ScEditDataArray::Item* ScEditDataArray::First()
350 + maIter = maArray.begin();
351 + if (maIter == maArray.end())
352 + return NULL;
353 + return &(*maIter++);
356 +const ScEditDataArray::Item* ScEditDataArray::Next()
358 + if (maIter == maArray.end())
359 + return NULL;
360 + return &(*maIter++);
363 +// ============================================================================
365 +ScEditDataArray::Item::Item(SCTAB nTab, SCCOL nCol, SCROW nRow,
366 + EditTextObject* pOldData, EditTextObject* pNewData) :
367 + mnTab(nTab),
368 + mnCol(nCol),
369 + mnRow(nRow)
371 + mpOldData.reset(pOldData);
372 + mpNewData.reset(pNewData);
375 +ScEditDataArray::Item::~Item()
379 +const EditTextObject* ScEditDataArray::Item::GetOldData() const
381 + return mpOldData.get();
384 +const EditTextObject* ScEditDataArray::Item::GetNewData() const
386 + return mpNewData.get();
389 +SCTAB ScEditDataArray::Item::GetTab() const
391 + return mnTab;
394 +SCCOL ScEditDataArray::Item::GetCol() const
396 + return mnCol;
399 +SCROW ScEditDataArray::Item::GetRow() const
401 + return mnRow;
404 // ============================================================================
406 BOOL ScFormulaCell::IsEmpty()
407 --- sc/source/core/data/column.cxx.old 2009-04-02 10:45:01.000000000 +0000
408 +++ sc/source/core/data/column.cxx 2009-04-06 16:41:49.000000000 +0000
409 @@ -364,7 +364,7 @@ ULONG ScColumn::GetNumberFormat( SCROW n
413 -SCsROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark )
414 +SCsROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray )
416 SCROW nTop = 0;
417 SCROW nBottom = 0;
418 @@ -375,7 +375,7 @@ SCsROW ScColumn::ApplySelectionCache( Sf
419 ScMarkArrayIter aMarkIter( rMark.GetArray() + nCol );
420 while (aMarkIter.Next( nTop, nBottom ))
422 - pAttrArray->ApplyCacheArea( nTop, nBottom, pCache );
423 + pAttrArray->ApplyCacheArea( nTop, nBottom, pCache, pDataArray );
424 bFound = TRUE;
427 @@ -449,11 +449,12 @@ void ScColumn::ApplyPattern( SCROW nRow,
431 -void ScColumn::ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr )
432 +void ScColumn::ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
433 + ScEditDataArray* pDataArray )
435 const SfxItemSet* pSet = &rPatAttr.GetItemSet();
436 SfxItemPoolCache aCache( pDocument->GetPool(), pSet );
437 - pAttrArray->ApplyCacheArea( nStartRow, nEndRow, &aCache );
438 + pAttrArray->ApplyCacheArea( nStartRow, nEndRow, &aCache, pDataArray );
442 --- sc/source/core/data/documen2.cxx.old 2009-04-06 16:41:49.000000000 +0000
443 +++ sc/source/core/data/documen2.cxx 2009-04-06 16:41:49.000000000 +0000
444 @@ -188,6 +188,7 @@ ScDocument::ScDocument( ScDocumentMode e
445 // bNoSetDirty( TRUE ),
446 bNoSetDirty( FALSE ),
447 bInsertingFromOtherDoc( FALSE ),
448 + bLoadingMedium(false),
449 bImportingXML( FALSE ),
450 bXMLFromWrapper( FALSE ),
451 bCalcingAfterLoad( FALSE ),
452 --- sc/source/core/data/documen9.cxx.old 2009-04-02 10:45:01.000000000 +0000
453 +++ sc/source/core/data/documen9.cxx 2009-04-06 16:41:49.000000000 +0000
454 @@ -799,6 +799,16 @@ void ScDocument::UpdateFontCharSet()
458 +void ScDocument::SetLoadingMedium( bool bVal )
460 + bLoadingMedium = bVal;
463 +bool ScDocument::IsLoadingMedium() const
465 + return bLoadingMedium;
468 void ScDocument::SetImportingXML( BOOL bVal )
470 bImportingXML = bVal;
471 --- sc/source/core/data/document.cxx.old 2009-04-06 16:41:49.000000000 +0000
472 +++ sc/source/core/data/document.cxx 2009-04-06 16:41:49.000000000 +0000
473 @@ -3098,12 +3098,13 @@ void ScDocument::ApplyPattern( SCCOL nCo
474 void ScDocument::ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
475 SCCOL nEndCol, SCROW nEndRow,
476 const ScMarkData& rMark,
477 - const ScPatternAttr& rAttr )
478 + const ScPatternAttr& rAttr,
479 + ScEditDataArray* pDataArray )
481 for (SCTAB i=0; i <= MAXTAB; i++)
482 if (pTab[i])
483 if (rMark.GetTableSelect(i))
484 - pTab[i]->ApplyPatternArea( nStartCol, nStartRow, nEndCol, nEndRow, rAttr );
485 + pTab[i]->ApplyPatternArea( nStartCol, nStartRow, nEndCol, nEndRow, rAttr, pDataArray );
489 @@ -4033,7 +4034,7 @@ void ScDocument::ApplyFrameAreaTab( cons
493 -void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark )
494 +void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark, ScEditDataArray* pDataArray )
496 const SfxItemSet* pSet = &rAttr.GetItemSet();
497 BOOL bSet = FALSE;
498 @@ -4050,7 +4051,7 @@ void ScDocument::ApplySelectionPattern(
499 ScRange aRange;
500 rMark.GetMarkArea( aRange );
501 ApplyPatternArea( aRange.aStart.Col(), aRange.aStart.Row(),
502 - aRange.aEnd.Col(), aRange.aEnd.Row(), rMark, rAttr );
503 + aRange.aEnd.Col(), aRange.aEnd.Row(), rMark, rAttr, pDataArray );
505 else
507 @@ -4058,7 +4059,7 @@ void ScDocument::ApplySelectionPattern(
508 for (SCTAB nTab=0; nTab<=MAXTAB; nTab++)
509 if (pTab[nTab])
510 if (rMark.GetTableSelect(nTab))
511 - pTab[nTab]->ApplySelectionCache( &aCache, rMark );
512 + pTab[nTab]->ApplySelectionCache( &aCache, rMark, pDataArray );
516 --- sc/source/core/data/table2.cxx.old 2009-04-06 16:41:49.000000000 +0000
517 +++ sc/source/core/data/table2.cxx 2009-04-06 16:41:49.000000000 +0000
518 @@ -1661,14 +1661,14 @@ void ScTable::ApplyPattern( SCCOL nCol,
521 void ScTable::ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
522 - const ScPatternAttr& rAttr )
523 + const ScPatternAttr& rAttr, ScEditDataArray* pDataArray )
525 if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
527 PutInOrder(nStartCol, nEndCol);
528 PutInOrder(nStartRow, nEndRow);
529 for (SCCOL i = nStartCol; i <= nEndCol; i++)
530 - aCol[i].ApplyPatternArea(nStartRow, nEndRow, rAttr);
531 + aCol[i].ApplyPatternArea(nStartRow, nEndRow, rAttr, pDataArray);
535 @@ -1876,10 +1876,11 @@ void ScTable::ApplyAttr( SCCOL nCol, SCR
539 -void ScTable::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark )
540 +void ScTable::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark,
541 + ScEditDataArray* pDataArray )
543 for (SCCOL i=0; i<=MAXCOL; i++)
544 - aCol[i].ApplySelectionCache( pCache, rMark );
545 + aCol[i].ApplySelectionCache( pCache, rMark, pDataArray );
549 --- sc/source/ui/docshell/docsh.cxx.old 2009-04-06 16:41:49.000000000 +0000
550 +++ sc/source/ui/docshell/docsh.cxx 2009-04-06 16:41:49.000000000 +0000
551 @@ -427,10 +427,31 @@ BOOL ScDocShell::SaveXML( SfxMedium* pSa
552 return bRet;
555 +namespace {
557 +class DocLoadChecker
559 +public:
560 + explicit DocLoadChecker(ScDocument* pDoc) :
561 + mpDoc(pDoc)
563 + mpDoc->SetLoadingMedium(true);
566 + ~DocLoadChecker()
568 + mpDoc->SetLoadingMedium(false);
570 +private:
571 + ScDocument* mpDoc;
576 BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium )
578 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::Load" );
580 + DocLoadChecker aChecker(&aDocument);
581 ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
583 // only the latin script language is loaded
584 @@ -769,7 +790,7 @@ void __EXPORT ScDocShell::Notify( SfxBro
585 BOOL __EXPORT ScDocShell::LoadFrom( SfxMedium& rMedium )
587 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::LoadFrom" );
589 + DocLoadChecker aChecker(&aDocument);
590 ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
592 WaitObject aWait( GetActiveDialogParent() );
593 @@ -796,6 +817,7 @@ BOOL __EXPORT ScDocShell::LoadFrom( SfxM
594 BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
596 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ConvertFrom" );
597 + DocLoadChecker aChecker(&aDocument);
599 BOOL bRet = FALSE; // FALSE heisst Benutzerabbruch !!
600 // bei Fehler: Fehler am Stream setzen!!
601 --- sc/source/ui/inc/undoblk.hxx.old 2009-04-02 10:45:37.000000000 +0000
602 +++ sc/source/ui/inc/undoblk.hxx 2009-04-06 16:41:49.000000000 +0000
603 @@ -35,6 +35,10 @@
604 #include "viewutil.hxx"
605 #include "spellparam.hxx"
607 +#include "cell.hxx"
609 +#include <boost/shared_ptr.hpp>
611 class ScDocShell;
612 class ScDocument;
613 class ScOutlineTable;
614 @@ -353,9 +357,11 @@ public:
616 virtual String GetComment() const;
618 + ScEditDataArray* GetDataArray();
619 private:
620 ScMarkData aMarkData;
621 ScRange aRange;
622 + ScEditDataArray aDataArray;
623 ScDocument* pUndoDoc;
624 BOOL bMulti;
625 ScPatternAttr* pApplyPattern;
626 @@ -363,6 +369,7 @@ private:
627 SvxBoxInfoItem* pLineInner;
629 void DoChange( const BOOL bUndo );
630 + void ChangeEditData( const bool bUndo );
634 --- sc/source/ui/inc/undocell.hxx.old 2009-04-02 10:45:37.000000000 +0000
635 +++ sc/source/ui/inc/undocell.hxx 2009-04-06 16:41:49.000000000 +0000
636 @@ -34,6 +34,8 @@
637 #include "undobase.hxx"
638 #include "postit.hxx"
640 +#include <boost/shared_ptr.hpp>
642 class ScDocShell;
643 class ScBaseCell;
644 class ScPatternAttr;
645 @@ -62,6 +64,11 @@ public:
647 virtual String GetComment() const;
649 + /** once the objects are passed to this class, their life-cycle is
650 + managed by this class; the calling function must pass new'ed
651 + objects to this method. */
652 + void SetEditData( EditTextObject* pOld, EditTextObject* pNew );
654 private:
655 SCCOL nCol;
656 SCROW nRow;
657 @@ -69,9 +76,11 @@ private:
658 ScPatternAttr* pOldPattern;
659 ScPatternAttr* pNewPattern;
660 ScPatternAttr* pApplyPattern;
661 + ::boost::shared_ptr<EditTextObject> pOldEditData;
662 + ::boost::shared_ptr<EditTextObject> pNewEditData;
663 BOOL bIsAutomatic;
665 - void DoChange( const ScPatternAttr* pWhichPattern ) const;
666 + void DoChange( const ScPatternAttr* pWhichPattern, const ::boost::shared_ptr<EditTextObject>& pEditData ) const;
670 --- sc/source/ui/undo/makefile.mk.old 2009-04-02 10:45:28.000000000 +0000
671 +++ sc/source/ui/undo/makefile.mk 2009-04-06 16:41:49.000000000 +0000
672 @@ -78,6 +78,7 @@ SLOFILES = \
673 $(SLO)$/undotab.obj
675 EXCEPTIONSFILES= \
676 + $(SLO)$/undocell.obj \
677 $(SLO)$/undostyl.obj
679 # --- Tagets -------------------------------------------------------
680 --- sc/source/ui/undo/undoblk3.cxx.old 2009-04-02 10:45:28.000000000 +0000
681 +++ sc/source/ui/undo/undoblk3.cxx 2009-04-06 16:41:49.000000000 +0000
682 @@ -481,6 +481,12 @@ String __EXPORT ScUndoSelectionAttr::Get
683 return ScGlobal::GetRscString( pLineOuter ? STR_UNDO_SELATTRLINES : STR_UNDO_SELATTR );
686 +//----------------------------------------------------------------------------
688 +ScEditDataArray* ScUndoSelectionAttr::GetDataArray()
690 + return &aDataArray;
693 //----------------------------------------------------------------------------
695 @@ -499,6 +505,8 @@ void ScUndoSelectionAttr::DoChange( cons
696 USHORT nExtFlags = 0;
697 pDocShell->UpdatePaintExt( nExtFlags, aEffRange );
699 + ChangeEditData(bUndo);
701 if (bUndo) // nur bei Undo
703 ScRange aCopyRange = aRange;
704 @@ -523,6 +531,24 @@ void ScUndoSelectionAttr::DoChange( cons
705 ShowTable( aRange );
708 +void ScUndoSelectionAttr::ChangeEditData( const bool bUndo )
710 + ScDocument* pDoc = pDocShell->GetDocument();
711 + for (const ScEditDataArray::Item* pItem = aDataArray.First(); pItem; pItem = aDataArray.Next())
713 + ScBaseCell* pCell;
714 + pDoc->GetCell(pItem->GetCol(), pItem->GetRow(), pItem->GetTab(), pCell);
715 + if (!pCell || pCell->GetCellType() != CELLTYPE_EDIT)
716 + continue;
718 + ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
719 + if (bUndo)
720 + pEditCell->SetData(pItem->GetOldData(), NULL);
721 + else
722 + pEditCell->SetData(pItem->GetNewData(), NULL);
727 //----------------------------------------------------------------------------
729 --- sc/source/ui/undo/undocell.cxx.old 2009-04-02 10:45:28.000000000 +0000
730 +++ sc/source/ui/undo/undocell.cxx 2009-04-06 16:41:49.000000000 +0000
731 @@ -57,6 +57,8 @@
732 #include "sc.hrc"
733 #include "docuno.hxx"
735 +using ::boost::shared_ptr;
737 // STATIC DATA -----------------------------------------------------------
739 TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo);
740 @@ -85,6 +87,8 @@ ScUndoCursorAttr::ScUndoCursorAttr( ScDo
741 nCol( nNewCol ),
742 nRow( nNewRow ),
743 nTab( nNewTab ),
744 + pOldEditData( static_cast<EditTextObject*>(NULL) ),
745 + pNewEditData( static_cast<EditTextObject*>(NULL) ),
746 bIsAutomatic( bAutomatic )
748 ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
749 @@ -109,9 +113,21 @@ String __EXPORT ScUndoCursorAttr::GetCom
750 return ScGlobal::GetRscString( nId );
753 -void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern ) const
754 +void ScUndoCursorAttr::SetEditData( EditTextObject* pOld, EditTextObject* pNew )
756 - pDocShell->GetDocument()->SetPattern( nCol, nRow, nTab, *pWhichPattern, TRUE );
757 + pOldEditData.reset(pOld);
758 + pNewEditData.reset(pNew);
761 +void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const shared_ptr<EditTextObject>& pEditData ) const
763 + ScDocument* pDoc = pDocShell->GetDocument();
764 + pDoc->SetPattern( nCol, nRow, nTab, *pWhichPattern, TRUE );
766 + ScBaseCell* pCell;
767 + pDoc->GetCell(nCol, nRow, nTab, pCell);
768 + if (pCell && pCell->GetCellType() == CELLTYPE_EDIT && pEditData.get())
769 + static_cast<ScEditCell*>(pCell)->SetData(pEditData.get(), NULL);
771 ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
772 if (pViewShell)
773 @@ -137,7 +153,7 @@ void ScUndoCursorAttr::DoChange( const S
774 void __EXPORT ScUndoCursorAttr::Undo()
776 BeginUndo();
777 - DoChange(pOldPattern);
778 + DoChange(pOldPattern, pOldEditData);
780 if ( bIsAutomatic )
782 @@ -155,7 +171,7 @@ void __EXPORT ScUndoCursorAttr::Undo()
783 void __EXPORT ScUndoCursorAttr::Redo()
785 BeginRedo();
786 - DoChange(pNewPattern);
787 + DoChange(pNewPattern, pNewEditData);
788 EndRedo();
791 --- sc/source/ui/view/viewfunc.cxx.old 2009-04-06 16:41:49.000000000 +0000
792 +++ sc/source/ui/view/viewfunc.cxx 2009-04-06 16:41:49.000000000 +0000
793 @@ -1348,6 +1348,8 @@ void ScViewFunc::ApplySelectionPattern(
794 SCROW nEndRow = aMarkRange.aEnd.Row();
795 SCTAB nEndTab = aMarkRange.aEnd.Tab();
797 + ScUndoSelectionAttr* pUndoAttr = NULL;
798 + ScEditDataArray* pEditDataArray = NULL;
799 if (bRecord)
801 ScRange aCopyRange = aMarkRange;
802 @@ -1363,15 +1365,14 @@ void ScViewFunc::ApplySelectionPattern(
804 aFuncMark.MarkToMulti();
806 - pDocSh->GetUndoManager()->AddUndoAction(
807 - new ScUndoSelectionAttr(
808 - pDocSh, aFuncMark,
809 - nStartCol, nStartRow, nStartTab,
810 - nEndCol, nEndRow, nEndTab,
811 - pUndoDoc, bMulti, &rAttr ) );
812 + pUndoAttr = new ScUndoSelectionAttr(
813 + pDocSh, aFuncMark, nStartCol, nStartRow, nStartTab,
814 + nEndCol, nEndRow, nEndTab, pUndoDoc, bMulti, &rAttr );
815 + pDocSh->GetUndoManager()->AddUndoAction(pUndoAttr);
816 + pEditDataArray = pUndoAttr->GetDataArray();
819 - pDoc->ApplySelectionPattern( rAttr, aFuncMark );
820 + pDoc->ApplySelectionPattern( rAttr, aFuncMark, pEditDataArray );
822 pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
823 nEndCol, nEndRow, nEndTab,
824 @@ -1385,6 +1386,19 @@ void ScViewFunc::ApplySelectionPattern(
825 SCCOL nCol = pViewData->GetCurX();
826 SCROW nRow = pViewData->GetCurY();
827 SCTAB nTab = pViewData->GetTabNo();
829 + ScBaseCell* pCell;
830 + pDoc->GetCell(nCol, nRow, nTab, pCell);
831 + EditTextObject* pOldEditData = NULL;
832 + EditTextObject* pNewEditData = NULL;
833 + if (pCell && pCell->GetCellType() == CELLTYPE_EDIT)
835 + ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
836 + pOldEditData = pEditCell->GetData()->Clone();
837 + pEditCell->RemoveCharAttribs(rAttr);
838 + pNewEditData = pEditCell->GetData()->Clone();
841 aChangeRanges.Append( ScRange( nCol, nRow, nTab ) );
842 ScPatternAttr* pOldPat = new ScPatternAttr(*pDoc->GetPattern( nCol, nRow, nTab ));
844 @@ -1394,11 +1408,10 @@ void ScViewFunc::ApplySelectionPattern(
846 if (bRecord)
848 - pDocSh->GetUndoManager()->AddUndoAction(
849 - new ScUndoCursorAttr( pDocSh,
850 - nCol, nRow, nTab,
851 - pOldPat, pNewPat, &rAttr,
852 - FALSE ) ); // FALSE = nicht automatisch
853 + ScUndoCursorAttr* pUndo = new ScUndoCursorAttr(
854 + pDocSh, nCol, nRow, nTab, pOldPat, pNewPat, &rAttr, false );
855 + pUndo->SetEditData(pOldEditData, pNewEditData);
856 + pDocSh->GetUndoManager()->AddUndoAction(pUndo);
858 delete pOldPat; // wird im Undo kopiert (Pool)