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
;
28 using namespace ::rtl
;
30 SvXMLAutoCorrectExport::SvXMLAutoCorrectExport(
31 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> xContext
,
32 const SvxAutocorrWordList
* pNewAutocorr_List
,
33 const OUString
&rFileName
,
34 com::sun::star::uno::Reference
< com::sun::star::xml::sax::XDocumentHandler
> &rHandler
)
35 : SvXMLExport( xContext
, rFileName
, util::MeasureUnit::CM
, rHandler
),
36 pAutocorr_List( pNewAutocorr_List
)
38 _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST
),
39 GetXMLToken ( XML_N_BLOCK_LIST
),
40 XML_NAMESPACE_BLOCKLIST
);
43 sal_uInt32
SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum
/*eClass*/)
45 GetDocHandler()->startDocument();
47 addChaffWhenEncryptedStorage();
49 AddAttribute ( XML_NAMESPACE_NONE
,
50 _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST
),
51 _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST
) );
53 SvXMLElementExport
aRoot (*this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK_LIST
, sal_True
, sal_True
);
54 SvxAutocorrWordList::Content aContent
= pAutocorr_List
->getSortedContent();
55 for( SvxAutocorrWordList::Content::iterator it
= aContent
.begin();
56 it
!= aContent
.end(); ++it
)
58 const SvxAutocorrWord
* p
= *it
;
60 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
62 OUString(p
->GetShort()));
63 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
65 OUString(p
->IsTextOnly() ? p
->GetLong() : p
->GetShort()));
67 SvXMLElementExport
aBlock( *this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK
, sal_True
, sal_True
);
70 GetDocHandler()->endDocument();
74 SvXMLExceptionListExport::SvXMLExceptionListExport(
75 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> xContext
,
76 const SvStringsISortDtor
&rNewList
,
77 const OUString
&rFileName
,
78 com::sun::star::uno::Reference
< com::sun::star::xml::sax::XDocumentHandler
> &rHandler
)
79 : SvXMLExport( xContext
, rFileName
, util::MeasureUnit::CM
, rHandler
),
82 _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST
),
83 GetXMLToken ( XML_N_BLOCK_LIST
),
84 XML_NAMESPACE_BLOCKLIST
);
87 sal_uInt32
SvXMLExceptionListExport::exportDoc(enum XMLTokenEnum
/*eClass*/)
89 GetDocHandler()->startDocument();
91 addChaffWhenEncryptedStorage();
93 AddAttribute ( XML_NAMESPACE_NONE
,
94 _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST
),
95 _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST
) );
97 SvXMLElementExport
aRoot (*this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK_LIST
, sal_True
, sal_True
);
98 sal_uInt16 nBlocks
= rList
.size();
99 for ( sal_uInt16 i
= 0; i
< nBlocks
; i
++)
101 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
102 XML_ABBREVIATED_NAME
,
103 OUString( *rList
[i
] ) );
104 SvXMLElementExport
aBlock( *this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK
, sal_True
, sal_True
);
107 GetDocHandler()->endDocument();
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */