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