LibreOffice Module sw (master)  1
unoatxt.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 <sal/config.h>
21 
22 #include <com/sun/star/io/IOException.hpp>
23 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
25 #include <com/sun/star/container/ElementExistException.hpp>
26 #include <o3tl/safeint.hxx>
27 #include <osl/diagnose.h>
28 #include <rtl/character.hxx>
29 #include <vcl/svapp.hxx>
30 #include <svtools/unoevent.hxx>
31 #include <sfx2/event.hxx>
32 #include <glosdoc.hxx>
33 #include <shellio.hxx>
34 #include <initui.hxx>
35 #include <gloslst.hxx>
36 #include <unoatxt.hxx>
37 #include <unomap.hxx>
38 #include <unotextbodyhf.hxx>
39 #include <unotextrange.hxx>
40 #include <TextCursorHelper.hxx>
41 #include <doc.hxx>
45 #include <IDocumentState.hxx>
46 #include <docsh.hxx>
47 #include <swdll.hxx>
48 #include <svl/hint.hxx>
49 #include <tools/urlobj.hxx>
50 #include <svl/macitem.hxx>
51 #include <editeng/acorrcfg.hxx>
53 #include <cppuhelper/exc_hlp.hxx>
55 
56 #include <memory>
57 
58 using namespace ::com::sun::star;
59 
61 {
63 
64 }
65 
67 {
68 
69 }
70 
72 {
74  "SwXAutoTextContainer::getCount: too many items");
75  return static_cast<sal_Int32>(pGlossaries->GetGroupCnt());
76 }
77 
79 {
80  SolarMutexGuard aGuard;
81  const size_t nCount = pGlossaries->GetGroupCnt();
82  if ( nIndex < 0 || o3tl::make_unsigned(nIndex) >= nCount )
83  throw lang::IndexOutOfBoundsException();
84  return getByName(pGlossaries->GetGroupName( static_cast<size_t>(nIndex) ));
85 }
86 
88 {
90 
91 }
92 
94 {
95  // At least standard should always exists!
96  return true;
97 }
98 
99 uno::Any SwXAutoTextContainer::getByName(const OUString& GroupName)
100 {
101  SolarMutexGuard aGuard;
102 
103  uno::Reference< text::XAutoTextGroup > xGroup;
104  if ( pGlossaries && hasByName( GroupName ) ) // group name already known?
105  // true = create group if not already available
106  xGroup = pGlossaries->GetAutoTextGroup( GroupName );
107 
108  if ( !xGroup.is() )
109  throw container::NoSuchElementException();
110 
111  return makeAny( xGroup );
112 }
113 
114 uno::Sequence< OUString > SwXAutoTextContainer::getElementNames()
115 {
116  SolarMutexGuard aGuard;
117  const size_t nCount = pGlossaries->GetGroupCnt();
118  OSL_ENSURE(nCount < o3tl::make_unsigned(SAL_MAX_INT32),
119  "SwXAutoTextContainer::getElementNames: too many groups");
120 
121  uno::Sequence< OUString > aGroupNames(static_cast<sal_Int32>(nCount));
122  OUString *pArr = aGroupNames.getArray();
123 
124  for ( size_t i = 0; i < nCount; ++i )
125  {
126  // The names will be passed without a path extension.
127  pArr[i] = pGlossaries->GetGroupName(i).getToken(0, GLOS_DELIM);
128  }
129  return aGroupNames;
130 }
131 // Finds group names with or without path index.
133 {
134  SolarMutexGuard aGuard;
135  OUString sGroupName( pGlossaries->GetCompleteGroupName( Name ) );
136  if(!sGroupName.isEmpty())
137  return true;
138  return false;
139 }
140 
141 uno::Reference< text::XAutoTextGroup > SwXAutoTextContainer::insertNewByName(
142  const OUString& aGroupName)
143 {
144  SolarMutexGuard aGuard;
145  if(hasByName(aGroupName))
146  throw container::ElementExistException();
147  //check for non-ASCII characters
148  if(aGroupName.isEmpty())
149  {
150  lang::IllegalArgumentException aIllegal;
151  aIllegal.Message = "group name must not be empty";
152  throw aIllegal;
153  }
154  for(sal_Int32 nPos = 0; nPos < aGroupName.getLength(); nPos++)
155  {
156  sal_Unicode cChar = aGroupName[nPos];
157  if (rtl::isAsciiAlphanumeric(cChar) ||
158  (cChar == '_') ||
159  (cChar == 0x20) ||
160  (cChar == GLOS_DELIM) )
161  {
162  continue;
163  }
164  lang::IllegalArgumentException aIllegal;
165  aIllegal.Message = "group name must contain a-z, A-z, '_', ' ' only";
166  throw aIllegal;
167  }
168  OUString sGroup(aGroupName);
169  if (sGroup.indexOf(GLOS_DELIM)<0)
170  {
171  sGroup += OUStringChar(GLOS_DELIM) + "0";
172  }
173  pGlossaries->NewGroupDoc(sGroup, sGroup.getToken(0, GLOS_DELIM));
174 
175  uno::Reference< text::XAutoTextGroup > xGroup = pGlossaries->GetAutoTextGroup( sGroup );
176  OSL_ENSURE( xGroup.is(), "SwXAutoTextContainer::insertNewByName: no UNO object created? How this?" );
177  // We just inserted the group into the glossaries, so why doesn't it exist?
178 
179  return xGroup;
180 }
181 
182 void SwXAutoTextContainer::removeByName(const OUString& aGroupName)
183 {
184  SolarMutexGuard aGuard;
185  // At first find the name with path extension
186  OUString sGroupName = pGlossaries->GetCompleteGroupName( aGroupName );
187  if(sGroupName.isEmpty())
188  throw container::NoSuchElementException();
189  pGlossaries->DelGroupDoc(sGroupName);
190 }
191 
193 {
194  return "SwXAutoTextContainer";
195 }
196 
197 sal_Bool SwXAutoTextContainer::supportsService(const OUString& rServiceName)
198 {
199  return cppu::supportsService(this, rServiceName);
200 }
201 
203 {
204  return { "com.sun.star.text.AutoTextContainer" };
205 }
206 
207 namespace
208 {
209  class theSwXAutoTextGroupUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXAutoTextGroupUnoTunnelId > {};
210 }
211 
212 const uno::Sequence< sal_Int8 > & SwXAutoTextGroup::getUnoTunnelId()
213 {
214  return theSwXAutoTextGroupUnoTunnelId::get().getSeq();
215 }
216 
217 sal_Int64 SAL_CALL SwXAutoTextGroup::getSomething( const uno::Sequence< sal_Int8 >& rId )
218 {
219  if( isUnoTunnelId<SwXAutoTextGroup>(rId) )
220  {
221  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
222  }
223  return 0;
224 }
225 
227  SwGlossaries* pGlos) :
228  pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_AUTO_TEXT_GROUP)),
229  pGlossaries(pGlos),
230  sName(rName),
231  m_sGroupName(rName)
232 {
233  OSL_ENSURE( -1 != rName.indexOf( GLOS_DELIM ),
234  "SwXAutoTextGroup::SwXAutoTextGroup: to be constructed with a complete name only!" );
235 }
236 
238 {
239 }
240 
241 uno::Sequence< OUString > SwXAutoTextGroup::getTitles()
242 {
243  SolarMutexGuard aGuard;
244  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
245  if (!pGlosGroup || pGlosGroup->GetError())
246  throw uno::RuntimeException();
247  const sal_uInt16 nCount = pGlosGroup->GetCount();
248 
249  uno::Sequence< OUString > aEntryTitles(nCount);
250  OUString *pArr = aEntryTitles.getArray();
251 
252  for ( sal_uInt16 i = 0; i < nCount; i++ )
253  pArr[i] = pGlosGroup->GetLongName(i);
254  return aEntryTitles;
255 }
256 
257 void SwXAutoTextGroup::renameByName(const OUString& aElementName,
258  const OUString& aNewElementName, const OUString& aNewElementTitle)
259 {
260  SolarMutexGuard aGuard;
261  // throw exception only if the programmatic name is to be changed into an existing name
262  if(aNewElementName != aElementName && hasByName(aNewElementName))
263  throw container::ElementExistException();
264  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
265  if(!pGlosGroup || pGlosGroup->GetError())
266  throw uno::RuntimeException();
267 
268  const sal_uInt16 nIdx = pGlosGroup->GetIndex( aElementName);
269  if(USHRT_MAX == nIdx)
270  throw lang::IllegalArgumentException();
271  OUString aNewShort(aNewElementName);
272  OUString aNewName(aNewElementTitle);
273  sal_uInt16 nOldLongIdx = pGlosGroup->GetLongIndex( aNewShort );
274  sal_uInt16 nOldIdx = pGlosGroup->GetIndex( aNewName );
275 
276  if ((nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx)
277  && (nOldIdx == USHRT_MAX || nOldIdx == nIdx))
278  {
279  pGlosGroup->Rename( nIdx, &aNewShort, &aNewName );
280  if(pGlosGroup->GetError() != ERRCODE_NONE)
281  throw io::IOException();
282  }
283 
284 }
285 
286 static bool lcl_CopySelToDoc(SwDoc& rInsDoc, OTextCursorHelper* pxCursor, SwXTextRange* pxRange)
287 {
288  SwNodes& rNds = rInsDoc.GetNodes();
289 
290  SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 );
291  SwContentNode * pNd = aIdx.GetNode().GetContentNode();
292  SwPosition aPos(aIdx, SwIndex(pNd, pNd ? pNd->Len() : 0));
293 
294  bool bRet = false;
296  {
297  SwDoc *const pDoc(pxCursor ? pxCursor->GetDoc() : &pxRange->GetDoc());
298  SwPaM aPam(pDoc->GetNodes());
299  SwPaM * pPam(nullptr);
300  if(pxCursor)
301  {
302  pPam = pxCursor->GetPaM();
303  }
304  else
305  {
306  if (pxRange->GetPositions(aPam))
307  {
308  pPam = & aPam;
309  }
310  }
311  if (!pPam) { return false; }
312  bRet = pDoc->getIDocumentContentOperations().CopyRange(*pPam, aPos, SwCopyFlags::CheckPosInFly)
313  || bRet;
314  }
315 
318  rInsDoc.getIDocumentFieldsAccess().UpdateExpFields(nullptr, true);
319 
320  return bRet;
321 }
322 
323 uno::Reference< text::XAutoTextEntry > SwXAutoTextGroup::insertNewByName(const OUString& aName,
324  const OUString& aTitle, const uno::Reference< text::XTextRange > & xTextRange)
325 {
326  SolarMutexGuard aGuard;
327  if(hasByName(aName))
328  throw container::ElementExistException();
329  if(!xTextRange.is())
330  throw uno::RuntimeException();
331 
332  std::unique_ptr<SwTextBlocks> pGlosGroup;
333  if (pGlossaries)
334  pGlosGroup = pGlossaries->GetGroupDoc(m_sGroupName);
335  const OUString& sShortName(aName);
336  const OUString& sLongName(aTitle);
337  if (pGlosGroup && !pGlosGroup->GetError())
338  {
339  uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
340  SwXTextRange* pxRange = nullptr;
341  OTextCursorHelper* pxCursor = nullptr;
342  if(xRangeTunnel.is())
343  {
344  pxRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething(
346  pxCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething(
348  }
349 
350  OUString sOnlyText;
351  OUString* pOnlyText = nullptr;
352  bool bNoAttr = !pxCursor && !pxRange;
353  if(bNoAttr)
354  {
355  sOnlyText = xTextRange->getString();
356  pOnlyText = &sOnlyText;
357  }
358 
359  const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
360 
361  SwDoc* pGDoc = pGlosGroup->GetDoc();
362 
363  // Until there is an option for that, delete base util::URL
364  if(rCfg.IsSaveRelFile())
365  {
366  INetURLObject aTemp(pGlosGroup->GetFileName());
367  pGlosGroup->SetBaseURL( aTemp.GetMainURL(INetURLObject::DecodeMechanism::NONE));
368  }
369  else
370  pGlosGroup->SetBaseURL( OUString() );
371 
372  sal_uInt16 nRet = USHRT_MAX;
373  if( pOnlyText )
374  nRet = pGlosGroup->PutText( sShortName, sLongName, *pOnlyText );
375  else
376  {
377  pGlosGroup->ClearDoc();
378  if( pGlosGroup->BeginPutDoc( sShortName, sLongName ) )
379  {
381  lcl_CopySelToDoc(*pGDoc, pxCursor, pxRange);
383  nRet = pGlosGroup->PutDoc();
384  }
385  }
386 
387  if (nRet == USHRT_MAX)
388  {
389  throw uno::RuntimeException();
390  }
391  }
392  pGlosGroup.reset();
393 
394  uno::Reference< text::XAutoTextEntry > xEntry;
395 
396  try
397  {
398  xEntry = pGlossaries ?
400  uno::Reference< text::XAutoTextEntry >();
401  OSL_ENSURE( xEntry.is(), "SwXAutoTextGroup::insertNewByName: no UNO object created? How this?" );
402  // we just inserted the entry into the group, so why doesn't it exist?
403  }
404  catch (const container::ElementExistException&)
405  {
406  throw;
407  }
408  catch (const uno::RuntimeException&)
409  {
410  throw;
411  }
412  catch (const uno::Exception&)
413  {
414  css::uno::Any anyEx = cppu::getCaughtException();
415  throw css::lang::WrappedTargetRuntimeException(
416  "Error Getting AutoText!",
417  static_cast < OWeakObject * > ( this ),
418  anyEx );
419  }
420 
421  return xEntry;
422 }
423 
424 void SwXAutoTextGroup::removeByName(const OUString& aEntryName)
425 {
426  SolarMutexGuard aGuard;
427  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
428  if(!pGlosGroup || pGlosGroup->GetError())
429  throw container::NoSuchElementException();
430 
431  sal_uInt16 nIdx = pGlosGroup->GetIndex(aEntryName);
432  if ( nIdx == USHRT_MAX )
433  throw container::NoSuchElementException();
434 
435  pGlosGroup->Delete(nIdx);
436 }
437 
439 {
440  SolarMutexGuard aGuard;
441  return sName;
442 }
443 
444 void SwXAutoTextGroup::setName(const OUString& rName)
445 {
446  SolarMutexGuard aGuard;
447  if( !pGlossaries )
448  throw uno::RuntimeException();
449 
450  sal_Int32 nNewDelimPos = rName.lastIndexOf( GLOS_DELIM );
451  sal_Int32 nOldDelimPos = sName.lastIndexOf( GLOS_DELIM );
452 
453  OUString aNewSuffix;
454  if (nNewDelimPos > -1)
455  aNewSuffix = rName.copy( nNewDelimPos + 1 );
456  OUString aOldSuffix;
457  if (nOldDelimPos > -1)
458  aOldSuffix = sName.copy( nOldDelimPos + 1 );
459 
460  sal_Int32 nNewNumeric = aNewSuffix.toInt32();
461  sal_Int32 nOldNumeric = aOldSuffix.toInt32();
462 
463  OUString aNewPrefix( (nNewDelimPos > 1) ? rName.copy( 0, nNewDelimPos ) : rName );
464  OUString aOldPrefix( (nOldDelimPos > 1) ? sName.copy( 0, nOldDelimPos ) : sName );
465 
466  if ( sName == rName ||
467  ( nNewNumeric == nOldNumeric && aNewPrefix == aOldPrefix ) )
468  return;
469  OUString sNewGroup(rName);
470  if (sNewGroup.indexOf(GLOS_DELIM)<0)
471  {
472  sNewGroup += OUStringChar(GLOS_DELIM) + "0";
473  }
474 
475  //the name must be saved, the group may be invalidated while in RenameGroupDoc()
476  SwGlossaries* pTempGlossaries = pGlossaries;
477 
478  OUString sPreserveTitle( pGlossaries->GetGroupTitle( sName ) );
479  if ( !pGlossaries->RenameGroupDoc( sName, sNewGroup, sPreserveTitle ) )
480  throw uno::RuntimeException();
481  sName = rName;
482  m_sGroupName = sNewGroup;
483  pGlossaries = pTempGlossaries;
484 }
485 
487 {
488  SolarMutexGuard aGuard;
489  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
490  if (!pGlosGroup || pGlosGroup->GetError())
491  throw uno::RuntimeException();
492  return static_cast<sal_Int32>(pGlosGroup->GetCount());
493 }
494 
496 {
497  SolarMutexGuard aGuard;
498  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
499  if (!pGlosGroup || pGlosGroup->GetError())
500  throw uno::RuntimeException();
501  const sal_uInt16 nCount = pGlosGroup->GetCount();
502  if (nIndex < 0 || nIndex >= static_cast<sal_Int32>(nCount))
503  throw lang::IndexOutOfBoundsException();
504  return getByName(pGlosGroup->GetShortName(static_cast<sal_uInt16>(nIndex)));
505 }
506 
508 {
510 
511 }
512 
514 {
515  SolarMutexGuard aGuard;
516  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
517  if (!pGlosGroup || pGlosGroup->GetError())
518  throw uno::RuntimeException();
519  return pGlosGroup->GetCount() > 0;
520 
521 }
522 
523 uno::Any SwXAutoTextGroup::getByName(const OUString& _rName)
524 {
525  SolarMutexGuard aGuard;
526  uno::Reference< text::XAutoTextEntry > xEntry = pGlossaries->GetAutoTextEntry( m_sGroupName, sName, _rName );
527  OSL_ENSURE( xEntry.is(), "SwXAutoTextGroup::getByName: GetAutoTextEntry is fractious!" );
528  // we told it to create the object, so why didn't it?
529  return makeAny( xEntry );
530 }
531 
532 uno::Sequence< OUString > SwXAutoTextGroup::getElementNames()
533 {
534  SolarMutexGuard aGuard;
535  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
536  if (!pGlosGroup || pGlosGroup->GetError())
537  throw uno::RuntimeException();
538 
539  const sal_uInt16 nCount = pGlosGroup->GetCount();
540  uno::Sequence< OUString > aEntryNames(nCount);
541  OUString *pArr = aEntryNames.getArray();
542 
543  for ( sal_uInt16 i = 0; i < nCount; i++ )
544  pArr[i] = pGlosGroup->GetShortName(i);
545  return aEntryNames;
546 }
547 
548 sal_Bool SwXAutoTextGroup::hasByName(const OUString& rName)
549 {
550  SolarMutexGuard aGuard;
551  bool bRet = false;
552  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
553  if (!pGlosGroup || pGlosGroup->GetError())
554  throw uno::RuntimeException();
555 
556  const sal_uInt16 nCount = pGlosGroup->GetCount();
557  for( sal_uInt16 i = 0; i < nCount; ++i )
558  {
559  OUString sCompare(pGlosGroup->GetShortName(i));
560  if(sCompare.equalsIgnoreAsciiCase(rName))
561  {
562  bRet = true;
563  break;
564  }
565  }
566  return bRet;
567 }
568 
569 uno::Reference< beans::XPropertySetInfo > SwXAutoTextGroup::getPropertySetInfo()
570 {
571  static uno::Reference< beans::XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
572  return xRet;
573 }
574 
576  const OUString& rPropertyName, const uno::Any& aValue)
577 {
578  SolarMutexGuard aGuard;
579  const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName );
580 
581  if(!pEntry)
582  throw beans::UnknownPropertyException(rPropertyName);
583 
584  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
585  if(!pGlosGroup || pGlosGroup->GetError())
586  throw uno::RuntimeException();
587  switch(pEntry->nWID)
588  {
589  case WID_GROUP_TITLE:
590  {
591  OUString sNewTitle;
592  aValue >>= sNewTitle;
593  if(sNewTitle.isEmpty())
594  throw lang::IllegalArgumentException();
595  bool bChanged = sNewTitle != pGlosGroup->GetName();
596  pGlosGroup->SetName(sNewTitle);
597  if(bChanged && HasGlossaryList())
599  }
600  break;
601  }
602 }
603 
604 uno::Any SwXAutoTextGroup::getPropertyValue(const OUString& rPropertyName)
605 {
606  SolarMutexGuard aGuard;
607  const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
608 
609  if(!pEntry)
610  throw beans::UnknownPropertyException(rPropertyName);
611  std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr);
612  if(!pGlosGroup || pGlosGroup->GetError())
613  throw uno::RuntimeException();
614 
615  uno::Any aAny;
616  switch(pEntry->nWID)
617  {
618  case WID_GROUP_PATH:
619  aAny <<= pGlosGroup->GetFileName();
620  break;
621  case WID_GROUP_TITLE:
622  aAny <<= pGlosGroup->GetName();
623  break;
624  }
625  return aAny;
626 }
627 
629  const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
630 {
631 }
632 
634  const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
635 {
636 }
637 
639  const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
640 {
641 }
642 
644  const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
645 {
646 }
647 
649 {
650  pGlossaries = nullptr;
651  sName.clear();
652  m_sGroupName.clear();
653 }
654 
656 {
657  return "SwXAutoTextGroup";
658 }
659 
660 sal_Bool SwXAutoTextGroup::supportsService(const OUString& rServiceName)
661 {
662  return cppu::supportsService(this, rServiceName);
663 }
664 
666 {
667  uno::Sequence<OUString> aRet { "com.sun.star.text.AutoTextGroup" };
668  return aRet;
669 }
670 
671 namespace
672 {
673  class theSwXAutoTextEntryUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXAutoTextEntryUnoTunnelId > {};
674 }
675 
676 const uno::Sequence< sal_Int8 > & SwXAutoTextEntry::getUnoTunnelId()
677 {
678  return theSwXAutoTextEntryUnoTunnelId::get().getSeq();
679 }
680 
681 sal_Int64 SAL_CALL SwXAutoTextEntry::getSomething( const uno::Sequence< sal_Int8 >& rId )
682 {
683  if( isUnoTunnelId<SwXAutoTextEntry>(rId) )
684  {
685  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
686  }
687  return 0;
688 }
689 
690 SwXAutoTextEntry::SwXAutoTextEntry(SwGlossaries* pGlss, const OUString& rGroupName,
691  const OUString& rEntryName) :
692  WeakComponentImplHelper(m_aMutex),
693  pGlossaries(pGlss),
694  sGroupName(rGroupName),
695  sEntryName(rEntryName)
696 {
697 }
698 
700 {
701  SolarMutexGuard aGuard;
702 
703  // ensure that any pending modifications are written
704  implFlushDocument( true );
705 }
706 
707 void SwXAutoTextEntry::implFlushDocument( bool _bCloseDoc )
708 {
709  if ( !xDocSh.is() )
710  return;
711 
712  if ( xDocSh->GetDoc()->getIDocumentState().IsModified () )
713  xDocSh->Save();
714 
715  if ( _bCloseDoc )
716  {
717  // stop listening at the document
718  EndListening( *xDocSh );
719 
720  xDocSh->DoClose();
721  xDocSh.clear();
722  }
723 }
724 
725 void SwXAutoTextEntry::Notify( SfxBroadcaster& _rBC, const SfxHint& _rHint )
726 {
727  if ( &_rBC != xDocSh.get() )
728  return;
729 
730 // it's our document
731  if (const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&_rHint))
732  {
733  if (SfxEventHintId::PrepareCloseDoc == pEventHint->GetEventId())
734  {
736  mxBodyText.clear();
737  EndListening( *xDocSh );
738  xDocSh.clear();
739  }
740  }
741  else
742  {
743  if ( SfxHintId::Deinitializing == _rHint.GetId() )
744  {
745  // our document is dying (possibly because we're shutting down, and the document was notified
746  // earlier than we are?)
747  // stop listening at the docu
748  EndListening( *xDocSh );
749  // and release our reference
750  xDocSh.clear();
751  }
752  }
753 }
754 
756 {
757  SolarMutexGuard aGuard;
758 
760  OSL_ENSURE( xDocSh.is(), "SwXAutoTextEntry::GetBodyText: unexpected: no doc returned by EditGroupDoc!" );
761 
762  // start listening at the document
764 
765  mxBodyText = new SwXBodyText ( xDocSh->GetDoc() );
766 }
767 
769 {
770  SolarMutexGuard g;
771  implFlushDocument(true);
772 }
773 
774 uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursor()
775 {
776  SolarMutexGuard aGuard;
777  EnsureBodyText();
778  return mxBodyText->createTextCursor();
779 }
780 
781 uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursorByRange(
782  const uno::Reference< text::XTextRange > & aTextPosition)
783 {
784  SolarMutexGuard aGuard;
785  EnsureBodyText();
786  return mxBodyText->createTextCursorByRange ( aTextPosition );
787 }
788 
789 void SwXAutoTextEntry::insertString(const uno::Reference< text::XTextRange > & xRange, const OUString& aString, sal_Bool bAbsorb)
790 {
791  SolarMutexGuard aGuard;
792  EnsureBodyText();
793  mxBodyText->insertString ( xRange, aString, bAbsorb );
794 }
795 
796 void SwXAutoTextEntry::insertControlCharacter(const uno::Reference< text::XTextRange > & xRange,
797  sal_Int16 nControlCharacter, sal_Bool bAbsorb)
798 {
799  SolarMutexGuard aGuard;
800  EnsureBodyText();
801  mxBodyText->insertControlCharacter ( xRange, nControlCharacter, bAbsorb );
802 }
803 
805  const uno::Reference< text::XTextRange > & xRange,
806  const uno::Reference< text::XTextContent > & xContent, sal_Bool bAbsorb)
807 {
808  SolarMutexGuard aGuard;
809  EnsureBodyText();
810  mxBodyText->insertTextContent ( xRange, xContent, bAbsorb );
811 }
812 
814  const uno::Reference< text::XTextContent > & xContent)
815 {
816  SolarMutexGuard aGuard;
817  EnsureBodyText();
818  mxBodyText->removeTextContent ( xContent );
819 }
820 
821 uno::Reference< text::XText > SwXAutoTextEntry::getText()
822 {
823  SolarMutexGuard aGuard;
824  uno::Reference< text::XText > xRet = static_cast<text::XText*>(this);
825  return xRet;
826 }
827 
828 uno::Reference< text::XTextRange > SwXAutoTextEntry::getStart()
829 {
830  SolarMutexGuard aGuard;
831  EnsureBodyText();
832  return mxBodyText->getStart();
833 }
834 
835 uno::Reference< text::XTextRange > SwXAutoTextEntry::getEnd()
836 {
837  SolarMutexGuard aGuard;
838  EnsureBodyText();
839  return mxBodyText->getEnd();
840 }
841 
843 {
844  SolarMutexGuard aGuard;
845  EnsureBodyText();
846  return mxBodyText->getString();
847 }
848 
849 void SwXAutoTextEntry::setString(const OUString& aString)
850 {
851  SolarMutexGuard aGuard;
852  EnsureBodyText();
853  mxBodyText->setString( aString );
854 }
855 
856 void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextRange)
857 {
858  SolarMutexGuard aGuard;
859 
860  // ensure that any pending modifications are written
861  // reason is that we're holding the _copy_ of the auto text, while the real auto text
862  // is stored somewhere. And below, we're not working with our copy, but only tell the target
863  // TextRange to work with the stored version.
864  // #96380# - 2003-03-03 - fs@openoffice.org
866  // TODO: think about if we should pass "true" here
867  // The difference would be that when the next modification is made to this instance here, then
868  // we would be forced to open the document again, instead of working on our current copy.
869  // This means that we would reflect any changes which were done to the AutoText by foreign instances
870  // in the meantime
871 
872  uno::Reference<lang::XUnoTunnel> xTunnel( xTextRange, uno::UNO_QUERY);
873  SwXTextRange* pRange = nullptr;
874  OTextCursorHelper* pCursor = nullptr;
875  SwXText *pText = nullptr;
876 
877  if(xTunnel.is())
878  {
879  pRange = reinterpret_cast < SwXTextRange* >
880  ( xTunnel->getSomething( SwXTextRange::getUnoTunnelId() ) );
881  pCursor = reinterpret_cast < OTextCursorHelper*>
882  ( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ) );
883  pText = reinterpret_cast < SwXText* >
884  ( xTunnel->getSomething( SwXText::getUnoTunnelId() ) );
885  }
886 
887  SwDoc* pDoc = nullptr;
888  if (pRange)
889  pDoc = &pRange->GetDoc();
890  else if ( pCursor )
891  pDoc = pCursor->GetDoc();
892  else if ( pText && pText->GetDoc() )
893  {
894  xTunnel.set(pText->getStart(), uno::UNO_QUERY);
895  if (xTunnel.is())
896  {
897  pCursor = reinterpret_cast < OTextCursorHelper* >
898  ( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ) );
899  if (pCursor)
900  pDoc = pText->GetDoc();
901  }
902  }
903 
904  if(!pDoc)
905  throw uno::RuntimeException();
906 
907  SwPaM InsertPaM(pDoc->GetNodes());
908  if (pRange)
909  {
910  if (!pRange->GetPositions(InsertPaM))
911  {
912  throw uno::RuntimeException();
913  }
914  }
915  else
916  {
917  InsertPaM = *pCursor->GetPaM();
918  }
919 
920  std::unique_ptr<SwTextBlocks> pBlock(pGlossaries->GetGroupDoc(sGroupName));
921  const bool bResult = pBlock && !pBlock->GetError()
922  && pDoc->InsertGlossary( *pBlock, sEntryName, InsertPaM);
923 
924  if(!bResult)
925  throw uno::RuntimeException();
926 }
927 
929 {
930  return "SwXAutoTextEntry";
931 }
932 
933 sal_Bool SwXAutoTextEntry::supportsService(const OUString& rServiceName)
934 {
935  return cppu::supportsService(this, rServiceName);
936 }
937 
939 {
940  uno::Sequence<OUString> aRet { "com.sun.star.text.AutoTextEntry" };
941  return aRet;
942 }
943 
944 uno::Reference< container::XNameReplace > SwXAutoTextEntry::getEvents()
945 {
946  return new SwAutoTextEventDescriptor( *this );
947 }
948 
950 {
951  { SvMacroItemId::SwStartInsGlossary, "OnInsertStart" },
952  { SvMacroItemId::SwEndInsGlossary, "OnInsertDone" },
953  { SvMacroItemId::NONE, nullptr }
954 };
955 
957  SwXAutoTextEntry& rAutoText ) :
958  SvBaseEventDescriptor(aAutotextEvents),
959  rAutoTextEntry(rAutoText)
960 {
961 }
962 
964 {
965 }
966 
968 {
969  return "SwAutoTextEventDescriptor";
970 }
971 
973  const SvMacroItemId nEvent,
974  const SvxMacro& rMacro)
975 {
976  OSL_ENSURE( nullptr != rAutoTextEntry.GetGlossaries(),
977  "Strangely enough, the AutoText vanished!" );
978  OSL_ENSURE( (nEvent == SvMacroItemId::SwEndInsGlossary) ||
979  (nEvent == SvMacroItemId::SwStartInsGlossary) ,
980  "Unknown event ID" );
981 
982  SwGlossaries *const pGlossaries =
983  const_cast<SwGlossaries*>(rAutoTextEntry.GetGlossaries());
984  std::unique_ptr<SwTextBlocks> pBlocks(
985  pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() ));
986  OSL_ENSURE( pBlocks,
987  "can't get autotext group; SwAutoTextEntry has illegal name?");
988 
989  if( !pBlocks || pBlocks->GetError())
990  return;
991 
992  sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() );
993  if( nIndex != USHRT_MAX )
994  {
995  SvxMacroTableDtor aMacroTable;
996  if( pBlocks->GetMacroTable( nIndex, aMacroTable ) )
997  {
998  aMacroTable.Insert( nEvent, rMacro );
999  pBlocks->SetMacroTable( nIndex, aMacroTable );
1000  }
1001  }
1002  // else: ignore
1003 }
1004 
1006  SvxMacro& rMacro,
1007  const SvMacroItemId nEvent )
1008 {
1009  OSL_ENSURE( nullptr != rAutoTextEntry.GetGlossaries(), "no AutoText" );
1010  OSL_ENSURE( (nEvent == SvMacroItemId::SwEndInsGlossary) ||
1011  (nEvent == SvMacroItemId::SwStartInsGlossary) ,
1012  "Unknown event ID" );
1013 
1014  SwGlossaries *const pGlossaries =
1015  const_cast<SwGlossaries*>(rAutoTextEntry.GetGlossaries());
1016  std::unique_ptr<SwTextBlocks> pBlocks(
1017  pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() ));
1018  OSL_ENSURE( pBlocks,
1019  "can't get autotext group; SwAutoTextEntry has illegal name?");
1020 
1021  // return empty macro, unless macro is found
1022  OUString sEmptyStr;
1023  SvxMacro aEmptyMacro(sEmptyStr, sEmptyStr);
1024  rMacro = aEmptyMacro;
1025 
1026  if ( !pBlocks || pBlocks->GetError())
1027  return;
1028 
1029  sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() );
1030  if( nIndex != USHRT_MAX )
1031  {
1032  SvxMacroTableDtor aMacroTable;
1033  if( pBlocks->GetMacroTable( nIndex, aMacroTable ) )
1034  {
1035  SvxMacro *pMacro = aMacroTable.Get( nEvent );
1036  if( pMacro )
1037  rMacro = *pMacro;
1038  }
1039  }
1040 }
1041 
1042 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1043 SwXAutoTextContainer_get_implementation(css::uno::XComponentContext*,
1044  css::uno::Sequence<css::uno::Any> const &)
1045 {
1046  //the module may not be loaded
1047  SolarMutexGuard aGuard;
1049  return cppu::acquire(new SwXAutoTextContainer());
1050 }
1051 
1052 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool is() const
virtual void SAL_CALL setName(const OUString &Name_) override
Definition: unoatxt.cxx:444
const SfxItemPropertySimpleEntry * getByName(std::u16string_view rName) const
SvxMacro & Insert(SvMacroItemId nEvent, const SvxMacro &rMacro)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoatxt.cxx:676
sal_Int32 nIndex
virtual const SwDoc * GetDoc() const =0
#define WID_GROUP_TITLE
Definition: unomap.hxx:298
static SvxAutoCorrCfg & Get()
Marks a position in the document model.
Definition: pam.hxx:35
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoatxt.cxx:569
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoatxt.cxx:628
bool HasGlossaryList()
Definition: initui.cxx:167
osl::Mutex m_aMutex
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: unoatxt.cxx:725
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoatxt.cxx:507
OUString m_sGroupName
Definition: unoatxt.hxx:102
virtual css::uno::Any SAL_CALL getByName(const OUString &Name) override
Definition: unoatxt.cxx:99
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoatxt.cxx:93
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
virtual sal_Bool SAL_CALL hasByName(const OUString &Name) override
Definition: unoatxt.cxx:132
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoatxt.cxx:821
Definition: doc.hxx:186
SwDocShellRef EditGroupDoc(const OUString &rGrpName, const OUString &rShortName, bool bShow=true)
Definition: glshell.cxx:197
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SwXAutoTextContainer_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: unoatxt.cxx:1043
OUString sGroupName
Definition: unoatxt.hxx:168
SvMacroItemId
const OUString & GetEntryName() const
Definition: unoatxt.hxx:238
size_t GetGroupCnt()
Definition: glosdoc.cxx:98
std::unique_ptr< SwTextBlocks > GetGroupDoc(const OUString &rName, bool bCreate=false)
Definition: glosdoc.cxx:158
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoatxt.cxx:495
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoatxt.cxx:938
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unoatxt.cxx:532
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unotext.cxx:1202
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
SfxHintId GetId() const
OUString GetCompleteGroupName(const OUString &GroupName)
Definition: glosdoc.cxx:476
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoatxt.cxx:87
void EnsureBodyText()
Definition: unoatxt.hxx:174
virtual void LockExpFields()=0
void SAL_CALL disposing() override
Definition: unoatxt.cxx:768
virtual void UpdateExpFields(SwTextField *pField, bool bUpdateRefFields)=0
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
virtual OUString SAL_CALL getString() override
Definition: unoatxt.cxx:842
sal_uInt16 sal_Unicode
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:762
virtual void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
Definition: unoatxt.cxx:789
Any SAL_CALL getCaughtException()
virtual css::uno::Sequence< OUString > SAL_CALL getTitles() override
Definition: unoatxt.cxx:241
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoatxt.cxx:78
check if target position is in fly anchored at source range
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unoatxt.cxx:604
bool GetPositions(SwPaM &rToFill,::sw::TextRangeMode eMode=::sw::TextRangeMode::RequireTextNode) const
Definition: unoobj2.cxx:1059
int nCount
virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override
Definition: unoatxt.cxx:944
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual bool IsExpFieldsLocked() const =0
bool InsertGlossary(SwTextBlocks &rBlock, const OUString &rEntry, SwPaM &rPaM, SwCursorShell *pShell=nullptr)
inserts an AutoText block
Definition: docglos.cxx:131
virtual void SAL_CALL applyTo(const css::uno::Reference< css::text::XTextRange > &xRange) override
Definition: unoatxt.cxx:856
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unoatxt.cxx:774
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unoatxt.cxx:681
SW_DLLPUBLIC SwGlossaries * GetGlossaries()
Definition: initui.cxx:160
SwXAutoTextGroup(const OUString &rName, SwGlossaries *pGloss)
Definition: unoatxt.cxx:226
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unoatxt.cxx:114
OUString sName
Definition: unoatxt.hxx:101
bool DelGroupDoc(const OUString &)
Definition: glosdoc.cxx:247
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoatxt.cxx:71
const char * sName
virtual void SAL_CALL removeByName(const OUString &aEntryName) override
Definition: unoatxt.cxx:424
virtual OUString SAL_CALL getImplementationName() override
Definition: unoatxt.cxx:655
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
virtual void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
Definition: unoatxt.cxx:813
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
T * get() const
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoatxt.cxx:828
SwXAutoTextEntry(SwGlossaries *, const OUString &rGroupName, const OUString &rEntryName)
Definition: unoatxt.cxx:690
#define SAL_MAX_INT32
int i
virtual bool IsModified() const =0
Changes of document?
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoatxt.cxx:513
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoatxt.cxx:486
void ensure()
Definition: swdll.cxx:67
virtual OUString SAL_CALL getImplementationName() override
Definition: unoatxt.cxx:967
static std::unique_ptr< SwGlossaries > pGlossaries
Definition: initui.cxx:36
SwContentNode * GetContentNode()
Definition: node.hxx:618
const OUString & GetGroupName() const
Definition: unoatxt.hxx:237
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
SwDocShellRef xDocSh
Definition: unoatxt.hxx:170
Marks a character position inside a document model node.
Definition: index.hxx:33
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoatxt.cxx:643
unsigned char sal_Bool
const SfxItemPropertyMap & getPropertyMap() const
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoatxt.cxx:933
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoatxt.cxx:660
Marks a node in the document model.
Definition: ndindex.hxx:31
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoatxt.cxx:665
css::uno::Type const & get()
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:707
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
bool IsSaveRelFile() const
css::uno::Reference< css::text::XAutoTextGroup > GetAutoTextGroup(const OUString &_rGroupName)
returns the cached AutoTextGroup (if any) for the given group name The group is created if it does no...
Definition: glosdoc.cxx:523
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unoatxt.cxx:633
virtual void replaceByName(const SvMacroItemId nEvent, const SvxMacro &rMacro) override
event (will be copied)
Definition: unoatxt.cxx:972
virtual ~SwXAutoTextContainer() override
Definition: unoatxt.cxx:66
const struct SvEventDescription aAutotextEvents[]
Definition: unoatxt.cxx:949
#define WID_GROUP_PATH
Definition: unomap.hxx:297
virtual ~SwXAutoTextGroup() override
Definition: unoatxt.cxx:237
virtual OUString SAL_CALL getName() override
Definition: unoatxt.cxx:438
const SfxItemPropertySet * pPropSet
Definition: unoatxt.hxx:99
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoatxt.cxx:835
virtual sal_Bool SAL_CALL hasByName(const OUString &Name) override
Definition: unoatxt.cxx:548
virtual const SwPaM * GetPaM() const =0
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:905
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoatxt.cxx:638
const SwDoc * GetDoc() const
Definition: unotext.cxx:132
css::uno::Reference< css::text::XAutoTextEntry > GetAutoTextEntry(const OUString &_rCompleteGroupName, const OUString &_rGroupName, const OUString &_rEntryName)
returns the cached AutoTextEntry (if any) for the given group/with the given name The entry is create...
Definition: glosdoc.cxx:573
Implement the XNameAccess for the AutoText events.
Definition: unoatxt.hxx:242
virtual void SAL_CALL removeByName(const OUString &aGroupName) override
Definition: unoatxt.cxx:182
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unoatxt.cxx:849
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unotext.cxx:861
const SvxMacro * Get(SvMacroItemId nEvent) const
OUString const & GetGroupName(size_t)
Definition: glosdoc.cxx:136
#define PROPERTY_MAP_AUTO_TEXT_GROUP
Definition: unomap.hxx:58
virtual ~SwXAutoTextEntry() override
Definition: unoatxt.cxx:699
OUString GetGroupTitle(const OUString &rGroupName)
Definition: glosdoc.cxx:143
#define ERRCODE_NONE
bool RenameGroupDoc(const OUString &sOldGroup, OUString &sNewGroup, const OUString &rNewTitle)
Definition: glosdoc.cxx:195
void ClearGroups()
Definition: gloslst.cxx:435
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unoatxt.cxx:575
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
SwNodes & GetNodes()
Definition: doc.hxx:407
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
virtual css::uno::Any SAL_CALL getByName(const OUString &Name) override
Definition: unoatxt.cxx:523
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
rtl::Reference< SwXBodyText > mxBodyText
Definition: unoatxt.hxx:172
virtual css::uno::Reference< css::text::XAutoTextGroup > SAL_CALL insertNewByName(const OUString &aGroupName) override
Definition: unoatxt.cxx:141
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoatxt.cxx:202
#define GLOS_DELIM
Definition: glosdoc.hxx:41
virtual void getByName(SvxMacro &rMacro, const SvMacroItemId nEvent) override
item ID of event
Definition: unoatxt.cxx:1005
SwGlossaries * pGlossaries
Definition: unoatxt.hxx:100
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:323
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoatxt.cxx: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
Definition: unoatxt.cxx:804
virtual void SAL_CALL renameByName(const OUString &aElementName, const OUString &aNewElementName, const OUString &aNewElementTitle) override
Definition: unoatxt.cxx:257
virtual OUString SAL_CALL getImplementationName() override
Definition: unoatxt.cxx:192
void Invalidate()
Definition: unoatxt.cxx:648
virtual ~SwAutoTextEventDescriptor() override
Definition: unoatxt.cxx:963
virtual void UnlockExpFields()=0
SwXAutoTextEntry & rAutoTextEntry
Definition: unoatxt.hxx:244
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unoatxt.cxx:217
virtual void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
Definition: unoatxt.cxx:796
SwAutoTextEventDescriptor(SwXAutoTextEntry &rAutoText)
Definition: unoatxt.cxx:956
SwGlossaries * pGlossaries
Definition: unoatxt.hxx:57
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoatxt.cxx:212
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &aTextPosition) override
Definition: unoatxt.cxx:781
void GetBodyText()
Definition: unoatxt.cxx:755
virtual OUString SAL_CALL getString() override
Definition: unoobj2.cxx:1037
SwGlossaries * pGlossaries
Definition: unoatxt.hxx:167
const SwGlossaries * GetGlossaries() const
Definition: unoatxt.hxx:236
bool NewGroupDoc(OUString &rGroupName, const OUString &rTitle)
Definition: glosdoc.cxx:175
virtual bool Save() override
global IO.
Definition: docsh.cxx:265
no RedlineFlags
sal_uInt16 nPos
virtual OUString SAL_CALL getImplementationName() override
Definition: unoatxt.cxx:928
static bool lcl_CopySelToDoc(SwDoc &rInsDoc, OTextCursorHelper *pxCursor, SwXTextRange *pxRange)
Definition: unoatxt.cxx:286
OUString sEntryName
Definition: unoatxt.hxx:169
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)
SwGlossaryList * GetGlossaryList()
Definition: initui.cxx:172