LibreOffice Module xmloff (master)  1
XMLChangeInfoContext.cxx
Go to the documentation of this file.
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 "XMLChangeInfoContext.hxx"
23 #include <com/sun/star/uno/Reference.h>
24 #include <xmloff/xmlnamespace.hxx>
25 #include <xmloff/xmltoken.hxx>
26 #include <xmloff/xmlimp.hxx>
27 
28 
29 using namespace ::xmloff::token;
30 
31 using ::com::sun::star::uno::Reference;
32 using ::com::sun::star::xml::sax::XAttributeList;
33 
34 
36  SvXMLImport& rImport,
37  sal_uInt16 nPrefix,
38  const OUString& rLocalName,
40  const OUString& rChangeType)
41 : SvXMLImportContext(rImport, nPrefix, rLocalName)
42 , rType(rChangeType)
43 , rChangedRegion(rPParent)
44 {
45 }
46 
48 {
49 }
50 
51 void XMLChangeInfoContext::StartElement(const Reference<XAttributeList> &)
52 {
53  // no attributes
54 }
55 
57  sal_uInt16 nPrefix,
58  const OUString& rLocalName,
59  const Reference<XAttributeList >& /*xAttrList*/ )
60 {
61  SvXMLImportContextRef xContext;
62 
63  if( XML_NAMESPACE_DC == nPrefix )
64  {
65  if( IsXMLToken( rLocalName, XML_CREATOR ) )
66  xContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
67  rLocalName, sAuthorBuffer);
68  else if( IsXMLToken( rLocalName, XML_DATE ) )
69  xContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
70  rLocalName, sDateTimeBuffer);
71  }
72  else if ( ( XML_NAMESPACE_TEXT == nPrefix ||
73  XML_NAMESPACE_LO_EXT == nPrefix ) &&
74  IsXMLToken( rLocalName, XML_P ) )
75  {
76  xContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
77  rLocalName, sCommentBuffer);
78  }
79 
80  return xContext;
81 }
82 
84 {
85  // set values at changed region context
86  rChangedRegion.SetChangeInfo(rType, sAuthorBuffer.makeStringAndClear(),
87  sCommentBuffer.makeStringAndClear(),
88  sDateTimeBuffer.makeStringAndClear());
89 }
90 
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3434
XMLChangeInfoContext(SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName, XMLChangedRegionImportContext &rChangedRegion, const OUString &rChangeType)
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
virtual ~XMLChangeInfoContext() override
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
void SetChangeInfo(const OUString &rType, const OUString &rAuthor, const OUString &rComment, const OUString &rDate)
change info: To be called from change-info context
XMLChangedRegionImportContext & rChangedRegion
constexpr sal_uInt16 XML_NAMESPACE_TEXT
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
Import elements contained in a element.
constexpr sal_uInt16 XML_NAMESPACE_DC
Import all text into a string buffer.
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
Handling of tokens in XML: