Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <SvXMLAutoCorrectExport.hxx>
21 :
22 : #include <com/sun/star/util/MeasureUnit.hpp>
23 : #include <xmloff/xmltoken.hxx>
24 :
25 : using namespace ::com::sun::star::uno;
26 : using namespace ::com::sun::star;
27 : using namespace ::xmloff::token;
28 : using namespace ::rtl;
29 :
30 0 : 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 0 : pAutocorr_List( pNewAutocorr_List )
37 : {
38 0 : _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST),
39 0 : GetXMLToken ( XML_N_BLOCK_LIST ),
40 0 : XML_NAMESPACE_BLOCKLIST );
41 0 : }
42 :
43 0 : sal_uInt32 SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum /*eClass*/)
44 : {
45 0 : GetDocHandler()->startDocument();
46 :
47 0 : addChaffWhenEncryptedStorage();
48 :
49 : AddAttribute ( XML_NAMESPACE_NONE,
50 0 : _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ),
51 0 : _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
52 : {
53 0 : SvXMLElementExport aRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, true, true);
54 0 : SvxAutocorrWordList::Content aContent = pAutocorr_List->getSortedContent();
55 0 : for( SvxAutocorrWordList::Content::iterator it = aContent.begin();
56 0 : it != aContent.end(); ++it )
57 : {
58 0 : const SvxAutocorrWord* p = *it;
59 :
60 : AddAttribute( XML_NAMESPACE_BLOCKLIST,
61 : XML_ABBREVIATED_NAME,
62 0 : OUString(p->GetShort()));
63 : AddAttribute( XML_NAMESPACE_BLOCKLIST,
64 : XML_NAME,
65 0 : OUString(p->IsTextOnly() ? p->GetLong() : p->GetShort()));
66 :
67 0 : SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, true, true);
68 0 : }
69 : }
70 0 : GetDocHandler()->endDocument();
71 0 : return 0;
72 : }
73 :
74 0 : 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 ),
80 0 : rList( rNewList )
81 : {
82 0 : _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST ),
83 0 : GetXMLToken ( XML_N_BLOCK_LIST ),
84 0 : XML_NAMESPACE_BLOCKLIST );
85 0 : }
86 :
87 0 : sal_uInt32 SvXMLExceptionListExport::exportDoc(enum XMLTokenEnum /*eClass*/)
88 : {
89 0 : GetDocHandler()->startDocument();
90 :
91 0 : addChaffWhenEncryptedStorage();
92 :
93 : AddAttribute ( XML_NAMESPACE_NONE,
94 0 : _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ),
95 0 : _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
96 : {
97 0 : SvXMLElementExport aRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, true, true);
98 0 : sal_uInt16 nBlocks= rList.size();
99 0 : for ( sal_uInt16 i = 0; i < nBlocks; i++)
100 : {
101 : AddAttribute( XML_NAMESPACE_BLOCKLIST,
102 : XML_ABBREVIATED_NAME,
103 0 : rList[i] );
104 0 : SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, true, true);
105 0 : }
106 : }
107 0 : GetDocHandler()->endDocument();
108 0 : return 0;
109 : }
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|