Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "XMLTrackedChangesImportContext.hxx"
21 : #include "XMLChangedRegionImportContext.hxx"
22 : #include <com/sun/star/uno/Reference.h>
23 : #include <com/sun/star/uno/Sequence.h>
24 : #include <sax/tools/converter.hxx>
25 : #include <xmloff/xmlimp.hxx>
26 : #include "xmloff/xmlnmspe.hxx"
27 : #include <xmloff/nmspmap.hxx>
28 : #include <xmloff/xmltoken.hxx>
29 :
30 :
31 : using ::rtl::OUString;
32 : using ::com::sun::star::uno::Reference;
33 : using ::com::sun::star::uno::Sequence;
34 : using ::com::sun::star::xml::sax::XAttributeList;
35 : using namespace ::xmloff::token;
36 :
37 :
38 :
39 0 : TYPEINIT1( XMLTrackedChangesImportContext, SvXMLImportContext );
40 :
41 0 : XMLTrackedChangesImportContext::XMLTrackedChangesImportContext(
42 : SvXMLImport& rImport,
43 : sal_uInt16 nPrefix,
44 : const OUString& rLocalName) :
45 0 : SvXMLImportContext(rImport, nPrefix, rLocalName)
46 : {
47 0 : }
48 :
49 0 : XMLTrackedChangesImportContext::~XMLTrackedChangesImportContext()
50 : {
51 0 : }
52 :
53 0 : void XMLTrackedChangesImportContext::StartElement(
54 : const Reference<XAttributeList> & xAttrList )
55 : {
56 0 : sal_Bool bTrackChanges = sal_True;
57 :
58 : // scan for text:track-changes and text:protection-key attributes
59 0 : sal_Int16 nLength = xAttrList->getLength();
60 0 : for( sal_Int16 i = 0; i < nLength; i++ )
61 : {
62 0 : OUString sLocalName;
63 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
64 0 : GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
65 :
66 0 : if ( XML_NAMESPACE_TEXT == nPrefix )
67 : {
68 0 : if ( IsXMLToken( sLocalName, XML_TRACK_CHANGES ) )
69 : {
70 0 : bool bTmp(false);
71 0 : if (::sax::Converter::convertBool(
72 0 : bTmp, xAttrList->getValueByIndex(i)) )
73 : {
74 0 : bTrackChanges = bTmp;
75 : }
76 : }
77 : }
78 0 : }
79 :
80 : // set tracked changes
81 0 : GetImport().GetTextImport()->SetRecordChanges( bTrackChanges );
82 0 : }
83 :
84 :
85 0 : SvXMLImportContext* XMLTrackedChangesImportContext::CreateChildContext(
86 : sal_uInt16 nPrefix,
87 : const OUString& rLocalName,
88 : const Reference<XAttributeList> & xAttrList)
89 : {
90 0 : SvXMLImportContext* pContext = NULL;
91 :
92 0 : if ( (XML_NAMESPACE_TEXT == nPrefix) &&
93 0 : IsXMLToken( rLocalName, XML_CHANGED_REGION ) )
94 : {
95 0 : pContext = new XMLChangedRegionImportContext(GetImport(),
96 0 : nPrefix, rLocalName);
97 : }
98 :
99 0 : if (NULL == pContext)
100 : {
101 : pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName,
102 0 : xAttrList);
103 : }
104 :
105 0 : return pContext;
106 : }
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|