LibreOffice Module sw (master)  1
xmltext.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 <xmloff/xmlnmspe.hxx>
21 #include "xmlimp.hxx"
22 
23 using namespace ::com::sun::star;
24 using namespace ::com::sun::star::uno;
25 using namespace ::com::sun::star::text;
26 
27 namespace {
28 
29 class SwXMLBodyContentContext_Impl : public SvXMLImportContext
30 {
31  SwXMLImport& GetSwImport() { return static_cast<SwXMLImport&>(GetImport()); }
32 
33 public:
34 
35  SwXMLBodyContentContext_Impl( SwXMLImport& rImport, const OUString& rLName );
36 
38  sal_uInt16 nPrefix, const OUString& rLocalName,
39  const Reference< xml::sax::XAttributeList > & xAttrList ) override;
40 
41  // The body element's text:global attribute can be ignored, because
42  // we must have the correct object shell already.
43  virtual void EndElement() override;
44 };
45 
46 }
47 
48 SwXMLBodyContentContext_Impl::SwXMLBodyContentContext_Impl( SwXMLImport& rImport,
49  const OUString& rLName ) :
50  SvXMLImportContext( rImport, XML_NAMESPACE_OFFICE, rLName )
51 {
52 }
53 
54 SvXMLImportContextRef SwXMLBodyContentContext_Impl::CreateChildContext(
55  sal_uInt16 nPrefix, const OUString& rLocalName,
56  const Reference< xml::sax::XAttributeList > & xAttrList )
57 {
58  SvXMLImportContext *pContext = GetSwImport().GetTextImport()->CreateTextChildContext(
59  GetImport(), nPrefix, rLocalName, xAttrList,
60  XMLTextType::Body );
61  if( !pContext )
62  pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
63 
64  return pContext;
65 }
66 
67 void SwXMLBodyContentContext_Impl::EndElement()
68 {
69  /* Code moved to SwXMLOmport::endDocument */
70  GetImport().GetTextImport()->SetOutlineStyles( false );
71 }
72 
74  const OUString& rLocalName )
75 {
76  SvXMLImportContext *pContext = nullptr;
77 
78  if( !IsStylesOnlyMode() )
79  pContext = new SwXMLBodyContentContext_Impl( *this, rLocalName );
80  else
81  pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE,
82  rLocalName );
83 
84  return pContext;
85 }
86 
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void EndElement()
SvXMLImport & GetImport()
SvXMLImportContext * CreateBodyContentContext(const OUString &rLocalName)
Definition: xmltext.cxx:73
bool IsStylesOnlyMode() const
Definition: xmlimp.hxx:155
friend friend class SvXMLImportContext
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)