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_editeng.hxx" 30 #include <SvXMLAutoCorrectExport.hxx> 31 #define _SVSTDARR_STRINGSISORTDTOR 32 #define _SVSTDARR_STRINGSDTOR 33 #include <svl/svstdarr.hxx> 34 #include <xmloff/xmltoken.hxx> 35 36 using namespace ::com::sun::star::uno; 37 using namespace ::com::sun::star; 38 using namespace ::xmloff::token; 39 using namespace ::rtl; 40 41 // #110680# 42 SvXMLAutoCorrectExport::SvXMLAutoCorrectExport( 43 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, 44 const SvxAutocorrWordList * pNewAutocorr_List, 45 const rtl::OUString &rFileName, 46 com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler> &rHandler) 47 : SvXMLExport( xServiceFactory, rFileName, rHandler ), 48 pAutocorr_List( pNewAutocorr_List ) 49 { 50 _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST), 51 GetXMLToken ( XML_N_BLOCK_LIST ), 52 XML_NAMESPACE_BLOCKLIST ); 53 } 54 55 sal_uInt32 SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum /*eClass*/) 56 { 57 GetDocHandler()->startDocument(); 58 59 AddAttribute ( XML_NAMESPACE_NONE, 60 _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ), 61 _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) ); 62 { 63 SvXMLElementExport aRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, sal_True, sal_True); 64 sal_uInt16 nBlocks= pAutocorr_List->Count(); 65 for ( sal_uInt16 i = 0; i < nBlocks; i++) 66 { 67 SvxAutocorrWord* p = pAutocorr_List->GetObject(i); 68 69 AddAttribute( XML_NAMESPACE_BLOCKLIST, 70 XML_ABBREVIATED_NAME, 71 OUString(p->GetShort())); 72 AddAttribute( XML_NAMESPACE_BLOCKLIST, 73 XML_NAME, 74 OUString(p->IsTextOnly() ? p->GetLong() : p->GetShort())); 75 76 SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, sal_True, sal_True); 77 } 78 } 79 GetDocHandler()->endDocument(); 80 return 0; 81 } 82 83 // #110680# 84 SvXMLExceptionListExport::SvXMLExceptionListExport( 85 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, 86 const SvStringsISortDtor &rNewList, 87 const rtl::OUString &rFileName, 88 com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler> &rHandler) 89 : SvXMLExport( xServiceFactory, rFileName, rHandler ), 90 rList( rNewList ) 91 { 92 _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST ), 93 GetXMLToken ( XML_N_BLOCK_LIST ), 94 XML_NAMESPACE_BLOCKLIST ); 95 } 96 97 sal_uInt32 SvXMLExceptionListExport::exportDoc(enum XMLTokenEnum /*eClass*/) 98 { 99 GetDocHandler()->startDocument(); 100 101 AddAttribute ( XML_NAMESPACE_NONE, 102 _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ), 103 _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) ); 104 { 105 SvXMLElementExport aRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, sal_True, sal_True); 106 sal_uInt16 nBlocks= rList.Count(); 107 for ( sal_uInt16 i = 0; i < nBlocks; i++) 108 { 109 AddAttribute( XML_NAMESPACE_BLOCKLIST, 110 XML_ABBREVIATED_NAME, 111 OUString( *rList[i] ) ); 112 SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, sal_True, sal_True); 113 } 114 } 115 GetDocHandler()->endDocument(); 116 return 0; 117 } 118