1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "XMLChangeInfoContext.hxx"
27 #include "XMLChangedRegionImportContext.hxx"
28 #include "XMLStringBufferImportContext.hxx"
29 #include <com/sun/star/uno/Reference.h>
30 #include "xmloff/xmlnmspe.hxx"
31 #include <xmloff/nmspmap.hxx>
32 #include <xmloff/xmltoken.hxx>
33 #include <xmloff/xmlimp.hxx>
34 
35 
36 
37 using namespace ::xmloff::token;
38 
39 using ::rtl::OUString;
40 using ::com::sun::star::uno::Reference;
41 using ::com::sun::star::xml::sax::XAttributeList;
42 
43 
44 TYPEINIT1(XMLChangeInfoContext, SvXMLImportContext);
45 
XMLChangeInfoContext(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,XMLChangedRegionImportContext & rPParent,const OUString & rChangeType)46 XMLChangeInfoContext::XMLChangeInfoContext(
47 	SvXMLImport& rImport,
48 	sal_uInt16 nPrefix,
49 	const OUString& rLocalName,
50 	XMLChangedRegionImportContext& rPParent,
51 	const OUString& rChangeType)
52 :	SvXMLImportContext(rImport, nPrefix, rLocalName)
53 ,	rType(rChangeType)
54 ,	rChangedRegion(rPParent)
55 {
56 }
57 
~XMLChangeInfoContext()58 XMLChangeInfoContext::~XMLChangeInfoContext()
59 {
60 }
61 
StartElement(const Reference<XAttributeList> &)62 void XMLChangeInfoContext::StartElement(const Reference<XAttributeList> &)
63 {
64 	// no attributes
65 }
66 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)67 SvXMLImportContext* XMLChangeInfoContext::CreateChildContext(
68 	sal_uInt16 nPrefix,
69 	const OUString& rLocalName,
70 	const Reference<XAttributeList >& xAttrList )
71 {
72 	SvXMLImportContext* pContext = NULL;
73 
74 	if( XML_NAMESPACE_DC == nPrefix )
75 	{
76 		if( IsXMLToken( rLocalName, XML_CREATOR ) )
77 			pContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
78 											rLocalName, sAuthorBuffer);
79 		else if( IsXMLToken( rLocalName, XML_DATE ) )
80 			pContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
81 											rLocalName, sDateTimeBuffer);
82 	}
83 	else if ( ( XML_NAMESPACE_TEXT == nPrefix ) &&
84          IsXMLToken( rLocalName, XML_P )       )
85 	{
86 		pContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
87 												   rLocalName, sCommentBuffer);
88 	}
89 
90 	if( !pContext )
91 	{
92 		pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName,
93 														  xAttrList);
94 	}
95 
96 	return pContext;
97 }
98 
EndElement()99 void XMLChangeInfoContext::EndElement()
100 {
101 	// set values at changed region context
102 	rChangedRegion.SetChangeInfo(rType, sAuthorBuffer.makeStringAndClear(),
103 								 sCommentBuffer.makeStringAndClear(),
104 								 sDateTimeBuffer.makeStringAndClear());
105 }
106