Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "XMLExportIterator.hxx"
21 : #include <com/sun/star/text/XSimpleText.hpp>
22 : #include <com/sun/star/sheet/XCellAddressable.hpp>
23 : #include <com/sun/star/sheet/CellFlags.hpp>
24 : #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
25 : #include <com/sun/star/container/XEnumerationAccess.hpp>
26 : #include <xmloff/xmlnmspe.hxx>
27 : #include "dociter.hxx"
28 : #include "convuno.hxx"
29 : #include "xmlexprt.hxx"
30 : #include "XMLExportSharedData.hxx"
31 : #include "XMLStylesExportHelper.hxx"
32 : #include "document.hxx"
33 :
34 : #include <algorithm>
35 :
36 : using namespace ::com::sun::star;
37 :
38 250 : ScMyIteratorBase::ScMyIteratorBase()
39 : {
40 250 : }
41 :
42 250 : ScMyIteratorBase::~ScMyIteratorBase()
43 : {
44 250 : }
45 :
46 3824 : void ScMyIteratorBase::UpdateAddress( table::CellAddress& rCellAddress )
47 : {
48 3824 : table::CellAddress aNewAddr( rCellAddress );
49 3824 : if( GetFirstAddress( aNewAddr ) )
50 : {
51 16 : if( (aNewAddr.Sheet == rCellAddress.Sheet) &&
52 8 : ((aNewAddr.Row < rCellAddress.Row) ||
53 0 : ((aNewAddr.Row == rCellAddress.Row) && (aNewAddr.Column < rCellAddress.Column))) )
54 8 : rCellAddress = aNewAddr;
55 : }
56 3824 : }
57 :
58 0 : bool ScMyShape::operator<(const ScMyShape& aShape) const
59 : {
60 0 : if( aAddress.Tab() != aShape.aAddress.Tab() )
61 0 : return (aAddress.Tab() < aShape.aAddress.Tab());
62 0 : else if( aAddress.Row() != aShape.aAddress.Row() )
63 0 : return (aAddress.Row() < aShape.aAddress.Row());
64 : else
65 0 : return (aAddress.Col() < aShape.aAddress.Col());
66 : }
67 :
68 4 : ScMyShapesContainer::ScMyShapesContainer()
69 4 : : aShapeList()
70 : {
71 4 : }
72 :
73 8 : ScMyShapesContainer::~ScMyShapesContainer()
74 : {
75 8 : }
76 :
77 4 : void ScMyShapesContainer::AddNewShape( const ScMyShape& aShape )
78 : {
79 4 : aShapeList.push_back(aShape);
80 4 : }
81 :
82 8 : bool ScMyShapesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
83 : {
84 8 : sal_Int32 nTable(rCellAddress.Sheet);
85 8 : if( !aShapeList.empty() )
86 : {
87 4 : ScUnoConversion::FillApiAddress( rCellAddress, aShapeList.begin()->aAddress );
88 4 : return (nTable == rCellAddress.Sheet);
89 : }
90 4 : return false;
91 : }
92 :
93 4 : void ScMyShapesContainer::SetCellData( ScMyCell& rMyCell )
94 : {
95 4 : rMyCell.aShapeList.clear();
96 :
97 4 : ScMyShapeList::iterator aItr(aShapeList.begin());
98 4 : ScMyShapeList::iterator aEndItr(aShapeList.end());
99 12 : while( (aItr != aEndItr) && (aItr->aAddress == rMyCell.maCellAddress) )
100 : {
101 4 : rMyCell.aShapeList.push_back(*aItr);
102 4 : aItr = aShapeList.erase(aItr);
103 : }
104 4 : rMyCell.bHasShape = !rMyCell.aShapeList.empty();
105 4 : }
106 :
107 0 : void ScMyShapesContainer::SkipTable(SCTAB nSkip)
108 : {
109 0 : ScMyShapeList::iterator aItr = aShapeList.begin();
110 0 : while( (aItr != aShapeList.end()) && (aItr->aAddress.Tab() == nSkip) )
111 0 : aItr = aShapeList.erase(aItr);
112 0 : }
113 :
114 4 : void ScMyShapesContainer::Sort()
115 : {
116 4 : aShapeList.sort();
117 4 : }
118 :
119 4 : bool ScMyNoteShape::operator<(const ScMyNoteShape& aNote) const
120 : {
121 4 : if( aPos.Tab() != aNote.aPos.Tab() )
122 0 : return (aPos.Tab() < aNote.aPos.Tab());
123 4 : else if( aPos.Row() != aNote.aPos.Row() )
124 4 : return (aPos.Row() < aNote.aPos.Row());
125 : else
126 0 : return (aPos.Col() < aNote.aPos.Col());
127 : }
128 :
129 2 : ScMyNoteShapesContainer::ScMyNoteShapesContainer()
130 2 : : aNoteShapeList()
131 : {
132 2 : }
133 :
134 4 : ScMyNoteShapesContainer::~ScMyNoteShapesContainer()
135 : {
136 4 : }
137 :
138 4 : void ScMyNoteShapesContainer::AddNewNote( const ScMyNoteShape& aNote )
139 : {
140 4 : aNoteShapeList.push_back(aNote);
141 4 : }
142 :
143 6 : bool ScMyNoteShapesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
144 : {
145 6 : sal_Int16 nTable = rCellAddress.Sheet;
146 6 : if( !aNoteShapeList.empty() )
147 : {
148 4 : ScUnoConversion::FillApiAddress( rCellAddress, aNoteShapeList.begin()->aPos );
149 4 : return (nTable == rCellAddress.Sheet);
150 : }
151 2 : return false;
152 : }
153 :
154 4 : void ScMyNoteShapesContainer::SetCellData( ScMyCell& rMyCell )
155 : {
156 4 : ScMyNoteShapeList::iterator aItr = aNoteShapeList.begin();
157 12 : while( (aItr != aNoteShapeList.end()) && (aItr->aPos == rMyCell.maCellAddress) )
158 : {
159 4 : aItr = aNoteShapeList.erase(aItr);
160 : }
161 4 : }
162 :
163 0 : void ScMyNoteShapesContainer::SkipTable(SCTAB nSkip)
164 : {
165 0 : ScMyNoteShapeList::iterator aItr = aNoteShapeList.begin();
166 0 : while( (aItr != aNoteShapeList.end()) && (aItr->aPos.Tab() == nSkip) )
167 0 : aItr = aNoteShapeList.erase(aItr);
168 0 : }
169 :
170 4 : void ScMyNoteShapesContainer::Sort()
171 : {
172 4 : aNoteShapeList.sort();
173 4 : }
174 :
175 0 : bool ScMyMergedRange::operator<(const ScMyMergedRange& aRange) const
176 : {
177 0 : if( aCellRange.Sheet != aRange.aCellRange.Sheet )
178 0 : return (aCellRange.Sheet < aRange.aCellRange.Sheet);
179 0 : else if( aCellRange.StartRow != aRange.aCellRange.StartRow )
180 0 : return (aCellRange.StartRow < aRange.aCellRange.StartRow);
181 : else
182 0 : return (aCellRange.StartColumn < aRange.aCellRange.StartColumn);
183 : }
184 :
185 52 : ScMyMergedRangesContainer::ScMyMergedRangesContainer()
186 52 : : aRangeList()
187 : {
188 52 : }
189 :
190 104 : ScMyMergedRangesContainer::~ScMyMergedRangesContainer()
191 : {
192 104 : }
193 :
194 0 : void ScMyMergedRangesContainer::AddRange(const table::CellRangeAddress aMergedRange)
195 : {
196 0 : sal_Int32 nStartRow(aMergedRange.StartRow);
197 0 : sal_Int32 nEndRow(aMergedRange.EndRow);
198 :
199 0 : ScMyMergedRange aRange;
200 0 : aRange.bIsFirst = true;
201 0 : aRange.aCellRange = aMergedRange;
202 0 : aRange.aCellRange.EndRow = nStartRow;
203 0 : aRange.nRows = nEndRow - nStartRow + 1;
204 0 : aRangeList.push_back( aRange );
205 :
206 0 : aRange.bIsFirst = false;
207 0 : aRange.nRows = 0;
208 0 : for( sal_Int32 nRow = nStartRow + 1; nRow <= nEndRow; ++nRow )
209 : {
210 0 : aRange.aCellRange.StartRow = aRange.aCellRange.EndRow = nRow;
211 0 : aRangeList.push_back(aRange);
212 : }
213 0 : }
214 :
215 762 : bool ScMyMergedRangesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
216 : {
217 762 : sal_Int32 nTable(rCellAddress.Sheet);
218 762 : if( !aRangeList.empty() )
219 : {
220 0 : ScUnoConversion::FillApiStartAddress( rCellAddress, aRangeList.begin()->aCellRange );
221 0 : return (nTable == rCellAddress.Sheet);
222 : }
223 762 : return false;
224 : }
225 :
226 706 : void ScMyMergedRangesContainer::SetCellData( ScMyCell& rMyCell )
227 : {
228 706 : rMyCell.bIsMergedBase = rMyCell.bIsCovered = false;
229 706 : ScMyMergedRangeList::iterator aItr(aRangeList.begin());
230 706 : if( aItr != aRangeList.end() )
231 : {
232 0 : table::CellAddress aFirstAddress;
233 0 : ScUnoConversion::FillApiStartAddress( aFirstAddress, aItr->aCellRange );
234 0 : if( aFirstAddress == rMyCell.aCellAddress )
235 : {
236 0 : rMyCell.aMergeRange = aItr->aCellRange;
237 0 : if (aItr->bIsFirst)
238 0 : rMyCell.aMergeRange.EndRow = rMyCell.aMergeRange.StartRow + aItr->nRows - 1;
239 0 : rMyCell.bIsMergedBase = aItr->bIsFirst;
240 0 : rMyCell.bIsCovered = !aItr->bIsFirst;
241 0 : if( aItr->aCellRange.StartColumn < aItr->aCellRange.EndColumn )
242 : {
243 0 : ++(aItr->aCellRange.StartColumn);
244 0 : aItr->bIsFirst = false;
245 : }
246 : else
247 0 : aRangeList.erase(aItr);
248 : }
249 : }
250 706 : }
251 :
252 0 : void ScMyMergedRangesContainer::SkipTable(SCTAB nSkip)
253 : {
254 0 : ScMyMergedRangeList::iterator aItr = aRangeList.begin();
255 0 : while( (aItr != aRangeList.end()) && (aItr->aCellRange.Sheet == nSkip) )
256 0 : aItr = aRangeList.erase(aItr);
257 0 : }
258 :
259 48 : void ScMyMergedRangesContainer::Sort()
260 : {
261 48 : aRangeList.sort();
262 48 : }
263 :
264 0 : bool ScMyAreaLink::Compare( const ScMyAreaLink& rAreaLink ) const
265 : {
266 0 : return (GetRowCount() == rAreaLink.GetRowCount()) &&
267 0 : (sFilter == rAreaLink.sFilter) &&
268 0 : (sFilterOptions == rAreaLink.sFilterOptions) &&
269 0 : (sURL == rAreaLink.sURL) &&
270 0 : (sSourceStr == rAreaLink.sSourceStr);
271 : }
272 :
273 0 : bool ScMyAreaLink::operator<(const ScMyAreaLink& rAreaLink ) const
274 : {
275 0 : if( aDestRange.Sheet != rAreaLink.aDestRange.Sheet )
276 0 : return (aDestRange.Sheet < rAreaLink.aDestRange.Sheet);
277 0 : else if( aDestRange.StartRow != rAreaLink.aDestRange.StartRow )
278 0 : return (aDestRange.StartRow < rAreaLink.aDestRange.StartRow);
279 : else
280 0 : return (aDestRange.StartColumn < rAreaLink.aDestRange.StartColumn);
281 : }
282 :
283 48 : ScMyAreaLinksContainer::ScMyAreaLinksContainer() :
284 48 : aAreaLinkList()
285 : {
286 48 : }
287 :
288 48 : ScMyAreaLinksContainer::~ScMyAreaLinksContainer()
289 : {
290 48 : }
291 :
292 762 : bool ScMyAreaLinksContainer::GetFirstAddress( table::CellAddress& rCellAddress )
293 : {
294 762 : sal_Int32 nTable(rCellAddress.Sheet);
295 762 : if( !aAreaLinkList.empty() )
296 : {
297 0 : ScUnoConversion::FillApiStartAddress( rCellAddress, aAreaLinkList.begin()->aDestRange );
298 0 : return (nTable == rCellAddress.Sheet);
299 : }
300 762 : return false;
301 : }
302 :
303 706 : void ScMyAreaLinksContainer::SetCellData( ScMyCell& rMyCell )
304 : {
305 706 : rMyCell.bHasAreaLink = false;
306 706 : ScMyAreaLinkList::iterator aItr(aAreaLinkList.begin());
307 706 : if( aItr != aAreaLinkList.end() )
308 : {
309 0 : table::CellAddress aAddress;
310 0 : ScUnoConversion::FillApiStartAddress( aAddress, aItr->aDestRange );
311 0 : if( aAddress == rMyCell.aCellAddress )
312 : {
313 0 : rMyCell.bHasAreaLink = true;
314 0 : rMyCell.aAreaLink = *aItr;
315 0 : aItr = aAreaLinkList.erase( aItr );
316 0 : bool bFound = true;
317 0 : while (aItr != aAreaLinkList.end() && bFound)
318 : {
319 0 : ScUnoConversion::FillApiStartAddress( aAddress, aItr->aDestRange );
320 0 : if (aAddress == rMyCell.aCellAddress)
321 : {
322 : OSL_FAIL("more than one linked range on one cell");
323 0 : aItr = aAreaLinkList.erase( aItr );
324 : }
325 : else
326 0 : bFound = false;
327 : }
328 : }
329 : }
330 706 : }
331 :
332 0 : void ScMyAreaLinksContainer::SkipTable(SCTAB nSkip)
333 : {
334 0 : ScMyAreaLinkList::iterator aItr = aAreaLinkList.begin();
335 0 : while( (aItr != aAreaLinkList.end()) && (aItr->aDestRange.Sheet == nSkip) )
336 0 : aItr = aAreaLinkList.erase(aItr);
337 0 : }
338 :
339 48 : void ScMyAreaLinksContainer::Sort()
340 : {
341 48 : aAreaLinkList.sort();
342 48 : }
343 :
344 0 : ScMyCellRangeAddress::ScMyCellRangeAddress(const table::CellRangeAddress& rRange)
345 0 : : table::CellRangeAddress(rRange)
346 : {
347 0 : }
348 :
349 0 : bool ScMyCellRangeAddress::operator<(const ScMyCellRangeAddress& rRange ) const
350 : {
351 0 : if( Sheet != rRange.Sheet )
352 0 : return (Sheet < rRange.Sheet);
353 0 : else if( StartRow != rRange.StartRow )
354 0 : return (StartRow < rRange.StartRow);
355 : else
356 0 : return (StartColumn < rRange.StartColumn);
357 : }
358 :
359 48 : ScMyEmptyDatabaseRangesContainer::ScMyEmptyDatabaseRangesContainer()
360 48 : : aDatabaseList()
361 : {
362 48 : }
363 :
364 48 : ScMyEmptyDatabaseRangesContainer::~ScMyEmptyDatabaseRangesContainer()
365 : {
366 48 : }
367 :
368 0 : void ScMyEmptyDatabaseRangesContainer::AddNewEmptyDatabaseRange(const table::CellRangeAddress& aCellRange)
369 : {
370 0 : sal_Int32 nStartRow(aCellRange.StartRow);
371 0 : sal_Int32 nEndRow(aCellRange.EndRow);
372 0 : ScMyCellRangeAddress aRange( aCellRange );
373 0 : for( sal_Int32 nRow = nStartRow; nRow <= nEndRow; ++nRow )
374 : {
375 0 : aRange.StartRow = aRange.EndRow = nRow;
376 0 : aDatabaseList.push_back( aRange );
377 : }
378 0 : }
379 :
380 762 : bool ScMyEmptyDatabaseRangesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
381 : {
382 762 : sal_Int32 nTable(rCellAddress.Sheet);
383 762 : if( !aDatabaseList.empty() )
384 : {
385 0 : ScUnoConversion::FillApiStartAddress( rCellAddress, *(aDatabaseList.begin()) );
386 0 : return (nTable == rCellAddress.Sheet);
387 : }
388 762 : return false;
389 : }
390 :
391 706 : void ScMyEmptyDatabaseRangesContainer::SetCellData( ScMyCell& rMyCell )
392 : {
393 706 : rMyCell.bHasEmptyDatabase = false;
394 706 : ScMyEmptyDatabaseRangeList::iterator aItr(aDatabaseList.begin());
395 706 : if( aItr != aDatabaseList.end() )
396 : {
397 0 : table::CellAddress aFirstAddress;
398 0 : ScUnoConversion::FillApiStartAddress( aFirstAddress, *aItr );
399 0 : if( aFirstAddress == rMyCell.aCellAddress )
400 : {
401 0 : rMyCell.bHasEmptyDatabase = true;
402 0 : if( aItr->StartColumn < aItr->EndColumn )
403 0 : ++(aItr->StartColumn);
404 : else
405 0 : aDatabaseList.erase(aItr);
406 : }
407 : }
408 706 : }
409 :
410 0 : void ScMyEmptyDatabaseRangesContainer::SkipTable(SCTAB nSkip)
411 : {
412 0 : ScMyEmptyDatabaseRangeList::iterator aItr = aDatabaseList.begin();
413 0 : while( (aItr != aDatabaseList.end()) && (aItr->Sheet == nSkip) )
414 0 : aItr = aDatabaseList.erase(aItr);
415 0 : }
416 :
417 0 : void ScMyEmptyDatabaseRangesContainer::Sort()
418 : {
419 0 : aDatabaseList.sort();
420 0 : }
421 :
422 0 : bool ScMyDetectiveObj::operator<( const ScMyDetectiveObj& rDetObj) const
423 : {
424 0 : if( aPosition.Sheet != rDetObj.aPosition.Sheet )
425 0 : return (aPosition.Sheet < rDetObj.aPosition.Sheet);
426 0 : else if( aPosition.Row != rDetObj.aPosition.Row )
427 0 : return (aPosition.Row < rDetObj.aPosition.Row);
428 : else
429 0 : return (aPosition.Column < rDetObj.aPosition.Column);
430 : }
431 :
432 48 : ScMyDetectiveObjContainer::ScMyDetectiveObjContainer() :
433 48 : aDetectiveObjList()
434 : {
435 48 : }
436 :
437 96 : ScMyDetectiveObjContainer::~ScMyDetectiveObjContainer()
438 : {
439 96 : }
440 :
441 0 : void ScMyDetectiveObjContainer::AddObject( ScDetectiveObjType eObjType, const SCTAB nSheet,
442 : const ScAddress& rPosition, const ScRange& rSourceRange,
443 : bool bHasError )
444 : {
445 0 : if( (eObjType == SC_DETOBJ_ARROW) ||
446 0 : (eObjType == SC_DETOBJ_FROMOTHERTAB) ||
447 0 : (eObjType == SC_DETOBJ_TOOTHERTAB) ||
448 : (eObjType == SC_DETOBJ_CIRCLE) )
449 : {
450 0 : ScMyDetectiveObj aDetObj;
451 0 : aDetObj.eObjType = eObjType;
452 0 : if( eObjType == SC_DETOBJ_TOOTHERTAB )
453 0 : ScUnoConversion::FillApiAddress( aDetObj.aPosition, rSourceRange.aStart );
454 : else
455 0 : ScUnoConversion::FillApiAddress( aDetObj.aPosition, rPosition );
456 0 : ScUnoConversion::FillApiRange( aDetObj.aSourceRange, rSourceRange );
457 :
458 : // #111064#; take the sheet where the object is found and not the sheet given in the ranges, because they are not always true
459 0 : if (eObjType != SC_DETOBJ_FROMOTHERTAB)
460 : {
461 : // if the ObjType == SC_DETOBJ_FROMOTHERTAB then the SourceRange is not used and so it has not to be tested and changed
462 : OSL_ENSURE(aDetObj.aPosition.Sheet == aDetObj.aSourceRange.Sheet, "It seems to be possible to have different sheets");
463 0 : aDetObj.aSourceRange.Sheet = nSheet;
464 : }
465 0 : aDetObj.aPosition.Sheet = nSheet;
466 :
467 0 : aDetObj.bHasError = bHasError;
468 0 : aDetectiveObjList.push_back( aDetObj );
469 : }
470 0 : }
471 :
472 762 : bool ScMyDetectiveObjContainer::GetFirstAddress( table::CellAddress& rCellAddress )
473 : {
474 762 : sal_Int32 nTable(rCellAddress.Sheet);
475 762 : if( !aDetectiveObjList.empty() )
476 : {
477 0 : rCellAddress = aDetectiveObjList.begin()->aPosition;
478 0 : return (nTable == rCellAddress.Sheet);
479 : }
480 762 : return false;
481 : }
482 :
483 706 : void ScMyDetectiveObjContainer::SetCellData( ScMyCell& rMyCell )
484 : {
485 706 : rMyCell.aDetectiveObjVec.clear();
486 706 : ScMyDetectiveObjList::iterator aItr(aDetectiveObjList.begin());
487 706 : ScMyDetectiveObjList::iterator aEndItr(aDetectiveObjList.end());
488 1412 : while( (aItr != aEndItr) && (aItr->aPosition == rMyCell.aCellAddress) )
489 : {
490 0 : rMyCell.aDetectiveObjVec.push_back( *aItr );
491 0 : aItr = aDetectiveObjList.erase( aItr );
492 : }
493 706 : rMyCell.bHasDetectiveObj = (rMyCell.aDetectiveObjVec.size() != 0);
494 706 : }
495 :
496 0 : void ScMyDetectiveObjContainer::SkipTable(SCTAB nSkip)
497 : {
498 0 : ScMyDetectiveObjList::iterator aItr = aDetectiveObjList.begin();
499 0 : while( (aItr != aDetectiveObjList.end()) && (aItr->aPosition.Sheet == nSkip) )
500 0 : aItr = aDetectiveObjList.erase(aItr);
501 0 : }
502 :
503 48 : void ScMyDetectiveObjContainer::Sort()
504 : {
505 48 : aDetectiveObjList.sort();
506 48 : }
507 :
508 0 : bool ScMyDetectiveOp::operator<( const ScMyDetectiveOp& rDetOp) const
509 : {
510 0 : if( aPosition.Sheet != rDetOp.aPosition.Sheet )
511 0 : return (aPosition.Sheet < rDetOp.aPosition.Sheet);
512 0 : else if( aPosition.Row != rDetOp.aPosition.Row )
513 0 : return (aPosition.Row < rDetOp.aPosition.Row);
514 : else
515 0 : return (aPosition.Column < rDetOp.aPosition.Column);
516 : }
517 :
518 48 : ScMyDetectiveOpContainer::ScMyDetectiveOpContainer() :
519 48 : aDetectiveOpList()
520 : {
521 48 : }
522 :
523 48 : ScMyDetectiveOpContainer::~ScMyDetectiveOpContainer()
524 : {
525 48 : }
526 :
527 0 : void ScMyDetectiveOpContainer::AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex )
528 : {
529 0 : ScMyDetectiveOp aDetOp;
530 0 : aDetOp.eOpType = eOpType;
531 0 : ScUnoConversion::FillApiAddress( aDetOp.aPosition, rPosition );
532 0 : aDetOp.nIndex = nIndex;
533 0 : aDetectiveOpList.push_back( aDetOp );
534 0 : }
535 :
536 762 : bool ScMyDetectiveOpContainer::GetFirstAddress( table::CellAddress& rCellAddress )
537 : {
538 762 : sal_Int32 nTable(rCellAddress.Sheet);
539 762 : if( !aDetectiveOpList.empty() )
540 : {
541 0 : rCellAddress = aDetectiveOpList.begin()->aPosition;
542 0 : return (nTable == rCellAddress.Sheet);
543 : }
544 762 : return false;
545 : }
546 :
547 706 : void ScMyDetectiveOpContainer::SetCellData( ScMyCell& rMyCell )
548 : {
549 706 : rMyCell.aDetectiveOpVec.clear();
550 706 : ScMyDetectiveOpList::iterator aItr(aDetectiveOpList.begin());
551 706 : ScMyDetectiveOpList::iterator aEndItr(aDetectiveOpList.end());
552 1412 : while( (aItr != aEndItr) && (aItr->aPosition == rMyCell.aCellAddress) )
553 : {
554 0 : rMyCell.aDetectiveOpVec.push_back( *aItr );
555 0 : aItr = aDetectiveOpList.erase( aItr );
556 : }
557 706 : rMyCell.bHasDetectiveOp = (rMyCell.aDetectiveOpVec.size() != 0);
558 706 : }
559 :
560 0 : void ScMyDetectiveOpContainer::SkipTable(SCTAB nSkip)
561 : {
562 0 : ScMyDetectiveOpList::iterator aItr = aDetectiveOpList.begin();
563 0 : while( (aItr != aDetectiveOpList.end()) && (aItr->aPosition.Sheet == nSkip) )
564 0 : aItr = aDetectiveOpList.erase(aItr);
565 0 : }
566 :
567 0 : void ScMyDetectiveOpContainer::Sort()
568 : {
569 0 : aDetectiveOpList.sort();
570 0 : }
571 :
572 112 : ScMyCell::ScMyCell() :
573 : aShapeList(),
574 : aDetectiveObjVec(),
575 : pNote(NULL),
576 : nValidationIndex(-1),
577 : nStyleIndex(-1),
578 : nNumberFormat(-1),
579 : nType(table::CellContentType_EMPTY),
580 : bIsAutoStyle( false ),
581 : bHasShape( false ),
582 : bIsMergedBase( false ),
583 : bIsCovered( false ),
584 : bHasAreaLink( false ),
585 : bHasEmptyDatabase( false ),
586 : bHasDetectiveObj( false ),
587 : bHasDetectiveOp( false ),
588 : bIsMatrixBase( false ),
589 : bIsMatrixCovered( false ),
590 112 : bHasAnnotation( false )
591 : {
592 112 : }
593 :
594 112 : ScMyCell::~ScMyCell()
595 : {
596 112 : }
597 :
598 52 : ScMyNotEmptyCellsIterator::ScMyNotEmptyCellsIterator(ScXMLExport& rTempXMLExport)
599 : : pShapes(NULL),
600 : pNoteShapes(NULL),
601 : pEmptyDatabaseRanges(NULL),
602 : pMergedRanges(NULL),
603 : pAreaLinks(NULL),
604 : pDetectiveObj(NULL),
605 : pDetectiveOp(NULL),
606 : rExport(rTempXMLExport),
607 : nCellCol(0),
608 : nCellRow(0),
609 52 : nCurrentTable(SCTAB_MAX)
610 : {
611 52 : }
612 :
613 104 : ScMyNotEmptyCellsIterator::~ScMyNotEmptyCellsIterator()
614 : {
615 52 : Clear();
616 52 : }
617 :
618 100 : void ScMyNotEmptyCellsIterator::Clear()
619 : {
620 100 : mpCellItr.reset();
621 100 : pShapes = NULL;
622 100 : pNoteShapes = NULL;
623 100 : pMergedRanges = NULL;
624 100 : pAreaLinks = NULL;
625 100 : pEmptyDatabaseRanges = NULL;
626 100 : pDetectiveObj = NULL;
627 100 : pDetectiveOp = NULL;
628 100 : nCurrentTable = SCTAB_MAX;
629 100 : }
630 :
631 762 : void ScMyNotEmptyCellsIterator::UpdateAddress( table::CellAddress& rAddress )
632 : {
633 762 : if (mpCellItr->GetPos(nCellCol, nCellRow))
634 : {
635 698 : rAddress.Column = nCellCol;
636 698 : rAddress.Row = nCellRow;
637 : }
638 762 : }
639 :
640 706 : void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, const table::CellAddress& rAddress )
641 : {
642 706 : rMyCell.maBaseCell.clear();
643 706 : rMyCell.aCellAddress = rAddress;
644 706 : ScUnoConversion::FillScAddress(rMyCell.maCellAddress, rMyCell.aCellAddress);
645 :
646 706 : if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) )
647 : {
648 700 : const ScRefCellValue* pCell = mpCellItr->GetNext(nCellCol, nCellRow);
649 700 : if (pCell)
650 698 : rMyCell.maBaseCell = *pCell;
651 : }
652 :
653 706 : rMyCell.bIsMatrixCovered = false;
654 706 : rMyCell.bIsMatrixBase = false;
655 :
656 706 : bool bIsMatrixBase = false;
657 :
658 706 : switch (rMyCell.maBaseCell.meType)
659 : {
660 : case CELLTYPE_VALUE:
661 576 : rMyCell.nType = table::CellContentType_VALUE;
662 576 : break;
663 : case CELLTYPE_STRING:
664 : case CELLTYPE_EDIT:
665 114 : rMyCell.nType = table::CellContentType_TEXT;
666 114 : break;
667 : case CELLTYPE_FORMULA:
668 8 : rMyCell.nType = table::CellContentType_FORMULA;
669 8 : break;
670 : default:
671 8 : rMyCell.nType = table::CellContentType_EMPTY;
672 : }
673 :
674 706 : if (rMyCell.maBaseCell.meType == CELLTYPE_FORMULA)
675 8 : if (rExport.IsMatrix(rMyCell.maCellAddress, rMyCell.aMatrixRange, bIsMatrixBase))
676 : {
677 0 : rMyCell.bIsMatrixBase = bIsMatrixBase;
678 0 : rMyCell.bIsMatrixCovered = !bIsMatrixBase;
679 : }
680 706 : }
681 :
682 706 : void ScMyNotEmptyCellsIterator::HasAnnotation(ScMyCell& aCell)
683 : {
684 706 : aCell.bHasAnnotation = false;
685 706 : ScPostIt* pNote = rExport.GetDocument()->GetNote(aCell.maCellAddress);
686 :
687 706 : if(pNote)
688 : {
689 4 : aCell.bHasAnnotation = true;
690 4 : aCell.pNote = pNote;
691 : }
692 706 : }
693 :
694 56 : void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
695 : uno::Reference<sheet::XSpreadsheet>& rxTable)
696 : {
697 56 : aLastAddress.Row = 0;
698 56 : aLastAddress.Column = 0;
699 56 : aLastAddress.Sheet = nTable;
700 56 : if (nCurrentTable != nTable)
701 : {
702 56 : nCurrentTable = nTable;
703 :
704 : mpCellItr.reset(
705 : new ScHorizontalCellIterator(
706 56 : rExport.GetDocument(), nCurrentTable, 0, 0,
707 56 : static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)),
708 112 : static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable))));
709 :
710 56 : xTable.set(rxTable);
711 56 : xCellRange.set(xTable, uno::UNO_QUERY);
712 : }
713 56 : }
714 :
715 0 : void ScMyNotEmptyCellsIterator::SkipTable(SCTAB nSkip)
716 : {
717 : // Skip entries for a sheet that is copied instead of saving normally.
718 : // Cells are handled separately in SetCurrentTable.
719 :
720 0 : if( pShapes )
721 0 : pShapes->SkipTable(nSkip);
722 0 : if( pNoteShapes )
723 0 : pNoteShapes->SkipTable(nSkip);
724 0 : if( pEmptyDatabaseRanges )
725 0 : pEmptyDatabaseRanges->SkipTable(nSkip);
726 0 : if( pMergedRanges )
727 0 : pMergedRanges->SkipTable(nSkip);
728 0 : if( pAreaLinks )
729 0 : pAreaLinks->SkipTable(nSkip);
730 0 : if( pDetectiveObj )
731 0 : pDetectiveObj->SkipTable(nSkip);
732 0 : if( pDetectiveOp )
733 0 : pDetectiveOp->SkipTable(nSkip);
734 0 : }
735 :
736 762 : bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles)
737 : {
738 762 : table::CellAddress aAddress( nCurrentTable, MAXCOL + 1, MAXROW + 1 );
739 :
740 762 : UpdateAddress( aAddress );
741 :
742 762 : if( pShapes )
743 8 : pShapes->UpdateAddress( aAddress );
744 762 : if( pNoteShapes )
745 6 : pNoteShapes->UpdateAddress( aAddress );
746 762 : if( pEmptyDatabaseRanges )
747 762 : pEmptyDatabaseRanges->UpdateAddress( aAddress );
748 762 : if( pMergedRanges )
749 762 : pMergedRanges->UpdateAddress( aAddress );
750 762 : if( pAreaLinks )
751 762 : pAreaLinks->UpdateAddress( aAddress );
752 762 : if( pDetectiveObj )
753 762 : pDetectiveObj->UpdateAddress( aAddress );
754 762 : if( pDetectiveOp )
755 762 : pDetectiveOp->UpdateAddress( aAddress );
756 :
757 762 : bool bFoundCell((aAddress.Column <= MAXCOL) && (aAddress.Row <= MAXROW));
758 762 : if( bFoundCell )
759 : {
760 706 : SetCellData( aCell, aAddress );
761 706 : if( pShapes )
762 4 : pShapes->SetCellData( aCell );
763 706 : if( pNoteShapes )
764 4 : pNoteShapes->SetCellData( aCell );
765 706 : if( pEmptyDatabaseRanges )
766 706 : pEmptyDatabaseRanges->SetCellData( aCell );
767 706 : if( pMergedRanges )
768 706 : pMergedRanges->SetCellData( aCell );
769 706 : if( pAreaLinks )
770 706 : pAreaLinks->SetCellData( aCell );
771 706 : if( pDetectiveObj )
772 706 : pDetectiveObj->SetCellData( aCell );
773 706 : if( pDetectiveOp )
774 706 : pDetectiveOp->SetCellData( aCell );
775 :
776 706 : HasAnnotation( aCell );
777 : bool bIsAutoStyle;
778 : // Ranges before the previous cell are not needed by ExportFormatRanges anymore and can be removed
779 706 : sal_Int32 nRemoveBeforeRow = aLastAddress.Row;
780 706 : aCell.nStyleIndex = pCellStyles->GetStyleNameIndex(aCell.maCellAddress.Tab(),
781 706 : aCell.maCellAddress.Col(), aCell.maCellAddress.Row(),
782 2118 : bIsAutoStyle, aCell.nValidationIndex, aCell.nNumberFormat, nRemoveBeforeRow);
783 706 : aLastAddress = aCell.aCellAddress;
784 706 : aCell.bIsAutoStyle = bIsAutoStyle;
785 :
786 : //#102799#; if the cell is in a DatabaseRange which should saved empty, the cell should have the type empty
787 706 : if (aCell.bHasEmptyDatabase)
788 0 : aCell.nType = table::CellContentType_EMPTY;
789 : }
790 762 : return bFoundCell;
791 228 : }
792 :
793 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|