1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <SvXMLAutoCorrectExport.hxx>
22 #include <com/sun/star/util/MeasureUnit.hpp>
23 #include <xmloff/xmltoken.hxx>
25 using namespace ::com::sun::star::uno
;
26 using namespace ::com::sun::star
;
27 using namespace ::xmloff::token
;
29 SvXMLAutoCorrectExport::SvXMLAutoCorrectExport(
30 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> xContext
,
31 const SvxAutocorrWordList
* pNewAutocorr_List
,
32 const OUString
&rFileName
,
33 com::sun::star::uno::Reference
< com::sun::star::xml::sax::XDocumentHandler
> &rHandler
)
34 : SvXMLExport( xContext
, "", rFileName
, util::MeasureUnit::CM
, rHandler
),
35 pAutocorr_List( pNewAutocorr_List
)
37 _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST
),
38 GetXMLToken ( XML_N_BLOCK_LIST
),
39 XML_NAMESPACE_BLOCKLIST
);
42 sal_uInt32
SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum
/*eClass*/)
44 GetDocHandler()->startDocument();
46 addChaffWhenEncryptedStorage();
48 AddAttribute ( XML_NAMESPACE_NONE
,
49 _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST
),
50 _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST
) );
52 SvXMLElementExport
aRoot (*this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK_LIST
, true, true);
53 SvxAutocorrWordList::Content aContent
= pAutocorr_List
->getSortedContent();
54 for( SvxAutocorrWordList::Content::iterator it
= aContent
.begin();
55 it
!= aContent
.end(); ++it
)
57 const SvxAutocorrWord
* p
= *it
;
59 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
61 OUString(p
->GetShort()));
62 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
64 OUString(p
->IsTextOnly() ? p
->GetLong() : p
->GetShort()));
66 SvXMLElementExport
aBlock( *this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK
, true, true);
69 GetDocHandler()->endDocument();
73 SvXMLExceptionListExport::SvXMLExceptionListExport(
74 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> xContext
,
75 const SvStringsISortDtor
&rNewList
,
76 const OUString
&rFileName
,
77 com::sun::star::uno::Reference
< com::sun::star::xml::sax::XDocumentHandler
> &rHandler
)
78 : SvXMLExport( xContext
, "", rFileName
, util::MeasureUnit::CM
, rHandler
),
81 _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST
),
82 GetXMLToken ( XML_N_BLOCK_LIST
),
83 XML_NAMESPACE_BLOCKLIST
);
86 sal_uInt32
SvXMLExceptionListExport::exportDoc(enum XMLTokenEnum
/*eClass*/)
88 GetDocHandler()->startDocument();
90 addChaffWhenEncryptedStorage();
92 AddAttribute ( XML_NAMESPACE_NONE
,
93 _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST
),
94 _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST
) );
96 SvXMLElementExport
aRoot (*this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK_LIST
, true, true);
97 sal_uInt16 nBlocks
= rList
.size();
98 for ( sal_uInt16 i
= 0; i
< nBlocks
; i
++)
100 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
101 XML_ABBREVIATED_NAME
,
103 SvXMLElementExport
aBlock( *this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK
, true, true);
106 GetDocHandler()->endDocument();
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */