LibreOffice Module sw (master) 1
unoatxt.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#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_UNOATXT_HXX
20#define INCLUDED_SW_SOURCE_UIBASE_INC_UNOATXT_HXX
21
22#include <com/sun/star/beans/XPropertySet.hpp>
23#include <com/sun/star/container/XNamed.hpp>
24#include <com/sun/star/document/XEventsSupplier.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
26#include <com/sun/star/text/XAutoTextGroup.hpp>
27#include <com/sun/star/text/XAutoTextEntry.hpp>
28#include <com/sun/star/text/XAutoTextContainer2.hpp>
29#include <com/sun/star/text/XText.hpp>
30#include <svl/itemprop.hxx>
31#include <svl/lstner.hxx>
34#include <rtl/ref.hxx>
35#include <svtools/unoevent.hxx>
36
37class SwTextBlocks;
38class SwGlossaries;
39class SwDoc;
40class SwDocShell;
41class SwXBodyText;
42
43#ifndef SW_DECL_SWDOCSHELL_DEFINED
44#define SW_DECL_SWDOCSHELL_DEFINED
45#include <tools/ref.hxx>
47#endif
48
49class SwXAutoTextContainer final : public cppu::WeakImplHelper
50<
51 css::text::XAutoTextContainer2,
52 css::lang::XServiceInfo
53>
54{
56
57 virtual ~SwXAutoTextContainer() override; // ref-counted objects are not to be deleted from outside -> protected dtor
58
59public:
61
62 //XIndexAccess
63 virtual sal_Int32 SAL_CALL getCount( ) override;
64 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
65
66 //XNameAccess
67 virtual css::uno::Any SAL_CALL getByName(const OUString& Name) override;
68 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
69 virtual sal_Bool SAL_CALL hasByName(const OUString& Name) override;
70
71 //XElementAccess
72 virtual css::uno::Type SAL_CALL getElementType( ) override;
73 virtual sal_Bool SAL_CALL hasElements( ) override;
74
75 //XAutoTextContainer
76 virtual css::uno::Reference< css::text::XAutoTextGroup > SAL_CALL insertNewByName(const OUString& aGroupName) override;
77 virtual void SAL_CALL removeByName(const OUString& aGroupName) override;
78
79 //XServiceInfo
80 virtual OUString SAL_CALL getImplementationName() override;
81 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
82 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
83
84};
85
86class SwXAutoTextGroup final : public cppu::WeakImplHelper
87<
88 css::text::XAutoTextGroup,
89 css::beans::XPropertySet,
90 css::lang::XServiceInfo,
91 css::container::XIndexAccess,
92 css::container::XNamed
93>
94{
97 OUString m_sName;
98 OUString m_sGroupName; // prefix m_ to disambiguate from some local vars in the implementation
99
100 virtual ~SwXAutoTextGroup() override; // ref-counted objects are not to be deleted from outside -> protected dtor
101
102public:
103 SwXAutoTextGroup(const OUString& rName, SwGlossaries* pGloss);
104
105 //XAutoTextGroup
106 virtual css::uno::Sequence< OUString > SAL_CALL getTitles() override;
107 virtual void SAL_CALL renameByName(const OUString& aElementName, const OUString& aNewElementName, const OUString& aNewElementTitle) override;
108 virtual css::uno::Reference< css::text::XAutoTextEntry > SAL_CALL insertNewByName(const OUString& aName, const OUString& aTitle, const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
109 virtual void SAL_CALL removeByName(const OUString& aEntryName) override;
110
111 //XNamed
112 virtual OUString SAL_CALL getName() override;
113 virtual void SAL_CALL setName(const OUString& Name_) override;
114
115 //XIndexAccess
116 virtual sal_Int32 SAL_CALL getCount( ) override;
117 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
118
119 //XNameAccess
120 virtual css::uno::Any SAL_CALL getByName(const OUString& Name) override;
121 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
122 virtual sal_Bool SAL_CALL hasByName(const OUString& Name) override;
123
124 //XElementAccess
125 virtual css::uno::Type SAL_CALL getElementType( ) override;
126 virtual sal_Bool SAL_CALL hasElements( ) override;
127
128 //XServiceInfo
129 virtual OUString SAL_CALL getImplementationName() override;
130 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
131 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
132
133 //XPropertySet
134 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
135 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
136 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
137 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
138 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
139 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
140 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
141
142 void Invalidate();
143};
144
146 :public SfxListener
148 <
149 css::text::XAutoTextEntry,
150 css::lang::XServiceInfo,
151 css::text::XText,
152 css::document::XEventsSupplier
153 >
154{
156 OUString m_sGroupName;
157 OUString m_sEntryName;
161
163 {
164 if ( !mxBodyText.is() )
165 GetBodyText();
166 }
167 void GetBodyText ();
168
169 void disposing(std::unique_lock<std::mutex>&) override;
170
182 void implFlushDocument( bool _bCloseDoc = false );
183
184 // SfxListener overridables
185 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
186
187 virtual ~SwXAutoTextEntry() override; // ref-counted objects are not to be deleted from outside -> protected dtor
188
189public:
190 SwXAutoTextEntry(SwGlossaries* , OUString aGroupName, OUString aEntryName);
191
192 //XText
193 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override;
194 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > & aTextPosition) override;
195 virtual void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > & xRange, const OUString& aString, sal_Bool bAbsorb) override;
196 virtual void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > & xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override;
197 virtual void SAL_CALL insertTextContent(const css::uno::Reference< css::text::XTextRange > & xRange, const css::uno::Reference< css::text::XTextContent > & xContent, sal_Bool bAbsorb) override;
198 virtual void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > & xContent) override;
199
200 //XTextRange
201 virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override;
202 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override;
203 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override;
204 virtual OUString SAL_CALL getString() override;
205 virtual void SAL_CALL setString(const OUString& aString) override;
206
207 //XAutoTextEntry
208 virtual void SAL_CALL applyTo(const css::uno::Reference< css::text::XTextRange > & xRange) override;
209
210 //XServiceInfo
211 virtual OUString SAL_CALL getImplementationName() override;
212 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
213 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
214
215 // XEventsSupplier
216 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
217
218 void Invalidate() {m_pGlossaries = nullptr;}
219 const SwGlossaries* GetGlossaries() const { return m_pGlossaries; }
220 const OUString& GetGroupName() const {return m_sGroupName;}
221 const OUString& GetEntryName() const {return m_sEntryName;}
222};
223
226{
228
231
232public:
234
235 virtual ~SwAutoTextEventDescriptor() override;
236
237 virtual OUString SAL_CALL getImplementationName() override;
238
239private:
240
241 virtual void replaceByName(
242 const SvMacroItemId nEvent,
243 const SvxMacro& rMacro)
244 override;
245
246 virtual void getByName(
247 SvxMacro& rMacro,
248 const SvMacroItemId nEvent )
249 override;
250};
251
252#endif
253
254/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL replaceByName(const OUString &rName, const css::uno::Any &rElement) override
virtual css::uno::Any SAL_CALL getByName(const OUString &rName) override
Implement the XNameAccess for the AutoText events.
Definition: unoatxt.hxx:226
SwXAutoTextEntry & m_rAutoTextEntry
Definition: unoatxt.hxx:227
virtual void getByName(SvxMacro &rMacro, const SvMacroItemId nEvent) override
item ID of event
Definition: unoatxt.cxx:949
SwAutoTextEventDescriptor(SwXAutoTextEntry &rAutoText)
Definition: unoatxt.cxx:900
virtual void replaceByName(const SvMacroItemId nEvent, const SvxMacro &rMacro) override
event (will be copied)
Definition: unoatxt.cxx:916
virtual ~SwAutoTextEventDescriptor() override
Definition: unoatxt.cxx:907
virtual OUString SAL_CALL getImplementationName() override
Definition: unoatxt.cxx:911
Definition: doc.hxx:197
virtual css::uno::Reference< css::text::XAutoTextGroup > SAL_CALL insertNewByName(const OUString &aGroupName) override
Definition: unoatxt.cxx:142
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoatxt.cxx:94
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unoatxt.cxx:115
virtual OUString SAL_CALL getImplementationName() override
Definition: unoatxt.cxx:193
virtual css::uno::Any SAL_CALL getByName(const OUString &Name) override
Definition: unoatxt.cxx:100
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoatxt.cxx:88
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoatxt.cxx:79
SwGlossaries * m_pGlossaries
Definition: unoatxt.hxx:55
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoatxt.cxx:198
virtual void SAL_CALL removeByName(const OUString &aGroupName) override
Definition: unoatxt.cxx:183
virtual sal_Bool SAL_CALL hasByName(const OUString &Name) override
Definition: unoatxt.cxx:133
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoatxt.cxx:72
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoatxt.cxx:203
virtual ~SwXAutoTextContainer() override
Definition: unoatxt.cxx:67
virtual OUString SAL_CALL getImplementationName() override
Definition: unoatxt.cxx:872
void implFlushDocument(bool _bCloseDoc=false)
ensure that the current content (which may only be in-memory so far) is flushed to the auto text grou...
Definition: unoatxt.cxx:663
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoatxt.cxx:784
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: unoatxt.cxx:681
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoatxt.cxx:777
virtual OUString SAL_CALL getString() override
Definition: unoatxt.cxx:798
void EnsureBodyText()
Definition: unoatxt.hxx:162
rtl::Reference< SwXBodyText > mxBodyText
Definition: unoatxt.hxx:160
const OUString & GetGroupName() const
Definition: unoatxt.hxx:220
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoatxt.cxx:791
virtual void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
Definition: unoatxt.cxx:752
virtual void SAL_CALL applyTo(const css::uno::Reference< css::text::XTextRange > &xRange) override
Definition: unoatxt.cxx:812
virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override
Definition: unoatxt.cxx:888
SwDocShellRef m_xDocSh
Definition: unoatxt.hxx:158
OUString m_sGroupName
Definition: unoatxt.hxx:156
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoatxt.cxx:877
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unoatxt.cxx:730
void disposing(std::unique_lock< std::mutex > &) override
Definition: unoatxt.cxx:724
void GetBodyText()
Definition: unoatxt.cxx:711
const OUString & GetEntryName() const
Definition: unoatxt.hxx:221
SwXAutoTextEntry(SwGlossaries *, OUString aGroupName, OUString aEntryName)
Definition: unoatxt.cxx:647
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoatxt.cxx:882
virtual void SAL_CALL insertTextContent(const css::uno::Reference< css::text::XTextRange > &xRange, const css::uno::Reference< css::text::XTextContent > &xContent, sal_Bool bAbsorb) override
Definition: unoatxt.cxx:760
const SwGlossaries * GetGlossaries() const
Definition: unoatxt.hxx:219
SwGlossaries * m_pGlossaries
Definition: unoatxt.hxx:155
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unoatxt.cxx:805
OUString m_sEntryName
Definition: unoatxt.hxx:157
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &aTextPosition) override
Definition: unoatxt.cxx:737
void Invalidate()
Definition: unoatxt.hxx:218
virtual void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
Definition: unoatxt.cxx:769
virtual void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
Definition: unoatxt.cxx:745
virtual ~SwXAutoTextEntry() override
Definition: unoatxt.cxx:655
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unoatxt.cxx:609
SwXAutoTextGroup(const OUString &rName, SwGlossaries *pGloss)
Definition: unoatxt.cxx:208
virtual void SAL_CALL setName(const OUString &Name_) override
Definition: unoatxt.cxx:418
const SfxItemPropertySet * m_pPropSet
Definition: unoatxt.hxx:95
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoatxt.cxx:614
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoatxt.cxx:619
SwGlossaries * m_pGlossaries
Definition: unoatxt.hxx:96
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoatxt.cxx:483
virtual OUString SAL_CALL getImplementationName() override
Definition: unoatxt.cxx:631
virtual css::uno::Sequence< OUString > SAL_CALL getTitles() override
Definition: unoatxt.cxx:223
OUString m_sName
Definition: unoatxt.hxx:97
virtual sal_Bool SAL_CALL hasByName(const OUString &Name) override
Definition: unoatxt.cxx:524
void Invalidate()
Definition: unoatxt.cxx:624
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoatxt.cxx:545
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoatxt.cxx:636
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoatxt.cxx:469
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoatxt.cxx:604
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoatxt.cxx:460
OUString m_sGroupName
Definition: unoatxt.hxx:98
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoatxt.cxx:489
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoatxt.cxx:641
virtual void SAL_CALL removeByName(const OUString &aEntryName) override
Definition: unoatxt.cxx:398
virtual css::uno::Reference< css::text::XAutoTextEntry > SAL_CALL insertNewByName(const OUString &aName, const OUString &aTitle, const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unoatxt.cxx:305
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unoatxt.cxx:580
virtual ~SwXAutoTextGroup() override
Definition: unoatxt.cxx:219
virtual css::uno::Any SAL_CALL getByName(const OUString &Name) override
Definition: unoatxt.cxx:499
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unoatxt.cxx:508
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unoatxt.cxx:551
virtual OUString SAL_CALL getName() override
Definition: unoatxt.cxx:412
virtual void SAL_CALL renameByName(const OUString &aElementName, const OUString &aNewElementName, const OUString &aNewElementTitle) override
Definition: unoatxt.cxx:239
SvMacroItemId
unsigned char sal_Bool
tools::SvRef< SwDocShell > SwDocShellRef
Definition: unoatxt.hxx:46