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 "XMLChangeElementImportContext.hxx"
21 : #include "XMLChangedRegionImportContext.hxx"
22 : #include "XMLChangeInfoContext.hxx"
23 : #include <com/sun/star/uno/Reference.h>
24 : #include <xmloff/xmlimp.hxx>
25 : #include <xmloff/xmlnmspe.hxx>
26 : #include <xmloff/xmltoken.hxx>
27 :
28 :
29 :
30 : using ::com::sun::star::uno::Reference;
31 : using ::com::sun::star::xml::sax::XAttributeList;
32 : using ::xmloff::token::IsXMLToken;
33 : using ::xmloff::token::XML_P;
34 : using ::xmloff::token::XML_CHANGE_INFO;
35 :
36 0 : TYPEINIT1( XMLChangeElementImportContext, SvXMLImportContext );
37 :
38 38 : XMLChangeElementImportContext::XMLChangeElementImportContext(
39 : SvXMLImport& rImport,
40 : sal_uInt16 nPrefix,
41 : const OUString& rLocalName,
42 : bool bAccContent,
43 : XMLChangedRegionImportContext& rParent) :
44 : SvXMLImportContext(rImport, nPrefix, rLocalName),
45 : bAcceptContent(bAccContent),
46 38 : rChangedRegion(rParent)
47 : {
48 38 : }
49 :
50 56 : SvXMLImportContext* XMLChangeElementImportContext::CreateChildContext(
51 : sal_uInt16 nPrefix,
52 : const OUString& rLocalName,
53 : const Reference<XAttributeList> & xAttrList)
54 : {
55 56 : SvXMLImportContext* pContext = NULL;
56 :
57 94 : if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
58 38 : IsXMLToken( rLocalName, XML_CHANGE_INFO) )
59 : {
60 38 : pContext = new XMLChangeInfoContext(GetImport(), nPrefix, rLocalName,
61 38 : rChangedRegion, GetLocalName());
62 : }
63 : else
64 : {
65 : // import into redline -> create XText
66 18 : rChangedRegion.UseRedlineText();
67 :
68 18 : pContext = GetImport().GetTextImport()->CreateTextChildContext(
69 18 : GetImport(), nPrefix, rLocalName, xAttrList,
70 36 : XML_TEXT_TYPE_CHANGED_REGION);
71 :
72 18 : if (NULL == pContext)
73 : {
74 : // no text element
75 : // illegal element content! TODO: discard this redline!
76 : // for the moment -> use default
77 : pContext = SvXMLImportContext::CreateChildContext(
78 0 : nPrefix, rLocalName, xAttrList);
79 : }
80 : }
81 :
82 56 : return pContext;
83 : }
84 :
85 : // #107848#
86 38 : void XMLChangeElementImportContext::StartElement( const Reference< XAttributeList >& )
87 : {
88 38 : if(bAcceptContent)
89 : {
90 14 : GetImport().GetTextImport()->SetInsideDeleteContext(true);
91 : }
92 38 : }
93 :
94 : // #107848#
95 38 : void XMLChangeElementImportContext::EndElement()
96 : {
97 38 : if(bAcceptContent)
98 : {
99 14 : GetImport().GetTextImport()->SetInsideDeleteContext(false);
100 : }
101 38 : }
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|