1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "XMLTrackedChangesContext.hxx"
22 #include "XMLChangeTrackingImportHelper.hxx"
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 <xmloff/xmltoken.hxx>
30 #include <xmloff/xmlnamespace.hxx>
31 #include <xmloff/namespacemap.hxx>
32 #include <xmloff/xmluconv.hxx>
33 #include <sax/tools/converter.hxx>
34 #include <svl/sharedstringpool.hxx>
35 #include <comphelper/base64.hxx>
36 #include <com/sun/star/text/XTextCursor.hpp>
37 #include <com/sun/star/text/ControlCharacter.hpp>
39 using namespace com::sun::star
;
40 using namespace xmloff::token
;
44 class ScXMLChangeInfoContext
: public ScXMLImportContext
47 OUStringBuffer sAuthorBuffer
{32};
48 OUStringBuffer sDateTimeBuffer
{32};
49 OUStringBuffer sCommentBuffer
{64};
50 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
51 sal_uInt32 nParagraphCount
;
54 ScXMLChangeInfoContext( ScXMLImport
& rImport
,
55 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
56 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
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
;
61 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
64 class ScXMLBigRangeContext
: public ScXMLImportContext
67 ScXMLBigRangeContext( ScXMLImport
& rImport
,
68 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
69 ScBigRange
& rBigRange
);
72 class ScXMLCellContentDeletionContext
: public ScXMLImportContext
74 OUString sFormulaAddress
;
76 OUString sFormulaNmsp
;
77 OUString sInputString
;
80 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
83 sal_Int32 nMatrixCols
;
84 sal_Int32 nMatrixRows
;
85 formula::FormulaGrammar::Grammar eGrammar
;
87 ScMatrixMode nMatrixFlag
;
90 ScXMLCellContentDeletionContext( ScXMLImport
& rImport
,
91 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
92 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
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
;
97 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
100 class ScXMLDependenceContext
: public ScXMLImportContext
103 ScXMLDependenceContext( ScXMLImport
& rImport
,
104 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
105 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
108 class ScXMLDependingsContext
: public ScXMLImportContext
110 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
113 ScXMLDependingsContext( ScXMLImport
& rImport
,
114 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
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
;
120 class ScXMLChangeDeletionContext
: public ScXMLImportContext
123 ScXMLChangeDeletionContext( ScXMLImport
& rImport
,
124 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
125 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
129 class ScXMLDeletionsContext
: public ScXMLImportContext
131 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
134 ScXMLDeletionsContext( ScXMLImport
& rImport
,
135 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
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
;
141 class ScXMLChangeCellContext
;
143 class ScXMLChangeTextPContext
: public ScXMLImportContext
145 css::uno::Reference
< css::xml::sax::XAttributeList
> xAttrList
;
147 OUStringBuffer sText
;
148 ScXMLChangeCellContext
* pChangeCellContext
;
149 rtl::Reference
<SvXMLImportContext
>
155 ScXMLChangeTextPContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
156 const OUString
& rLName
,
157 const css::uno::Reference
<css::xml::sax::XAttributeList
>& xAttrList
,
158 ScXMLChangeCellContext
* pChangeCellContext
);
160 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
,
161 const OUString
& rLocalName
,
162 const css::uno::Reference
<css::xml::sax::XAttributeList
>& xAttrList
) override
;
164 virtual void SAL_CALL
characters( const OUString
& rChars
) override
;
166 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
169 class ScXMLChangeCellContext
: public ScXMLImportContext
171 ScCellValue
& mrOldCell
;
174 OUString
& rInputString
;
175 rtl::Reference
<ScEditEngineTextObj
> mpEditTextObj
;
179 bool bFirstParagraph
;
184 ScXMLChangeCellContext( ScXMLImport
& rImport
,
185 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
186 ScCellValue
& rOldCell
, OUString
& sAddress
,
187 OUString
& rFormula
, OUString
& rFormulaNmsp
,
188 formula::FormulaGrammar::Grammar
& rGrammar
,
189 OUString
& rInputString
, double& fValue
, sal_uInt16
& nType
,
190 ScMatrixMode
& nMatrixFlag
, sal_Int32
& nMatrixCols
, sal_Int32
& nMatrixRows
);
192 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
,
193 const OUString
& rLocalName
,
194 const css::uno::Reference
<css::xml::sax::XAttributeList
>& xAttrList
) override
;
195 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
196 sal_Int32
/*nElement*/, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& /*xAttrList*/ ) override
199 void CreateTextPContext(bool bIsNewParagraph
);
200 bool IsEditCell() const { return mpEditTextObj
.is(); }
201 void SetText(const OUString
& sTempText
) { sText
= sTempText
; }
203 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
206 class ScXMLPreviousContext
: public ScXMLImportContext
208 OUString sFormulaAddress
;
210 OUString sFormulaNmsp
;
211 OUString sInputString
;
213 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
214 ScCellValue maOldCell
;
216 sal_Int32 nMatrixCols
;
217 sal_Int32 nMatrixRows
;
218 formula::FormulaGrammar::Grammar eGrammar
;
220 ScMatrixMode nMatrixFlag
;
223 ScXMLPreviousContext( ScXMLImport
& rImport
,
224 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
225 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
227 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
228 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
230 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
233 class ScXMLContentChangeContext
: public ScXMLImportContext
235 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
236 ScBigRange aBigRange
;
239 ScXMLContentChangeContext( ScXMLImport
& rImport
,
240 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
241 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
243 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
244 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
246 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
249 class ScXMLInsertionContext
: public ScXMLImportContext
251 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
254 ScXMLInsertionContext( ScXMLImport
& rImport
,
255 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
256 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
258 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
259 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
261 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
264 class ScXMLInsertionCutOffContext
: public ScXMLImportContext
267 ScXMLInsertionCutOffContext( ScXMLImport
& rImport
,
268 const css::uno::Reference
<css::xml::sax::XFastAttributeList
>& xAttrList
,
269 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
272 class ScXMLMovementCutOffContext
: public ScXMLImportContext
275 ScXMLMovementCutOffContext( ScXMLImport
& rImport
,
276 const css::uno::Reference
<css::xml::sax::XFastAttributeList
>& xAttrList
,
277 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
280 class ScXMLCutOffsContext
: public ScXMLImportContext
282 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
285 ScXMLCutOffsContext( ScXMLImport
& rImport
,
286 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
288 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
289 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
292 class ScXMLDeletionContext
: public ScXMLImportContext
294 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
297 ScXMLDeletionContext( ScXMLImport
& rImport
,
298 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
299 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
301 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
302 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
304 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
307 class ScXMLMovementContext
: public ScXMLImportContext
309 ScBigRange aSourceRange
;
310 ScBigRange aTargetRange
;
311 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
314 ScXMLMovementContext( ScXMLImport
& rImport
,
315 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
316 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
318 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
319 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
321 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
324 class ScXMLRejectionContext
: public ScXMLImportContext
326 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
329 ScXMLRejectionContext( ScXMLImport
& rImport
,
330 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
331 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
333 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
334 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
336 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
341 ScXMLTrackedChangesContext::ScXMLTrackedChangesContext( ScXMLImport
& rImport
,
342 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
343 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
344 ScXMLImportContext( rImport
),
345 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
347 rImport
.LockSolarMutex();
349 if ( !rAttrList
.is() )
352 auto aIter( rAttrList
->find( XML_ELEMENT( TABLE
, XML_PROTECTION_KEY
) ) );
353 if (aIter
!= rAttrList
->end())
355 if( !aIter
.isEmpty() )
357 uno::Sequence
<sal_Int8
> aPass
;
358 ::comphelper::Base64::decode( aPass
, aIter
.toString() );
359 pChangeTrackingImportHelper
->SetProtection(aPass
);
364 ScXMLTrackedChangesContext::~ScXMLTrackedChangesContext()
366 GetScImport().UnlockSolarMutex();
369 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLTrackedChangesContext::createFastChildContext(
370 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
372 SvXMLImportContext
*pContext(nullptr);
373 sax_fastparser::FastAttributeList
*pAttribList
=
374 &sax_fastparser::castToFastAttributeList( xAttrList
);
378 case XML_ELEMENT( TABLE
, XML_CELL_CONTENT_CHANGE
):
379 pContext
= new ScXMLContentChangeContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
381 case XML_ELEMENT( TABLE
, XML_INSERTION
):
382 pContext
= new ScXMLInsertionContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
384 case XML_ELEMENT( TABLE
, XML_DELETION
):
385 pContext
= new ScXMLDeletionContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
387 case XML_ELEMENT( TABLE
, XML_MOVEMENT
):
388 pContext
= new ScXMLMovementContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
390 case XML_ELEMENT( TABLE
, XML_REJECTION
):
391 pContext
= new ScXMLRejectionContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
398 ScXMLChangeInfoContext::ScXMLChangeInfoContext( ScXMLImport
& rImport
,
399 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
400 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
401 ScXMLImportContext( rImport
),
403 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
),
406 if ( rAttrList
.is() )
408 for (auto &aIter
: *rAttrList
)
410 sal_Int32 nToken
= aIter
.getToken();
411 if ( nToken
== XML_ELEMENT( OFFICE
, XML_CHG_AUTHOR
) )
412 sAuthorBuffer
= aIter
.toString();
413 else if ( nToken
== XML_ELEMENT( OFFICE
, XML_CHG_DATE_TIME
) )
414 sDateTimeBuffer
= aIter
.toString();
419 css::uno::Reference
< css::xml::sax::XFastContextHandler
> ScXMLChangeInfoContext::createFastChildContext(
420 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& /*xAttrList*/ )
422 SvXMLImportContext
*pContext(nullptr);
424 if( nElement
== XML_ELEMENT(DC
, XML_CREATOR
) )
425 pContext
= new ScXMLContentContext(GetScImport(), sAuthorBuffer
);
426 else if( nElement
== XML_ELEMENT(DC
, XML_DATE
) )
427 pContext
= new ScXMLContentContext(GetScImport(), sDateTimeBuffer
);
428 else if (nElement
== XML_ELEMENT(TEXT
, XML_P
))
431 sCommentBuffer
.append('\n');
433 pContext
= new ScXMLContentContext( GetScImport(), sCommentBuffer
);
439 void SAL_CALL
ScXMLChangeInfoContext::endFastElement( sal_Int32
/*nElement*/ )
441 aInfo
.sUser
= sAuthorBuffer
.makeStringAndClear();
442 ::sax::Converter::parseDateTime(aInfo
.aDateTime
,
443 sDateTimeBuffer
.makeStringAndClear());
444 aInfo
.sComment
= sCommentBuffer
.makeStringAndClear();
445 pChangeTrackingImportHelper
->SetActionInfo(aInfo
);
448 ScXMLBigRangeContext::ScXMLBigRangeContext( ScXMLImport
& rImport
,
449 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
450 ScBigRange
& rBigRange
) :
451 ScXMLImportContext( rImport
)
456 sal_Int32
nColumn(0);
459 sal_Int32
nStartColumn(0);
460 sal_Int32
nEndColumn(0);
461 sal_Int32
nStartRow(0);
462 sal_Int32
nEndRow(0);
463 sal_Int32
nStartTable(0);
464 sal_Int32
nEndTable(0);
465 if ( rAttrList
.is() )
467 for (auto &aIter
: *rAttrList
)
469 switch (aIter
.getToken())
471 case XML_ELEMENT( TABLE
, XML_COLUMN
):
472 nColumn
= aIter
.toInt32();
475 case XML_ELEMENT( TABLE
, XML_ROW
):
476 nRow
= aIter
.toInt32();
479 case XML_ELEMENT( TABLE
, XML_TABLE
):
480 nTable
= aIter
.toInt32();
483 case XML_ELEMENT( TABLE
, XML_START_COLUMN
):
484 nStartColumn
= aIter
.toInt32();
486 case XML_ELEMENT( TABLE
, XML_END_COLUMN
):
487 nEndColumn
= aIter
.toInt32();
489 case XML_ELEMENT( TABLE
, XML_START_ROW
):
490 nStartRow
= aIter
.toInt32();
492 case XML_ELEMENT( TABLE
, XML_END_ROW
):
493 nEndRow
= aIter
.toInt32();
495 case XML_ELEMENT( TABLE
, XML_START_TABLE
):
496 nStartTable
= aIter
.toInt32();
498 case XML_ELEMENT( TABLE
, XML_END_TABLE
):
499 nEndTable
= aIter
.toInt32();
506 nStartColumn
= nEndColumn
= nColumn
;
508 nStartRow
= nEndRow
= nRow
;
510 nStartTable
= nEndTable
= nTable
;
511 rBigRange
.Set(nStartColumn
, nStartRow
, nStartTable
,
512 nEndColumn
, nEndRow
, nEndTable
);
515 ScXMLCellContentDeletionContext::ScXMLCellContentDeletionContext( ScXMLImport
& rImport
,
516 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
517 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
518 ScXMLImportContext( rImport
),
520 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
),
524 eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT
),
525 nType(css::util::NumberFormat::ALL
),
526 nMatrixFlag(ScMatrixMode::NONE
)
528 if ( rAttrList
.is() )
530 auto aIter( rAttrList
->find( XML_ELEMENT( TABLE
, XML_ID
) ) );
531 if (aIter
!= rAttrList
->end())
532 nID
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
536 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLCellContentDeletionContext::createFastChildContext(
537 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
539 SvXMLImportContext
*pContext(nullptr);
540 sax_fastparser::FastAttributeList
*pAttribList
=
541 &sax_fastparser::castToFastAttributeList( xAttrList
);
545 case XML_ELEMENT( TABLE
, XML_CHANGE_TRACK_TABLE_CELL
):
546 pContext
= new ScXMLChangeCellContext(GetScImport(), pAttribList
,
547 maCell
, sFormulaAddress
, sFormula
, sFormulaNmsp
, eGrammar
, sInputString
, fValue
, nType
, nMatrixFlag
, nMatrixCols
, nMatrixRows
);
549 case XML_ELEMENT( TABLE
, XML_CELL_ADDRESS
):
550 OSL_ENSURE(!nID
, "a action with a ID should not contain a BigRange");
551 pContext
= new ScXMLBigRangeContext(GetScImport(), pAttribList
, aBigRange
);
558 void SAL_CALL
ScXMLCellContentDeletionContext::endFastElement( sal_Int32
/*nElement*/ )
560 std::unique_ptr
<ScMyCellInfo
> pCellInfo(new ScMyCellInfo(maCell
, sFormulaAddress
, sFormula
, eGrammar
, sInputString
, fValue
, nType
,
561 nMatrixFlag
, nMatrixCols
, nMatrixRows
));
563 pChangeTrackingImportHelper
->AddDeleted(nID
, std::move(pCellInfo
));
565 pChangeTrackingImportHelper
->AddGenerated(std::move(pCellInfo
), aBigRange
);
568 ScXMLDependenceContext::ScXMLDependenceContext( ScXMLImport
& rImport
,
569 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
570 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
) :
571 ScXMLImportContext( rImport
)
574 if ( rAttrList
.is() )
576 auto aIter( rAttrList
->find( XML_ELEMENT( TABLE
, XML_ID
) ) );
577 if (aIter
!= rAttrList
->end())
578 nID
= ScXMLChangeTrackingImportHelper::GetIDFromString(aIter
.toString());
580 pChangeTrackingImportHelper
->AddDependence(nID
);
583 ScXMLDependingsContext::ScXMLDependingsContext( ScXMLImport
& rImport
,
584 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
585 ScXMLImportContext( rImport
),
586 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
588 // here are no attributes
591 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDependingsContext::createFastChildContext(
592 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
594 SvXMLImportContext
*pContext(nullptr);
595 sax_fastparser::FastAttributeList
*pAttribList
=
596 &sax_fastparser::castToFastAttributeList( xAttrList
);
598 // #i80033# read both old (dependence) and new (dependency) elements
599 if (nElement
== XML_ELEMENT( TABLE
, XML_DEPENDENCE
) ||
600 nElement
== XML_ELEMENT( TABLE
, XML_DEPENDENCY
))
602 pContext
= new ScXMLDependenceContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
608 ScXMLChangeDeletionContext::ScXMLChangeDeletionContext( ScXMLImport
& rImport
,
609 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
610 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
) :
611 ScXMLImportContext( rImport
)
614 if ( rAttrList
.is() )
616 auto aIter( rAttrList
->find( XML_ELEMENT( TABLE
, XML_ID
) ) );
617 if (aIter
!= rAttrList
->end())
618 nID
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
620 pChangeTrackingImportHelper
->AddDeleted(nID
);
623 ScXMLDeletionsContext::ScXMLDeletionsContext( ScXMLImport
& rImport
,
624 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
625 ScXMLImportContext( rImport
),
626 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
628 // here are no attributes
631 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDeletionsContext::createFastChildContext(
632 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
634 SvXMLImportContext
*pContext(nullptr);
635 sax_fastparser::FastAttributeList
*pAttribList
=
636 &sax_fastparser::castToFastAttributeList( xAttrList
);
640 case XML_ELEMENT( TABLE
, XML_CHANGE_DELETION
):
641 pContext
= new ScXMLChangeDeletionContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
643 case XML_ELEMENT( TABLE
, XML_CELL_CONTENT_DELETION
):
644 pContext
= new ScXMLCellContentDeletionContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
651 ScXMLChangeTextPContext::ScXMLChangeTextPContext( ScXMLImport
& rImport
,
653 const OUString
& rLName
,
654 const css::uno::Reference
<css::xml::sax::XAttributeList
>& xTempAttrList
,
655 ScXMLChangeCellContext
* pTempChangeCellContext
) :
656 ScXMLImportContext( rImport
, nPrfx
, rLName
),
657 xAttrList(xTempAttrList
),
660 pChangeCellContext(pTempChangeCellContext
),
663 // here are no attributes
666 SvXMLImportContextRef
ScXMLChangeTextPContext::CreateChildContext( sal_uInt16 nTempPrefix
,
667 const OUString
& rLName
,
668 const css::uno::Reference
<css::xml::sax::XAttributeList
>& xTempAttrList
)
670 SvXMLImportContextRef xContext
;
672 if ((nPrefix
== XML_NAMESPACE_TEXT
) && (IsXMLToken(rLName
, XML_S
)) && !pTextPContext
)
674 sal_Int32
nRepeat(0);
675 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
676 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
678 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
679 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
681 sal_uInt16
nPrfx(GetScImport().GetNamespaceMap().GetKeyByAttrName(
682 sAttrName
, &aLocalName
));
683 if ((nPrfx
== XML_NAMESPACE_TEXT
) && (IsXMLToken(aLocalName
, XML_C
)))
684 nRepeat
= sValue
.toInt32();
687 for (sal_Int32 j
= 0; j
< nRepeat
; ++j
)
694 if (!pChangeCellContext
->IsEditCell())
695 pChangeCellContext
->CreateTextPContext(false);
696 bool bWasContext (true);
700 pTextPContext
= GetScImport().GetTextImport()->CreateTextChildContext(
701 GetScImport(), nPrefix
, sLName
, xAttrList
);
706 pTextPContext
->characters(sText
.makeStringAndClear());
707 xContext
= pTextPContext
->CreateChildContext(nTempPrefix
, rLName
, xTempAttrList
);
714 void ScXMLChangeTextPContext::characters( const OUString
& rChars
)
717 sText
.append(rChars
);
719 pTextPContext
->characters(rChars
);
722 void ScXMLChangeTextPContext::endFastElement(sal_Int32
)
725 pChangeCellContext
->SetText(sText
.makeStringAndClear());
728 ScXMLChangeCellContext::ScXMLChangeCellContext( ScXMLImport
& rImport
,
729 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
730 ScCellValue
& rOldCell
, OUString
& rAddress
,
731 OUString
& rFormula
, OUString
& rFormulaNmsp
,
732 formula::FormulaGrammar::Grammar
& rGrammar
,
733 OUString
& rTempInputString
, double& rDateTimeValue
, sal_uInt16
& nType
,
734 ScMatrixMode
& nMatrixFlag
, sal_Int32
& nMatrixCols
, sal_Int32
& nMatrixRows
)
735 : ScXMLImportContext( rImport
)
736 , mrOldCell(rOldCell
)
737 , rInputString(rTempInputString
)
741 , bFirstParagraph(true)
745 bool bIsMatrix(false);
746 bool bIsCoveredMatrix(false);
747 if ( rAttrList
.is() )
749 for (auto &aIter
: *rAttrList
)
751 switch (aIter
.getToken())
753 case XML_ELEMENT( TABLE
, XML_FORMULA
):
755 GetScImport().ExtractFormulaNamespaceGrammar( rFormula
, rFormulaNmsp
, rGrammar
, aIter
.toString() );
758 case XML_ELEMENT( TABLE
, XML_CELL_ADDRESS
):
759 rAddress
= aIter
.toString();
761 case XML_ELEMENT( TABLE
, XML_MATRIX_COVERED
):
762 bIsCoveredMatrix
= IsXMLToken(aIter
, XML_TRUE
);
764 case XML_ELEMENT( TABLE
, XML_NUMBER_MATRIX_COLUMNS_SPANNED
):
766 nMatrixCols
= aIter
.toInt32();
768 case XML_ELEMENT( TABLE
, XML_NUMBER_MATRIX_ROWS_SPANNED
):
770 nMatrixRows
= aIter
.toInt32();
772 case XML_ELEMENT( OFFICE
, XML_VALUE_TYPE
):
773 if (IsXMLToken(aIter
, XML_FLOAT
))
775 else if (IsXMLToken(aIter
, XML_DATE
))
777 rType
= css::util::NumberFormat::DATE
;
780 else if (IsXMLToken(aIter
, XML_TIME
))
782 rType
= css::util::NumberFormat::TIME
;
786 case XML_ELEMENT( OFFICE
, XML_VALUE
):
787 fValue
= aIter
.toDouble();
790 case XML_ELEMENT( OFFICE
, XML_DATE_VALUE
):
792 if (GetScImport().GetMM100UnitConverter().setNullDate(GetScImport().GetModel()))
793 GetScImport().GetMM100UnitConverter().convertDateTime(rDateTimeValue
, aIter
.toString());
794 fValue
= rDateTimeValue
;
796 case XML_ELEMENT( OFFICE
, XML_TIME_VALUE
):
798 ::sax::Converter::convertDuration(rDateTimeValue
, aIter
.toString());
799 fValue
= rDateTimeValue
;
804 if (bIsCoveredMatrix
)
805 nMatrixFlag
= ScMatrixMode::Reference
;
806 else if (bIsMatrix
&& nMatrixRows
&& nMatrixCols
)
807 nMatrixFlag
= ScMatrixMode::Formula
;
810 SvXMLImportContextRef
ScXMLChangeCellContext::CreateChildContext( sal_uInt16 nPrefix
,
811 const OUString
& rLocalName
,
812 const css::uno::Reference
<css::xml::sax::XAttributeList
>& xAttrList
)
814 SvXMLImportContext
*pContext(nullptr);
816 if ((nPrefix
== XML_NAMESPACE_TEXT
) && (IsXMLToken(rLocalName
, XML_P
)))
821 pContext
= new ScXMLChangeTextPContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, this);
822 bFirstParagraph
= false;
826 if (!mpEditTextObj
.is())
827 CreateTextPContext(true);
828 pContext
= GetScImport().GetTextImport()->CreateTextChildContext(
829 GetScImport(), nPrefix
, rLocalName
, xAttrList
);
836 void ScXMLChangeCellContext::CreateTextPContext(bool bIsNewParagraph
)
838 if (!GetScImport().GetDocument())
841 mpEditTextObj
= new ScEditEngineTextObj();
842 mpEditTextObj
->GetEditEngine()->SetEditTextObjectPool(GetScImport().GetDocument()->GetEditPool());
843 uno::Reference
<text::XText
> xText(mpEditTextObj
.get());
846 uno::Reference
<text::XTextCursor
> xTextCursor(xText
->createTextCursor());
849 xText
->setString(sText
);
850 xTextCursor
->gotoEnd(false);
851 xText
->insertControlCharacter(xTextCursor
, text::ControlCharacter::PARAGRAPH_BREAK
, false);
853 GetScImport().GetTextImport()->SetCursor(xTextCursor
);
857 void SAL_CALL
ScXMLChangeCellContext::endFastElement( sal_Int32
/*nElement*/ )
861 ScDocument
* pDoc
= GetScImport().GetDocument();
862 if (mpEditTextObj
.is())
864 if (GetImport().GetTextImport()->GetCursor().is())
866 //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False);
867 if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, true ) )
869 GetImport().GetTextImport()->GetText()->insertString(
870 GetImport().GetTextImport()->GetCursorAsRange(), "",
875 // The cell will own the text object instance.
876 mrOldCell
.meType
= CELLTYPE_EDIT
;
877 mrOldCell
.mpEditText
= mpEditTextObj
->CreateTextObject().release();
878 GetScImport().GetTextImport()->ResetCursor();
879 mpEditTextObj
.clear();
885 if (!sText
.isEmpty() && bString
)
887 mrOldCell
.meType
= CELLTYPE_STRING
;
888 mrOldCell
.mpString
= new svl::SharedString(pDoc
->GetSharedStringPool().intern(sText
));
892 mrOldCell
.meType
= CELLTYPE_VALUE
;
893 mrOldCell
.mfValue
= fValue
;
895 if (rType
== css::util::NumberFormat::DATE
|| rType
== css::util::NumberFormat::TIME
)
896 rInputString
= sText
;
904 ScXMLPreviousContext::ScXMLPreviousContext( ScXMLImport
& rImport
,
905 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
906 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
907 ScXMLImportContext( rImport
),
909 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
),
913 eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT
),
914 nType(css::util::NumberFormat::ALL
),
915 nMatrixFlag(ScMatrixMode::NONE
)
917 if ( rAttrList
.is() )
919 auto aIter( rAttrList
->find( XML_ELEMENT( TABLE
, XML_ID
) ) );
920 if (aIter
!= rAttrList
->end())
921 nID
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
925 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLPreviousContext::createFastChildContext(
926 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
928 SvXMLImportContext
*pContext(nullptr);
929 sax_fastparser::FastAttributeList
*pAttribList
=
930 &sax_fastparser::castToFastAttributeList( xAttrList
);
932 if ( nElement
== XML_ELEMENT( TABLE
, XML_CHANGE_TRACK_TABLE_CELL
) )
933 pContext
= new ScXMLChangeCellContext(GetScImport(), pAttribList
,
934 maOldCell
, sFormulaAddress
, sFormula
, sFormulaNmsp
, eGrammar
, sInputString
, fValue
, nType
, nMatrixFlag
, nMatrixCols
, nMatrixRows
);
939 void SAL_CALL
ScXMLPreviousContext::endFastElement( sal_Int32
/*nElement*/ )
941 pChangeTrackingImportHelper
->SetPreviousChange(nID
, new ScMyCellInfo(maOldCell
, sFormulaAddress
, sFormula
, eGrammar
, sInputString
,
942 fValue
, nType
, nMatrixFlag
, nMatrixCols
, nMatrixRows
));
945 ScXMLContentChangeContext::ScXMLContentChangeContext( ScXMLImport
& rImport
,
946 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
947 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
948 ScXMLImportContext( rImport
),
949 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
951 sal_uInt32
nActionNumber(0);
952 sal_uInt32
nRejectingNumber(0);
953 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
955 if ( rAttrList
.is() )
957 for (auto &aIter
: *rAttrList
)
959 switch (aIter
.getToken())
961 case XML_ELEMENT( TABLE
, XML_ID
):
962 nActionNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
964 case XML_ELEMENT( TABLE
, XML_ACCEPTANCE_STATE
):
965 if (IsXMLToken( aIter
, XML_ACCEPTED
))
966 nActionState
= SC_CAS_ACCEPTED
;
967 else if (IsXMLToken( aIter
, XML_REJECTED
))
968 nActionState
= SC_CAS_REJECTED
;
970 case XML_ELEMENT( TABLE
, XML_REJECTING_CHANGE_ID
):
971 nRejectingNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
976 pChangeTrackingImportHelper
->StartChangeAction(SC_CAT_CONTENT
);
977 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
978 pChangeTrackingImportHelper
->SetActionState(nActionState
);
979 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
982 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLContentChangeContext::createFastChildContext(
983 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
985 SvXMLImportContext
*pContext(nullptr);
986 sax_fastparser::FastAttributeList
*pAttribList
=
987 &sax_fastparser::castToFastAttributeList( xAttrList
);
991 case XML_ELEMENT( OFFICE
, XML_CHANGE_INFO
):
992 pContext
= new ScXMLChangeInfoContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
994 case XML_ELEMENT( TABLE
, XML_CELL_ADDRESS
):
995 pContext
= new ScXMLBigRangeContext(GetScImport(), pAttribList
, aBigRange
);
997 case XML_ELEMENT( TABLE
, XML_DEPENDENCIES
):
998 pContext
= new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper
);
1000 case XML_ELEMENT( TABLE
, XML_DELETIONS
):
1001 pContext
= new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper
);
1003 case XML_ELEMENT( TABLE
, XML_PREVIOUS
):
1004 pContext
= new ScXMLPreviousContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
1011 void SAL_CALL
ScXMLContentChangeContext::endFastElement( sal_Int32
/*nElement*/ )
1013 pChangeTrackingImportHelper
->SetBigRange(aBigRange
);
1014 pChangeTrackingImportHelper
->EndChangeAction();
1017 ScXMLInsertionContext::ScXMLInsertionContext( ScXMLImport
& rImport
,
1018 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
1019 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1020 ScXMLImportContext( rImport
),
1021 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1023 sal_uInt32
nActionNumber(0);
1024 sal_uInt32
nRejectingNumber(0);
1025 sal_Int32
nPosition(0);
1026 sal_Int32
nCount(1);
1027 sal_Int32
nTable(0);
1028 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1029 ScChangeActionType
nActionType(SC_CAT_INSERT_COLS
);
1031 if ( rAttrList
.is() )
1033 for (auto &aIter
: *rAttrList
)
1035 switch (aIter
.getToken())
1037 case XML_ELEMENT( TABLE
, XML_ID
):
1038 nActionNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
1040 case XML_ELEMENT( TABLE
, XML_ACCEPTANCE_STATE
):
1041 if (IsXMLToken( aIter
, XML_ACCEPTED
))
1042 nActionState
= SC_CAS_ACCEPTED
;
1043 else if (IsXMLToken( aIter
, XML_REJECTED
))
1044 nActionState
= SC_CAS_REJECTED
;
1046 case XML_ELEMENT( TABLE
, XML_REJECTING_CHANGE_ID
):
1047 nRejectingNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
1049 case XML_ELEMENT( TABLE
, XML_TYPE
):
1050 if (IsXMLToken( aIter
, XML_ROW
))
1051 nActionType
= SC_CAT_INSERT_ROWS
;
1052 else if (IsXMLToken( aIter
, XML_TABLE
))
1053 nActionType
= SC_CAT_INSERT_TABS
;
1055 case XML_ELEMENT( TABLE
, XML_POSITION
):
1056 nPosition
= aIter
.toInt32();
1058 case XML_ELEMENT( TABLE
, XML_TABLE
):
1059 nTable
= aIter
.toInt32();
1061 case XML_ELEMENT( TABLE
, XML_COUNT
):
1062 nCount
= aIter
.toInt32();
1068 pChangeTrackingImportHelper
->StartChangeAction(nActionType
);
1069 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1070 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1071 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1072 pChangeTrackingImportHelper
->SetPosition(nPosition
, nCount
, nTable
);
1075 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLInsertionContext::createFastChildContext(
1076 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
1078 SvXMLImportContext
*pContext(nullptr);
1079 sax_fastparser::FastAttributeList
*pAttribList
=
1080 &sax_fastparser::castToFastAttributeList( xAttrList
);
1084 case XML_ELEMENT( OFFICE
, XML_CHANGE_INFO
):
1085 pContext
= new ScXMLChangeInfoContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
1087 case XML_ELEMENT( TABLE
, XML_DEPENDENCIES
):
1088 pContext
= new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper
);
1090 case XML_ELEMENT( TABLE
, XML_DELETIONS
):
1091 pContext
= new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper
);
1098 void SAL_CALL
ScXMLInsertionContext::endFastElement( sal_Int32
/*nElement*/ )
1100 pChangeTrackingImportHelper
->EndChangeAction();
1103 ScXMLInsertionCutOffContext::ScXMLInsertionCutOffContext( ScXMLImport
& rImport
,
1104 const uno::Reference
<xml::sax::XFastAttributeList
>& xAttrList
,
1105 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
) :
1106 ScXMLImportContext( rImport
)
1109 sal_Int32
nPosition(0);
1110 for (auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
))
1112 const OUString sValue
= aIter
.toString();
1114 switch (aIter
.getToken())
1116 case XML_ELEMENT(TABLE
, XML_ID
):
1117 nID
= ScXMLChangeTrackingImportHelper::GetIDFromString(sValue
);
1119 case XML_ELEMENT(TABLE
, XML_POSITION
):
1120 ::sax::Converter::convertNumber(nPosition
, sValue
);
1124 pChangeTrackingImportHelper
->SetInsertionCutOff(nID
, nPosition
);
1128 ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport
& rImport
,
1129 const uno::Reference
<xml::sax::XFastAttributeList
>& xAttrList
,
1130 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
) :
1131 ScXMLImportContext( rImport
)
1134 sal_Int32
nPosition(0);
1135 sal_Int32
nStartPosition(0);
1136 sal_Int32
nEndPosition(0);
1137 bool bPosition(false);
1138 for (auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
))
1140 const OUString sValue
= aIter
.toString();
1142 switch (aIter
.getToken())
1144 case XML_ELEMENT(TABLE
, XML_ID
):
1145 nID
= ScXMLChangeTrackingImportHelper::GetIDFromString(sValue
);
1147 case XML_ELEMENT(TABLE
, XML_POSITION
):
1149 ::sax::Converter::convertNumber(nPosition
, sValue
);
1151 case XML_ELEMENT(TABLE
, XML_START_POSITION
):
1152 ::sax::Converter::convertNumber(nStartPosition
, sValue
);
1154 case XML_ELEMENT(TABLE
, XML_END_POSITION
):
1155 ::sax::Converter::convertNumber(nEndPosition
, sValue
);
1160 nStartPosition
= nEndPosition
= nPosition
;
1161 pChangeTrackingImportHelper
->AddMoveCutOff(nID
, nStartPosition
, nEndPosition
);
1164 ScXMLCutOffsContext::ScXMLCutOffsContext( ScXMLImport
& rImport
,
1165 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1166 ScXMLImportContext( rImport
),
1167 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1169 // here are no attributes
1172 css::uno::Reference
< css::xml::sax::XFastContextHandler
> ScXMLCutOffsContext::createFastChildContext(
1173 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
1175 SvXMLImportContext
*pContext(nullptr);
1177 if (nElement
== XML_ELEMENT(TABLE
, XML_INSERTION_CUT_OFF
))
1178 pContext
= new ScXMLInsertionCutOffContext(GetScImport(), xAttrList
, pChangeTrackingImportHelper
);
1179 else if (nElement
== XML_ELEMENT(TABLE
, XML_MOVEMENT_CUT_OFF
))
1180 pContext
= new ScXMLMovementCutOffContext(GetScImport(), xAttrList
, pChangeTrackingImportHelper
);
1185 ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport
& rImport
,
1186 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
1187 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1188 ScXMLImportContext( rImport
),
1189 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1191 sal_uInt32
nActionNumber(0);
1192 sal_uInt32
nRejectingNumber(0);
1193 sal_Int32
nPosition(0);
1194 sal_Int32
nMultiSpanned(0);
1195 sal_Int32
nTable(0);
1196 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1197 ScChangeActionType
nActionType(SC_CAT_DELETE_COLS
);
1199 if ( rAttrList
.is() )
1201 for (auto &aIter
: *rAttrList
)
1203 sal_Int32 nToken
= aIter
.getToken();
1206 case XML_ELEMENT( TABLE
, XML_ID
):
1207 nActionNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
1209 case XML_ELEMENT( TABLE
, XML_ACCEPTANCE_STATE
):
1210 if (IsXMLToken( aIter
, XML_ACCEPTED
))
1211 nActionState
= SC_CAS_ACCEPTED
;
1212 else if (IsXMLToken( aIter
, XML_REJECTED
))
1213 nActionState
= SC_CAS_REJECTED
;
1215 case XML_ELEMENT( TABLE
, XML_REJECTING_CHANGE_ID
):
1216 nRejectingNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
1218 case XML_ELEMENT( TABLE
, XML_TYPE
):
1219 if (IsXMLToken( aIter
, XML_ROW
))
1220 nActionType
= SC_CAT_DELETE_ROWS
;
1221 else if (IsXMLToken( aIter
, XML_TABLE
))
1222 nActionType
= SC_CAT_DELETE_TABS
;
1224 case XML_ELEMENT( TABLE
, XML_POSITION
):
1225 nPosition
= aIter
.toInt32();
1227 case XML_ELEMENT( TABLE
, XML_TABLE
):
1228 nTable
= aIter
.toInt32();
1230 case XML_ELEMENT( TABLE
, XML_MULTI_DELETION_SPANNED
):
1231 nMultiSpanned
= aIter
.toInt32();
1237 pChangeTrackingImportHelper
->StartChangeAction(nActionType
);
1238 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1239 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1240 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1241 pChangeTrackingImportHelper
->SetPosition(nPosition
, 1, nTable
);
1242 pChangeTrackingImportHelper
->SetMultiSpanned(static_cast<sal_Int16
>(nMultiSpanned
));
1245 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDeletionContext::createFastChildContext(
1246 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
1248 SvXMLImportContext
*pContext(nullptr);
1249 sax_fastparser::FastAttributeList
*pAttribList
=
1250 &sax_fastparser::castToFastAttributeList( xAttrList
);
1254 case XML_ELEMENT( OFFICE
, XML_CHANGE_INFO
):
1255 pContext
= new ScXMLChangeInfoContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
1257 case XML_ELEMENT( TABLE
, XML_DEPENDENCIES
):
1258 pContext
= new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper
);
1260 case XML_ELEMENT( TABLE
, XML_DELETIONS
):
1261 pContext
= new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper
);
1263 case XML_ELEMENT( TABLE
, XML_CUT_OFFS
):
1264 case XML_ELEMENT( TABLE
, XML_CUT_OFFS2
): // cut_offs
1265 pContext
= new ScXMLCutOffsContext(GetScImport(), pChangeTrackingImportHelper
);
1271 void SAL_CALL
ScXMLDeletionContext::endFastElement( sal_Int32
/*nElement*/ )
1273 pChangeTrackingImportHelper
->EndChangeAction();
1276 ScXMLMovementContext::ScXMLMovementContext( ScXMLImport
& rImport
,
1277 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
1278 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1279 ScXMLImportContext( rImport
),
1280 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1282 sal_uInt32
nActionNumber(0);
1283 sal_uInt32
nRejectingNumber(0);
1284 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1286 if ( rAttrList
.is() )
1288 for (auto &aIter
: *rAttrList
)
1290 switch (aIter
.getToken())
1292 case XML_ELEMENT( TABLE
, XML_ID
):
1293 nActionNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
1295 case XML_ELEMENT( TABLE
, XML_ACCEPTANCE_STATE
):
1296 if (IsXMLToken( aIter
, XML_ACCEPTED
))
1297 nActionState
= SC_CAS_ACCEPTED
;
1298 else if (IsXMLToken( aIter
, XML_REJECTED
))
1299 nActionState
= SC_CAS_REJECTED
;
1301 case XML_ELEMENT( TABLE
, XML_REJECTING_CHANGE_ID
):
1302 nRejectingNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
1308 pChangeTrackingImportHelper
->StartChangeAction(SC_CAT_MOVE
);
1309 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1310 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1311 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1314 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLMovementContext::createFastChildContext(
1315 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
1317 SvXMLImportContext
*pContext(nullptr);
1318 sax_fastparser::FastAttributeList
*pAttribList
=
1319 &sax_fastparser::castToFastAttributeList( xAttrList
);
1323 case XML_ELEMENT( OFFICE
, XML_CHANGE_INFO
):
1324 pContext
= new ScXMLChangeInfoContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
1326 case XML_ELEMENT( TABLE
, XML_DEPENDENCIES
):
1327 pContext
= new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper
);
1329 case XML_ELEMENT( TABLE
, XML_DELETIONS
):
1330 pContext
= new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper
);
1332 case XML_ELEMENT( TABLE
, XML_SOURCE_RANGE_ADDRESS
):
1333 pContext
= new ScXMLBigRangeContext(GetScImport(), pAttribList
, aSourceRange
);
1335 case XML_ELEMENT( TABLE
, XML_TARGET_RANGE_ADDRESS
):
1336 pContext
= new ScXMLBigRangeContext(GetScImport(), pAttribList
, aTargetRange
);
1343 void SAL_CALL
ScXMLMovementContext::endFastElement( sal_Int32
/*nElement*/ )
1345 pChangeTrackingImportHelper
->SetMoveRanges(aSourceRange
, aTargetRange
);
1346 pChangeTrackingImportHelper
->EndChangeAction();
1349 ScXMLRejectionContext::ScXMLRejectionContext( ScXMLImport
& rImport
,
1350 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
1351 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1352 ScXMLImportContext( rImport
),
1353 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1355 sal_uInt32
nActionNumber(0);
1356 sal_uInt32
nRejectingNumber(0);
1357 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1359 if ( rAttrList
.is() )
1361 for (auto &aIter
: *rAttrList
)
1363 switch (aIter
.getToken())
1365 case XML_ELEMENT( TABLE
, XML_ID
):
1366 nActionNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
1368 case XML_ELEMENT( TABLE
, XML_ACCEPTANCE_STATE
):
1369 if (IsXMLToken( aIter
, XML_ACCEPTED
))
1370 nActionState
= SC_CAS_ACCEPTED
;
1371 else if (IsXMLToken( aIter
, XML_REJECTED
))
1372 nActionState
= SC_CAS_REJECTED
;
1374 case XML_ELEMENT( TABLE
, XML_REJECTING_CHANGE_ID
):
1375 nRejectingNumber
= ScXMLChangeTrackingImportHelper::GetIDFromString( aIter
.toString() );
1381 pChangeTrackingImportHelper
->StartChangeAction(SC_CAT_MOVE
);
1382 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1383 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1384 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1387 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLRejectionContext::createFastChildContext(
1388 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
1390 SvXMLImportContext
*pContext(nullptr);
1391 sax_fastparser::FastAttributeList
*pAttribList
=
1392 &sax_fastparser::castToFastAttributeList( xAttrList
);
1396 case XML_ELEMENT( OFFICE
, XML_CHANGE_INFO
):
1397 pContext
= new ScXMLChangeInfoContext(GetScImport(), pAttribList
, pChangeTrackingImportHelper
);
1399 case XML_ELEMENT( TABLE
, XML_DEPENDENCIES
):
1400 pContext
= new ScXMLDependingsContext(GetScImport(), pChangeTrackingImportHelper
);
1402 case XML_ELEMENT( TABLE
, XML_DELETIONS
):
1403 pContext
= new ScXMLDeletionsContext(GetScImport(), pChangeTrackingImportHelper
);
1410 void SAL_CALL
ScXMLRejectionContext::endFastElement( sal_Int32
/*nElement*/ )
1412 pChangeTrackingImportHelper
->EndChangeAction();
1415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */