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