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 <com/sun/star/xml/sax/XDocumentHandler.hpp>
24 #include <xmloff/namespacemap.hxx>
25 #include <xmloff/xmlnamespace.hxx>
26 #include <xmloff/xmltoken.hxx>
28 using namespace ::com::sun::star::uno
;
29 using namespace ::com::sun::star
;
30 using namespace ::xmloff::token
;
32 SvXMLAutoCorrectExport::SvXMLAutoCorrectExport(
33 const css::uno::Reference
< css::uno::XComponentContext
> & xContext
,
34 const SvxAutocorrWordList
* pNewAutocorr_List
,
35 const OUString
&rFileName
,
36 css::uno::Reference
< css::xml::sax::XDocumentHandler
> const &rHandler
)
37 : SvXMLExport( xContext
, u
""_ustr
, rFileName
, util::MeasureUnit::CM
, rHandler
),
38 pAutocorr_List( pNewAutocorr_List
)
40 GetNamespaceMap_().Add( GetXMLToken ( XML_NP_BLOCK_LIST
),
41 GetXMLToken ( XML_N_BLOCK_LIST
),
42 XML_NAMESPACE_BLOCKLIST
);
45 ErrCode
SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum
/*eClass*/)
47 GetDocHandler()->startDocument();
49 addChaffWhenEncryptedStorage();
51 AddAttribute ( XML_NAMESPACE_NONE
,
52 GetNamespaceMap_().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST
),
53 GetNamespaceMap_().GetNameByKey ( XML_NAMESPACE_BLOCKLIST
) );
55 SvXMLElementExport
aRoot (*this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK_LIST
, true, true);
56 const SvxAutocorrWordList::AutocorrWordSetType
& rContent
= pAutocorr_List
->getSortedContent();
57 for (auto const& content
: rContent
)
59 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
62 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
64 content
.IsTextOnly() ? content
.GetLong() : content
.GetShort());
66 SvXMLElementExport
aBlock( *this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK
, true, true);
69 GetDocHandler()->endDocument();
73 SvXMLExceptionListExport::SvXMLExceptionListExport(
74 const css::uno::Reference
< css::uno::XComponentContext
> & xContext
,
75 const SvStringsISortDtor
&rNewList
,
76 const OUString
&rFileName
,
77 css::uno::Reference
< css::xml::sax::XDocumentHandler
> const &rHandler
)
78 : SvXMLExport( xContext
, u
""_ustr
, rFileName
, util::MeasureUnit::CM
, rHandler
),
81 GetNamespaceMap_().Add( GetXMLToken ( XML_NP_BLOCK_LIST
),
82 GetXMLToken ( XML_N_BLOCK_LIST
),
83 XML_NAMESPACE_BLOCKLIST
);
86 ErrCode
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: */