LibreOffice Module sc (master) 1
XMLTrackedChangesContext.cxx
Go to the documentation of this file.
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 <memory>
23#include "xmlimprt.hxx"
24#include "xmlconti.hxx"
25#include <formulacell.hxx>
26#include <textuno.hxx>
27#include <editutil.hxx>
28#include <document.hxx>
29#include <utility>
30#include <xmloff/xmltoken.hxx>
32#include <xmloff/xmluconv.hxx>
35#include <comphelper/base64.hxx>
36#include <com/sun/star/text/XTextCursor.hpp>
37#include <com/sun/star/text/ControlCharacter.hpp>
38
39using namespace com::sun::star;
40using namespace xmloff::token;
41
42namespace {
43
44class ScXMLChangeInfoContext : public ScXMLImportContext
45{
46 ScMyActionInfo aInfo;
47 OUStringBuffer sAuthorBuffer{32};
48 OUStringBuffer sDateTimeBuffer{32};
49 OUStringBuffer sCommentBuffer{64};
50 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
51 sal_uInt32 nParagraphCount;
52
53public:
54 ScXMLChangeInfoContext( ScXMLImport& rImport,
56 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
57
58 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
59 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
60
61 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
62};
63
64class ScXMLBigRangeContext : public ScXMLImportContext
65{
66public:
67 ScXMLBigRangeContext( ScXMLImport& rImport,
69 ScBigRange& rBigRange);
70};
71
72class ScXMLCellContentDeletionContext : public ScXMLImportContext
73{
74 OUString sFormulaAddress;
75 OUString sFormula;
76 OUString sFormulaNmsp;
77 OUString sInputString;
78 ScBigRange aBigRange;
79 double fValue;
80 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
81 ScCellValue maCell;
82 sal_uInt32 nID;
83 sal_Int32 nMatrixCols;
84 sal_Int32 nMatrixRows;
86 sal_uInt16 nType;
87 ScMatrixMode nMatrixFlag;
88
89public:
90 ScXMLCellContentDeletionContext( ScXMLImport& rImport,
92 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
93
94 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
95 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
96
97 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
98};
99
100class ScXMLDependenceContext : public ScXMLImportContext
101{
102public:
103 ScXMLDependenceContext( ScXMLImport& rImport,
105 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
106};
107
108class ScXMLDependingsContext : public ScXMLImportContext
109{
110 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
111
112public:
113 ScXMLDependingsContext( ScXMLImport& rImport,
114 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
115
116 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
117 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
118};
119
120class ScXMLChangeDeletionContext : public ScXMLImportContext
121{
122public:
123 ScXMLChangeDeletionContext( ScXMLImport& rImport,
125 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
126
127};
128
129class ScXMLDeletionsContext : public ScXMLImportContext
130{
131 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
132
133public:
134 ScXMLDeletionsContext( ScXMLImport& rImport,
135 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
136
137 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
138 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
139};
140
141class ScXMLChangeCellContext;
142
143class ScXMLChangeTextPContext : public ScXMLImportContext
144{
145 css::uno::Reference< css::xml::sax::XFastAttributeList> mxAttrList;
146 sal_Int32 mnElement;
147 OUStringBuffer sText;
148 ScXMLChangeCellContext* pChangeCellContext;
150 pTextPContext;
151
152public:
153
154 ScXMLChangeTextPContext( ScXMLImport& rImport, sal_Int32 nElement,
155 css::uno::Reference<css::xml::sax::XFastAttributeList> xAttrList,
156 ScXMLChangeCellContext* pChangeCellContext);
157
158 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
159 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
160
161 virtual void SAL_CALL characters( const OUString& rChars ) override;
162
163 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
164};
165
166class ScXMLChangeCellContext : public ScXMLImportContext
167{
168 ScCellValue& mrOldCell;
169
170 OUString sText;
171 OUString& rInputString;
173 double fValue;
174 sal_uInt16& rType;
175 bool bEmpty;
176 bool bFirstParagraph;
177 bool bString;
178 bool bFormula;
179
180public:
181 ScXMLChangeCellContext( ScXMLImport& rImport,
183 ScCellValue& rOldCell, OUString& sAddress,
184 OUString& rFormula, OUString& rFormulaNmsp,
186 OUString& rInputString, double& fValue, sal_uInt16& nType,
187 ScMatrixMode& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows);
188
189 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
190 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
191
192 void CreateTextPContext(bool bIsNewParagraph);
193 bool IsEditCell() const { return mpEditTextObj.is(); }
194 void SetText(const OUString& sTempText) { sText = sTempText; }
195
196 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
197};
198
199class ScXMLPreviousContext : public ScXMLImportContext
200{
201 OUString sFormulaAddress;
202 OUString sFormula;
203 OUString sFormulaNmsp;
204 OUString sInputString;
205 double fValue;
206 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
207 ScCellValue maOldCell;
208 sal_uInt32 nID;
209 sal_Int32 nMatrixCols;
210 sal_Int32 nMatrixRows;
212 sal_uInt16 nType;
213 ScMatrixMode nMatrixFlag;
214
215public:
216 ScXMLPreviousContext( ScXMLImport& rImport,
218 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
219
220 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
221 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
222
223 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
224};
225
226class ScXMLContentChangeContext : public ScXMLImportContext
227{
228 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
229 ScBigRange aBigRange;
230
231public:
232 ScXMLContentChangeContext( ScXMLImport& rImport,
234 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
235
236 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
237 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
238
239 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
240};
241
242class ScXMLInsertionContext : public ScXMLImportContext
243{
244 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
245
246public:
247 ScXMLInsertionContext( ScXMLImport& rImport,
249 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
250
251 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
252 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
253
254 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
255};
256
257class ScXMLInsertionCutOffContext : public ScXMLImportContext
258{
259public:
260 ScXMLInsertionCutOffContext( ScXMLImport& rImport,
261 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
262 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
263};
264
265class ScXMLMovementCutOffContext : public ScXMLImportContext
266{
267public:
268 ScXMLMovementCutOffContext( ScXMLImport& rImport,
269 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
270 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
271};
272
273class ScXMLCutOffsContext : public ScXMLImportContext
274{
275 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
276
277public:
278 ScXMLCutOffsContext( ScXMLImport& rImport,
279 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
280
281 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
282 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
283};
284
285class ScXMLDeletionContext : public ScXMLImportContext
286{
287 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
288
289public:
290 ScXMLDeletionContext( ScXMLImport& rImport,
292 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
293
294 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
295 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
296
297 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
298};
299
300class ScXMLMovementContext : public ScXMLImportContext
301{
302 ScBigRange aSourceRange;
303 ScBigRange aTargetRange;
304 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
305
306public:
307 ScXMLMovementContext( ScXMLImport& rImport,
309 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
310
311 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
312 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
313
314 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
315};
316
317class ScXMLRejectionContext : public ScXMLImportContext
318{
319 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
320
321public:
322 ScXMLRejectionContext( ScXMLImport& rImport,
324 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
325
326 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
327 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
328
329 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
330};
331
332}
333
336 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
337 ScXMLImportContext( rImport ),
338 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
339{
340 rImport.LockSolarMutex();
341
342 if ( !rAttrList.is() )
343 return;
344
345 auto aIter( rAttrList->find( XML_ELEMENT( TABLE, XML_PROTECTION_KEY ) ) );
346 if (aIter != rAttrList->end())
347 {
348 if( !aIter.isEmpty() )
349 {
350 uno::Sequence<sal_Int8> aPass;
351 ::comphelper::Base64::decode( aPass, aIter.toString() );
353 }
354 }
355}
356
358{
360}
361
362uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLTrackedChangesContext::createFastChildContext(
363 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
364{
365 SvXMLImportContext *pContext(nullptr);
368
369 switch (nElement)
370 {
372 pContext = new ScXMLContentChangeContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
373 break;
375 pContext = new ScXMLInsertionContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
376 break;
378 pContext = new ScXMLDeletionContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
379 break;
381 pContext = new ScXMLMovementContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
382 break;
384 pContext = new ScXMLRejectionContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
385 break;
386 }
387
388 return pContext;
389}
390
391ScXMLChangeInfoContext::ScXMLChangeInfoContext( ScXMLImport& rImport,
393 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
394 ScXMLImportContext( rImport ),
395 aInfo(),
396 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
397 nParagraphCount(0)
398{
399 if ( rAttrList.is() )
400 {
401 for (auto &aIter : *rAttrList)
402 {
403 sal_Int32 nToken = aIter.getToken();
404 if ( nToken == XML_ELEMENT( OFFICE, XML_CHG_AUTHOR ) )
405 sAuthorBuffer = aIter.toString();
406 else if ( nToken == XML_ELEMENT( OFFICE, XML_CHG_DATE_TIME ) )
407 sDateTimeBuffer = aIter.toString();
408 }
409 }
410}
411
412css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLChangeInfoContext::createFastChildContext(
413 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ )
414{
415 SvXMLImportContext *pContext(nullptr);
416
417 if( nElement == XML_ELEMENT(DC, XML_CREATOR ) )
418 pContext = new ScXMLContentContext(GetScImport(), sAuthorBuffer);
419 else if( nElement == XML_ELEMENT(DC, XML_DATE ) )
420 pContext = new ScXMLContentContext(GetScImport(), sDateTimeBuffer);
421 else if (nElement == XML_ELEMENT(TEXT, XML_P))
422 {
423 if(nParagraphCount)
424 sCommentBuffer.append('\n');
425 ++nParagraphCount;
426 pContext = new ScXMLContentContext( GetScImport(), sCommentBuffer);
427 }
428
429 return pContext;
430}
431
432void SAL_CALL ScXMLChangeInfoContext::endFastElement( sal_Int32 /*nElement*/ )
433{
434 aInfo.sUser = sAuthorBuffer.makeStringAndClear();
435 if (!::sax::Converter::parseDateTime(aInfo.aDateTime, sDateTimeBuffer))
436 SAL_WARN("sc.filter", "ScXMLChangeInfoContext: broken DateTime '" << sDateTimeBuffer.toString() << "'");
437 sDateTimeBuffer.setLength(0);
438 aInfo.sComment = sCommentBuffer.makeStringAndClear();
439 pChangeTrackingImportHelper->SetActionInfo(aInfo);
440}
441
442ScXMLBigRangeContext::ScXMLBigRangeContext( ScXMLImport& rImport,
444 ScBigRange& rBigRange ) :
445 ScXMLImportContext( rImport )
446{
447 bool bColumn(false);
448 bool bRow(false);
449 bool bTable(false);
450 sal_Int32 nColumn(0);
451 sal_Int32 nRow(0);
452 sal_Int32 nTable(0);
453 sal_Int32 nStartColumn(0);
454 sal_Int32 nEndColumn(0);
455 sal_Int32 nStartRow(0);
456 sal_Int32 nEndRow(0);
457 sal_Int32 nStartTable(0);
458 sal_Int32 nEndTable(0);
459 if ( rAttrList.is() )
460 {
461 for (auto &aIter : *rAttrList)
462 {
463 switch (aIter.getToken())
464 {
465 case XML_ELEMENT( TABLE, XML_COLUMN ):
466 nColumn = aIter.toInt32();
467 bColumn = true;
468 break;
469 case XML_ELEMENT( TABLE, XML_ROW ):
470 nRow = aIter.toInt32();
471 bRow = true;
472 break;
473 case XML_ELEMENT( TABLE, XML_TABLE ):
474 nTable = aIter.toInt32();
475 bTable = true;
476 break;
477 case XML_ELEMENT( TABLE, XML_START_COLUMN ):
478 nStartColumn = aIter.toInt32();
479 break;
480 case XML_ELEMENT( TABLE, XML_END_COLUMN ):
481 nEndColumn = aIter.toInt32();
482 break;
483 case XML_ELEMENT( TABLE, XML_START_ROW ):
484 nStartRow = aIter.toInt32();
485 break;
486 case XML_ELEMENT( TABLE, XML_END_ROW ):
487 nEndRow = aIter.toInt32();
488 break;
489 case XML_ELEMENT( TABLE, XML_START_TABLE ):
490 nStartTable = aIter.toInt32();
491 break;
492 case XML_ELEMENT( TABLE, XML_END_TABLE ):
493 nEndTable = aIter.toInt32();
494 break;
495 }
496 }
497 }
498
499 if (bColumn)
500 nStartColumn = nEndColumn = nColumn;
501 if (bRow)
502 nStartRow = nEndRow = nRow;
503 if (bTable)
504 nStartTable = nEndTable = nTable;
505 rBigRange.Set(nStartColumn, nStartRow, nStartTable,
506 nEndColumn, nEndRow, nEndTable);
507}
508
509ScXMLCellContentDeletionContext::ScXMLCellContentDeletionContext( ScXMLImport& rImport,
511 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper) :
512 ScXMLImportContext( rImport ),
513 fValue(0.0),
514 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
515 nID(0),
516 nMatrixCols(0),
517 nMatrixRows(0),
518 eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT),
519 nType(css::util::NumberFormat::ALL),
520 nMatrixFlag(ScMatrixMode::NONE)
521{
522 if ( rAttrList.is() )
523 {
524 auto aIter( rAttrList->find( XML_ELEMENT( TABLE, XML_ID ) ) );
525 if (aIter != rAttrList->end())
527 }
528}
529
530uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCellContentDeletionContext::createFastChildContext(
531 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
532{
533 SvXMLImportContext *pContext(nullptr);
536
537 switch (nElement)
538 {
539 case XML_ELEMENT( TABLE, XML_CHANGE_TRACK_TABLE_CELL ):
540 pContext = new ScXMLChangeCellContext(GetScImport(), pAttribList,
541 maCell, sFormulaAddress, sFormula, sFormulaNmsp, eGrammar, sInputString, fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows );
542 break;
543 case XML_ELEMENT( TABLE, XML_CELL_ADDRESS ):
544 OSL_ENSURE(!nID, "a action with a ID should not contain a BigRange");
545 pContext = new ScXMLBigRangeContext(GetScImport(), pAttribList, aBigRange);
546 break;
547 }
548
549 return pContext;
550}
551
552void SAL_CALL ScXMLCellContentDeletionContext::endFastElement( sal_Int32 /*nElement*/ )
553{
554 std::unique_ptr<ScMyCellInfo> pCellInfo(new ScMyCellInfo(maCell, sFormulaAddress, sFormula, eGrammar, sInputString, fValue, nType,
555 nMatrixFlag, nMatrixCols, nMatrixRows));
556 if (nID)
557 pChangeTrackingImportHelper->AddDeleted(nID, std::move(pCellInfo));
558 else
559 pChangeTrackingImportHelper->AddGenerated(std::move(pCellInfo), aBigRange);
560}
561
562ScXMLDependenceContext::ScXMLDependenceContext( ScXMLImport& rImport,
564 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper ) :
565 ScXMLImportContext( rImport )
566{
567 sal_uInt32 nID(0);
568 if ( rAttrList.is() )
569 {
570 auto aIter( rAttrList->find( XML_ELEMENT( TABLE, XML_ID ) ) );
571 if (aIter != rAttrList->end())
573 }
575}
576
577ScXMLDependingsContext::ScXMLDependingsContext( ScXMLImport& rImport,
578 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
579 ScXMLImportContext( rImport ),
580 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
581{
582 // here are no attributes
583}
584
585uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLDependingsContext::createFastChildContext(
586 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
587{
588 SvXMLImportContext *pContext(nullptr);
591
592 // #i80033# read both old (dependence) and new (dependency) elements
593 if (nElement == XML_ELEMENT( TABLE, XML_DEPENDENCE ) ||
594 nElement == XML_ELEMENT( TABLE, XML_DEPENDENCY ))
595 {
596 pContext = new ScXMLDependenceContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
597 }
598
599 return pContext;
600}
601
602ScXMLChangeDeletionContext::ScXMLChangeDeletionContext( ScXMLImport& rImport,
604 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper ) :
605 ScXMLImportContext( rImport )
606{
607 sal_uInt32 nID(0);
608 if ( rAttrList.is() )
609 {
610 auto aIter( rAttrList->find( XML_ELEMENT( TABLE, XML_ID ) ) );
611 if (aIter != rAttrList->end())
613 }
615}
616
617ScXMLDeletionsContext::ScXMLDeletionsContext( ScXMLImport& rImport,
618 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
619 ScXMLImportContext( rImport ),
620 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
621{
622 // here are no attributes
623}
624
625uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLDeletionsContext::createFastChildContext(
626 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
627{
628 SvXMLImportContext *pContext(nullptr);
631
632 switch (nElement)
633 {
634 case XML_ELEMENT( TABLE, XML_CHANGE_DELETION ):
635 pContext = new ScXMLChangeDeletionContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
636 break;
637 case XML_ELEMENT( TABLE, XML_CELL_CONTENT_DELETION ):
638 pContext = new ScXMLCellContentDeletionContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
639 break;
640 }
641
642 return pContext;
643}
644
645ScXMLChangeTextPContext::ScXMLChangeTextPContext( ScXMLImport& rImport,
646 sal_Int32 nElement,
647 css::uno::Reference<css::xml::sax::XFastAttributeList> xAttrList,
648 ScXMLChangeCellContext* pTempChangeCellContext) :
649 ScXMLImportContext( rImport ),
650 mxAttrList(std::move(xAttrList)),
651 mnElement(nElement),
652 pChangeCellContext(pTempChangeCellContext)
653{
654 // here are no attributes
655}
656
657uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLChangeTextPContext::createFastChildContext(
658 sal_Int32 nElement,
659 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
660{
661 uno::Reference< xml::sax::XFastContextHandler > xContext;
662 if (IsTokenInNamespace(mnElement, XML_NAMESPACE_TEXT)
663 && (nElement & TOKEN_MASK) == XML_S
664 && !pTextPContext)
665 {
666 sal_Int32 nRepeat(0);
667 for( auto& aIter : sax_fastparser::castToFastAttributeList(mxAttrList) )
668 {
669 if (aIter.getToken() == XML_ELEMENT(TEXT, XML_C))
670 nRepeat = aIter.toInt32();
671 else
672 XMLOFF_WARN_UNKNOWN("sc", aIter);
673 }
674 if (nRepeat)
675 for (sal_Int32 j = 0; j < nRepeat; ++j)
676 sText.append(' ');
677 else
678 sText.append(' ');
679 }
680 else
681 {
682 if (!pChangeCellContext->IsEditCell())
683 pChangeCellContext->CreateTextPContext(false);
684 bool bWasContext (true);
685 if (!pTextPContext)
686 {
687 bWasContext = false;
688 pTextPContext = GetScImport().GetTextImport()->CreateTextChildContext(
689 GetScImport(), mnElement, mxAttrList);
690 }
691 if (pTextPContext)
692 {
693 if (!bWasContext)
694 pTextPContext->characters(sText.makeStringAndClear());
695 xContext = pTextPContext->createFastChildContext(nElement, xAttrList);
696 }
697 }
698
699 return xContext;
700}
701
702void ScXMLChangeTextPContext::characters( const OUString& rChars )
703{
704 if (!pTextPContext)
705 sText.append(rChars);
706 else
707 pTextPContext->characters(rChars);
708}
709
710void ScXMLChangeTextPContext::endFastElement(sal_Int32 /*nElement*/)
711{
712 if (!pTextPContext)
713 pChangeCellContext->SetText(sText.makeStringAndClear());
714}
715
716ScXMLChangeCellContext::ScXMLChangeCellContext( ScXMLImport& rImport,
718 ScCellValue& rOldCell, OUString& rAddress,
719 OUString& rFormula, OUString& rFormulaNmsp,
721 OUString& rTempInputString, double& rDateTimeValue, sal_uInt16& nType,
722 ScMatrixMode& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows )
723 : ScXMLImportContext( rImport )
724 , mrOldCell(rOldCell)
725 , rInputString(rTempInputString)
726 , fValue(0.0)
727 , rType(nType)
728 , bEmpty(true)
729 , bFirstParagraph(true)
730 , bString(true)
731 , bFormula(false)
732{
733 bool bIsMatrix(false);
734 bool bIsCoveredMatrix(false);
735 if ( rAttrList.is() )
736 {
737 for (auto &aIter : *rAttrList)
738 {
739 switch (aIter.getToken())
740 {
741 case XML_ELEMENT( TABLE, XML_FORMULA ):
742 bEmpty = false;
743 GetScImport().ExtractFormulaNamespaceGrammar( rFormula, rFormulaNmsp, rGrammar, aIter.toString() );
744 bFormula = true;
745 break;
746 case XML_ELEMENT( TABLE, XML_CELL_ADDRESS ):
747 rAddress = aIter.toString();
748 break;
749 case XML_ELEMENT( TABLE, XML_MATRIX_COVERED ):
750 bIsCoveredMatrix = IsXMLToken(aIter, XML_TRUE);
751 break;
752 case XML_ELEMENT( TABLE, XML_NUMBER_MATRIX_COLUMNS_SPANNED ):
753 bIsMatrix = true;
754 nMatrixCols = aIter.toInt32();
755 break;
756 case XML_ELEMENT( TABLE, XML_NUMBER_MATRIX_ROWS_SPANNED ):
757 bIsMatrix = true;
758 nMatrixRows = aIter.toInt32();
759 break;
760 case XML_ELEMENT( OFFICE, XML_VALUE_TYPE ):
761 if (IsXMLToken(aIter, XML_FLOAT))
762 bString = false;
763 else if (IsXMLToken(aIter, XML_DATE))
764 {
766 bString = false;
767 }
768 else if (IsXMLToken(aIter, XML_TIME))
769 {
770 rType = css::util::NumberFormat::TIME;
771 bString = false;
772 }
773 break;
774 case XML_ELEMENT( OFFICE, XML_VALUE ):
775 fValue = aIter.toDouble();
776 bEmpty = false;
777 break;
778 case XML_ELEMENT( OFFICE, XML_DATE_VALUE ):
779 bEmpty = false;
780 if (GetScImport().GetMM100UnitConverter().setNullDate(GetScImport().GetModel()))
781 GetScImport().GetMM100UnitConverter().convertDateTime(rDateTimeValue, aIter.toView());
782 fValue = rDateTimeValue;
783 break;
784 case XML_ELEMENT( OFFICE, XML_TIME_VALUE ):
785 bEmpty = false;
786 ::sax::Converter::convertDuration(rDateTimeValue, aIter.toView());
787 fValue = rDateTimeValue;
788 }
789 }
790 }
791
792 if (bIsCoveredMatrix)
793 nMatrixFlag = ScMatrixMode::Reference;
794 else if (bIsMatrix && nMatrixRows && nMatrixCols)
795 nMatrixFlag = ScMatrixMode::Formula;
796}
797
798uno::Reference< xml::sax::XFastContextHandler > ScXMLChangeCellContext::createFastChildContext(
799 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
800{
801 SvXMLImportContext *pContext(nullptr);
802
803 if (nElement == XML_ELEMENT(TEXT, XML_P))
804 {
805 bEmpty = false;
806 if (bFirstParagraph)
807 {
808 pContext = new ScXMLChangeTextPContext(GetScImport(), nElement, xAttrList, this);
809 bFirstParagraph = false;
810 }
811 else
812 {
813 if (!mpEditTextObj.is())
814 CreateTextPContext(true);
815 pContext = GetScImport().GetTextImport()->CreateTextChildContext(
816 GetScImport(), nElement, xAttrList);
817 }
818 }
819 else
820 XMLOFF_WARN_UNKNOWN_ELEMENT("sc", nElement);
821
822 return pContext;
823}
824
825void ScXMLChangeCellContext::CreateTextPContext(bool bIsNewParagraph)
826{
827 if (!GetScImport().GetDocument())
828 return;
829
830 mpEditTextObj = new ScEditEngineTextObj();
831 mpEditTextObj->GetEditEngine()->SetEditTextObjectPool(GetScImport().GetDocument()->GetEditPool());
832 uno::Reference <text::XText> xText(mpEditTextObj);
833 if (xText.is())
834 {
835 uno::Reference<text::XTextCursor> xTextCursor(xText->createTextCursor());
836 if (bIsNewParagraph)
837 {
838 xText->setString(sText);
839 xTextCursor->gotoEnd(false);
840 xText->insertControlCharacter(xTextCursor, text::ControlCharacter::PARAGRAPH_BREAK, false);
841 }
842 GetScImport().GetTextImport()->SetCursor(xTextCursor);
843 }
844}
845
846void SAL_CALL ScXMLChangeCellContext::endFastElement( sal_Int32 /*nElement*/ )
847{
848 if (!bEmpty)
849 {
850 ScDocument* pDoc = GetScImport().GetDocument();
851 if (mpEditTextObj.is())
852 {
853 if (GetImport().GetTextImport()->GetCursor().is())
854 {
855 //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False);
856 if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, true ) )
857 {
858 GetImport().GetTextImport()->GetText()->insertString(
859 GetImport().GetTextImport()->GetCursorAsRange(), "",
860 true );
861 }
862 }
863
864 // The cell will own the text object instance.
865 mrOldCell.set(mpEditTextObj->CreateTextObject());
866 GetScImport().GetTextImport()->ResetCursor();
867 mpEditTextObj.clear();
868 }
869 else
870 {
871 if (!bFormula)
872 {
873 if (!sText.isEmpty() && bString)
874 {
875 mrOldCell.set(pDoc->GetSharedStringPool().intern(sText));
876 }
877 else
878 {
879 mrOldCell.set(fValue);
880 }
881 if (rType == css::util::NumberFormat::DATE || rType == css::util::NumberFormat::TIME)
882 rInputString = sText;
883 }
884 }
885 }
886 else
887 mrOldCell.clear();
888}
889
890ScXMLPreviousContext::ScXMLPreviousContext( ScXMLImport& rImport,
892 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
893 ScXMLImportContext( rImport ),
894 fValue(0.0),
895 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
896 nID(0),
897 nMatrixCols(0),
898 nMatrixRows(0),
899 eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT),
900 nType(css::util::NumberFormat::ALL),
901 nMatrixFlag(ScMatrixMode::NONE)
902{
903 if ( rAttrList.is() )
904 {
905 auto aIter( rAttrList->find( XML_ELEMENT( TABLE, XML_ID ) ) );
906 if (aIter != rAttrList->end())
908 }
909}
910
911uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLPreviousContext::createFastChildContext(
912 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
913{
914 SvXMLImportContext *pContext(nullptr);
917
918 if ( nElement == XML_ELEMENT( TABLE, XML_CHANGE_TRACK_TABLE_CELL ) )
919 pContext = new ScXMLChangeCellContext(GetScImport(), pAttribList,
920 maOldCell, sFormulaAddress, sFormula, sFormulaNmsp, eGrammar, sInputString, fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows);
921
922 return pContext;
923}
924
925void SAL_CALL ScXMLPreviousContext::endFastElement( sal_Int32 /*nElement*/ )
926{
927 pChangeTrackingImportHelper->SetPreviousChange(nID, new ScMyCellInfo(maOldCell, sFormulaAddress, sFormula, eGrammar, sInputString,
928 fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows));
929}
930
931ScXMLContentChangeContext::ScXMLContentChangeContext( ScXMLImport& rImport,
933 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
934 ScXMLImportContext( rImport ),
935 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
936{
937 sal_uInt32 nActionNumber(0);
938 sal_uInt32 nRejectingNumber(0);
940
941 if ( rAttrList.is() )
942 {
943 for (auto &aIter : *rAttrList)
944 {
945 switch (aIter.getToken())
946 {
947 case XML_ELEMENT( TABLE, XML_ID ):
948 nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
949 break;
950 case XML_ELEMENT( TABLE, XML_ACCEPTANCE_STATE ):
951 if (IsXMLToken( aIter, XML_ACCEPTED ))
952 nActionState = SC_CAS_ACCEPTED;
953 else if (IsXMLToken( aIter, XML_REJECTED ))
954 nActionState = SC_CAS_REJECTED;
955 break;
956 case XML_ELEMENT( TABLE, XML_REJECTING_CHANGE_ID ):
957 nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
958 }
959 }
960 }
961
966}
967
968uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentChangeContext::createFastChildContext(
969 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
970{
971 SvXMLImportContext *pContext(nullptr);
974
975 switch (nElement)
976 {
977 case XML_ELEMENT( OFFICE, XML_CHANGE_INFO ):
978 pContext = new ScXMLChangeInfoContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
979 break;
980 case XML_ELEMENT( TABLE, XML_CELL_ADDRESS ):
981 pContext = new ScXMLBigRangeContext(GetScImport(), pAttribList, aBigRange);
982 break;
983 case XML_ELEMENT( TABLE, XML_DEPENDENCIES ):
984 pContext = new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper);
985 break;
986 case XML_ELEMENT( TABLE, XML_DELETIONS ):
987 pContext = new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper);
988 break;
989 case XML_ELEMENT( TABLE, XML_PREVIOUS ):
990 pContext = new ScXMLPreviousContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
991 break;
992 }
993
994 return pContext;
995}
996
997void SAL_CALL ScXMLContentChangeContext::endFastElement( sal_Int32 /*nElement*/ )
998{
999 pChangeTrackingImportHelper->SetBigRange(aBigRange);
1000 pChangeTrackingImportHelper->EndChangeAction();
1001}
1002
1003ScXMLInsertionContext::ScXMLInsertionContext( ScXMLImport& rImport,
1005 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1006 ScXMLImportContext( rImport ),
1007 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1008{
1009 sal_uInt32 nActionNumber(0);
1010 sal_uInt32 nRejectingNumber(0);
1011 sal_Int32 nPosition(0);
1012 sal_Int32 nCount(1);
1013 sal_Int32 nTable(0);
1014 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1016
1017 if ( rAttrList.is() )
1018 {
1019 for (auto &aIter : *rAttrList)
1020 {
1021 switch (aIter.getToken())
1022 {
1023 case XML_ELEMENT( TABLE, XML_ID ):
1024 nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
1025 break;
1026 case XML_ELEMENT( TABLE, XML_ACCEPTANCE_STATE ):
1027 if (IsXMLToken( aIter, XML_ACCEPTED ))
1028 nActionState = SC_CAS_ACCEPTED;
1029 else if (IsXMLToken( aIter, XML_REJECTED ))
1030 nActionState = SC_CAS_REJECTED;
1031 break;
1032 case XML_ELEMENT( TABLE, XML_REJECTING_CHANGE_ID ):
1033 nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
1034 break;
1035 case XML_ELEMENT( TABLE, XML_TYPE ):
1036 if (IsXMLToken( aIter, XML_ROW ))
1037 nActionType = SC_CAT_INSERT_ROWS;
1038 else if (IsXMLToken( aIter, XML_TABLE ))
1039 nActionType = SC_CAT_INSERT_TABS;
1040 break;
1041 case XML_ELEMENT( TABLE, XML_POSITION ):
1042 nPosition = aIter.toInt32();
1043 break;
1044 case XML_ELEMENT( TABLE, XML_TABLE ):
1045 nTable = aIter.toInt32();
1046 break;
1047 case XML_ELEMENT( TABLE, XML_COUNT ):
1048 nCount = aIter.toInt32();
1049 break;
1050 }
1051 }
1052 }
1053
1058 pChangeTrackingImportHelper->SetPosition(nPosition, nCount, nTable);
1059}
1060
1061uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLInsertionContext::createFastChildContext(
1062 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
1063{
1064 SvXMLImportContext *pContext(nullptr);
1067
1068 switch (nElement)
1069 {
1070 case XML_ELEMENT( OFFICE, XML_CHANGE_INFO ):
1071 pContext = new ScXMLChangeInfoContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
1072 break;
1073 case XML_ELEMENT( TABLE, XML_DEPENDENCIES ):
1074 pContext = new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper);
1075 break;
1076 case XML_ELEMENT( TABLE, XML_DELETIONS ):
1077 pContext = new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper);
1078 break;
1079 }
1080
1081 return pContext;
1082}
1083
1084void SAL_CALL ScXMLInsertionContext::endFastElement( sal_Int32 /*nElement*/ )
1085{
1086 pChangeTrackingImportHelper->EndChangeAction();
1087}
1088
1089ScXMLInsertionCutOffContext::ScXMLInsertionCutOffContext( ScXMLImport& rImport,
1090 const uno::Reference<xml::sax::XFastAttributeList>& xAttrList,
1091 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper ) :
1092 ScXMLImportContext( rImport )
1093{
1094 sal_uInt32 nID(0);
1095 sal_Int32 nPosition(0);
1096 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
1097 {
1098 switch (aIter.getToken())
1099 {
1100 case XML_ELEMENT(TABLE, XML_ID):
1101 nID = ScXMLChangeTrackingImportHelper::GetIDFromString(aIter.toView());
1102 break;
1103 case XML_ELEMENT(TABLE, XML_POSITION):
1104 ::sax::Converter::convertNumber(nPosition, aIter.toView());
1105 break;
1106 }
1107 }
1109}
1110
1111
1112ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport& rImport,
1113 const uno::Reference<xml::sax::XFastAttributeList>& xAttrList,
1114 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper ) :
1115 ScXMLImportContext( rImport )
1116{
1117 sal_uInt32 nID(0);
1118 sal_Int32 nPosition(0);
1119 sal_Int32 nStartPosition(0);
1120 sal_Int32 nEndPosition(0);
1121 bool bPosition(false);
1122 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
1123 {
1124 switch (aIter.getToken())
1125 {
1126 case XML_ELEMENT(TABLE, XML_ID):
1127 nID = ScXMLChangeTrackingImportHelper::GetIDFromString(aIter.toView());
1128 break;
1129 case XML_ELEMENT(TABLE, XML_POSITION):
1130 bPosition = true;
1131 ::sax::Converter::convertNumber(nPosition, aIter.toView());
1132 break;
1133 case XML_ELEMENT(TABLE, XML_START_POSITION):
1134 ::sax::Converter::convertNumber(nStartPosition, aIter.toView());
1135 break;
1136 case XML_ELEMENT(TABLE, XML_END_POSITION):
1137 ::sax::Converter::convertNumber(nEndPosition, aIter.toView());
1138 break;
1139 }
1140 }
1141 if (bPosition)
1142 nStartPosition = nEndPosition = nPosition;
1143 pChangeTrackingImportHelper->AddMoveCutOff(nID, nStartPosition, nEndPosition);
1144}
1145
1146ScXMLCutOffsContext::ScXMLCutOffsContext( ScXMLImport& rImport,
1147 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1148 ScXMLImportContext( rImport ),
1149 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1150{
1151 // here are no attributes
1152}
1153
1154css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLCutOffsContext::createFastChildContext(
1155 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1156{
1157 SvXMLImportContext *pContext(nullptr);
1158
1159 if (nElement == XML_ELEMENT(TABLE, XML_INSERTION_CUT_OFF))
1160 pContext = new ScXMLInsertionCutOffContext(GetScImport(), xAttrList, pChangeTrackingImportHelper);
1161 else if (nElement == XML_ELEMENT(TABLE, XML_MOVEMENT_CUT_OFF))
1162 pContext = new ScXMLMovementCutOffContext(GetScImport(), xAttrList, pChangeTrackingImportHelper);
1163
1164 return pContext;
1165}
1166
1167ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport& rImport,
1169 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1170 ScXMLImportContext( rImport ),
1171 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1172{
1173 sal_uInt32 nActionNumber(0);
1174 sal_uInt32 nRejectingNumber(0);
1175 sal_Int32 nPosition(0);
1176 sal_Int32 nMultiSpanned(0);
1177 sal_Int32 nTable(0);
1178 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1180
1181 if ( rAttrList.is() )
1182 {
1183 for (auto &aIter : *rAttrList)
1184 {
1185 sal_Int32 nToken = aIter.getToken();
1186 switch (nToken)
1187 {
1188 case XML_ELEMENT( TABLE, XML_ID ):
1189 nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
1190 break;
1191 case XML_ELEMENT( TABLE, XML_ACCEPTANCE_STATE ):
1192 if (IsXMLToken( aIter, XML_ACCEPTED ))
1193 nActionState = SC_CAS_ACCEPTED;
1194 else if (IsXMLToken( aIter, XML_REJECTED ))
1195 nActionState = SC_CAS_REJECTED;
1196 break;
1197 case XML_ELEMENT( TABLE, XML_REJECTING_CHANGE_ID ):
1198 nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
1199 break;
1200 case XML_ELEMENT( TABLE, XML_TYPE ):
1201 if (IsXMLToken( aIter, XML_ROW ))
1202 nActionType = SC_CAT_DELETE_ROWS;
1203 else if (IsXMLToken( aIter, XML_TABLE ))
1204 nActionType = SC_CAT_DELETE_TABS;
1205 break;
1206 case XML_ELEMENT( TABLE, XML_POSITION ):
1207 nPosition = aIter.toInt32();
1208 break;
1209 case XML_ELEMENT( TABLE, XML_TABLE ):
1210 nTable = aIter.toInt32();
1211 break;
1212 case XML_ELEMENT( TABLE, XML_MULTI_DELETION_SPANNED ):
1213 nMultiSpanned = aIter.toInt32();
1214 break;
1215 }
1216 }
1217 }
1218
1223 pChangeTrackingImportHelper->SetPosition(nPosition, 1, nTable);
1224 pChangeTrackingImportHelper->SetMultiSpanned(static_cast<sal_Int16>(nMultiSpanned));
1225}
1226
1227uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLDeletionContext::createFastChildContext(
1228 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
1229{
1230 SvXMLImportContext *pContext(nullptr);
1233
1234 switch (nElement)
1235 {
1236 case XML_ELEMENT( OFFICE, XML_CHANGE_INFO ):
1237 pContext = new ScXMLChangeInfoContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
1238 break;
1239 case XML_ELEMENT( TABLE, XML_DEPENDENCIES ):
1240 pContext = new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper);
1241 break;
1242 case XML_ELEMENT( TABLE, XML_DELETIONS ):
1243 pContext = new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper);
1244 break;
1245 case XML_ELEMENT( TABLE, XML_CUT_OFFS ):
1246 case XML_ELEMENT( TABLE, XML_CUT_OFFS2 ): // cut_offs
1247 pContext = new ScXMLCutOffsContext(GetScImport(), pChangeTrackingImportHelper);
1248 }
1249
1250 return pContext;
1251}
1252
1253void SAL_CALL ScXMLDeletionContext::endFastElement( sal_Int32 /*nElement*/ )
1254{
1255 pChangeTrackingImportHelper->EndChangeAction();
1256}
1257
1258ScXMLMovementContext::ScXMLMovementContext( ScXMLImport& rImport,
1260 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1261 ScXMLImportContext( rImport ),
1262 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1263{
1264 sal_uInt32 nActionNumber(0);
1265 sal_uInt32 nRejectingNumber(0);
1266 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1267
1268 if ( rAttrList.is() )
1269 {
1270 for (auto &aIter : *rAttrList)
1271 {
1272 switch (aIter.getToken())
1273 {
1274 case XML_ELEMENT( TABLE, XML_ID ):
1275 nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
1276 break;
1277 case XML_ELEMENT( TABLE, XML_ACCEPTANCE_STATE ):
1278 if (IsXMLToken( aIter, XML_ACCEPTED ))
1279 nActionState = SC_CAS_ACCEPTED;
1280 else if (IsXMLToken( aIter, XML_REJECTED ))
1281 nActionState = SC_CAS_REJECTED;
1282 break;
1283 case XML_ELEMENT( TABLE, XML_REJECTING_CHANGE_ID ):
1284 nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
1285 break;
1286 }
1287 }
1288 }
1289
1294}
1295
1296uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLMovementContext::createFastChildContext(
1297 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
1298{
1299 SvXMLImportContext *pContext(nullptr);
1302
1303 switch (nElement)
1304 {
1305 case XML_ELEMENT( OFFICE, XML_CHANGE_INFO ):
1306 pContext = new ScXMLChangeInfoContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
1307 break;
1308 case XML_ELEMENT( TABLE, XML_DEPENDENCIES ):
1309 pContext = new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper);
1310 break;
1311 case XML_ELEMENT( TABLE, XML_DELETIONS ):
1312 pContext = new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper);
1313 break;
1314 case XML_ELEMENT( TABLE, XML_SOURCE_RANGE_ADDRESS ):
1315 pContext = new ScXMLBigRangeContext(GetScImport(), pAttribList, aSourceRange);
1316 break;
1317 case XML_ELEMENT( TABLE, XML_TARGET_RANGE_ADDRESS ):
1318 pContext = new ScXMLBigRangeContext(GetScImport(), pAttribList, aTargetRange);
1319 break;
1320 }
1321
1322 return pContext;
1323}
1324
1325void SAL_CALL ScXMLMovementContext::endFastElement( sal_Int32 /*nElement*/ )
1326{
1327 pChangeTrackingImportHelper->SetMoveRanges(aSourceRange, aTargetRange);
1328 pChangeTrackingImportHelper->EndChangeAction();
1329}
1330
1331ScXMLRejectionContext::ScXMLRejectionContext( ScXMLImport& rImport,
1333 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1334 ScXMLImportContext( rImport ),
1335 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1336{
1337 sal_uInt32 nActionNumber(0);
1338 sal_uInt32 nRejectingNumber(0);
1339 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1340
1341 if ( rAttrList.is() )
1342 {
1343 for (auto &aIter : *rAttrList)
1344 {
1345 switch (aIter.getToken())
1346 {
1347 case XML_ELEMENT( TABLE, XML_ID ):
1348 nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
1349 break;
1350 case XML_ELEMENT( TABLE, XML_ACCEPTANCE_STATE ):
1351 if (IsXMLToken( aIter, XML_ACCEPTED ))
1352 nActionState = SC_CAS_ACCEPTED;
1353 else if (IsXMLToken( aIter, XML_REJECTED ))
1354 nActionState = SC_CAS_REJECTED;
1355 break;
1356 case XML_ELEMENT( TABLE, XML_REJECTING_CHANGE_ID ):
1357 nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString( aIter.toView() );
1358 break;
1359 }
1360 }
1361 }
1362
1367}
1368
1369uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLRejectionContext::createFastChildContext(
1370 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
1371{
1372 SvXMLImportContext *pContext(nullptr);
1375
1376 switch (nElement)
1377 {
1378 case XML_ELEMENT( OFFICE, XML_CHANGE_INFO ):
1379 pContext = new ScXMLChangeInfoContext(GetScImport(), pAttribList, pChangeTrackingImportHelper);
1380 break;
1381 case XML_ELEMENT( TABLE, XML_DEPENDENCIES ):
1382 pContext = new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper);
1383 break;
1384 case XML_ELEMENT( TABLE, XML_DELETIONS ):
1385 pContext = new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper);
1386 break;
1387 }
1388
1389 return pContext;
1390}
1391
1392void SAL_CALL ScXMLRejectionContext::endFastElement( sal_Int32 /*nElement*/ )
1393{
1394 pChangeTrackingImportHelper->EndChangeAction();
1395}
1396
1397/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScChangeActionType
Definition: chgtrack.hxx:63
@ SC_CAT_MOVE
Definition: chgtrack.hxx:71
@ SC_CAT_DELETE_TABS
Definition: chgtrack.hxx:70
@ SC_CAT_INSERT_TABS
Definition: chgtrack.hxx:67
@ SC_CAT_DELETE_ROWS
Definition: chgtrack.hxx:69
@ SC_CAT_CONTENT
Definition: chgtrack.hxx:72
@ SC_CAT_DELETE_COLS
Definition: chgtrack.hxx:68
@ SC_CAT_INSERT_ROWS
Definition: chgtrack.hxx:66
@ SC_CAT_INSERT_COLS
Definition: chgtrack.hxx:65
ScChangeActionState
Definition: chgtrack.hxx:77
@ SC_CAS_REJECTED
Definition: chgtrack.hxx:80
@ SC_CAS_VIRGIN
Definition: chgtrack.hxx:78
@ SC_CAS_ACCEPTED
Definition: chgtrack.hxx:79
void Set(sal_Int64 nCol1, sal_Int64 nRow1, sal_Int64 nTab1, sal_Int64 nCol2, sal_Int64 nRow2, sal_Int64 nTab2)
Definition: bigrange.hxx:122
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:586
void SetMultiSpanned(const sal_Int16 nMultiSpanned)
static sal_uInt32 GetIDFromString(std::string_view sID)
void SetActionState(const ScChangeActionState nActionState)
void SetProtection(const css::uno::Sequence< sal_Int8 > &rProtect)
void StartChangeAction(const ScChangeActionType nActionType)
void SetActionNumber(const sal_uInt32 nActionNumber)
void AddMoveCutOff(const sal_uInt32 nID, const sal_Int32 nStartPosition, const sal_Int32 nEndPosition)
void SetRejectingNumber(const sal_uInt32 nRejectingNumber)
void SetPreviousChange(const sal_uInt32 nPreviousAction, ScMyCellInfo *pCellInfo)
void SetMoveRanges(const ScBigRange &aSourceRange, const ScBigRange &aTargetRange)
void SetBigRange(const ScBigRange &aBigRange)
void SetPosition(const sal_Int32 nPosition, const sal_Int32 nCount, const sal_Int32 nTable)
void SetInsertionCutOff(const sal_uInt32 nID, const sal_Int32 nPosition)
This class exists only to provide GetScImport() to its derived classes.
ScXMLImport & GetScImport()
void LockSolarMutex()
Definition: xmlimprt.cxx:1520
void UnlockSolarMutex()
Definition: xmlimprt.cxx:1538
void ExtractFormulaNamespaceGrammar(OUString &rFormula, OUString &rFormulaNmsp, ::formula::FormulaGrammar::Grammar &reGrammar, const OUString &rAttrValue, bool bRestrictToExternalNmsp=false) const
Extracts the formula string, the formula grammar namespace URL, and a grammar enum value from the pas...
Definition: xmlimprt.cxx:1581
ScXMLChangeTrackingImportHelper * pChangeTrackingImportHelper
virtual ~ScXMLTrackedChangesContext() override
ScXMLTrackedChangesContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList, ScXMLChangeTrackingImportHelper *pChangeTrackingImportHelper)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
virtual void SAL_CALL characters(const OUString &aChars) override
const SvXMLUnitConverter & GetMM100UnitConverter() const
void convertDateTime(OUStringBuffer &rBuffer, const double &fDateTime, bool const bAddTimeIf0AM=false)
static void decode(css::uno::Sequence< sal_Int8 > &aPass, std::u16string_view sBuffer)
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
static bool parseDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
SharedString intern(const OUString &rStr)
int nCount
virtual void SetText(const OUString &rStr) override
OString sFormula
ScMatrixMode
#define SAL_WARN(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
TABLE
double toDouble(std::u16string_view str)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
OUString toString(OptionInfo const *info)
XML_ACCEPTED
XML_REJECTION
XML_ROW
XML_TRUE
XML_DELETION
XML_INSERTION
XML_CUT_OFFS2
XML_FLOAT
XML_CELL_CONTENT_CHANGE
XML_PROTECTION_KEY
XML_MOVEMENT
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
sal_Int32 toInt32(OUString const &rStr)
DefTokenId nToken
Definition: qproform.cxx:397
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:32
@ TABLE
Definition: xmldpimp.hxx:43
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)