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