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 "SvXMLAutoCorrectImport.hxx"
21 #include "SvXMLAutoCorrectTokenHandler.hxx"
24 using namespace css::xml::sax
;
26 SvXMLAutoCorrectImport::SvXMLAutoCorrectImport(
27 const uno::Reference
< uno::XComponentContext
> & xContext
,
28 SvxAutocorrWordList
*pNewAutocorr_List
,
29 SvxAutoCorrect
&rNewAutoCorrect
,
30 const css::uno::Reference
< css::embed::XStorage
>& rNewStorage
)
31 : SvXMLImport( xContext
, "" ),
32 pAutocorr_List (pNewAutocorr_List
),
33 rAutoCorrect ( rNewAutoCorrect
),
34 xStorage ( rNewStorage
)
38 SvXMLAutoCorrectImport::~SvXMLAutoCorrectImport() throw ()
42 SvXMLImportContext
*SvXMLAutoCorrectImport::CreateFastContext( sal_Int32 Element
,
43 const uno::Reference
< xml::sax::XFastAttributeList
> & /*xAttrList*/ )
45 if( Element
== SvXMLAutoCorrectToken::BLOCKLIST
)
46 return new SvXMLWordListContext( *this );
50 SvXMLWordListContext::SvXMLWordListContext(
51 SvXMLAutoCorrectImport
& rImport
) :
52 SvXMLImportContext ( rImport
),
55 rLocalRef
.rAutoCorrect
.refreshBlockList( rLocalRef
.xStorage
);
58 css::uno::Reference
<XFastContextHandler
> SAL_CALL
SvXMLWordListContext::createFastChildContext(
59 sal_Int32 Element
, const uno::Reference
< xml::sax::XFastAttributeList
> & xAttrList
)
61 if ( Element
== SvXMLAutoCorrectToken::BLOCK
)
62 return new SvXMLWordContext (rLocalRef
, xAttrList
);
66 SvXMLWordListContext::~SvXMLWordListContext()
70 SvXMLWordContext::SvXMLWordContext(
71 SvXMLAutoCorrectImport
& rImport
,
72 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) :
73 SvXMLImportContext ( rImport
)
75 OUString sWrong
, sRight
;
76 if ( xAttrList
.is() && xAttrList
->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME
) )
77 sWrong
= xAttrList
->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME
);
79 if ( xAttrList
.is() && xAttrList
->hasAttribute( SvXMLAutoCorrectToken::NAME
) )
80 sRight
= xAttrList
->getValue( SvXMLAutoCorrectToken::NAME
);
82 if ( sWrong
.isEmpty() || sRight
.isEmpty())
85 bool bOnlyTxt
= sRight
!= sWrong
;
88 const OUString
sLongSave( sRight
);
89 if( !rImport
.rAutoCorrect
.GetLongText( sWrong
, sRight
) &&
90 !sLongSave
.isEmpty() )
96 rImport
.pAutocorr_List
->LoadEntry( sWrong
, sRight
, bOnlyTxt
);
99 SvXMLWordContext::~SvXMLWordContext()
103 SvXMLExceptionListImport::SvXMLExceptionListImport(
104 const uno::Reference
< uno::XComponentContext
> & xContext
,
105 SvStringsISortDtor
& rNewList
)
106 : SvXMLImport( xContext
, "" ),
111 SvXMLExceptionListImport::~SvXMLExceptionListImport() throw ()
115 SvXMLImportContext
*SvXMLExceptionListImport::CreateFastContext(sal_Int32 Element
,
116 const uno::Reference
< xml::sax::XFastAttributeList
> & /*xAttrList*/ )
118 if( Element
== SvXMLAutoCorrectToken::BLOCKLIST
)
119 return new SvXMLExceptionListContext( *this );
123 SvXMLExceptionListContext::SvXMLExceptionListContext(
124 SvXMLExceptionListImport
& rImport
) :
125 SvXMLImportContext ( rImport
),
130 css::uno::Reference
<xml::sax::XFastContextHandler
> SAL_CALL
SvXMLExceptionListContext::createFastChildContext(
131 sal_Int32 Element
, const uno::Reference
< xml::sax::XFastAttributeList
> & xAttrList
)
133 if ( Element
== SvXMLAutoCorrectToken::BLOCK
)
134 return new SvXMLExceptionContext (rLocalRef
, xAttrList
);
138 SvXMLExceptionListContext::~SvXMLExceptionListContext()
142 SvXMLExceptionContext::SvXMLExceptionContext(
143 SvXMLExceptionListImport
& rImport
,
144 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) :
145 SvXMLImportContext ( rImport
)
148 if( xAttrList
.is() && xAttrList
->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME
) )
149 sWord
= xAttrList
->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME
);
154 rImport
.rList
.insert( sWord
);
157 SvXMLExceptionContext::~SvXMLExceptionContext()
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */