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 152 : ScMyIteratorBase::ScMyIteratorBase()
39 : {
40 152 : }
41 :
42 152 : ScMyIteratorBase::~ScMyIteratorBase()
43 : {
44 152 : }
45 :
46 1951 : void ScMyIteratorBase::UpdateAddress( table::CellAddress& rCellAddress )
47 : {
48 1951 : table::CellAddress aNewAddr( rCellAddress );
49 1951 : if( GetFirstAddress( aNewAddr ) )
50 : {
51 12 : if( (aNewAddr.Sheet == rCellAddress.Sheet) &&
52 6 : ((aNewAddr.Row < rCellAddress.Row) ||
53 0 : ((aNewAddr.Row == rCellAddress.Row) && (aNewAddr.Column < rCellAddress.Column))) )
54 6 : rCellAddress = aNewAddr;
55 : }
56 1951 : }
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 2 : bool ScMyNoteShape::operator<(const ScMyNoteShape& aNote) const
120 : {
121 2 : if( aPos.Tab() != aNote.aPos.Tab() )
122 0 : return (aPos.Tab() < aNote.aPos.Tab());
123 2 : else if( aPos.Row() != aNote.aPos.Row() )
124 2 : return (aPos.Row() < aNote.aPos.Row());
125 : else
126 0 : return (aPos.Col() < aNote.aPos.Col());
127 : }
128 :
129 1 : ScMyNoteShapesContainer::ScMyNoteShapesContainer()
130 1 : : aNoteShapeList()
131 : {
132 1 : }
133 :
134 2 : ScMyNoteShapesContainer::~ScMyNoteShapesContainer()
135 : {
136 2 : }
137 :
138 2 : void ScMyNoteShapesContainer::AddNewNote( const ScMyNoteShape& aNote )
139 : {
140 2 : aNoteShapeList.push_back(aNote);
141 2 : }
142 :
143 3 : bool ScMyNoteShapesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
144 : {
145 3 : sal_Int16 nTable = rCellAddress.Sheet;
146 3 : if( !aNoteShapeList.empty() )
147 : {
148 2 : ScUnoConversion::FillApiAddress( rCellAddress, aNoteShapeList.begin()->aPos );
149 2 : return (nTable == rCellAddress.Sheet);
150 : }
151 1 : return false;
152 : }
153 :
154 2 : void ScMyNoteShapesContainer::SetCellData( ScMyCell& rMyCell )
155 : {
156 2 : ScMyNoteShapeList::iterator aItr = aNoteShapeList.begin();
157 6 : while( (aItr != aNoteShapeList.end()) && (aItr->aPos == rMyCell.maCellAddress) )
158 : {
159 2 : aItr = aNoteShapeList.erase(aItr);
160 : }
161 2 : }
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 2 : void ScMyNoteShapesContainer::Sort()
171 : {
172 2 : aNoteShapeList.sort();
173 2 : }
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 31 : ScMyMergedRangesContainer::ScMyMergedRangesContainer()
186 31 : : aRangeList()
187 : {
188 31 : }
189 :
190 62 : ScMyMergedRangesContainer::~ScMyMergedRangesContainer()
191 : {
192 62 : }
193 :
194 0 : void ScMyMergedRangesContainer::AddRange(const table::CellRangeAddress& rMergedRange)
195 : {
196 0 : sal_Int32 nStartRow(rMergedRange.StartRow);
197 0 : sal_Int32 nEndRow(rMergedRange.EndRow);
198 :
199 0 : ScMyMergedRange aRange;
200 0 : aRange.bIsFirst = true;
201 0 : aRange.aCellRange = rMergedRange;
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 388 : bool ScMyMergedRangesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
216 : {
217 388 : sal_Int32 nTable(rCellAddress.Sheet);
218 388 : if( !aRangeList.empty() )
219 : {
220 0 : ScUnoConversion::FillApiStartAddress( rCellAddress, aRangeList.begin()->aCellRange );
221 0 : return (nTable == rCellAddress.Sheet);
222 : }
223 388 : return false;
224 : }
225 :
226 355 : void ScMyMergedRangesContainer::SetCellData( ScMyCell& rMyCell )
227 : {
228 355 : rMyCell.bIsMergedBase = rMyCell.bIsCovered = false;
229 355 : ScMyMergedRangeList::iterator aItr(aRangeList.begin());
230 355 : 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 355 : }
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 29 : void ScMyMergedRangesContainer::Sort()
260 : {
261 29 : aRangeList.sort();
262 29 : }
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 29 : ScMyAreaLinksContainer::ScMyAreaLinksContainer() :
284 29 : aAreaLinkList()
285 : {
286 29 : }
287 :
288 29 : ScMyAreaLinksContainer::~ScMyAreaLinksContainer()
289 : {
290 29 : }
291 :
292 388 : bool ScMyAreaLinksContainer::GetFirstAddress( table::CellAddress& rCellAddress )
293 : {
294 388 : sal_Int32 nTable(rCellAddress.Sheet);
295 388 : if( !aAreaLinkList.empty() )
296 : {
297 0 : ScUnoConversion::FillApiStartAddress( rCellAddress, aAreaLinkList.begin()->aDestRange );
298 0 : return (nTable == rCellAddress.Sheet);
299 : }
300 388 : return false;
301 : }
302 :
303 355 : void ScMyAreaLinksContainer::SetCellData( ScMyCell& rMyCell )
304 : {
305 355 : rMyCell.bHasAreaLink = false;
306 355 : ScMyAreaLinkList::iterator aItr(aAreaLinkList.begin());
307 355 : 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 355 : }
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 29 : void ScMyAreaLinksContainer::Sort()
340 : {
341 29 : aAreaLinkList.sort();
342 29 : }
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 29 : ScMyEmptyDatabaseRangesContainer::ScMyEmptyDatabaseRangesContainer()
360 29 : : aDatabaseList()
361 : {
362 29 : }
363 :
364 29 : ScMyEmptyDatabaseRangesContainer::~ScMyEmptyDatabaseRangesContainer()
365 : {
366 29 : }
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 388 : bool ScMyEmptyDatabaseRangesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
381 : {
382 388 : sal_Int32 nTable(rCellAddress.Sheet);
383 388 : if( !aDatabaseList.empty() )
384 : {
385 0 : ScUnoConversion::FillApiStartAddress( rCellAddress, *(aDatabaseList.begin()) );
386 0 : return (nTable == rCellAddress.Sheet);
387 : }
388 388 : return false;
389 : }
390 :
391 355 : void ScMyEmptyDatabaseRangesContainer::SetCellData( ScMyCell& rMyCell )
392 : {
393 355 : rMyCell.bHasEmptyDatabase = false;
394 355 : ScMyEmptyDatabaseRangeList::iterator aItr(aDatabaseList.begin());
395 355 : 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 355 : }
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 29 : ScMyDetectiveObjContainer::ScMyDetectiveObjContainer() :
433 29 : aDetectiveObjList()
434 : {
435 29 : }
436 :
437 58 : ScMyDetectiveObjContainer::~ScMyDetectiveObjContainer()
438 : {
439 58 : }
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 388 : bool ScMyDetectiveObjContainer::GetFirstAddress( table::CellAddress& rCellAddress )
473 : {
474 388 : sal_Int32 nTable(rCellAddress.Sheet);
475 388 : if( !aDetectiveObjList.empty() )
476 : {
477 0 : rCellAddress = aDetectiveObjList.begin()->aPosition;
478 0 : return (nTable == rCellAddress.Sheet);
479 : }
480 388 : return false;
481 : }
482 :
483 355 : void ScMyDetectiveObjContainer::SetCellData( ScMyCell& rMyCell )
484 : {
485 355 : rMyCell.aDetectiveObjVec.clear();
486 355 : ScMyDetectiveObjList::iterator aItr(aDetectiveObjList.begin());
487 355 : ScMyDetectiveObjList::iterator aEndItr(aDetectiveObjList.end());
488 710 : while( (aItr != aEndItr) && (aItr->aPosition == rMyCell.aCellAddress) )
489 : {
490 0 : rMyCell.aDetectiveObjVec.push_back( *aItr );
491 0 : aItr = aDetectiveObjList.erase( aItr );
492 : }
493 355 : rMyCell.bHasDetectiveObj = (rMyCell.aDetectiveObjVec.size() != 0);
494 355 : }
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 29 : void ScMyDetectiveObjContainer::Sort()
504 : {
505 29 : aDetectiveObjList.sort();
506 29 : }
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 29 : ScMyDetectiveOpContainer::ScMyDetectiveOpContainer() :
519 29 : aDetectiveOpList()
520 : {
521 29 : }
522 :
523 29 : ScMyDetectiveOpContainer::~ScMyDetectiveOpContainer()
524 : {
525 29 : }
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 388 : bool ScMyDetectiveOpContainer::GetFirstAddress( table::CellAddress& rCellAddress )
537 : {
538 388 : sal_Int32 nTable(rCellAddress.Sheet);
539 388 : if( !aDetectiveOpList.empty() )
540 : {
541 0 : rCellAddress = aDetectiveOpList.begin()->aPosition;
542 0 : return (nTable == rCellAddress.Sheet);
543 : }
544 388 : return false;
545 : }
546 :
547 355 : void ScMyDetectiveOpContainer::SetCellData( ScMyCell& rMyCell )
548 : {
549 355 : rMyCell.aDetectiveOpVec.clear();
550 355 : ScMyDetectiveOpList::iterator aItr(aDetectiveOpList.begin());
551 355 : ScMyDetectiveOpList::iterator aEndItr(aDetectiveOpList.end());
552 710 : while( (aItr != aEndItr) && (aItr->aPosition == rMyCell.aCellAddress) )
553 : {
554 0 : rMyCell.aDetectiveOpVec.push_back( *aItr );
555 0 : aItr = aDetectiveOpList.erase( aItr );
556 : }
557 355 : rMyCell.bHasDetectiveOp = (rMyCell.aDetectiveOpVec.size() != 0);
558 355 : }
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 66 : 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 66 : bHasAnnotation( false )
591 : {
592 66 : }
593 :
594 66 : ScMyCell::~ScMyCell()
595 : {
596 66 : }
597 :
598 31 : 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 31 : nCurrentTable(SCTAB_MAX)
610 : {
611 31 : }
612 :
613 62 : ScMyNotEmptyCellsIterator::~ScMyNotEmptyCellsIterator()
614 : {
615 31 : Clear();
616 31 : }
617 :
618 60 : void ScMyNotEmptyCellsIterator::Clear()
619 : {
620 60 : mpCellItr.reset();
621 60 : pShapes = NULL;
622 60 : pNoteShapes = NULL;
623 60 : pMergedRanges = NULL;
624 60 : pAreaLinks = NULL;
625 60 : pEmptyDatabaseRanges = NULL;
626 60 : pDetectiveObj = NULL;
627 60 : pDetectiveOp = NULL;
628 60 : nCurrentTable = SCTAB_MAX;
629 60 : }
630 :
631 388 : void ScMyNotEmptyCellsIterator::UpdateAddress( table::CellAddress& rAddress )
632 : {
633 388 : if (mpCellItr->GetPos(nCellCol, nCellRow))
634 : {
635 349 : rAddress.Column = nCellCol;
636 349 : rAddress.Row = nCellRow;
637 : }
638 388 : }
639 :
640 355 : void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, const table::CellAddress& rAddress )
641 : {
642 355 : rMyCell.maBaseCell.clear();
643 355 : rMyCell.aCellAddress = rAddress;
644 355 : ScUnoConversion::FillScAddress(rMyCell.maCellAddress, rMyCell.aCellAddress);
645 :
646 355 : if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) )
647 : {
648 350 : const ScRefCellValue* pCell = mpCellItr->GetNext(nCellCol, nCellRow);
649 350 : if (pCell)
650 349 : rMyCell.maBaseCell = *pCell;
651 : }
652 :
653 355 : rMyCell.bIsMatrixCovered = false;
654 355 : rMyCell.bIsMatrixBase = false;
655 :
656 355 : switch (rMyCell.maBaseCell.meType)
657 : {
658 : case CELLTYPE_VALUE:
659 288 : rMyCell.nType = table::CellContentType_VALUE;
660 288 : break;
661 : case CELLTYPE_STRING:
662 : case CELLTYPE_EDIT:
663 57 : rMyCell.nType = table::CellContentType_TEXT;
664 57 : break;
665 : case CELLTYPE_FORMULA:
666 4 : rMyCell.nType = table::CellContentType_FORMULA;
667 4 : break;
668 : default:
669 6 : rMyCell.nType = table::CellContentType_EMPTY;
670 : }
671 :
672 355 : if (rMyCell.maBaseCell.meType == CELLTYPE_FORMULA)
673 : {
674 4 : bool bIsMatrixBase = false;
675 4 : if (rExport.IsMatrix(rMyCell.maCellAddress, rMyCell.aMatrixRange, bIsMatrixBase))
676 : {
677 0 : rMyCell.bIsMatrixBase = bIsMatrixBase;
678 0 : rMyCell.bIsMatrixCovered = !bIsMatrixBase;
679 : }
680 : }
681 355 : }
682 :
683 355 : void ScMyNotEmptyCellsIterator::HasAnnotation(ScMyCell& aCell)
684 : {
685 355 : aCell.bHasAnnotation = false;
686 355 : ScPostIt* pNote = rExport.GetDocument()->GetNote(aCell.maCellAddress);
687 :
688 355 : if(pNote)
689 : {
690 2 : aCell.bHasAnnotation = true;
691 2 : aCell.pNote = pNote;
692 : }
693 355 : }
694 :
695 33 : void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
696 : uno::Reference<sheet::XSpreadsheet>& rxTable)
697 : {
698 33 : aLastAddress.Row = 0;
699 33 : aLastAddress.Column = 0;
700 33 : aLastAddress.Sheet = nTable;
701 33 : if (nCurrentTable != nTable)
702 : {
703 33 : nCurrentTable = nTable;
704 :
705 : mpCellItr.reset(
706 : new ScHorizontalCellIterator(
707 33 : rExport.GetDocument(), nCurrentTable, 0, 0,
708 33 : static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)),
709 66 : static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable))));
710 :
711 33 : xTable.set(rxTable);
712 33 : xCellRange.set(xTable, uno::UNO_QUERY);
713 : }
714 33 : }
715 :
716 0 : void ScMyNotEmptyCellsIterator::SkipTable(SCTAB nSkip)
717 : {
718 : // Skip entries for a sheet that is copied instead of saving normally.
719 : // Cells are handled separately in SetCurrentTable.
720 :
721 0 : if( pShapes )
722 0 : pShapes->SkipTable(nSkip);
723 0 : if( pNoteShapes )
724 0 : pNoteShapes->SkipTable(nSkip);
725 0 : if( pEmptyDatabaseRanges )
726 0 : pEmptyDatabaseRanges->SkipTable(nSkip);
727 0 : if( pMergedRanges )
728 0 : pMergedRanges->SkipTable(nSkip);
729 0 : if( pAreaLinks )
730 0 : pAreaLinks->SkipTable(nSkip);
731 0 : if( pDetectiveObj )
732 0 : pDetectiveObj->SkipTable(nSkip);
733 0 : if( pDetectiveOp )
734 0 : pDetectiveOp->SkipTable(nSkip);
735 0 : }
736 :
737 388 : bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles)
738 : {
739 388 : table::CellAddress aAddress( nCurrentTable, MAXCOL + 1, MAXROW + 1 );
740 :
741 388 : UpdateAddress( aAddress );
742 :
743 388 : if( pShapes )
744 8 : pShapes->UpdateAddress( aAddress );
745 388 : if( pNoteShapes )
746 3 : pNoteShapes->UpdateAddress( aAddress );
747 388 : if( pEmptyDatabaseRanges )
748 388 : pEmptyDatabaseRanges->UpdateAddress( aAddress );
749 388 : if( pMergedRanges )
750 388 : pMergedRanges->UpdateAddress( aAddress );
751 388 : if( pAreaLinks )
752 388 : pAreaLinks->UpdateAddress( aAddress );
753 388 : if( pDetectiveObj )
754 388 : pDetectiveObj->UpdateAddress( aAddress );
755 388 : if( pDetectiveOp )
756 388 : pDetectiveOp->UpdateAddress( aAddress );
757 :
758 388 : bool bFoundCell((aAddress.Column <= MAXCOL) && (aAddress.Row <= MAXROW));
759 388 : if( bFoundCell )
760 : {
761 355 : SetCellData( aCell, aAddress );
762 355 : if( pShapes )
763 4 : pShapes->SetCellData( aCell );
764 355 : if( pNoteShapes )
765 2 : pNoteShapes->SetCellData( aCell );
766 355 : if( pEmptyDatabaseRanges )
767 355 : pEmptyDatabaseRanges->SetCellData( aCell );
768 355 : if( pMergedRanges )
769 355 : pMergedRanges->SetCellData( aCell );
770 355 : if( pAreaLinks )
771 355 : pAreaLinks->SetCellData( aCell );
772 355 : if( pDetectiveObj )
773 355 : pDetectiveObj->SetCellData( aCell );
774 355 : if( pDetectiveOp )
775 355 : pDetectiveOp->SetCellData( aCell );
776 :
777 355 : HasAnnotation( aCell );
778 : bool bIsAutoStyle;
779 : // Ranges before the previous cell are not needed by ExportFormatRanges anymore and can be removed
780 355 : sal_Int32 nRemoveBeforeRow = aLastAddress.Row;
781 355 : aCell.nStyleIndex = pCellStyles->GetStyleNameIndex(aCell.maCellAddress.Tab(),
782 355 : aCell.maCellAddress.Col(), aCell.maCellAddress.Row(),
783 1065 : bIsAutoStyle, aCell.nValidationIndex, aCell.nNumberFormat, nRemoveBeforeRow);
784 355 : aLastAddress = aCell.aCellAddress;
785 355 : aCell.bIsAutoStyle = bIsAutoStyle;
786 :
787 : //#102799#; if the cell is in a DatabaseRange which should saved empty, the cell should have the type empty
788 355 : if (aCell.bHasEmptyDatabase)
789 0 : aCell.nType = table::CellContentType_EMPTY;
790 : }
791 388 : return bFoundCell;
792 156 : }
793 :
794 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|