LibreOffice Module svx (master) 1
SmartTagMgr.hxx
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#ifndef INCLUDED_SVX_SMARTTAGMGR_HXX
21#define INCLUDED_SVX_SMARTTAGMGR_HXX
22
24#include <com/sun/star/uno/Reference.hxx>
25#include <com/sun/star/uno/Sequence.hxx>
26#include <com/sun/star/util/XModifyListener.hpp>
27#include <com/sun/star/util/XChangesListener.hpp>
28#include <svx/svxdllapi.h>
29
30#include <utility>
31#include <vector>
32#include <map>
33#include <set>
34#include <string_view>
35
36namespace com::sun::star::uno {
37 class XComponentContext;
38}
39
41 class XSmartTagRecognizer;
42 class XSmartTagAction;
43}
44
45namespace com::sun::star::text {
46 class XTextMarkup;
47 class XTextRange;
48}
49
50namespace com::sun::star::i18n {
51 class XBreakIterator;
52}
53
54namespace com::sun::star::lang {
55 struct Locale;
56 struct EventObject;
57 struct ChangesEvent;
58}
59
60namespace com::sun::star::beans {
61 class XPropertySet;
62}
63
64namespace com::sun::star::frame {
65 class XController;
66}
67
74{
75 css::uno::Reference< css::smarttags::XSmartTagAction > mxSmartTagAction;
76 sal_Int32 mnSmartTagIndex;
77 ActionReference( css::uno::Reference< css::smarttags::XSmartTagAction > xSmartTagAction, sal_Int32 nSmartTagIndex )
78 : mxSmartTagAction(std::move( xSmartTagAction)), mnSmartTagIndex( nSmartTagIndex ) {}
79};
80
86class SVX_DLLPUBLIC SmartTagMgr : public cppu::WeakImplHelper< css::util::XModifyListener,
87 css::util::XChangesListener >
88{
89private:
90
91 const OUString maApplicationName;
92 std::vector< css::uno::Reference< css::smarttags::XSmartTagRecognizer > > maRecognizerList;
93 std::vector< css::uno::Reference< css::smarttags::XSmartTagAction > > maActionList;
94 std::set< OUString > maDisabledSmartTagTypes;
95 std::multimap < OUString, ActionReference > maSmartTagMap;
96 mutable css::uno::Reference< css::i18n::XBreakIterator > mxBreakIter;
97 css::uno::Reference< css::uno::XComponentContext> mxContext;
98 css::uno::Reference< css::beans::XPropertySet > mxConfigurationSettings;
100
104 void LoadLibraries();
105
108 void PrepareConfiguration( std::u16string_view rConfigurationGroupName );
109
112 void ReadConfiguration( bool bExcludedTypes, bool bRecognize );
113
116 void RegisterListener();
117
120 void AssociateActionsWithRecognizers();
121
122public:
123
124 SmartTagMgr( OUString aApplicationName );
125 virtual ~SmartTagMgr() override;
126
130 void Init( std::u16string_view rConfigurationGroupName );
131
154 void RecognizeString( const OUString& rText,
155 const css::uno::Reference< css::text::XTextMarkup >& rMarkup,
156 const css::uno::Reference< css::frame::XController >& rController,
157 const css::lang::Locale& rLocale,
158 sal_uInt32 nStart, sal_uInt32 nLen ) const;
159
160 void RecognizeTextRange(const css::uno::Reference< css::text::XTextRange>& rRange,
161 const css::uno::Reference< css::text::XTextMarkup >& rMarkup,
162 const css::uno::Reference< css::frame::XController >& rController) const;
163
175 void GetActionSequences( std::vector< OUString >& rSmartTagTypes,
176 css::uno::Sequence < css::uno::Sequence< css::uno::Reference< css::smarttags::XSmartTagAction > > >& rActionComponentsSequence,
177 css::uno::Sequence < css::uno::Sequence< sal_Int32 > >& rActionIndicesSequence ) const;
178
187 OUString GetSmartTagCaption( const OUString& rSmartTagType, const css::lang::Locale& rLocale ) const;
188
191 bool IsSmartTagTypeEnabled( const OUString& rSmartTagType ) const;
192
195 bool IsLabelTextWithSmartTags() const { return mbLabelTextWithSmartTags; }
196
199 sal_uInt32 NumberOfRecognizers() const { return maRecognizerList.size(); }
200
203 css::uno::Reference< css::smarttags::XSmartTagRecognizer > const &
204 GetRecognizer( sal_uInt32 i ) const { return maRecognizerList[i]; }
205
208 bool IsSmartTagsEnabled() const { return 0 != NumberOfRecognizers() &&
209 IsLabelTextWithSmartTags(); }
210
213 void WriteConfiguration( const bool* bLabelTextWithSmartTags,
214 const std::vector< OUString >* pDisabledTypes ) const;
215
218 const OUString& GetApplicationName() const { return maApplicationName; }
219
220 // css::lang::XEventListener
221 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
222
223 // css::util::XModifyListener
224 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
225
226 // css::util::XChangesListener
227 virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& Event ) override;
228};
229
230#endif
231
232/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The smart tag manager maintains all installed action and recognizer services.
Definition: SmartTagMgr.hxx:88
css::uno::Reference< css::beans::XPropertySet > mxConfigurationSettings
Definition: SmartTagMgr.hxx:98
bool IsLabelTextWithSmartTags() const
Enable or disable smart tags.
css::uno::Reference< css::uno::XComponentContext > mxContext
Definition: SmartTagMgr.hxx:97
const OUString & GetApplicationName() const
Returns the name of the application this instance has been created by.
sal_uInt32 NumberOfRecognizers() const
Returns the number of registered recognizers.
std::vector< css::uno::Reference< css::smarttags::XSmartTagAction > > maActionList
Definition: SmartTagMgr.hxx:93
std::vector< css::uno::Reference< css::smarttags::XSmartTagRecognizer > > maRecognizerList
Definition: SmartTagMgr.hxx:92
const OUString maApplicationName
Definition: SmartTagMgr.hxx:91
std::set< OUString > maDisabledSmartTagTypes
Definition: SmartTagMgr.hxx:94
css::uno::Reference< css::i18n::XBreakIterator > mxBreakIter
Definition: SmartTagMgr.hxx:96
bool mbLabelTextWithSmartTags
Definition: SmartTagMgr.hxx:99
css::uno::Reference< css::smarttags::XSmartTagRecognizer > const & GetRecognizer(sal_uInt32 i) const
Returns a recognizer.
std::multimap< OUString, ActionReference > maSmartTagMap
Definition: SmartTagMgr.hxx:95
bool IsSmartTagsEnabled() const
Is smart tag recognition active?
void Init()
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:29
int i
A reference to a smart tag action.
Definition: SmartTagMgr.hxx:74
sal_Int32 mnSmartTagIndex
Definition: SmartTagMgr.hxx:76
css::uno::Reference< css::smarttags::XSmartTagAction > mxSmartTagAction
Definition: SmartTagMgr.hxx:75
ActionReference(css::uno::Reference< css::smarttags::XSmartTagAction > xSmartTagAction, sal_Int32 nSmartTagIndex)
Definition: SmartTagMgr.hxx:77
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28