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 <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;
28 :
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";
32 :
33 0 : SwXMLBlockListImport::SwXMLBlockListImport(
34 : const uno::Reference< uno::XComponentContext > xContext,
35 : SwXMLTextBlocks &rBlocks )
36 : : SvXMLImport( xContext, "", 0 ),
37 0 : rBlockList (rBlocks)
38 : {
39 0 : GetNamespaceMap().Add( OUString ( sXML_np__block_list ),
40 0 : GetXMLToken ( XML_N_BLOCK_LIST ),
41 0 : XML_NAMESPACE_BLOCKLIST );
42 0 : }
43 :
44 0 : SwXMLBlockListImport::~SwXMLBlockListImport ( void )
45 0 : throw ()
46 : {
47 0 : }
48 :
49 0 : SvXMLImportContext *SwXMLBlockListImport::CreateContext(
50 : sal_uInt16 nPrefix,
51 : const OUString& rLocalName,
52 : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
53 : {
54 0 : SvXMLImportContext *pContext = 0;
55 0 : if ( XML_NAMESPACE_BLOCKLIST == nPrefix &&
56 0 : IsXMLToken ( rLocalName, XML_BLOCK_LIST ) )
57 : pContext = new SwXMLBlockListContext( *this, nPrefix, rLocalName,
58 0 : xAttrList );
59 : else
60 0 : pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
61 0 : return pContext;
62 : }
63 :
64 0 : SwXMLTextBlockImport::SwXMLTextBlockImport(
65 : const uno::Reference< uno::XComponentContext > xContext,
66 : SwXMLTextBlocks &rBlocks,
67 : OUString & rNewText,
68 : sal_Bool bNewTextOnly )
69 : : SvXMLImport(xContext, "", IMPORT_ALL ),
70 : rBlockList ( rBlocks ),
71 : bTextOnly ( bNewTextOnly ),
72 0 : m_rText ( rNewText )
73 : {
74 0 : GetNamespaceMap().Add( OUString( sXML_np__office ),
75 0 : GetXMLToken(XML_N_OFFICE_OOO),
76 0 : XML_NAMESPACE_OFFICE );
77 0 : GetNamespaceMap().Add( OUString( sXML_np__text ),
78 0 : GetXMLToken(XML_N_TEXT_OOO),
79 0 : XML_NAMESPACE_TEXT );
80 0 : }
81 :
82 0 : SwXMLTextBlockImport::~SwXMLTextBlockImport ( void )
83 0 : throw()
84 : {
85 0 : }
86 :
87 0 : SvXMLImportContext *SwXMLTextBlockImport::CreateContext(
88 : sal_uInt16 nPrefix,
89 : const OUString& rLocalName,
90 : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
91 : {
92 0 : SvXMLImportContext *pContext = 0;
93 0 : if( XML_NAMESPACE_OFFICE == nPrefix &&
94 0 : IsXMLToken ( rLocalName, bTextOnly ? XML_DOCUMENT : XML_DOCUMENT_CONTENT ) )
95 0 : pContext = new SwXMLTextBlockDocumentContext( *this, nPrefix, rLocalName, xAttrList );
96 : else
97 0 : pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
98 0 : return pContext;
99 : }
100 0 : void SAL_CALL SwXMLTextBlockImport::endDocument(void)
101 : throw( xml::sax::SAXException, uno::RuntimeException, std::exception )
102 : {
103 0 : }
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|