LibreOffice Module editeng (master) 1
SvXMLAutoCorrectImport.cxx
Go to the documentation of this file.
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 <utility>
21
24
25using namespace css;
26using namespace css::xml::sax;
27
29 const uno::Reference< uno::XComponentContext > & xContext,
30 SvxAutocorrWordList *pNewAutocorr_List,
31 SvxAutoCorrect &rNewAutoCorrect,
32 css::uno::Reference < css::embed::XStorage > xNewStorage)
33: SvXMLImport( xContext, "" ),
34 pAutocorr_List (pNewAutocorr_List),
35 rAutoCorrect ( rNewAutoCorrect ),
36 xStorage (std::move( xNewStorage ))
37{
38}
39
41{
42}
43
45 const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ )
46{
48 return new SvXMLWordListContext( *this );
49 return nullptr;
50}
51
53 SvXMLAutoCorrectImport& rImport ) :
54 SvXMLImportContext ( rImport ),
55 rLocalRef(rImport)
56{
58}
59
60css::uno::Reference<XFastContextHandler> SAL_CALL SvXMLWordListContext::createFastChildContext(
61 sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
62{
63 if ( Element == SvXMLAutoCorrectToken::BLOCK )
64 return new SvXMLWordContext (rLocalRef, xAttrList);
65 return nullptr;
66}
67
69{
70}
71
74 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) :
75 SvXMLImportContext ( rImport )
76{
77 OUString sWrong, sRight;
78 if ( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME ) )
79 sWrong = xAttrList->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME );
80
81 if ( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::NAME ) )
82 sRight = xAttrList->getValue( SvXMLAutoCorrectToken::NAME );
83
84 if ( sWrong.isEmpty() || sRight.isEmpty())
85 return;
86
87 bool bOnlyTxt = sRight != sWrong;
88 if( !bOnlyTxt )
89 {
90 const OUString sLongSave( sRight );
91 if( !rImport.rAutoCorrect.GetLongText( sWrong, sRight ) &&
92 !sLongSave.isEmpty() )
93 {
94 sRight = sLongSave;
95 bOnlyTxt = true;
96 }
97 }
98 rImport.pAutocorr_List->LoadEntry( sWrong, sRight, bOnlyTxt );
99}
100
102{
103}
104
106 const uno::Reference< uno::XComponentContext > & xContext,
107 SvStringsISortDtor & rNewList )
108: SvXMLImport( xContext, "" ),
109 rList (rNewList)
110{
111}
112
114{
115}
116
118 const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ )
119{
120 if( Element == SvXMLAutoCorrectToken::BLOCKLIST )
121 return new SvXMLExceptionListContext( *this );
122 return nullptr;
123}
124
126 SvXMLExceptionListImport& rImport ) :
127 SvXMLImportContext ( rImport ),
128 rLocalRef(rImport)
129{
130}
131
132css::uno::Reference<xml::sax::XFastContextHandler> SAL_CALL SvXMLExceptionListContext::createFastChildContext(
133 sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
134{
135 if ( Element == SvXMLAutoCorrectToken::BLOCK )
136 return new SvXMLExceptionContext (rLocalRef, xAttrList);
137 return nullptr;
138}
139
141{
142}
143
146 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) :
147 SvXMLImportContext ( rImport )
148{
149 OUString sWord;
150 if( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME ) )
151 sWord = xAttrList->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME );
152
153 if (sWord.isEmpty())
154 return;
155
156 rImport.rList.insert( sWord );
157}
158
160{
161}
162
163/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxAutocorrWordList * pAutocorr_List
SvXMLAutoCorrectImport(const css::uno::Reference< css::uno::XComponentContext > &xContext, SvxAutocorrWordList *pNewAutocorr_List, SvxAutoCorrect &rNewAutoCorrect, css::uno::Reference< css::embed::XStorage > xNewStorage)
virtual ~SvXMLAutoCorrectImport() noexcept override
virtual SvXMLImportContext * CreateFastContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
css::uno::Reference< css::embed::XStorage > xStorage
virtual ~SvXMLExceptionContext() override
SvXMLExceptionContext(SvXMLExceptionListImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual ~SvXMLExceptionListContext() override
SvXMLExceptionListContext(SvXMLExceptionListImport &rImport)
SvXMLExceptionListImport & rLocalRef
SvXMLExceptionListImport(const css::uno::Reference< css::uno::XComponentContext > &xContext, SvStringsISortDtor &rNewList)
virtual SvXMLImportContext * CreateFastContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual ~SvXMLExceptionListImport() noexcept override
virtual ~SvXMLWordContext() override
SvXMLWordContext(SvXMLAutoCorrectImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual ~SvXMLWordListContext() override
SvXMLWordListContext(SvXMLAutoCorrectImport &rImport)
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
SvXMLAutoCorrectImport & rLocalRef
virtual void refreshBlockList(const css::uno::Reference< css::embed::XStorage > &rStg)
Definition: svxacorr.cxx:1921
virtual bool GetLongText(const OUString &rShort, OUString &rLong)
Definition: svxacorr.cxx:1916
void LoadEntry(const OUString &sWrong, const OUString &sRight, bool bOnlyTxt)
Definition: svxacorr.cxx:2924
std::pair< const_iterator, bool > insert(Value &&x)