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