nss: upgrade to release 3.73
[LibreOffice.git] / editeng / source / misc / SvXMLAutoCorrectImport.cxx
blobb2a9e51d9823e8b0fd2513d441cf2180b4578bf0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
23 using namespace css;
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 );
47 return nullptr;
50 SvXMLWordListContext::SvXMLWordListContext(
51 SvXMLAutoCorrectImport& rImport ) :
52 SvXMLImportContext ( rImport ),
53 rLocalRef(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);
63 return nullptr;
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())
83 return;
85 bool bOnlyTxt = sRight != sWrong;
86 if( !bOnlyTxt )
88 const OUString sLongSave( sRight );
89 if( !rImport.rAutoCorrect.GetLongText( sWrong, sRight ) &&
90 !sLongSave.isEmpty() )
92 sRight = sLongSave;
93 bOnlyTxt = true;
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, "" ),
107 rList (rNewList)
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 );
120 return nullptr;
123 SvXMLExceptionListContext::SvXMLExceptionListContext(
124 SvXMLExceptionListImport& rImport ) :
125 SvXMLImportContext ( rImport ),
126 rLocalRef(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);
135 return nullptr;
138 SvXMLExceptionListContext::~SvXMLExceptionListContext()
142 SvXMLExceptionContext::SvXMLExceptionContext(
143 SvXMLExceptionListImport& rImport,
144 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) :
145 SvXMLImportContext ( rImport )
147 OUString sWord;
148 if( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME ) )
149 sWord = xAttrList->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME );
151 if (sWord.isEmpty())
152 return;
154 rImport.rList.insert( sWord );
157 SvXMLExceptionContext::~SvXMLExceptionContext()
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */