xref: /AOO41X/main/sw/source/core/swg/SwXMLBlockImport.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 #include <SwXMLBlockImport.hxx>
27 #include <xmloff/nmspmap.hxx>
28 #include <xmloff/xmlnmspe.hxx>
29 #ifndef _SW_XMLBLOCKLIST_CONTEXT_HXX
30 #include <SwXMLBlockListContext.hxx>
31 #endif
32 #include <SwXMLTextBlocks.hxx>
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star;
35 using namespace ::xmloff::token;
36 using ::rtl::OUString;
37 
38 sal_Char __READONLY_DATA sXML_np__block_list[] = "_block-list";
39 sal_Char __READONLY_DATA sXML_np__office[] = "_ooffice";
40 sal_Char __READONLY_DATA sXML_np__text[] = "_otext";
41 
42 // #110680#
SwXMLBlockListImport(const uno::Reference<lang::XMultiServiceFactory> xServiceFactory,SwXMLTextBlocks & rBlocks)43 SwXMLBlockListImport::SwXMLBlockListImport(
44     const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
45     SwXMLTextBlocks &rBlocks )
46 :   SvXMLImport( xServiceFactory, 0 ),
47     rBlockList (rBlocks)
48 {
49     GetNamespaceMap().Add( OUString ( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__block_list ) ),
50                            GetXMLToken ( XML_N_BLOCK_LIST ),
51                            XML_NAMESPACE_BLOCKLIST );
52 }
53 
~SwXMLBlockListImport(void)54 SwXMLBlockListImport::~SwXMLBlockListImport ( void )
55     throw ()
56 {
57 }
58 
CreateContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)59 SvXMLImportContext *SwXMLBlockListImport::CreateContext(
60         sal_uInt16 nPrefix,
61         const OUString& rLocalName,
62         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
63 {
64     SvXMLImportContext *pContext = 0;
65     if ( XML_NAMESPACE_BLOCKLIST == nPrefix &&
66          IsXMLToken ( rLocalName, XML_BLOCK_LIST ) )
67         pContext = new SwXMLBlockListContext( *this, nPrefix, rLocalName,
68                                               xAttrList );
69     else
70         pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
71     return pContext;
72 }
73 
74 // #110680#
SwXMLTextBlockImport(const uno::Reference<lang::XMultiServiceFactory> xServiceFactory,SwXMLTextBlocks & rBlocks,String & rNewText,sal_Bool bNewTextOnly)75 SwXMLTextBlockImport::SwXMLTextBlockImport(
76     const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
77     SwXMLTextBlocks &rBlocks,
78     String & rNewText,
79     sal_Bool bNewTextOnly )
80 :   SvXMLImport(xServiceFactory, IMPORT_ALL ),
81     rBlockList ( rBlocks ),
82     bTextOnly ( bNewTextOnly ),
83     m_rText ( rNewText )
84 {
85     GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
86                             GetXMLToken(XML_N_OFFICE_OOO),
87                             XML_NAMESPACE_OFFICE );
88     GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text ) ),
89                             GetXMLToken(XML_N_TEXT_OOO),
90                             XML_NAMESPACE_TEXT );
91 }
92 
~SwXMLTextBlockImport(void)93 SwXMLTextBlockImport::~SwXMLTextBlockImport ( void )
94     throw()
95 {
96 }
97 
CreateContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)98 SvXMLImportContext *SwXMLTextBlockImport::CreateContext(
99         sal_uInt16 nPrefix,
100         const OUString& rLocalName,
101         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
102 {
103     SvXMLImportContext *pContext = 0;
104     if( XML_NAMESPACE_OFFICE == nPrefix &&
105         IsXMLToken ( rLocalName, bTextOnly ? XML_DOCUMENT : XML_DOCUMENT_CONTENT ) )
106         pContext = new SwXMLTextBlockDocumentContext( *this, nPrefix, rLocalName, xAttrList );
107     else
108         pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
109     return pContext;
110 }
endDocument(void)111 void SAL_CALL SwXMLTextBlockImport::endDocument(void)
112         throw( xml::sax::SAXException, uno::RuntimeException )
113 {
114 }
115