lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / svx / SmartTagMgr.hxx
blob42dbf494cb3c1dfb7242b2453ab0e9f08cc97c50
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 #ifndef INCLUDED_SVX_SMARTTAGMGR_HXX
21 #define INCLUDED_SVX_SMARTTAGMGR_HXX
23 #include <cppuhelper/implbase.hxx>
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>
30 #include <vector>
31 #include <map>
32 #include <set>
34 namespace com { namespace sun { namespace star { namespace uno {
35 class XComponentContext;
36 } } } }
38 namespace com { namespace sun { namespace star { namespace smarttags {
39 class XSmartTagRecognizer;
40 class XSmartTagAction;
41 } } } }
43 namespace com { namespace sun { namespace star { namespace text {
44 class XTextMarkup;
45 class XTextRange;
46 } } } }
48 namespace com { namespace sun { namespace star { namespace i18n {
49 class XBreakIterator;
50 } } } }
52 namespace com { namespace sun { namespace star { namespace lang {
53 struct Locale;
54 struct EventObject;
55 struct ChangesEvent;
56 } } } }
58 namespace com { namespace sun { namespace star { namespace beans {
59 class XPropertySet;
60 } } } }
62 namespace com { namespace sun { namespace star { namespace frame {
63 class XController;
64 } } } }
66 /** A reference to a smart tag action
68 An action service can support various actions. Therefore an ActionReference
69 consists of a reference to the service and index.
71 struct ActionReference
73 css::uno::Reference< css::smarttags::XSmartTagAction > mxSmartTagAction;
74 sal_Int32 const mnSmartTagIndex;
75 ActionReference( css::uno::Reference< css::smarttags::XSmartTagAction > const & xSmartTagAction, sal_Int32 nSmartTagIndex )
76 : mxSmartTagAction( xSmartTagAction), mnSmartTagIndex( nSmartTagIndex ) {}
79 /** The smart tag manager maintains all installed action and recognizer services
81 This class organizes the available smarttag libraries and provides access functions
82 to these libraries. The smart tag manager is a singleton.
84 class SVX_DLLPUBLIC SmartTagMgr : public cppu::WeakImplHelper< css::util::XModifyListener,
85 css::util::XChangesListener >
87 private:
89 const OUString maApplicationName;
90 std::vector< css::uno::Reference< css::smarttags::XSmartTagRecognizer > > maRecognizerList;
91 std::vector< css::uno::Reference< css::smarttags::XSmartTagAction > > maActionList;
92 std::set< OUString > maDisabledSmartTagTypes;
93 std::multimap < OUString, ActionReference > maSmartTagMap;
94 mutable css::uno::Reference< css::i18n::XBreakIterator > mxBreakIter;
95 css::uno::Reference< css::uno::XComponentContext> mxContext;
96 css::uno::Reference< css::beans::XPropertySet > mxConfigurationSettings;
97 bool mbLabelTextWithSmartTags;
99 /** Checks for installed smart tag recognizers/actions and stores them in
100 maRecognizerList and maActionList.
102 void LoadLibraries();
104 /** Prepare configuration access.
106 void PrepareConfiguration( const OUString& rConfigurationGroupName );
108 /** Reads the configuration data.
110 void ReadConfiguration( bool bExcludedTypes, bool bRecognize );
112 /** Registers the smart tag manager as listener at the package manager.
114 void RegisterListener();
116 /** Sets up a map that maps smart tag type names to actions references.
118 void AssociateActionsWithRecognizers();
120 public:
122 SmartTagMgr( const OUString& rApplicationName );
123 virtual ~SmartTagMgr() override;
125 /** Triggers configuration reading, library loading and listener registration
126 NOTE: MUST BE CALLED AFTER CONSTRUCTION!
128 void Init( const OUString& rConfigurationGroupName );
130 /** Dispatches the recognize call to all installed smart tag recognizers
132 @param rText
133 The string to be scanned by the recognizers.
135 @param xMarkup
136 The object allows the recognizers to store any found smart tags.
138 @param xController
139 The current controller of the document.
141 @param rLocale
142 The locale of rText.
144 @param nStart
145 The start offset of the text to be scanned in rText.
147 @param nLen
148 The length of the text to be scanned.
152 void RecognizeString( const OUString& rText,
153 const css::uno::Reference< css::text::XTextMarkup >& rMarkup,
154 const css::uno::Reference< css::frame::XController >& rController,
155 const css::lang::Locale& rLocale,
156 sal_uInt32 nStart, sal_uInt32 nLen ) const;
158 void RecognizeTextRange(const css::uno::Reference< css::text::XTextRange>& rRange,
159 const css::uno::Reference< css::text::XTextMarkup >& rMarkup,
160 const css::uno::Reference< css::frame::XController >& rController) const;
162 /** Returns all action references associated with a given list of smart tag types
164 @param rSmartTagTypes
165 The list of types
167 @param rActionComponentsSequence
168 Output parameter
170 @param rActionIndicesSequence
171 Output parameter
173 void GetActionSequences( std::vector< OUString >& rSmartTagTypes,
174 css::uno::Sequence < css::uno::Sequence< css::uno::Reference< css::smarttags::XSmartTagAction > > >& rActionComponentsSequence,
175 css::uno::Sequence < css::uno::Sequence< sal_Int32 > >& rActionIndicesSequence ) const;
177 /** Returns the caption for a smart tag type.
179 @param rSmartTagType
180 The given smart tag type.
182 @param rLocale
183 The locale.
185 OUString GetSmartTagCaption( const OUString& rSmartTagType, const css::lang::Locale& rLocale ) const;
187 /** Returns true if the given smart tag type is enabled.
189 bool IsSmartTagTypeEnabled( const OUString& rSmartTagType ) const;
191 /** Enable or disable smart tags.
193 bool IsLabelTextWithSmartTags() const { return mbLabelTextWithSmartTags; }
195 /** Returns the number of registered recognizers.
197 sal_uInt32 NumberOfRecognizers() const { return maRecognizerList.size(); }
199 /** Returns a recognizer.
201 css::uno::Reference< css::smarttags::XSmartTagRecognizer > const &
202 GetRecognizer( sal_uInt32 i ) const { return maRecognizerList[i]; }
204 /** Is smart tag recognition active?
206 bool IsSmartTagsEnabled() const { return 0 != NumberOfRecognizers() &&
207 IsLabelTextWithSmartTags(); }
209 /** Writes configuration settings.
211 void WriteConfiguration( const bool* bLabelTextWithSmartTags,
212 const std::vector< OUString >* pDisabledTypes ) const;
214 /** Returns the name of the application this instance has been created by.
216 const OUString& GetApplicationName() const { return maApplicationName; }
218 // css::lang::XEventListener
219 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
221 // css::util::XModifyListener
222 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
224 // css::util::XChangesListener
225 virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& Event ) override;
228 #endif
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */