1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <SvXMLAutoCorrectExport.hxx>
31 #include <com/sun/star/util/MeasureUnit.hpp>
32 #include <svl/svstdarr.hxx>
33 #include <xmloff/xmltoken.hxx>
35 using namespace ::com::sun::star::uno
;
36 using namespace ::com::sun::star
;
37 using namespace ::xmloff::token
;
38 using namespace ::rtl
;
40 SvXMLAutoCorrectExport::SvXMLAutoCorrectExport(
41 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
42 const SvxAutocorrWordList
* pNewAutocorr_List
,
43 const rtl::OUString
&rFileName
,
44 com::sun::star::uno::Reference
< com::sun::star::xml::sax::XDocumentHandler
> &rHandler
)
45 : SvXMLExport( xServiceFactory
, rFileName
, util::MeasureUnit::CM
, rHandler
),
46 pAutocorr_List( pNewAutocorr_List
)
48 _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST
),
49 GetXMLToken ( XML_N_BLOCK_LIST
),
50 XML_NAMESPACE_BLOCKLIST
);
53 sal_uInt32
SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum
/*eClass*/)
55 GetDocHandler()->startDocument();
57 addChaffWhenEncryptedStorage();
59 AddAttribute ( XML_NAMESPACE_NONE
,
60 _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST
),
61 _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST
) );
63 SvXMLElementExport
aRoot (*this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK_LIST
, sal_True
, sal_True
);
64 sal_uInt16 nBlocks
= pAutocorr_List
->Count();
65 for ( sal_uInt16 i
= 0; i
< nBlocks
; i
++)
67 SvxAutocorrWord
* p
= pAutocorr_List
->GetObject(i
);
69 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
71 OUString(p
->GetShort()));
72 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
74 OUString(p
->IsTextOnly() ? p
->GetLong() : p
->GetShort()));
76 SvXMLElementExport
aBlock( *this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK
, sal_True
, sal_True
);
79 GetDocHandler()->endDocument();
83 SvXMLExceptionListExport::SvXMLExceptionListExport(
84 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
85 const SvStringsISortDtor
&rNewList
,
86 const rtl::OUString
&rFileName
,
87 com::sun::star::uno::Reference
< com::sun::star::xml::sax::XDocumentHandler
> &rHandler
)
88 : SvXMLExport( xServiceFactory
, rFileName
, util::MeasureUnit::CM
, rHandler
),
91 _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST
),
92 GetXMLToken ( XML_N_BLOCK_LIST
),
93 XML_NAMESPACE_BLOCKLIST
);
96 sal_uInt32
SvXMLExceptionListExport::exportDoc(enum XMLTokenEnum
/*eClass*/)
98 GetDocHandler()->startDocument();
100 addChaffWhenEncryptedStorage();
102 AddAttribute ( XML_NAMESPACE_NONE
,
103 _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST
),
104 _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST
) );
106 SvXMLElementExport
aRoot (*this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK_LIST
, sal_True
, sal_True
);
107 sal_uInt16 nBlocks
= rList
.Count();
108 for ( sal_uInt16 i
= 0; i
< nBlocks
; i
++)
110 AddAttribute( XML_NAMESPACE_BLOCKLIST
,
111 XML_ABBREVIATED_NAME
,
112 OUString( *rList
[i
] ) );
113 SvXMLElementExport
aBlock( *this, XML_NAMESPACE_BLOCKLIST
, XML_BLOCK
, sal_True
, sal_True
);
116 GetDocHandler()->endDocument();
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */