1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*190118d0SAndrew Rist  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19*190118d0SAndrew Rist  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir #include <SvXMLAutoCorrectExport.hxx>
27cdf0e10cSrcweir #define _SVSTDARR_STRINGSISORTDTOR
28cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
29cdf0e10cSrcweir #include <svl/svstdarr.hxx>
30cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace ::com::sun::star::uno;
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir using namespace ::xmloff::token;
35cdf0e10cSrcweir using namespace ::rtl;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir // #110680#
SvXMLAutoCorrectExport(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> xServiceFactory,const SvxAutocorrWordList * pNewAutocorr_List,const rtl::OUString & rFileName,com::sun::star::uno::Reference<com::sun::star::xml::sax::XDocumentHandler> & rHandler)38cdf0e10cSrcweir SvXMLAutoCorrectExport::SvXMLAutoCorrectExport(
39cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
40cdf0e10cSrcweir 	const SvxAutocorrWordList *  pNewAutocorr_List,
41cdf0e10cSrcweir 	const rtl::OUString &rFileName,
42cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler> &rHandler)
43cdf0e10cSrcweir :	SvXMLExport( xServiceFactory, rFileName, rHandler ),
44cdf0e10cSrcweir 	pAutocorr_List( pNewAutocorr_List )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	_GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST),
47cdf0e10cSrcweir 							GetXMLToken ( XML_N_BLOCK_LIST ),
48cdf0e10cSrcweir 							XML_NAMESPACE_BLOCKLIST );
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
exportDoc(enum XMLTokenEnum)51cdf0e10cSrcweir sal_uInt32 SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum /*eClass*/)
52cdf0e10cSrcweir {
53cdf0e10cSrcweir 	GetDocHandler()->startDocument();
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 	AddAttribute ( XML_NAMESPACE_NONE,
56cdf0e10cSrcweir 				   _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ),
57cdf0e10cSrcweir 				   _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
58cdf0e10cSrcweir 	{
59cdf0e10cSrcweir 		SvXMLElementExport aRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, sal_True, sal_True);
60cdf0e10cSrcweir 		sal_uInt16 nBlocks= pAutocorr_List->Count();
61cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < nBlocks; i++)
62cdf0e10cSrcweir 		{
63cdf0e10cSrcweir 			SvxAutocorrWord* p = pAutocorr_List->GetObject(i);
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 			AddAttribute( XML_NAMESPACE_BLOCKLIST,
66cdf0e10cSrcweir 						  XML_ABBREVIATED_NAME,
67cdf0e10cSrcweir 						  OUString(p->GetShort()));
68cdf0e10cSrcweir 			AddAttribute( XML_NAMESPACE_BLOCKLIST,
69cdf0e10cSrcweir 						  XML_NAME,
70cdf0e10cSrcweir 						  OUString(p->IsTextOnly() ? p->GetLong() : p->GetShort()));
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 			SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, sal_True, sal_True);
73cdf0e10cSrcweir 		}
74cdf0e10cSrcweir 	}
75cdf0e10cSrcweir 	GetDocHandler()->endDocument();
76cdf0e10cSrcweir 	return 0;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // #110680#
SvXMLExceptionListExport(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> xServiceFactory,const SvStringsISortDtor & rNewList,const rtl::OUString & rFileName,com::sun::star::uno::Reference<com::sun::star::xml::sax::XDocumentHandler> & rHandler)80cdf0e10cSrcweir SvXMLExceptionListExport::SvXMLExceptionListExport(
81cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
82cdf0e10cSrcweir 	const SvStringsISortDtor &rNewList,
83cdf0e10cSrcweir 	const rtl::OUString &rFileName,
84cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler> &rHandler)
85cdf0e10cSrcweir :	SvXMLExport( xServiceFactory, rFileName, rHandler ),
86cdf0e10cSrcweir 	rList( rNewList )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	_GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST ),
89cdf0e10cSrcweir 							GetXMLToken ( XML_N_BLOCK_LIST ),
90cdf0e10cSrcweir 							XML_NAMESPACE_BLOCKLIST );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
exportDoc(enum XMLTokenEnum)93cdf0e10cSrcweir sal_uInt32 SvXMLExceptionListExport::exportDoc(enum XMLTokenEnum /*eClass*/)
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	GetDocHandler()->startDocument();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	AddAttribute ( XML_NAMESPACE_NONE,
98cdf0e10cSrcweir 			       _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ),
99cdf0e10cSrcweir 				   _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
100cdf0e10cSrcweir 	{
101cdf0e10cSrcweir 		SvXMLElementExport aRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, sal_True, sal_True);
102cdf0e10cSrcweir 		sal_uInt16 nBlocks= rList.Count();
103cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < nBlocks; i++)
104cdf0e10cSrcweir 		{
105cdf0e10cSrcweir 			AddAttribute( XML_NAMESPACE_BLOCKLIST,
106cdf0e10cSrcweir 						  XML_ABBREVIATED_NAME,
107cdf0e10cSrcweir 						  OUString( *rList[i] ) );
108cdf0e10cSrcweir 			SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, sal_True, sal_True);
109cdf0e10cSrcweir 		}
110cdf0e10cSrcweir 	}
111cdf0e10cSrcweir 	GetDocHandler()->endDocument();
112cdf0e10cSrcweir 	return 0;
113cdf0e10cSrcweir }
114