/src/libreoffice/xmloff/source/text/XMLTrackedChangesImportContext.cxx
Line | Count | Source |
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 <sal/log.hxx> |
24 | | #include <sax/tools/converter.hxx> |
25 | | #include <xmloff/xmlimp.hxx> |
26 | | #include <xmloff/xmlnamespace.hxx> |
27 | | #include <xmloff/xmltoken.hxx> |
28 | | |
29 | | |
30 | | using ::com::sun::star::uno::Reference; |
31 | | using namespace ::xmloff::token; |
32 | | |
33 | | |
34 | | XMLTrackedChangesImportContext::XMLTrackedChangesImportContext( |
35 | | SvXMLImport& rImport) : |
36 | 229 | SvXMLImportContext(rImport) |
37 | 229 | { |
38 | 229 | } |
39 | | |
40 | | XMLTrackedChangesImportContext::~XMLTrackedChangesImportContext() |
41 | 229 | { |
42 | 229 | } |
43 | | |
44 | | void XMLTrackedChangesImportContext::startFastElement( sal_Int32 /*nElement*/, |
45 | | const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) |
46 | 229 | { |
47 | 229 | bool bTrackChanges = true; |
48 | | |
49 | | // scan for text:track-changes and text:protection-key attributes |
50 | 229 | for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) |
51 | 0 | { |
52 | 0 | if (aIter.getToken() == XML_ELEMENT(TEXT, XML_TRACK_CHANGES) ) |
53 | 0 | { |
54 | 0 | bool bTmp(false); |
55 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
56 | 0 | { |
57 | 0 | bTrackChanges = bTmp; |
58 | 0 | } |
59 | 0 | break; |
60 | 0 | } |
61 | 0 | else |
62 | 0 | XMLOFF_WARN_UNKNOWN("xmloff", aIter); |
63 | 0 | } |
64 | | |
65 | | // set tracked changes |
66 | 229 | GetImport().GetTextImport()->SetRecordChanges( bTrackChanges ); |
67 | 229 | } |
68 | | |
69 | | |
70 | | css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTrackedChangesImportContext::createFastChildContext( |
71 | | sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) |
72 | 10 | { |
73 | 10 | if ( nElement == XML_ELEMENT(TEXT, XML_CHANGED_REGION) ) |
74 | 0 | { |
75 | 0 | return new XMLChangedRegionImportContext(GetImport()); |
76 | 0 | } |
77 | 10 | else |
78 | 10 | XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); |
79 | 10 | return nullptr; |
80 | 10 | } |
81 | | |
82 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |