1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLTrackedChangesContext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "XMLTrackedChangesContext.hxx"
35 #include "xmlimprt.hxx"
36 #include "xmlconti.hxx"
37 #include "XMLConverter.hxx"
39 #include "textuno.hxx"
40 #include "editutil.hxx"
41 #include <xmloff/xmltoken.hxx>
42 #include <xmloff/xmlnmspe.hxx>
43 #include <xmloff/nmspmap.hxx>
44 #include <xmloff/xmluconv.hxx>
45 #include <svtools/zforlist.hxx>
46 #include <com/sun/star/text/XTextCursor.hpp>
47 #include <com/sun/star/text/ControlCharacter.hpp>
50 using namespace com::sun::star
;
51 using namespace xmloff::token
;
53 //-----------------------------------------------------------------------------
55 class ScXMLChangeInfoContext
: public SvXMLImportContext
58 ::rtl::OUStringBuffer sAuthorBuffer
;
59 ::rtl::OUStringBuffer sDateTimeBuffer
;
60 ::rtl::OUStringBuffer sCommentBuffer
;
61 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
62 sal_uInt32 nParagraphCount
;
64 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
65 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
68 ScXMLChangeInfoContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
69 const ::com::sun::star::uno::Reference
<
70 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
71 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
72 virtual ~ScXMLChangeInfoContext();
74 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
75 const ::rtl::OUString
& rLocalName
,
76 const ::com::sun::star::uno::Reference
<
77 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
79 virtual void EndElement();
82 //-----------------------------------------------------------------------------
84 class ScXMLBigRangeContext
: public SvXMLImportContext
86 ScBigRange
& rBigRange
;
88 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
89 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
92 ScXMLBigRangeContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
93 const ::com::sun::star::uno::Reference
<
94 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
95 ScBigRange
& rBigRange
);
96 virtual ~ScXMLBigRangeContext();
98 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
99 const ::rtl::OUString
& rLocalName
,
100 const ::com::sun::star::uno::Reference
<
101 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
103 virtual void EndElement();
106 //-----------------------------------------------------------------------------
108 class ScXMLCellContentDeletionContext
: public SvXMLImportContext
110 rtl::OUString sFormulaAddress
;
111 rtl::OUString sFormula
;
112 rtl::OUString sFormulaNmsp
;
113 rtl::OUString sInputString
;
114 ScBigRange aBigRange
;
116 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
119 sal_Int32 nMatrixCols
;
120 sal_Int32 nMatrixRows
;
121 formula::FormulaGrammar::Grammar eGrammar
;
123 sal_uInt8 nMatrixFlag
;
125 sal_Bool bContainsCell
;
127 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
128 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
131 ScXMLCellContentDeletionContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
132 const ::com::sun::star::uno::Reference
<
133 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
134 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
135 virtual ~ScXMLCellContentDeletionContext();
137 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
138 const ::rtl::OUString
& rLocalName
,
139 const ::com::sun::star::uno::Reference
<
140 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
142 virtual void EndElement();
145 //-----------------------------------------------------------------------------
147 class ScXMLDependenceContext
: public SvXMLImportContext
149 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
151 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
152 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
155 ScXMLDependenceContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
156 const ::com::sun::star::uno::Reference
<
157 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
158 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
159 virtual ~ScXMLDependenceContext();
161 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
162 const ::rtl::OUString
& rLocalName
,
163 const ::com::sun::star::uno::Reference
<
164 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
166 virtual void EndElement();
169 //-----------------------------------------------------------------------------
171 class ScXMLDependingsContext
: public SvXMLImportContext
173 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
175 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
176 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
179 ScXMLDependingsContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
180 const ::com::sun::star::uno::Reference
<
181 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
182 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
183 virtual ~ScXMLDependingsContext();
185 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
186 const ::rtl::OUString
& rLocalName
,
187 const ::com::sun::star::uno::Reference
<
188 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
190 virtual void EndElement();
193 //-----------------------------------------------------------------------------
195 class ScXMLChangeDeletionContext
: public SvXMLImportContext
197 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
199 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
200 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
203 ScXMLChangeDeletionContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
204 const ::com::sun::star::uno::Reference
<
205 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
206 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
207 virtual ~ScXMLChangeDeletionContext();
209 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
210 const ::rtl::OUString
& rLocalName
,
211 const ::com::sun::star::uno::Reference
<
212 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
214 virtual void EndElement();
217 //-----------------------------------------------------------------------------
219 class ScXMLDeletionsContext
: public SvXMLImportContext
221 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
223 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
224 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
227 ScXMLDeletionsContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
228 const ::com::sun::star::uno::Reference
<
229 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
230 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
231 virtual ~ScXMLDeletionsContext();
233 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
234 const ::rtl::OUString
& rLocalName
,
235 const ::com::sun::star::uno::Reference
<
236 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
238 virtual void EndElement();
241 //-----------------------------------------------------------------------------
243 class ScXMLChangeCellContext
;
245 class ScXMLChangeTextPContext
: public SvXMLImportContext
247 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> xAttrList
;
248 rtl::OUString sLName
;
249 rtl::OUStringBuffer sText
;
250 ScXMLChangeCellContext
* pChangeCellContext
;
251 SvXMLImportContext
* pTextPContext
;
254 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
255 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
259 ScXMLChangeTextPContext( ScXMLImport
& rImport
, USHORT nPrfx
,
260 const ::rtl::OUString
& rLName
,
261 const ::com::sun::star::uno::Reference
<
262 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
263 ScXMLChangeCellContext
* pChangeCellContext
);
265 virtual ~ScXMLChangeTextPContext();
267 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
268 const ::rtl::OUString
& rLocalName
,
269 const ::com::sun::star::uno::Reference
<
270 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
272 virtual void Characters( const ::rtl::OUString
& rChars
);
274 virtual void EndElement();
277 //-----------------------------------------------------------------------------
279 class ScXMLChangeCellContext
: public SvXMLImportContext
282 rtl::OUString
& rInputString
;
283 ScBaseCell
*& rOldCell
;
284 ScEditEngineTextObj
* pEditTextObj
;
285 double& rDateTimeValue
;
288 // sal_Bool bIsMatrix;
289 // sal_Bool bIsCoveredMatrix;
291 sal_Bool bFirstParagraph
;
295 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
296 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
299 ScXMLChangeCellContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
300 const ::com::sun::star::uno::Reference
<
301 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
302 ScBaseCell
*& rOldCell
, rtl::OUString
& sAddress
,
303 rtl::OUString
& rFormula
, rtl::OUString
& rFormulaNmsp
,
304 formula::FormulaGrammar::Grammar
& rGrammar
,
305 rtl::OUString
& rInputString
, double& fValue
, sal_uInt16
& nType
,
306 sal_uInt8
& nMatrixFlag
, sal_Int32
& nMatrixCols
, sal_Int32
& nMatrixRows
);
307 virtual ~ScXMLChangeCellContext();
309 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
310 const ::rtl::OUString
& rLocalName
,
311 const ::com::sun::star::uno::Reference
<
312 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
314 void CreateTextPContext(sal_Bool bIsNewParagraph
);
315 sal_Bool
IsEditCell() { return pEditTextObj
!= 0; }
316 void SetText(const rtl::OUString
& sTempText
) { sText
= sTempText
; }
318 virtual void EndElement();
321 //-----------------------------------------------------------------------------
323 class ScXMLPreviousContext
: public SvXMLImportContext
325 rtl::OUString sFormulaAddress
;
326 rtl::OUString sFormula
;
327 rtl::OUString sFormulaNmsp
;
328 rtl::OUString sInputString
;
330 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
331 ScBaseCell
* pOldCell
;
333 sal_Int32 nMatrixCols
;
334 sal_Int32 nMatrixRows
;
335 formula::FormulaGrammar::Grammar eGrammar
;
337 sal_uInt8 nMatrixFlag
;
339 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
340 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
343 ScXMLPreviousContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
344 const ::com::sun::star::uno::Reference
<
345 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
346 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
347 virtual ~ScXMLPreviousContext();
349 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
350 const ::rtl::OUString
& rLocalName
,
351 const ::com::sun::star::uno::Reference
<
352 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
354 virtual void EndElement();
357 //-----------------------------------------------------------------------------
359 class ScXMLContentChangeContext
: public SvXMLImportContext
361 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
362 ScBigRange aBigRange
;
364 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
365 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
368 ScXMLContentChangeContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
369 const ::com::sun::star::uno::Reference
<
370 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
371 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
372 virtual ~ScXMLContentChangeContext();
374 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
375 const ::rtl::OUString
& rLocalName
,
376 const ::com::sun::star::uno::Reference
<
377 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
378 virtual void EndElement();
381 //-----------------------------------------------------------------------------
383 class ScXMLInsertionContext
: public SvXMLImportContext
385 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
387 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
388 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
391 ScXMLInsertionContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
392 const ::com::sun::star::uno::Reference
<
393 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
394 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
395 virtual ~ScXMLInsertionContext();
397 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
398 const ::rtl::OUString
& rLocalName
,
399 const ::com::sun::star::uno::Reference
<
400 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
401 virtual void EndElement();
404 //-----------------------------------------------------------------------------
406 class ScXMLInsertionCutOffContext
: public SvXMLImportContext
408 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
410 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
411 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
414 ScXMLInsertionCutOffContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
415 const ::com::sun::star::uno::Reference
<
416 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
417 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
418 virtual ~ScXMLInsertionCutOffContext();
420 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
421 const ::rtl::OUString
& rLocalName
,
422 const ::com::sun::star::uno::Reference
<
423 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
424 virtual void EndElement();
427 //-----------------------------------------------------------------------------
429 class ScXMLMovementCutOffContext
: public SvXMLImportContext
431 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
433 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
434 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
437 ScXMLMovementCutOffContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
438 const ::com::sun::star::uno::Reference
<
439 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
440 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
441 virtual ~ScXMLMovementCutOffContext();
443 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
444 const ::rtl::OUString
& rLocalName
,
445 const ::com::sun::star::uno::Reference
<
446 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
447 virtual void EndElement();
450 //-----------------------------------------------------------------------------
452 class ScXMLCutOffsContext
: public SvXMLImportContext
454 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
456 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
457 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
460 ScXMLCutOffsContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
461 const ::com::sun::star::uno::Reference
<
462 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
463 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
464 virtual ~ScXMLCutOffsContext();
466 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
467 const ::rtl::OUString
& rLocalName
,
468 const ::com::sun::star::uno::Reference
<
469 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
470 virtual void EndElement();
473 //-----------------------------------------------------------------------------
475 class ScXMLDeletionContext
: public SvXMLImportContext
477 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
479 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
480 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
483 ScXMLDeletionContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
484 const ::com::sun::star::uno::Reference
<
485 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
486 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
487 virtual ~ScXMLDeletionContext();
489 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
490 const ::rtl::OUString
& rLocalName
,
491 const ::com::sun::star::uno::Reference
<
492 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
493 virtual void EndElement();
496 //-----------------------------------------------------------------------------
498 class ScXMLMovementContext
: public SvXMLImportContext
500 ScBigRange aSourceRange
;
501 ScBigRange aTargetRange
;
502 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
504 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
505 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
508 ScXMLMovementContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
509 const ::com::sun::star::uno::Reference
<
510 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
511 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
512 virtual ~ScXMLMovementContext();
514 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
515 const ::rtl::OUString
& rLocalName
,
516 const ::com::sun::star::uno::Reference
<
517 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
518 virtual void EndElement();
521 //-----------------------------------------------------------------------------
523 class ScXMLRejectionContext
: public SvXMLImportContext
525 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
;
527 const ScXMLImport
& GetScImport() const { return (const ScXMLImport
&)GetImport(); }
528 ScXMLImport
& GetScImport() { return (ScXMLImport
&)GetImport(); }
531 ScXMLRejectionContext( ScXMLImport
& rImport
, USHORT nPrfx
, const ::rtl::OUString
& rLName
,
532 const ::com::sun::star::uno::Reference
<
533 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
534 ScXMLChangeTrackingImportHelper
* pChangeTrackingImportHelper
);
535 virtual ~ScXMLRejectionContext();
537 virtual SvXMLImportContext
*CreateChildContext( USHORT nPrefix
,
538 const ::rtl::OUString
& rLocalName
,
539 const ::com::sun::star::uno::Reference
<
540 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
541 virtual void EndElement();
544 //------------------------------------------------------------------
546 ScXMLTrackedChangesContext::ScXMLTrackedChangesContext( ScXMLImport
& rImport
,
548 const ::rtl::OUString
& rLName
,
549 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
550 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
551 SvXMLImportContext( rImport
, nPrfx
, rLName
),
552 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
554 rImport
.LockSolarMutex();
555 pChangeTrackingImportHelper
->SetChangeTrack(sal_True
);
557 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
558 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
560 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
561 rtl::OUString aLocalName
;
562 sal_uInt16
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
563 sAttrName
, &aLocalName
));
564 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
565 if (nPrefix
== XML_NAMESPACE_TABLE
)
567 if (IsXMLToken(aLocalName
, XML_PROTECTION_KEY
))
569 if (sValue
.getLength())
571 uno::Sequence
<sal_Int8
> aPass
;
572 SvXMLUnitConverter::decodeBase64(aPass
, sValue
);
573 pChangeTrackingImportHelper
->SetProtection(aPass
);
580 ScXMLTrackedChangesContext::~ScXMLTrackedChangesContext()
582 GetScImport().UnlockSolarMutex();
585 SvXMLImportContext
*ScXMLTrackedChangesContext::CreateChildContext( USHORT nPrefix
,
586 const ::rtl::OUString
& rLocalName
,
587 const ::com::sun::star::uno::Reference
<
588 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
590 SvXMLImportContext
*pContext(0);
592 if (nPrefix
== XML_NAMESPACE_TABLE
)
594 if (IsXMLToken(rLocalName
, XML_CELL_CONTENT_CHANGE
))
596 pContext
= new ScXMLContentChangeContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
598 else if (IsXMLToken(rLocalName
, XML_INSERTION
))
600 pContext
= new ScXMLInsertionContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
602 else if (IsXMLToken(rLocalName
, XML_DELETION
))
604 pContext
= new ScXMLDeletionContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
606 else if (IsXMLToken(rLocalName
, XML_MOVEMENT
))
608 pContext
= new ScXMLMovementContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
610 else if (IsXMLToken(rLocalName
, XML_REJECTION
))
612 pContext
= new ScXMLRejectionContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
617 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
622 void ScXMLTrackedChangesContext::EndElement()
626 ScXMLChangeInfoContext::ScXMLChangeInfoContext( ScXMLImport
& rImport
,
628 const ::rtl::OUString
& rLName
,
629 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
630 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
631 SvXMLImportContext( rImport
, nPrfx
, rLName
),
633 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
),
636 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
637 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
639 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
640 rtl::OUString aLocalName
;
641 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
642 sAttrName
, &aLocalName
));
643 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
645 if (nPrefix
== XML_NAMESPACE_OFFICE
)
647 if (IsXMLToken(aLocalName
, XML_CHG_AUTHOR
))
649 sAuthorBuffer
= sValue
;
651 else if (IsXMLToken(aLocalName
, XML_CHG_DATE_TIME
))
653 sDateTimeBuffer
= sValue
;
659 ScXMLChangeInfoContext::~ScXMLChangeInfoContext()
663 SvXMLImportContext
*ScXMLChangeInfoContext::CreateChildContext( USHORT nPrefix
,
664 const ::rtl::OUString
& rLocalName
,
665 const ::com::sun::star::uno::Reference
<
666 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
668 SvXMLImportContext
*pContext(0);
670 if( XML_NAMESPACE_DC
== nPrefix
)
672 if( IsXMLToken( rLocalName
, XML_CREATOR
) )
673 pContext
= new ScXMLContentContext(GetScImport(), nPrefix
,
674 rLocalName
, xAttrList
, sAuthorBuffer
);
675 else if( IsXMLToken( rLocalName
, XML_DATE
) )
676 pContext
= new ScXMLContentContext(GetScImport(), nPrefix
,
677 rLocalName
, xAttrList
, sDateTimeBuffer
);
679 else if ((nPrefix
== XML_NAMESPACE_TEXT
) && (IsXMLToken(rLocalName
, XML_P
)) )
682 sCommentBuffer
.append(static_cast<sal_Unicode
>('\n'));
684 pContext
= new ScXMLContentContext( GetScImport(), nPrefix
, rLocalName
, xAttrList
, sCommentBuffer
);
688 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
693 void ScXMLChangeInfoContext::EndElement()
695 aInfo
.sUser
= sAuthorBuffer
.makeStringAndClear();
696 GetScImport().GetMM100UnitConverter().convertDateTime(aInfo
.aDateTime
, sDateTimeBuffer
.makeStringAndClear());
697 aInfo
.sComment
= sCommentBuffer
.makeStringAndClear();
698 pChangeTrackingImportHelper
->SetActionInfo(aInfo
);
701 ScXMLBigRangeContext::ScXMLBigRangeContext( ScXMLImport
& rImport
,
703 const ::rtl::OUString
& rLName
,
704 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
705 ScBigRange
& rTempBigRange
) :
706 SvXMLImportContext( rImport
, nPrfx
, rLName
),
707 rBigRange(rTempBigRange
)
709 sal_Bool
bColumn(sal_False
);
710 sal_Bool
bRow(sal_False
);
711 sal_Bool
bTable(sal_False
);
712 sal_Int32
nColumn(0);
715 sal_Int32
nStartColumn(0);
716 sal_Int32
nEndColumn(0);
717 sal_Int32
nStartRow(0);
718 sal_Int32
nEndRow(0);
719 sal_Int32
nStartTable(0);
720 sal_Int32
nEndTable(0);
721 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
722 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
724 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
725 rtl::OUString aLocalName
;
726 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
727 sAttrName
, &aLocalName
));
728 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
730 if (nPrefix
== XML_NAMESPACE_TABLE
)
732 if (IsXMLToken(aLocalName
, XML_COLUMN
))
734 SvXMLUnitConverter::convertNumber(nColumn
, sValue
);
737 else if (IsXMLToken(aLocalName
, XML_ROW
))
739 SvXMLUnitConverter::convertNumber(nRow
, sValue
);
742 else if (IsXMLToken(aLocalName
, XML_TABLE
))
744 SvXMLUnitConverter::convertNumber(nTable
, sValue
);
747 else if (IsXMLToken(aLocalName
, XML_START_COLUMN
))
748 SvXMLUnitConverter::convertNumber(nStartColumn
, sValue
);
749 else if (IsXMLToken(aLocalName
, XML_END_COLUMN
))
750 SvXMLUnitConverter::convertNumber(nEndColumn
, sValue
);
751 else if (IsXMLToken(aLocalName
, XML_START_ROW
))
752 SvXMLUnitConverter::convertNumber(nStartRow
, sValue
);
753 else if (IsXMLToken(aLocalName
, XML_END_ROW
))
754 SvXMLUnitConverter::convertNumber(nEndRow
, sValue
);
755 else if (IsXMLToken(aLocalName
, XML_START_TABLE
))
756 SvXMLUnitConverter::convertNumber(nStartTable
, sValue
);
757 else if (IsXMLToken(aLocalName
, XML_END_TABLE
))
758 SvXMLUnitConverter::convertNumber(nEndTable
, sValue
);
762 nStartColumn
= nEndColumn
= nColumn
;
764 nStartRow
= nEndRow
= nRow
;
766 nStartTable
= nEndTable
= nTable
;
767 rBigRange
.Set(nStartColumn
, nStartRow
, nStartTable
,
768 nEndColumn
, nEndRow
, nEndTable
);
771 ScXMLBigRangeContext::~ScXMLBigRangeContext()
775 SvXMLImportContext
*ScXMLBigRangeContext::CreateChildContext( USHORT nPrefix
,
776 const ::rtl::OUString
& rLocalName
,
777 const ::com::sun::star::uno::Reference
<
778 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
780 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
783 void ScXMLBigRangeContext::EndElement()
787 ScXMLCellContentDeletionContext::ScXMLCellContentDeletionContext( ScXMLImport
& rImport
,
789 const ::rtl::OUString
& rLName
,
790 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
791 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
792 SvXMLImportContext( rImport
, nPrfx
, rLName
),
793 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
),
798 nType(NUMBERFORMAT_ALL
),
799 nMatrixFlag(MM_NONE
),
800 bBigRange(sal_False
),
801 bContainsCell(sal_False
)
803 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
804 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
806 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
807 rtl::OUString aLocalName
;
808 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
809 sAttrName
, &aLocalName
));
810 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
812 if (nPrefix
== XML_NAMESPACE_TABLE
)
814 if (IsXMLToken(aLocalName
, XML_ID
))
815 nID
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
820 ScXMLCellContentDeletionContext::~ScXMLCellContentDeletionContext()
824 SvXMLImportContext
*ScXMLCellContentDeletionContext::CreateChildContext( USHORT nPrefix
,
825 const ::rtl::OUString
& rLocalName
,
826 const ::com::sun::star::uno::Reference
<
827 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
829 SvXMLImportContext
*pContext(0);
831 if (nPrefix
== XML_NAMESPACE_TABLE
)
833 if (IsXMLToken(rLocalName
, XML_CHANGE_TRACK_TABLE_CELL
))
835 bContainsCell
= sal_True
;
836 pContext
= new ScXMLChangeCellContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
,
837 pCell
, sFormulaAddress
, sFormula
, sFormulaNmsp
, eGrammar
, sInputString
, fValue
, nType
, nMatrixFlag
, nMatrixCols
, nMatrixRows
);
839 else if (IsXMLToken(rLocalName
, XML_CELL_ADDRESS
))
841 DBG_ASSERT(!nID
, "a action with a ID should not contain a BigRange");
842 bBigRange
= sal_True
;
843 pContext
= new ScXMLBigRangeContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, aBigRange
);
848 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
853 void ScXMLCellContentDeletionContext::EndElement()
855 ScMyCellInfo
* pCellInfo(new ScMyCellInfo(pCell
, sFormulaAddress
, sFormula
, eGrammar
, sInputString
, fValue
, nType
,
856 nMatrixFlag
, nMatrixCols
, nMatrixRows
));
858 pChangeTrackingImportHelper
->AddDeleted(nID
, pCellInfo
);
860 pChangeTrackingImportHelper
->AddGenerated(pCellInfo
, aBigRange
);
863 ScXMLDependenceContext::ScXMLDependenceContext( ScXMLImport
& rImport
,
865 const ::rtl::OUString
& rLName
,
866 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
867 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
868 SvXMLImportContext( rImport
, nPrfx
, rLName
),
869 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
872 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
873 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
875 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
876 rtl::OUString aLocalName
;
877 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
878 sAttrName
, &aLocalName
));
879 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
881 if (nPrefix
== XML_NAMESPACE_TABLE
)
883 if (IsXMLToken(aLocalName
, XML_ID
))
884 nID
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
887 pChangeTrackingImportHelper
->AddDependence(nID
);
890 ScXMLDependenceContext::~ScXMLDependenceContext()
894 SvXMLImportContext
*ScXMLDependenceContext::CreateChildContext( USHORT nPrefix
,
895 const ::rtl::OUString
& rLocalName
,
896 const ::com::sun::star::uno::Reference
<
897 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
899 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
902 void ScXMLDependenceContext::EndElement()
906 ScXMLDependingsContext::ScXMLDependingsContext( ScXMLImport
& rImport
,
908 const ::rtl::OUString
& rLName
,
909 const uno::Reference
<xml::sax::XAttributeList
>& /* xAttrList */,
910 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
911 SvXMLImportContext( rImport
, nPrfx
, rLName
),
912 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
914 // here are no attributes
917 ScXMLDependingsContext::~ScXMLDependingsContext()
921 SvXMLImportContext
*ScXMLDependingsContext::CreateChildContext( USHORT nPrefix
,
922 const ::rtl::OUString
& rLocalName
,
923 const ::com::sun::star::uno::Reference
<
924 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
926 SvXMLImportContext
*pContext(0);
928 if (nPrefix
== XML_NAMESPACE_TABLE
)
930 // #i80033# read both old (dependence) and new (dependency) elements
931 if (IsXMLToken(rLocalName
, XML_DEPENDENCE
) || IsXMLToken(rLocalName
, XML_DEPENDENCY
))
932 pContext
= new ScXMLDependenceContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
936 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
941 void ScXMLDependingsContext::EndElement()
945 ScXMLChangeDeletionContext::ScXMLChangeDeletionContext( ScXMLImport
& rImport
,
947 const ::rtl::OUString
& rLName
,
948 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
949 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
950 SvXMLImportContext( rImport
, nPrfx
, rLName
),
951 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
954 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
955 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
957 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
958 rtl::OUString aLocalName
;
959 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
960 sAttrName
, &aLocalName
));
961 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
963 if (nPrefix
== XML_NAMESPACE_TABLE
)
965 if (IsXMLToken(aLocalName
, XML_ID
))
966 nID
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
969 pChangeTrackingImportHelper
->AddDeleted(nID
);
972 ScXMLChangeDeletionContext::~ScXMLChangeDeletionContext()
976 SvXMLImportContext
*ScXMLChangeDeletionContext::CreateChildContext( USHORT nPrefix
,
977 const ::rtl::OUString
& rLocalName
,
978 const ::com::sun::star::uno::Reference
<
979 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
981 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
984 void ScXMLChangeDeletionContext::EndElement()
988 ScXMLDeletionsContext::ScXMLDeletionsContext( ScXMLImport
& rImport
,
990 const ::rtl::OUString
& rLName
,
991 const uno::Reference
<xml::sax::XAttributeList
>& /* xAttrList */,
992 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
993 SvXMLImportContext( rImport
, nPrfx
, rLName
),
994 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
996 // here are no attributes
999 ScXMLDeletionsContext::~ScXMLDeletionsContext()
1003 SvXMLImportContext
*ScXMLDeletionsContext::CreateChildContext( USHORT nPrefix
,
1004 const ::rtl::OUString
& rLocalName
,
1005 const ::com::sun::star::uno::Reference
<
1006 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1008 SvXMLImportContext
*pContext(0);
1010 if (nPrefix
== XML_NAMESPACE_TABLE
)
1012 if (IsXMLToken(rLocalName
, XML_CHANGE_DELETION
))
1013 pContext
= new ScXMLChangeDeletionContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1014 else if (IsXMLToken(rLocalName
, XML_CELL_CONTENT_DELETION
))
1015 pContext
= new ScXMLCellContentDeletionContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1019 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1024 void ScXMLDeletionsContext::EndElement()
1028 ScXMLChangeTextPContext::ScXMLChangeTextPContext( ScXMLImport
& rImport
,
1030 const ::rtl::OUString
& rLName
,
1031 const ::com::sun::star::uno::Reference
<
1032 ::com::sun::star::xml::sax::XAttributeList
>& xTempAttrList
,
1033 ScXMLChangeCellContext
* pTempChangeCellContext
) :
1034 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1035 xAttrList(xTempAttrList
),
1038 pChangeCellContext(pTempChangeCellContext
),
1039 pTextPContext(NULL
),
1042 // here are no attributes
1045 ScXMLChangeTextPContext::~ScXMLChangeTextPContext()
1048 delete pTextPContext
;
1051 SvXMLImportContext
*ScXMLChangeTextPContext::CreateChildContext( USHORT nTempPrefix
,
1052 const ::rtl::OUString
& rLName
,
1053 const ::com::sun::star::uno::Reference
<
1054 ::com::sun::star::xml::sax::XAttributeList
>& xTempAttrList
)
1056 SvXMLImportContext
*pContext(0);
1058 if ((nPrefix
== XML_NAMESPACE_TEXT
) && (IsXMLToken(rLName
, XML_S
)) && !pTextPContext
)
1060 sal_Int32
nRepeat(0);
1061 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1062 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1064 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1065 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1066 rtl::OUString aLocalName
;
1067 USHORT
nPrfx(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1068 sAttrName
, &aLocalName
));
1069 if ((nPrfx
== XML_NAMESPACE_TEXT
) && (IsXMLToken(aLocalName
, XML_C
)))
1070 nRepeat
= sValue
.toInt32();
1073 for (sal_Int32 j
= 0; j
< nRepeat
; ++j
)
1074 sText
.append(static_cast<sal_Unicode
>(' '));
1076 sText
.append(static_cast<sal_Unicode
>(' '));
1080 if (!pChangeCellContext
->IsEditCell())
1081 pChangeCellContext
->CreateTextPContext(sal_False
);
1082 sal_Bool
bWasContext (sal_True
);
1085 bWasContext
= sal_False
;
1086 pTextPContext
= GetScImport().GetTextImport()->CreateTextChildContext(
1087 GetScImport(), nPrefix
, sLName
, xAttrList
);
1092 pTextPContext
->Characters(sText
.makeStringAndClear());
1093 pContext
= pTextPContext
->CreateChildContext(nTempPrefix
, rLName
, xTempAttrList
);
1098 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1103 void ScXMLChangeTextPContext::Characters( const ::rtl::OUString
& rChars
)
1106 sText
.append(rChars
);
1108 pTextPContext
->Characters(rChars
);
1111 void ScXMLChangeTextPContext::EndElement()
1114 pChangeCellContext
->SetText(sText
.makeStringAndClear());
1117 ScXMLChangeCellContext::ScXMLChangeCellContext( ScXMLImport
& rImport
,
1119 const ::rtl::OUString
& rLName
,
1120 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1121 ScBaseCell
*& rTempOldCell
, rtl::OUString
& rAddress
,
1122 rtl::OUString
& rFormula
, rtl::OUString
& rFormulaNmsp
,
1123 formula::FormulaGrammar::Grammar
& rGrammar
,
1124 rtl::OUString
& rTempInputString
, double& fDateTimeValue
, sal_uInt16
& nType
,
1125 sal_uInt8
& nMatrixFlag
, sal_Int32
& nMatrixCols
, sal_Int32
& nMatrixRows
) :
1126 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1127 rInputString(rTempInputString
),
1128 rOldCell(rTempOldCell
),
1130 rDateTimeValue(fDateTimeValue
),
1133 bFirstParagraph(sal_True
),
1137 sal_Bool
bIsMatrix(sal_False
);
1138 sal_Bool
bIsCoveredMatrix(sal_False
);
1139 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1140 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1142 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1143 rtl::OUString aLocalName
;
1144 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1145 sAttrName
, &aLocalName
));
1146 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1148 if (nPrefix
== XML_NAMESPACE_TABLE
)
1150 if (IsXMLToken(aLocalName
, XML_FORMULA
))
1153 GetScImport().ExtractFormulaNamespaceGrammar( rFormula
, rFormulaNmsp
, rGrammar
, sValue
);
1154 bFormula
= sal_True
;
1156 else if (IsXMLToken(aLocalName
, XML_CELL_ADDRESS
))
1160 else if (IsXMLToken(aLocalName
, XML_MATRIX_COVERED
))
1162 bIsCoveredMatrix
= IsXMLToken(sValue
, XML_TRUE
);
1164 else if (IsXMLToken(aLocalName
, XML_NUMBER_MATRIX_COLUMNS_SPANNED
))
1166 bIsMatrix
= sal_True
;
1167 SvXMLUnitConverter::convertNumber(nMatrixCols
, sValue
);
1169 else if (IsXMLToken(aLocalName
, XML_NUMBER_MATRIX_ROWS_SPANNED
))
1171 bIsMatrix
= sal_True
;
1172 SvXMLUnitConverter::convertNumber(nMatrixRows
, sValue
);
1175 else if (nPrefix
== XML_NAMESPACE_OFFICE
)
1177 if (IsXMLToken(aLocalName
, XML_VALUE_TYPE
))
1179 if (IsXMLToken(sValue
, XML_FLOAT
))
1180 bString
= sal_False
;
1181 else if (IsXMLToken(sValue
, XML_DATE
))
1183 rType
= NUMBERFORMAT_DATE
;
1184 bString
= sal_False
;
1186 else if (IsXMLToken(sValue
, XML_TIME
))
1188 rType
= NUMBERFORMAT_TIME
;
1189 bString
= sal_False
;
1192 else if (IsXMLToken(aLocalName
, XML_VALUE
))
1194 SvXMLUnitConverter::convertDouble(fValue
, sValue
);
1197 else if (IsXMLToken(aLocalName
, XML_DATE_VALUE
))
1200 if (GetScImport().GetMM100UnitConverter().setNullDate(GetScImport().GetModel()))
1201 GetScImport().GetMM100UnitConverter().convertDateTime(rDateTimeValue
, sValue
);
1202 fValue
= rDateTimeValue
;
1204 else if (IsXMLToken(aLocalName
, XML_TIME_VALUE
))
1207 GetScImport().GetMM100UnitConverter().convertTime(rDateTimeValue
, sValue
);
1208 fValue
= rDateTimeValue
;
1212 if (bIsCoveredMatrix
)
1213 nMatrixFlag
= MM_REFERENCE
;
1214 else if (bIsMatrix
&& nMatrixRows
&& nMatrixCols
)
1215 nMatrixFlag
= MM_FORMULA
;
1218 ScXMLChangeCellContext::~ScXMLChangeCellContext()
1222 SvXMLImportContext
*ScXMLChangeCellContext::CreateChildContext( USHORT nPrefix
,
1223 const ::rtl::OUString
& rLocalName
,
1224 const ::com::sun::star::uno::Reference
<
1225 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1227 SvXMLImportContext
*pContext(0);
1229 if ((nPrefix
== XML_NAMESPACE_TEXT
) && (IsXMLToken(rLocalName
, XML_P
)))
1232 if (bFirstParagraph
)
1234 pContext
= new ScXMLChangeTextPContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, this);
1235 bFirstParagraph
= sal_False
;
1240 CreateTextPContext(sal_True
);
1241 pContext
= GetScImport().GetTextImport()->CreateTextChildContext(
1242 GetScImport(), nPrefix
, rLocalName
, xAttrList
);
1247 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1252 void ScXMLChangeCellContext::CreateTextPContext(sal_Bool bIsNewParagraph
)
1254 if (GetScImport().GetDocument())
1256 pEditTextObj
= new ScEditEngineTextObj();
1257 pEditTextObj
->acquire();
1258 pEditTextObj
->GetEditEngine()->SetEditTextObjectPool(GetScImport().GetDocument()->GetEditPool());
1259 uno::Reference
<text::XText
> xText(pEditTextObj
);
1262 uno::Reference
<text::XTextCursor
> xTextCursor(xText
->createTextCursor());
1263 if (bIsNewParagraph
)
1265 xText
->setString(sText
);
1266 xTextCursor
->gotoEnd(sal_False
);
1267 uno::Reference
< text::XTextRange
> xTextRange (xTextCursor
, uno::UNO_QUERY
);
1268 if (xTextRange
.is())
1269 xText
->insertControlCharacter(xTextRange
, text::ControlCharacter::PARAGRAPH_BREAK
, sal_False
);
1271 GetScImport().GetTextImport()->SetCursor(xTextCursor
);
1276 void ScXMLChangeCellContext::EndElement()
1282 if (GetImport().GetTextImport()->GetCursor().is())
1284 //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False);
1285 if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True
) )
1288 GetImport().GetTextImport()->GetText()->insertString(
1289 GetImport().GetTextImport()->GetCursorAsRange(), sEmpty
,
1293 if (GetScImport().GetDocument())
1294 rOldCell
= new ScEditCell(pEditTextObj
->CreateTextObject(), GetScImport().GetDocument(), GetScImport().GetDocument()->GetEditPool());
1295 GetScImport().GetTextImport()->ResetCursor();
1296 // delete pEditTextObj;
1297 pEditTextObj
->release();
1303 if (sText
.getLength() && bString
)
1304 rOldCell
= new ScStringCell(sText
);
1306 rOldCell
= new ScValueCell(fValue
);
1307 if (rType
== NUMBERFORMAT_DATE
|| rType
== NUMBERFORMAT_TIME
)
1308 rInputString
= sText
;
1312 // do nothing, this has to do later (on another place)
1313 /*ScAddress aCellPos;
1314 rOldCell = new ScFormulaCell(GetScImport().GetDocument(), aCellPos, sFormula);
1316 static_cast<ScFormulaCell*>(rOldCell)->SetString(sValue);
1318 static_cast<ScFormulaCell*>(rOldCell)->SetDouble(fValue);
1319 static_cast<ScFormulaCell*>(rOldCell)->SetInChangeTrack(sal_True);
1320 if (bIsCoveredMatrix)
1321 static_cast<ScFormulaCell*>(rOldCell)->SetMatrixFlag(MM_REFERENCE);
1322 else if (bIsMatrix && nMatrixRows && nMatrixCols)
1324 static_cast<ScFormulaCell*>(rOldCell)->SetMatrixFlag(MM_FORMULA);
1325 static_cast<ScFormulaCell*>(rOldCell)->SetMatColsRows(static_cast<SCCOL>(nMatrixCols), static_cast<SCROW>(nMatrixRows));
1334 ScXMLPreviousContext::ScXMLPreviousContext( ScXMLImport
& rImport
,
1336 const ::rtl::OUString
& rLName
,
1337 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1338 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1339 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1340 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
),
1345 eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT
),
1346 nType(NUMBERFORMAT_ALL
),
1347 nMatrixFlag(MM_NONE
)
1349 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1350 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1352 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1353 rtl::OUString aLocalName
;
1354 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1355 sAttrName
, &aLocalName
));
1356 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1358 if (nPrefix
== XML_NAMESPACE_TABLE
)
1360 if (IsXMLToken(aLocalName
, XML_ID
))
1361 nID
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1366 ScXMLPreviousContext::~ScXMLPreviousContext()
1370 SvXMLImportContext
*ScXMLPreviousContext::CreateChildContext( USHORT nPrefix
,
1371 const ::rtl::OUString
& rLocalName
,
1372 const ::com::sun::star::uno::Reference
<
1373 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1375 SvXMLImportContext
*pContext(0);
1377 if ((nPrefix
== XML_NAMESPACE_TABLE
) && (IsXMLToken(rLocalName
, XML_CHANGE_TRACK_TABLE_CELL
)))
1378 pContext
= new ScXMLChangeCellContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
,
1379 pOldCell
, sFormulaAddress
, sFormula
, sFormulaNmsp
, eGrammar
, sInputString
, fValue
, nType
, nMatrixFlag
, nMatrixCols
, nMatrixRows
);
1382 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1387 void ScXMLPreviousContext::EndElement()
1389 pChangeTrackingImportHelper
->SetPreviousChange(nID
, new ScMyCellInfo(pOldCell
, sFormulaAddress
, sFormula
, eGrammar
, sInputString
,
1390 fValue
, nType
, nMatrixFlag
, nMatrixCols
, nMatrixRows
));
1393 ScXMLContentChangeContext::ScXMLContentChangeContext( ScXMLImport
& rImport
,
1395 const ::rtl::OUString
& rLName
,
1396 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1397 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1398 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1399 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1401 sal_uInt32
nActionNumber(0);
1402 sal_uInt32
nRejectingNumber(0);
1403 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1405 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1406 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1408 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1409 rtl::OUString aLocalName
;
1410 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1411 sAttrName
, &aLocalName
));
1412 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1414 if (nPrefix
== XML_NAMESPACE_TABLE
)
1416 if (IsXMLToken(aLocalName
, XML_ID
))
1418 nActionNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1420 else if (IsXMLToken(aLocalName
, XML_ACCEPTANCE_STATE
))
1422 if (IsXMLToken(sValue
, XML_ACCEPTED
))
1423 nActionState
= SC_CAS_ACCEPTED
;
1424 else if (IsXMLToken(sValue
, XML_REJECTED
))
1425 nActionState
= SC_CAS_REJECTED
;
1427 else if (IsXMLToken(aLocalName
, XML_REJECTING_CHANGE_ID
))
1429 nRejectingNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1434 pChangeTrackingImportHelper
->StartChangeAction(SC_CAT_CONTENT
);
1435 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1436 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1437 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1440 ScXMLContentChangeContext::~ScXMLContentChangeContext()
1444 SvXMLImportContext
*ScXMLContentChangeContext::CreateChildContext( USHORT nPrefix
,
1445 const ::rtl::OUString
& rLocalName
,
1446 const ::com::sun::star::uno::Reference
<
1447 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1449 SvXMLImportContext
*pContext(0);
1451 if ((nPrefix
== XML_NAMESPACE_OFFICE
) && (IsXMLToken(rLocalName
, XML_CHANGE_INFO
)))
1453 pContext
= new ScXMLChangeInfoContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1455 else if (nPrefix
== XML_NAMESPACE_TABLE
)
1457 if (IsXMLToken(rLocalName
, XML_CELL_ADDRESS
))
1459 pContext
= new ScXMLBigRangeContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, aBigRange
);
1461 else if (IsXMLToken(rLocalName
, XML_DEPENDENCIES
))
1463 pContext
= new ScXMLDependingsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1465 else if (IsXMLToken(rLocalName
, XML_DELETIONS
))
1466 pContext
= new ScXMLDeletionsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1467 else if (IsXMLToken(rLocalName
, XML_PREVIOUS
))
1469 pContext
= new ScXMLPreviousContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1474 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1479 void ScXMLContentChangeContext::EndElement()
1481 pChangeTrackingImportHelper
->SetBigRange(aBigRange
);
1482 pChangeTrackingImportHelper
->EndChangeAction();
1485 ScXMLInsertionContext::ScXMLInsertionContext( ScXMLImport
& rImport
,
1487 const ::rtl::OUString
& rLName
,
1488 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1489 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1490 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1491 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1493 sal_uInt32
nActionNumber(0);
1494 sal_uInt32
nRejectingNumber(0);
1495 sal_Int32
nPosition(0);
1496 sal_Int32
nCount(1);
1497 sal_Int32
nTable(0);
1498 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1499 ScChangeActionType
nActionType(SC_CAT_INSERT_COLS
);
1501 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1502 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1504 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1505 rtl::OUString aLocalName
;
1506 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1507 sAttrName
, &aLocalName
));
1508 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1510 if (nPrefix
== XML_NAMESPACE_TABLE
)
1512 if (IsXMLToken(aLocalName
, XML_ID
))
1514 nActionNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1516 else if (IsXMLToken(aLocalName
, XML_ACCEPTANCE_STATE
))
1518 if (IsXMLToken(sValue
, XML_ACCEPTED
))
1519 nActionState
= SC_CAS_ACCEPTED
;
1520 else if (IsXMLToken(sValue
, XML_REJECTED
))
1521 nActionState
= SC_CAS_REJECTED
;
1523 else if (IsXMLToken(aLocalName
, XML_REJECTING_CHANGE_ID
))
1525 nRejectingNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1527 else if (IsXMLToken(aLocalName
, XML_TYPE
))
1529 if (IsXMLToken(sValue
, XML_ROW
))
1530 nActionType
= SC_CAT_INSERT_ROWS
;
1531 else if (IsXMLToken(sValue
, XML_TABLE
))
1532 nActionType
= SC_CAT_INSERT_TABS
;
1534 else if (IsXMLToken(aLocalName
, XML_POSITION
))
1536 SvXMLUnitConverter::convertNumber(nPosition
, sValue
);
1538 else if (IsXMLToken(aLocalName
, XML_TABLE
))
1540 SvXMLUnitConverter::convertNumber(nTable
, sValue
);
1542 else if (IsXMLToken(aLocalName
, XML_COUNT
))
1544 SvXMLUnitConverter::convertNumber(nCount
, sValue
);
1549 pChangeTrackingImportHelper
->StartChangeAction(nActionType
);
1550 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1551 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1552 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1553 pChangeTrackingImportHelper
->SetPosition(nPosition
, nCount
, nTable
);
1556 ScXMLInsertionContext::~ScXMLInsertionContext()
1560 SvXMLImportContext
*ScXMLInsertionContext::CreateChildContext( USHORT nPrefix
,
1561 const ::rtl::OUString
& rLocalName
,
1562 const ::com::sun::star::uno::Reference
<
1563 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1565 SvXMLImportContext
*pContext(0);
1567 if ((nPrefix
== XML_NAMESPACE_OFFICE
) && (IsXMLToken(rLocalName
, XML_CHANGE_INFO
)))
1569 pContext
= new ScXMLChangeInfoContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1571 else if (nPrefix
== XML_NAMESPACE_TABLE
)
1573 if (IsXMLToken(rLocalName
, XML_DEPENDENCIES
))
1574 pContext
= new ScXMLDependingsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1575 else if (IsXMLToken(rLocalName
, XML_DELETIONS
))
1576 pContext
= new ScXMLDeletionsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1580 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1585 void ScXMLInsertionContext::EndElement()
1587 pChangeTrackingImportHelper
->EndChangeAction();
1590 ScXMLInsertionCutOffContext::ScXMLInsertionCutOffContext( ScXMLImport
& rImport
,
1592 const ::rtl::OUString
& rLName
,
1593 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1594 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1595 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1596 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1599 sal_Int32
nPosition(0);
1600 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1601 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1603 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1604 rtl::OUString aLocalName
;
1605 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1606 sAttrName
, &aLocalName
));
1607 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1609 if (nPrefix
== XML_NAMESPACE_TABLE
)
1611 if (IsXMLToken(aLocalName
, XML_ID
))
1613 nID
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1615 else if (IsXMLToken(aLocalName
, XML_POSITION
))
1617 SvXMLUnitConverter::convertNumber(nPosition
, sValue
);
1621 pChangeTrackingImportHelper
->SetInsertionCutOff(nID
, nPosition
);
1624 ScXMLInsertionCutOffContext::~ScXMLInsertionCutOffContext()
1628 SvXMLImportContext
*ScXMLInsertionCutOffContext::CreateChildContext( USHORT nPrefix
,
1629 const ::rtl::OUString
& rLocalName
,
1630 const ::com::sun::star::uno::Reference
<
1631 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
1633 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1636 void ScXMLInsertionCutOffContext::EndElement()
1640 ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport
& rImport
,
1642 const ::rtl::OUString
& rLName
,
1643 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1644 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1645 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1646 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1649 sal_Int32
nPosition(0);
1650 sal_Int32
nStartPosition(0);
1651 sal_Int32
nEndPosition(0);
1652 sal_Bool
bPosition(sal_False
);
1653 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1654 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1656 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1657 rtl::OUString aLocalName
;
1658 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1659 sAttrName
, &aLocalName
));
1660 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1662 if (nPrefix
== XML_NAMESPACE_TABLE
)
1664 if (IsXMLToken(aLocalName
, XML_ID
))
1666 nID
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1668 else if (IsXMLToken(aLocalName
, XML_POSITION
))
1670 bPosition
= sal_True
;
1671 SvXMLUnitConverter::convertNumber(nPosition
, sValue
);
1673 else if (IsXMLToken(aLocalName
, XML_START_POSITION
))
1675 SvXMLUnitConverter::convertNumber(nStartPosition
, sValue
);
1677 else if (IsXMLToken(aLocalName
, XML_END_POSITION
))
1679 SvXMLUnitConverter::convertNumber(nEndPosition
, sValue
);
1684 nStartPosition
= nEndPosition
= nPosition
;
1685 pChangeTrackingImportHelper
->AddMoveCutOff(nID
, nStartPosition
, nEndPosition
);
1688 ScXMLMovementCutOffContext::~ScXMLMovementCutOffContext()
1692 SvXMLImportContext
*ScXMLMovementCutOffContext::CreateChildContext( USHORT nPrefix
,
1693 const ::rtl::OUString
& rLocalName
,
1694 const ::com::sun::star::uno::Reference
<
1695 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
1697 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1700 void ScXMLMovementCutOffContext::EndElement()
1704 ScXMLCutOffsContext::ScXMLCutOffsContext( ScXMLImport
& rImport
,
1706 const ::rtl::OUString
& rLName
,
1707 const uno::Reference
<xml::sax::XAttributeList
>& /* xAttrList */,
1708 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1709 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1710 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1712 // here are no attributes
1715 ScXMLCutOffsContext::~ScXMLCutOffsContext()
1719 SvXMLImportContext
*ScXMLCutOffsContext::CreateChildContext( USHORT nPrefix
,
1720 const ::rtl::OUString
& rLocalName
,
1721 const ::com::sun::star::uno::Reference
<
1722 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1724 SvXMLImportContext
*pContext(0);
1726 if (nPrefix
== XML_NAMESPACE_TABLE
)
1728 if (IsXMLToken(rLocalName
, XML_INSERTION_CUT_OFF
))
1729 pContext
= new ScXMLInsertionCutOffContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1730 else if (IsXMLToken(rLocalName
, XML_MOVEMENT_CUT_OFF
))
1731 pContext
= new ScXMLMovementCutOffContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1735 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1740 void ScXMLCutOffsContext::EndElement()
1744 ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport
& rImport
,
1746 const ::rtl::OUString
& rLName
,
1747 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1748 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1749 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1750 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1752 sal_uInt32
nActionNumber(0);
1753 sal_uInt32
nRejectingNumber(0);
1754 sal_Int32
nPosition(0);
1755 sal_Int32
nMultiSpanned(0);
1756 sal_Int32
nTable(0);
1757 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1758 ScChangeActionType
nActionType(SC_CAT_DELETE_COLS
);
1760 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1761 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1763 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1764 rtl::OUString aLocalName
;
1765 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1766 sAttrName
, &aLocalName
));
1767 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1769 if (nPrefix
== XML_NAMESPACE_TABLE
)
1771 if (IsXMLToken(aLocalName
, XML_ID
))
1773 nActionNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1775 else if (IsXMLToken(aLocalName
, XML_ACCEPTANCE_STATE
))
1777 if (IsXMLToken(sValue
, XML_ACCEPTED
))
1778 nActionState
= SC_CAS_ACCEPTED
;
1779 else if (IsXMLToken(sValue
, XML_REJECTED
))
1780 nActionState
= SC_CAS_REJECTED
;
1782 else if (IsXMLToken(aLocalName
, XML_REJECTING_CHANGE_ID
))
1784 nRejectingNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1786 else if (IsXMLToken(aLocalName
, XML_TYPE
))
1788 if (IsXMLToken(sValue
, XML_ROW
))
1790 nActionType
= SC_CAT_DELETE_ROWS
;
1792 else if (IsXMLToken(aLocalName
, XML_TABLE
))
1794 nActionType
= SC_CAT_DELETE_TABS
;
1797 else if (IsXMLToken(aLocalName
, XML_POSITION
))
1799 SvXMLUnitConverter::convertNumber(nPosition
, sValue
);
1801 else if (IsXMLToken(aLocalName
, XML_TABLE
))
1803 SvXMLUnitConverter::convertNumber(nTable
, sValue
);
1805 else if (IsXMLToken(aLocalName
, XML_MULTI_DELETION_SPANNED
))
1807 SvXMLUnitConverter::convertNumber(nMultiSpanned
, sValue
);
1812 pChangeTrackingImportHelper
->StartChangeAction(nActionType
);
1813 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1814 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1815 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1816 pChangeTrackingImportHelper
->SetPosition(nPosition
, 1, nTable
);
1817 pChangeTrackingImportHelper
->SetMultiSpanned(static_cast<sal_Int16
>(nMultiSpanned
));
1820 ScXMLDeletionContext::~ScXMLDeletionContext()
1824 SvXMLImportContext
*ScXMLDeletionContext::CreateChildContext( USHORT nPrefix
,
1825 const ::rtl::OUString
& rLocalName
,
1826 const ::com::sun::star::uno::Reference
<
1827 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1829 SvXMLImportContext
*pContext(0);
1831 if ((nPrefix
== XML_NAMESPACE_OFFICE
) && (IsXMLToken(rLocalName
, XML_CHANGE_INFO
)))
1833 pContext
= new ScXMLChangeInfoContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1835 else if (nPrefix
== XML_NAMESPACE_TABLE
)
1837 if (IsXMLToken(rLocalName
, XML_DEPENDENCIES
))
1838 pContext
= new ScXMLDependingsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1839 else if (IsXMLToken(rLocalName
, XML_DELETIONS
))
1840 pContext
= new ScXMLDeletionsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1841 else if (IsXMLToken(rLocalName
, XML_CUT_OFFS
) || rLocalName
.equalsAsciiL("cut_offs", 8))
1842 pContext
= new ScXMLCutOffsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1845 DBG_ERROR("don't know this");
1850 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1855 void ScXMLDeletionContext::EndElement()
1857 pChangeTrackingImportHelper
->EndChangeAction();
1860 ScXMLMovementContext::ScXMLMovementContext( ScXMLImport
& rImport
,
1862 const ::rtl::OUString
& rLName
,
1863 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1864 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1865 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1866 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1868 sal_uInt32
nActionNumber(0);
1869 sal_uInt32
nRejectingNumber(0);
1870 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1872 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1873 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1875 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1876 rtl::OUString aLocalName
;
1877 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1878 sAttrName
, &aLocalName
));
1879 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1881 if (nPrefix
== XML_NAMESPACE_TABLE
)
1883 if (IsXMLToken(aLocalName
, XML_ID
))
1885 nActionNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1887 else if (IsXMLToken(aLocalName
, XML_ACCEPTANCE_STATE
))
1889 if (IsXMLToken(sValue
, XML_ACCEPTED
))
1890 nActionState
= SC_CAS_ACCEPTED
;
1891 else if (IsXMLToken(sValue
, XML_REJECTED
))
1892 nActionState
= SC_CAS_REJECTED
;
1894 else if (IsXMLToken(aLocalName
, XML_REJECTING_CHANGE_ID
))
1896 nRejectingNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1901 pChangeTrackingImportHelper
->StartChangeAction(SC_CAT_MOVE
);
1902 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1903 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1904 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1907 ScXMLMovementContext::~ScXMLMovementContext()
1911 SvXMLImportContext
*ScXMLMovementContext::CreateChildContext( USHORT nPrefix
,
1912 const ::rtl::OUString
& rLocalName
,
1913 const ::com::sun::star::uno::Reference
<
1914 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1916 SvXMLImportContext
*pContext(0);
1918 if ((nPrefix
== XML_NAMESPACE_OFFICE
) && (IsXMLToken(rLocalName
, XML_CHANGE_INFO
)))
1920 pContext
= new ScXMLChangeInfoContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1922 else if (nPrefix
== XML_NAMESPACE_TABLE
)
1924 if (IsXMLToken(rLocalName
, XML_DEPENDENCIES
))
1925 pContext
= new ScXMLDependingsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1926 else if (IsXMLToken(rLocalName
, XML_DELETIONS
))
1927 pContext
= new ScXMLDeletionsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
1928 else if (IsXMLToken(rLocalName
, XML_SOURCE_RANGE_ADDRESS
))
1929 pContext
= new ScXMLBigRangeContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, aSourceRange
);
1930 else if (IsXMLToken(rLocalName
, XML_TARGET_RANGE_ADDRESS
))
1931 pContext
= new ScXMLBigRangeContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, aTargetRange
);
1935 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1940 void ScXMLMovementContext::EndElement()
1942 pChangeTrackingImportHelper
->SetMoveRanges(aSourceRange
, aTargetRange
);
1943 pChangeTrackingImportHelper
->EndChangeAction();
1946 ScXMLRejectionContext::ScXMLRejectionContext( ScXMLImport
& rImport
,
1948 const ::rtl::OUString
& rLName
,
1949 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1950 ScXMLChangeTrackingImportHelper
* pTempChangeTrackingImportHelper
) :
1951 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1952 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper
)
1954 sal_uInt32
nActionNumber(0);
1955 sal_uInt32
nRejectingNumber(0);
1956 ScChangeActionState
nActionState(SC_CAS_VIRGIN
);
1958 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
1959 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1961 const rtl::OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1962 rtl::OUString aLocalName
;
1963 USHORT
nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1964 sAttrName
, &aLocalName
));
1965 const rtl::OUString
& sValue(xAttrList
->getValueByIndex( i
));
1967 if (nPrefix
== XML_NAMESPACE_TABLE
)
1969 if (IsXMLToken(aLocalName
, XML_ID
))
1971 nActionNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1973 else if (IsXMLToken(aLocalName
, XML_ACCEPTANCE_STATE
))
1975 if (IsXMLToken(sValue
, XML_ACCEPTED
))
1976 nActionState
= SC_CAS_ACCEPTED
;
1977 else if (IsXMLToken(sValue
, XML_REJECTED
))
1978 nActionState
= SC_CAS_REJECTED
;
1980 else if (IsXMLToken(aLocalName
, XML_REJECTING_CHANGE_ID
))
1982 nRejectingNumber
= pChangeTrackingImportHelper
->GetIDFromString(sValue
);
1987 pChangeTrackingImportHelper
->StartChangeAction(SC_CAT_MOVE
);
1988 pChangeTrackingImportHelper
->SetActionNumber(nActionNumber
);
1989 pChangeTrackingImportHelper
->SetActionState(nActionState
);
1990 pChangeTrackingImportHelper
->SetRejectingNumber(nRejectingNumber
);
1993 ScXMLRejectionContext::~ScXMLRejectionContext()
1997 SvXMLImportContext
*ScXMLRejectionContext::CreateChildContext( USHORT nPrefix
,
1998 const ::rtl::OUString
& rLocalName
,
1999 const ::com::sun::star::uno::Reference
<
2000 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2002 SvXMLImportContext
*pContext(0);
2004 if ((nPrefix
== XML_NAMESPACE_OFFICE
) && (IsXMLToken(rLocalName
, XML_CHANGE_INFO
)))
2006 pContext
= new ScXMLChangeInfoContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
2008 else if (nPrefix
== XML_NAMESPACE_TABLE
)
2010 if (IsXMLToken(rLocalName
, XML_DEPENDENCIES
))
2011 pContext
= new ScXMLDependingsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
2012 else if (IsXMLToken(rLocalName
, XML_DELETIONS
))
2013 pContext
= new ScXMLDeletionsContext(GetScImport(), nPrefix
, rLocalName
, xAttrList
, pChangeTrackingImportHelper
);
2017 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
2022 void ScXMLRejectionContext::EndElement()
2024 pChangeTrackingImportHelper
->EndChangeAction();