update credits
[LibreOffice.git] / sw / source / core / swg / SwXMLBlockImport.cxx
blobc007cd871e578c3d61fd9522b6b4042c3db45d90
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <SwXMLBlockImport.hxx>
21 #include <xmloff/nmspmap.hxx>
22 #include <xmloff/xmlnmspe.hxx>
23 #include <SwXMLBlockListContext.hxx>
24 #include <SwXMLTextBlocks.hxx>
25 using namespace ::com::sun::star::uno;
26 using namespace ::com::sun::star;
27 using namespace ::xmloff::token;
29 sal_Char const sXML_np__block_list[] = "_block-list";
30 sal_Char const sXML_np__office[] = "_ooffice";
31 sal_Char const sXML_np__text[] = "_otext";
33 SwXMLBlockListImport::SwXMLBlockListImport(
34 const uno::Reference< uno::XComponentContext > xContext,
35 SwXMLTextBlocks &rBlocks )
36 : SvXMLImport( xContext, 0 ),
37 rBlockList (rBlocks)
39 GetNamespaceMap().Add( OUString ( sXML_np__block_list ),
40 GetXMLToken ( XML_N_BLOCK_LIST ),
41 XML_NAMESPACE_BLOCKLIST );
44 SwXMLBlockListImport::~SwXMLBlockListImport ( void )
45 throw ()
49 SvXMLImportContext *SwXMLBlockListImport::CreateContext(
50 sal_uInt16 nPrefix,
51 const OUString& rLocalName,
52 const uno::Reference< xml::sax::XAttributeList > & xAttrList )
54 SvXMLImportContext *pContext = 0;
55 if ( XML_NAMESPACE_BLOCKLIST == nPrefix &&
56 IsXMLToken ( rLocalName, XML_BLOCK_LIST ) )
57 pContext = new SwXMLBlockListContext( *this, nPrefix, rLocalName,
58 xAttrList );
59 else
60 pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
61 return pContext;
64 SwXMLTextBlockImport::SwXMLTextBlockImport(
65 const uno::Reference< uno::XComponentContext > xContext,
66 SwXMLTextBlocks &rBlocks,
67 String & rNewText,
68 sal_Bool bNewTextOnly )
69 : SvXMLImport(xContext, IMPORT_ALL ),
70 rBlockList ( rBlocks ),
71 bTextOnly ( bNewTextOnly ),
72 m_rText ( rNewText )
74 GetNamespaceMap().Add( OUString( sXML_np__office ),
75 GetXMLToken(XML_N_OFFICE_OOO),
76 XML_NAMESPACE_OFFICE );
77 GetNamespaceMap().Add( OUString( sXML_np__text ),
78 GetXMLToken(XML_N_TEXT_OOO),
79 XML_NAMESPACE_TEXT );
82 SwXMLTextBlockImport::~SwXMLTextBlockImport ( void )
83 throw()
87 SvXMLImportContext *SwXMLTextBlockImport::CreateContext(
88 sal_uInt16 nPrefix,
89 const OUString& rLocalName,
90 const uno::Reference< xml::sax::XAttributeList > & xAttrList )
92 SvXMLImportContext *pContext = 0;
93 if( XML_NAMESPACE_OFFICE == nPrefix &&
94 IsXMLToken ( rLocalName, bTextOnly ? XML_DOCUMENT : XML_DOCUMENT_CONTENT ) )
95 pContext = new SwXMLTextBlockDocumentContext( *this, nPrefix, rLocalName, xAttrList );
96 else
97 pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
98 return pContext;
100 void SAL_CALL SwXMLTextBlockImport::endDocument(void)
101 throw( xml::sax::SAXException, uno::RuntimeException )
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */