Update ooo320-m1
[ooovba.git] / sw / source / core / swg / SwXMLBlockImport.cxx
blob32ec8376a33ffc27a74c716cd03ac254beece756
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SwXMLBlockImport.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <SwXMLBlockImport.hxx>
34 #include <xmloff/nmspmap.hxx>
35 #include <xmloff/xmlnmspe.hxx>
36 #ifndef _SW_XMLBLOCKLIST_CONTEXT_HXX
37 #include <SwXMLBlockListContext.hxx>
38 #endif
39 #include <SwXMLTextBlocks.hxx>
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star;
42 using namespace ::xmloff::token;
43 using ::rtl::OUString;
45 sal_Char __READONLY_DATA sXML_np__block_list[] = "_block-list";
46 sal_Char __READONLY_DATA sXML_np__office[] = "_ooffice";
47 sal_Char __READONLY_DATA sXML_np__text[] = "_otext";
49 // #110680#
50 SwXMLBlockListImport::SwXMLBlockListImport(
51 const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
52 SwXMLTextBlocks &rBlocks )
53 : SvXMLImport( xServiceFactory, 0 ),
54 rBlockList (rBlocks)
56 GetNamespaceMap().Add( OUString ( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__block_list ) ),
57 GetXMLToken ( XML_N_BLOCK_LIST ),
58 XML_NAMESPACE_BLOCKLIST );
61 SwXMLBlockListImport::~SwXMLBlockListImport ( void )
62 throw ()
66 SvXMLImportContext *SwXMLBlockListImport::CreateContext(
67 sal_uInt16 nPrefix,
68 const OUString& rLocalName,
69 const uno::Reference< xml::sax::XAttributeList > & xAttrList )
71 SvXMLImportContext *pContext = 0;
72 if ( XML_NAMESPACE_BLOCKLIST == nPrefix &&
73 IsXMLToken ( rLocalName, XML_BLOCK_LIST ) )
74 pContext = new SwXMLBlockListContext( *this, nPrefix, rLocalName,
75 xAttrList );
76 else
77 pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
78 return pContext;
81 // #110680#
82 SwXMLTextBlockImport::SwXMLTextBlockImport(
83 const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
84 SwXMLTextBlocks &rBlocks,
85 String & rNewText,
86 sal_Bool bNewTextOnly )
87 : SvXMLImport(xServiceFactory, IMPORT_ALL ),
88 rBlockList ( rBlocks ),
89 bTextOnly ( bNewTextOnly ),
90 m_rText ( rNewText )
92 GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
93 GetXMLToken(XML_N_OFFICE_OOO),
94 XML_NAMESPACE_OFFICE );
95 GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text ) ),
96 GetXMLToken(XML_N_TEXT_OOO),
97 XML_NAMESPACE_TEXT );
100 SwXMLTextBlockImport::~SwXMLTextBlockImport ( void )
101 throw()
105 SvXMLImportContext *SwXMLTextBlockImport::CreateContext(
106 sal_uInt16 nPrefix,
107 const OUString& rLocalName,
108 const uno::Reference< xml::sax::XAttributeList > & xAttrList )
110 SvXMLImportContext *pContext = 0;
111 if( XML_NAMESPACE_OFFICE == nPrefix &&
112 IsXMLToken ( rLocalName, bTextOnly ? XML_DOCUMENT : XML_DOCUMENT_CONTENT ) )
113 pContext = new SwXMLTextBlockDocumentContext( *this, nPrefix, rLocalName, xAttrList );
114 else
115 pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
116 return pContext;
118 void SAL_CALL SwXMLTextBlockImport::endDocument(void)
119 throw( xml::sax::SAXException, uno::RuntimeException )