LibreOffice Module sw (master)  1
gloshdl.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 <vcl/errinf.hxx>
21 #include <vcl/weld.hxx>
22 #include <svl/macitem.hxx>
23 #include <sfx2/fcontnr.hxx>
24 #include <sfx2/docfile.hxx>
25 #include <sfx2/docfilt.hxx>
27 #include <o3tl/string_view.hxx>
28 #include <docsh.hxx>
29 #include <wrtsh.hxx>
30 #include <view.hxx>
31 #include <gloshdl.hxx>
32 #include <glosdoc.hxx>
33 #include <shellio.hxx>
34 #include <swundo.hxx>
35 #include <expfld.hxx>
36 #include <initui.hxx>
37 #include <gloslst.hxx>
38 #include <swdtflvr.hxx>
39 
40 #include <strings.hrc>
41 #include <vcl/svapp.hxx>
42 #include <osl/diagnose.h>
43 
44 #include <editeng/acorrcfg.hxx>
45 #include <sfx2/event.hxx>
46 #include <swabstdlg.hxx>
47 
48 #include <memory>
49 
50 using namespace ::com::sun::star;
51 
52 const short RET_EDIT = 100;
53 
54 namespace {
55 
56 struct TextBlockInfo_Impl
57 {
58  OUString sTitle;
59  OUString sLongName;
60  OUString sGroupName;
61  TextBlockInfo_Impl(OUString const& rTitle, OUString const& rLongName, OUString const& rGroupName)
62  : sTitle(rTitle), sLongName(rLongName), sGroupName(rGroupName) {}
63 };
64 
65 }
66 
67 // Dialog for edit templates
69 {
72  OUString sName;
73  OUString sShortName;
74 
75  if( RET_EDIT == pDlg->Execute() )
76  {
77  sName = pDlg->GetCurrGrpName();
78  sShortName = pDlg->GetCurrShortName();
79  }
80 
81  pDlg.disposeAndClear();
82  m_pCurGrp.reset();
83  if(HasGlossaryList())
84  {
86  }
87 
88  if( !sName.isEmpty() || !sShortName.isEmpty() )
89  m_rStatGlossaries.EditGroupDoc( sName, sShortName );
90 }
91 
92 // set the default group; if called from the dialog
93 // the group is created temporarily for faster access
94 void SwGlossaryHdl::SetCurGroup(const OUString &rGrp, bool bApi, bool bAlwaysCreateNew )
95 {
96  OUString sGroup(rGrp);
97  if (sGroup.indexOf(GLOS_DELIM)<0 && !FindGroupName(sGroup))
98  {
99  sGroup += OUStringChar(GLOS_DELIM) + "0";
100  }
101  if(m_pCurGrp)
102  {
103  bool bPathEqual = false;
104  if(!bAlwaysCreateNew)
105  {
106  INetURLObject aTemp( m_pCurGrp->GetFileName() );
107  const OUString sCurBase = aTemp.getBase();
108  aTemp.removeSegment();
109  const OUString sCurEntryPath = aTemp.GetMainURL(INetURLObject::DecodeMechanism::NONE);
110  const std::vector<OUString> & rPathArr = m_rStatGlossaries.GetPathArray();
111  sal_uInt16 nCurrentPath = USHRT_MAX;
112  for (size_t nPath = 0; nPath < rPathArr.size(); ++nPath)
113  {
114  if (sCurEntryPath == rPathArr[nPath])
115  {
116  nCurrentPath = o3tl::narrowing<sal_uInt16>(nPath);
117  break;
118  }
119  }
120  const std::u16string_view sPath = o3tl::getToken(sGroup, 1, GLOS_DELIM);
121  sal_uInt16 nComparePath = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(sPath));
122  if(nCurrentPath == nComparePath &&
123  o3tl::getToken(sGroup, 0, GLOS_DELIM) == sCurBase)
124  bPathEqual = true;
125  }
126 
127  // When path changed, the name is not reliable
128  if(!bAlwaysCreateNew && bPathEqual)
129  return;
130  }
131  m_aCurGrp = sGroup;
132  if(!bApi)
133  {
135  }
136 }
137 
139 {
141 }
142 
143 OUString SwGlossaryHdl::GetGroupName( size_t nId, OUString* pTitle )
144 {
145  OUString sRet = m_rStatGlossaries.GetGroupName(nId);
146  if(pTitle)
147  {
148  std::unique_ptr<SwTextBlocks> pGroup = m_rStatGlossaries.GetGroupDoc(sRet);
149  if (pGroup && !pGroup->GetError())
150  {
151  *pTitle = pGroup->GetName();
152  if (pTitle->isEmpty())
153  {
154  *pTitle = sRet.getToken(0, GLOS_DELIM);
155  pGroup->SetName(*pTitle);
156  }
157  }
158  else
159  {
160  sRet.clear();
161  }
162  }
163  return sRet;
164 }
165 
166 void SwGlossaryHdl::NewGroup(OUString &rGrpName, const OUString& rTitle)
167 {
168  if (rGrpName.indexOf(GLOS_DELIM)<0)
169  FindGroupName(rGrpName);
170  m_rStatGlossaries.NewGroupDoc(rGrpName, rTitle);
171 }
172 
173 void SwGlossaryHdl::RenameGroup(const OUString& rOld, OUString& rNew, const OUString& rNewTitle)
174 {
175  OUString sOldGroup(rOld);
176  if (rOld.indexOf(GLOS_DELIM)<0)
177  FindGroupName(sOldGroup);
178  if(rOld == rNew)
179  {
180  std::unique_ptr<SwTextBlocks> pGroup = m_rStatGlossaries.GetGroupDoc(sOldGroup);
181  if(pGroup)
182  {
183  pGroup->SetName(rNewTitle);
184  }
185  }
186  else
187  {
188  OUString sNewGroup(rNew);
189  if (sNewGroup.indexOf(GLOS_DELIM)<0)
190  {
191  sNewGroup += OUStringChar(GLOS_DELIM) + "0";
192  }
193  m_rStatGlossaries.RenameGroupDoc(sOldGroup, sNewGroup, rNewTitle);
194  rNew = sNewGroup;
195  }
196 }
197 
198 // delete an autotext-file-group
199 bool SwGlossaryHdl::DelGroup(const OUString &rGrpName)
200 {
201  OUString sGroup(rGrpName);
202  if (sGroup.indexOf(GLOS_DELIM)<0)
203  FindGroupName(sGroup);
204  if( m_rStatGlossaries.DelGroupDoc(sGroup) )
205  {
206  if(m_pCurGrp)
207  {
208  if (m_pCurGrp->GetName() == sGroup)
209  m_pCurGrp.reset();
210  }
211  return true;
212  }
213  return false;
214 }
215 
216 // ask for number of autotexts
218 {
219  return m_pCurGrp ? m_pCurGrp->GetCount() : 0;
220 }
221 
222 OUString SwGlossaryHdl::GetGlossaryName( sal_uInt16 nId )
223 {
224  OSL_ENSURE(nId < GetGlossaryCnt(), "Text building block array over-indexed.");
225  return m_pCurGrp->GetLongName( nId );
226 }
227 
228 OUString SwGlossaryHdl::GetGlossaryShortName(sal_uInt16 nId)
229 {
230  OSL_ENSURE(nId < GetGlossaryCnt(), "Text building block array over-indexed.");
231  return m_pCurGrp->GetShortName( nId );
232 }
233 
234 // ask for short name
235 OUString SwGlossaryHdl::GetGlossaryShortName(const OUString &rName)
236 {
237  OUString sReturn;
238  SwTextBlocks *pTmp =
240  if(pTmp)
241  {
242  sal_uInt16 nIdx = pTmp->GetLongIndex( rName );
243  if( nIdx != sal_uInt16(-1) )
244  sReturn = pTmp->GetShortName( nIdx );
245  if( !m_pCurGrp )
246  delete pTmp;
247  }
248  return sReturn;
249 }
250 
251 // short name for autotext already used?
252 bool SwGlossaryHdl::HasShortName(const OUString& rShortName) const
253 {
254  SwTextBlocks *pBlock = m_pCurGrp ? m_pCurGrp.get()
255  : m_rStatGlossaries.GetGroupDoc( m_aCurGrp ).release();
256  bool bRet = pBlock->GetIndex( rShortName ) != sal_uInt16(-1);
257  if( !m_pCurGrp )
258  delete pBlock;
259  return bRet;
260 }
261 
262 // Create autotext
263 bool SwGlossaryHdl::NewGlossary(const OUString& rName, const OUString& rShortName,
264  bool bCreateGroup, bool bNoAttr)
265 {
266  SwTextBlocks *pTmp =
267  m_pCurGrp ? m_pCurGrp.get() : m_rStatGlossaries.GetGroupDoc( m_aCurGrp, bCreateGroup ).release();
268  //pTmp == 0 if the AutoText path setting is wrong
269  if(!pTmp)
270  {
271  if (!m_pCurGrp)
272  delete pTmp;
273  return false;
274  }
275 
276  OUString sOnlyText;
277  OUString* pOnlyText = nullptr;
278  if( bNoAttr )
279  {
281  pOnlyText = &sOnlyText;
282  }
283 
284  const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
285 
286  const sal_uInt16 nSuccess = m_pWrtShell->MakeGlossary( *pTmp, rName, rShortName,
287  rCfg.IsSaveRelFile(), pOnlyText );
288  if(nSuccess == sal_uInt16(-1) )
289  {
290  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_pWrtShell->GetView().GetFrameWeld(),
291  VclMessageType::Info, VclButtonsType::Ok, SwResId(STR_ERR_INSERT_GLOS)));
292  xBox->run();
293  }
294  if( !m_pCurGrp )
295  delete pTmp;
296  return nSuccess != sal_uInt16(-1);
297 }
298 
299 // Delete an autotext
300 bool SwGlossaryHdl::DelGlossary(const OUString &rShortName)
301 {
302  SwTextBlocks *pGlossary = m_pCurGrp ? m_pCurGrp.get()
304  //pTmp == 0 if the AutoText path setting is wrong
305  if(!pGlossary)
306  {
307  if( !m_pCurGrp )
308  delete pGlossary;
309  return false;
310  }
311 
312  sal_uInt16 nIdx = pGlossary->GetIndex( rShortName );
313  if( nIdx != sal_uInt16(-1) )
314  pGlossary->Delete( nIdx );
315  if( !m_pCurGrp )
316  delete pGlossary;
317  return true;
318 }
319 
320 // expand short name
322 {
323  OSL_ENSURE(m_pWrtShell->CanInsert(), "illegal");
325  ::GlossaryGetCurrGroup fnGetCurrGroup = pFact->GetGlossaryCurrGroupFunc();
326  OUString sGroupName( (*fnGetCurrGroup)() );
327  if (sGroupName.indexOf(GLOS_DELIM)<0)
328  FindGroupName(sGroupName);
329  std::unique_ptr<SwTextBlocks> pGlossary = m_rStatGlossaries.GetGroupDoc(sGroupName);
330 
331  OUString aShortName;
332 
333  // use this at text selection
334  if(m_pWrtShell->SwCursorShell::HasSelection() && !m_pWrtShell->IsBlockMode())
335  {
336  aShortName = m_pWrtShell->GetSelText();
337  }
338  else
339  {
340  if(m_pWrtShell->IsAddMode())
342  else if(m_pWrtShell->IsBlockMode())
344  else if(m_pWrtShell->IsExtMode())
346  // select word (tdf#126589: part to the left of cursor)
348  m_pWrtShell->PrvWrd(true);
349  // ask for word
350  if(m_pWrtShell->IsSelection())
351  aShortName = m_pWrtShell->GetSelText();
352  }
353  return pGlossary && Expand(pParent, aShortName, &m_rStatGlossaries, std::move(pGlossary));
354 }
355 
356 bool SwGlossaryHdl::Expand(weld::Window* pParent, const OUString& rShortName,
358  std::unique_ptr<SwTextBlocks> pGlossary)
359 {
360  std::vector<TextBlockInfo_Impl> aFoundArr;
361  OUString aShortName( rShortName );
362  bool bCancel = false;
363  // search for text block
364  // - don't prefer current group depending on configuration setting
365  const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
366  sal_uInt16 nFound = !rCfg.IsSearchInAllCategories() ? pGlossary->GetIndex( aShortName ) : -1;
367  // if not found then search in all groups
368  if( nFound == sal_uInt16(-1) )
369  {
370  const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
372  const size_t nGroupCount = pGlossaryList->GetGroupCount();
373  for(size_t i = 0; i < nGroupCount; ++i)
374  {
375  // get group name with path-extension
376  const OUString sGroupName = pGlossaryList->GetGroupName(i);
377  if(sGroupName == pGlossary->GetName())
378  continue;
379  const sal_uInt16 nBlockCount = pGlossaryList->GetBlockCount(i);
380  if(nBlockCount)
381  {
382  const OUString sTitle = pGlossaryList->GetGroupTitle(i);
383  for(sal_uInt16 j = 0; j < nBlockCount; j++)
384  {
385  const OUString sLongName(pGlossaryList->GetBlockLongName(i, j));
386  const OUString sShortName(pGlossaryList->GetBlockShortName(i, j));
387  if( rSCmp.isEqual( rShortName, sShortName ))
388  {
389  aFoundArr.emplace_back(sTitle, sLongName, sGroupName);
390  }
391  }
392  }
393  }
394  if( !aFoundArr.empty() ) // one was found
395  {
396  pGlossary.reset();
397  if (1 == aFoundArr.size())
398  {
399  TextBlockInfo_Impl& rData = aFoundArr.front();
400  pGlossary = pGlossaries->GetGroupDoc(rData.sGroupName);
401  nFound = pGlossary->GetIndex( aShortName );
402  }
403  else
404  {
406  ScopedVclPtr<AbstractSwSelGlossaryDlg> pDlg(pFact->CreateSwSelGlossaryDlg(pParent, aShortName));
407  for(const TextBlockInfo_Impl & i : aFoundArr)
408  {
409  pDlg->InsertGlos(i.sTitle, i.sLongName);
410  }
411  pDlg->SelectEntryPos(0);
412  const sal_Int32 nRet = RET_OK == pDlg->Execute() ?
413  pDlg->GetSelectedIdx() :
414  -1;
415  pDlg.disposeAndClear();
416  if (nRet != -1)
417  {
418  TextBlockInfo_Impl& rData = aFoundArr[nRet];
419  pGlossary = pGlossaries->GetGroupDoc(rData.sGroupName);
420  nFound = pGlossary->GetIndex( aShortName );
421  }
422  else
423  {
424  nFound = sal_uInt16(-1);
425  bCancel = true;
426  }
427  }
428  }
429  }
430 
431  // not found
432  if( nFound == sal_uInt16(-1) )
433  {
434  if( !bCancel )
435  {
436  pGlossary.reset();
437 
438  const sal_Int32 nMaxLen = 50;
439  if(m_pWrtShell->IsSelection() && aShortName.getLength() > nMaxLen)
440  {
441  aShortName = OUString::Concat(aShortName.subView(0, nMaxLen)) + " ...";
442  }
443  OUString aTmp( SwResId(STR_NOGLOS));
444  aTmp = aTmp.replaceFirst("%1", aShortName);
445  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_pWrtShell->GetView().GetFrameWeld(),
446  VclMessageType::Info, VclButtonsType::Ok,
447  aTmp));
448  xInfoBox->run();
449  }
450 
451  return false;
452  }
453  else
454  {
455  SvxMacro aStartMacro(OUString(), OUString(), STARBASIC);
456  SvxMacro aEndMacro(OUString(), OUString(), STARBASIC);
457  GetMacros( aShortName, aStartMacro, aEndMacro, pGlossary.get() );
458 
459  // StartAction must not be before HasSelection and DelRight,
460  // otherwise the possible Shell change gets delayed and
461  // API-programs would hang.
462  // Moreover the event macro must also not be called in an action
464  if( aStartMacro.HasMacro() )
465  m_pWrtShell->ExecMacro( aStartMacro );
467  m_pWrtShell->DelLeft();
469 
470  // cache all InputFields
471  SwInputFieldList aFieldLst( m_pWrtShell, true );
472 
473  m_pWrtShell->InsertGlossary(*pGlossary, aShortName);
475  if( aEndMacro.HasMacro() )
476  {
477  m_pWrtShell->ExecMacro( aEndMacro );
478  }
480 
481  // demand input for all new InputFields
482  if( aFieldLst.BuildSortLst() )
483  m_pWrtShell->UpdateInputFields( &aFieldLst );
484  }
485  return true;
486 }
487 
488 // add autotext
489 bool SwGlossaryHdl::InsertGlossary(const OUString &rName)
490 {
491  OSL_ENSURE(m_pWrtShell->CanInsert(), "illegal");
492 
493  SwTextBlocks *pGlos =
495 
496  if (!pGlos)
497  {
498  if (!m_pCurGrp)
499  delete pGlos;
500  return false;
501  }
502 
503  SvxMacro aStartMacro(OUString(), OUString(), STARBASIC);
504  SvxMacro aEndMacro(OUString(), OUString(), STARBASIC);
505  GetMacros( rName, aStartMacro, aEndMacro, pGlos );
506 
507  // StartAction must not be before HasSelection and DelRight,
508  // otherwise the possible Shell change gets delayed and
509  // API-programs would hang.
510  // Moreover the event macro must also not be called in an action
511  if( aStartMacro.HasMacro() )
512  m_pWrtShell->ExecMacro( aStartMacro );
513  if( m_pWrtShell->HasSelection() )
516 
517  // cache all InputFields
518  SwInputFieldList aFieldLst( m_pWrtShell, true );
519 
520  m_pWrtShell->InsertGlossary(*pGlos, rName);
522  if( aEndMacro.HasMacro() )
523  {
524  m_pWrtShell->ExecMacro( aEndMacro );
525  }
526 
527  // demand input for all new InputFields
528  if( aFieldLst.BuildSortLst() )
529  m_pWrtShell->UpdateInputFields( &aFieldLst );
530 
531  if(!m_pCurGrp)
532  delete pGlos;
533  return true;
534 }
535 
536 // set / ask for macro
537 void SwGlossaryHdl::SetMacros(const OUString& rShortName,
538  const SvxMacro* pStart,
539  const SvxMacro* pEnd,
540  SwTextBlocks *pGlossary )
541 {
542  SwTextBlocks *pGlos = pGlossary ? pGlossary :
543  m_pCurGrp ? m_pCurGrp.get()
544  : m_rStatGlossaries.GetGroupDoc( m_aCurGrp ).release();
545  SvxMacroTableDtor aMacroTable;
546  if( pStart )
547  aMacroTable.Insert( SvMacroItemId::SwStartInsGlossary, *pStart);
548  if( pEnd )
549  aMacroTable.Insert( SvMacroItemId::SwEndInsGlossary, *pEnd);
550  sal_uInt16 nIdx = pGlos->GetIndex( rShortName );
551  if( !pGlos->SetMacroTable( nIdx, aMacroTable ) && pGlos->GetError() )
553 
554  if(!m_pCurGrp && !pGlossary)
555  delete pGlos;
556 }
557 
558 void SwGlossaryHdl::GetMacros( const OUString &rShortName,
559  SvxMacro& rStart,
560  SvxMacro& rEnd,
561  SwTextBlocks *pGlossary )
562 {
563  SwTextBlocks *pGlos = pGlossary ? pGlossary
564  : m_pCurGrp ? m_pCurGrp.get()
566  sal_uInt16 nIndex = pGlos->GetIndex( rShortName );
567  if( nIndex != USHRT_MAX )
568  {
569  SvxMacroTableDtor aMacroTable;
570  if( pGlos->GetMacroTable( nIndex, aMacroTable ) )
571  {
572  SvxMacro *pMacro = aMacroTable.Get( SvMacroItemId::SwStartInsGlossary );
573  if( pMacro )
574  rStart = *pMacro;
575 
576  pMacro = aMacroTable.Get( SvMacroItemId::SwEndInsGlossary );
577  if( pMacro )
578  rEnd = *pMacro;
579  }
580  }
581 
582  if( !m_pCurGrp && !pGlossary )
583  delete pGlos;
584 }
585 
586 // ctor, dtor
588  : m_rStatGlossaries( *::GetGlossaries() ),
589  m_aCurGrp( SwGlossaries::GetDefName() ),
590  m_pViewFrame( pVwFrame ),
591  m_pWrtShell( pSh )
592 {
593 }
594 
596 {
597 }
598 
599 // rename an autotext
600 bool SwGlossaryHdl::Rename(const OUString& rOldShort, const OUString& rNewShortName,
601  const OUString& rNewName )
602 {
603  bool bRet = false;
604  SwTextBlocks *pGlossary = m_pCurGrp ? m_pCurGrp.get()
606  if(pGlossary)
607  {
608  sal_uInt16 nIdx = pGlossary->GetIndex( rOldShort );
609  sal_uInt16 nOldLongIdx = pGlossary->GetLongIndex( rNewName );
610  sal_uInt16 nOldIdx = pGlossary->GetIndex( rNewShortName );
611 
612  if( nIdx != USHRT_MAX &&
613  (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&&
614  (nOldIdx == USHRT_MAX || nOldIdx == nIdx ))
615  {
616  pGlossary->Rename( nIdx, &rNewShortName, &rNewName );
617  bRet = pGlossary->GetError() == ERRCODE_NONE;
618  }
619  if( !m_pCurGrp )
620  delete pGlossary;
621  }
622  return bRet;
623 }
624 
625 bool SwGlossaryHdl::IsReadOnly( const OUString* pGrpNm ) const
626 {
627  SwTextBlocks *pGlossary = nullptr;
628 
629  if (pGrpNm)
630  pGlossary = m_rStatGlossaries.GetGroupDoc( *pGrpNm ).release();
631  else if (m_pCurGrp)
632  pGlossary = m_pCurGrp.get();
633  else
634  pGlossary = m_rStatGlossaries.GetGroupDoc(m_aCurGrp).release();
635 
636  const bool bRet = !pGlossary || pGlossary->IsReadOnly();
637  if( pGrpNm || !m_pCurGrp )
638  delete pGlossary;
639  return bRet;
640 }
641 
643 {
644  if( !m_pCurGrp )
646  return false;
647 }
648 
649 // find group without path index
650 bool SwGlossaryHdl::FindGroupName(OUString& rGroup)
651 {
652  return m_rStatGlossaries.FindGroupName(rGroup);
653 }
654 
655 bool SwGlossaryHdl::CopyToClipboard(SwWrtShell& rSh, const OUString& rShortName)
656 {
657  SwTextBlocks *pGlossary = m_pCurGrp ? m_pCurGrp.get()
659 
660  rtl::Reference<SwTransferable> pTransfer = new SwTransferable( rSh );
661 
662  bool bRet = pTransfer->CopyGlossary( *pGlossary, rShortName );
663  if( !m_pCurGrp )
664  delete pGlossary;
665  return bRet;
666 }
667 
668 bool SwGlossaryHdl::ImportGlossaries( const OUString& rName )
669 {
670  bool bRet = false;
671  if( !rName.isEmpty() )
672  {
673  std::shared_ptr<const SfxFilter> pFilter;
674  SfxMedium aMed( rName, StreamMode::READ, nullptr, nullptr );
675  SfxFilterMatcher aMatcher( "swriter" );
676  aMed.UseInteractionHandler( true );
677  if (!aMatcher.GuessFilter(aMed, pFilter, SfxFilterFlags::NONE))
678  {
679  SwTextBlocks *pGlossary = nullptr;
680  aMed.SetFilter( pFilter );
681  Reader* pR = SwReaderWriter::GetReader( pFilter->GetUserData() );
682  if( pR && nullptr != ( pGlossary = m_pCurGrp ? m_pCurGrp.get()
683  : m_rStatGlossaries.GetGroupDoc(m_aCurGrp).release()) )
684  {
685  SwReader aReader( aMed, rName );
686  if( aReader.HasGlossaries( *pR ) )
687  {
688  const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
689  bRet = aReader.ReadGlossaries( *pR, *pGlossary,
690  rCfg.IsSaveRelFile() );
691  }
692 
693  if (!m_pCurGrp)
694  delete pGlossary;
695  }
696  }
697  }
698  return bRet;
699 }
700 
701 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const short RET_EDIT
Definition: gloshdl.cxx:52
void InsertGlossary(SwTextBlocks &rGlossary, const OUString &)
Glossary from glossary document in current document.
Definition: edglss.cxx:39
OUString(* GlossaryGetCurrGroup)()
Definition: swabstdlg.hxx:87
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
Definition: init.cxx:786
SvxMacro & Insert(SvMacroItemId nEvent, const SvxMacro &rMacro)
sal_uInt16 GetBlockCount(size_t nGroup)
Definition: gloslst.cxx:199
sal_Int32 nIndex
std::unique_ptr< SwTextBlocks > m_pCurGrp
Definition: gloshdl.hxx:42
bool BuildSortLst()
Put all that are new into SortList for updating.
Definition: fldlst.cxx:114
static SvxAutoCorrCfg & Get()
bool Rename(const OUString &rOldShortName, const OUString &rNewShortName, const OUString &rNewName)
Definition: gloshdl.cxx:600
bool HasGlossaryList()
Definition: initui.cxx:169
bool ReadGlossaries(const Reader &, SwTextBlocks &, bool bSaveRelFiles)
Definition: shellio.cxx:657
sal_uInt16 MakeGlossary(SwTextBlocks &rToFill, const OUString &rName, const OUString &rShortName, bool bSaveRelFile, const OUString *pOnlyText)
Make current selection glossary and insert into glossary document including styles.
Definition: edglss.cxx:47
void LeaveBlockMode()
Definition: select.cxx:660
OUString getBase(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetGlossaryShortName(const OUString &rName)
Definition: gloshdl.cxx:235
void GetSelectedText(OUString &rBuf, ParaBreakType nHndlParaBreak=ParaBreakType::ToBlank)
Query text within selection.
Definition: edglss.cxx:261
sal_uInt16 GetGlossaryCnt() const
Definition: gloshdl.cxx:217
SwDocShellRef EditGroupDoc(const OUString &rGrpName, const OUString &rShortName, bool bShow=true)
Definition: glshell.cxx:196
bool DelGlossary(const OUString &)
Definition: gloshdl.cxx:300
const ContentProperties & rData
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
size_t GetGroupCnt()
Definition: glosdoc.cxx:99
void UpdateInputFields(SwInputFieldList *pLst=nullptr)
Definition: wrtsh2.cxx:146
size_t GetGroupCount()
Definition: gloslst.cxx:169
std::unique_ptr< SwTextBlocks > GetGroupDoc(const OUString &rName, bool bCreate=false)
Definition: glosdoc.cxx:159
void Rename(sal_uInt16, const OUString *, const OUString *)
Definition: swblocks.cxx:310
void EndAllAction()
Definition: edws.cxx:97
bool FindGroupName(OUString &rGroup)
Definition: glosdoc.cxx:105
ErrCode const & GetError() const
Definition: shellio.hxx:324
bool IsOld() const
Definition: gloshdl.cxx:642
bool DelRight()
Definition: delete.cxx:294
size_t GetGroupCnt() const
Definition: gloshdl.cxx:138
Used by the UI to modify the document model.
Definition: wrtsh.hxx:96
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
bool HasMacro() const
const SwView & GetView() const
Definition: wrtsh.hxx:437
virtual VclPtr< AbstractGlossaryDlg > CreateGlossaryDlg(SfxViewFrame *pViewFrame, SwGlossaryHdl *pGlosHdl, SwWrtShell *pWrtShell)=0
void LeaveAddMode()
Definition: select.cxx:641
Reader * GetReader(const OUString &rFltName)
Return reader based on the name.
Definition: fltini.cxx:169
void SetMacros(const OUString &rName, const SvxMacro *pStart, const SvxMacro *pEnd, SwTextBlocks *pGlossary=nullptr)
Definition: gloshdl.cxx:537
bool PrvWrd(bool bSelect=false)
Definition: wrtsh.hxx:217
void SetCurGroup(const OUString &aGrp, bool bApi=false, bool bAlwaysCreateNew=false)
Definition: gloshdl.cxx:94
OUString GetBlockLongName(size_t nGroup, sal_uInt16 nBlock)
Definition: gloslst.cxx:210
OUString GetGroupName(size_t nPos)
Definition: gloslst.cxx:176
SW_DLLPUBLIC SwGlossaries * GetGlossaries()
Definition: initui.cxx:162
OUString GetBlockShortName(size_t nGroup, sal_uInt16 nBlock)
Definition: gloslst.cxx:221
bool IsBlockMode() const
Definition: wrtsh.hxx:167
const char * sName
void ExecMacro(const SvxMacro &rMacro, OUString *pRet=nullptr, SbxArray *pArgs=nullptr)
Definition: wrtsh3.cxx:292
SAL_DLLPRIVATE bool Expand(weld::Window *pParent, const OUString &rShortName, SwGlossaries *pGlossaries, std::unique_ptr< SwTextBlocks > pGlossary)
Definition: gloshdl.cxx:356
OUString GetGlossaryName(sal_uInt16)
Definition: gloshdl.cxx:222
bool DelGroup(const OUString &)
Definition: gloshdl.cxx:199
bool IsSelection() const
Definition: crsrsh.hxx:888
SwGlossaryHdl(SfxViewFrame *pViewFrame, SwWrtShell *)
Definition: gloshdl.cxx:587
void GlossaryDlg()
Definition: gloshdl.cxx:68
bool HasSelection() const
Definition: wrtsh.hxx:147
int i
OUString GetGroupTitle(size_t nPos)
Definition: gloslst.cxx:188
static SwGlossaryList * pGlossaryList
Definition: initui.cxx:41
void UseInteractionHandler(bool)
bool CopyToClipboard(SwWrtShell &rSh, const OUString &rShortName)
Definition: gloshdl.cxx:655
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
static std::unique_ptr< SwGlossaries > pGlossaries
Definition: initui.cxx:38
bool ExpandGlossary(weld::Window *pParent)
Definition: gloshdl.cxx:321
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
sal_uInt16 GetLongIndex(const OUString &) const
Definition: swblocks.cxx:265
bool IsInWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES) const
Definition: crstrvl1.cxx:36
bool IsReadOnly(const OUString *=nullptr) const
Definition: gloshdl.cxx:625
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
OUString GetGroupName(size_t, OUString *pTitle)
Definition: gloshdl.cxx:143
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
bool IsSaveRelFile() const
bool DelLeft()
Definition: delete.cxx:134
virtual OUString GetCurrGrpName() const =0
void NewGroup(OUString &rGroupName, const OUString &rTitle)
Definition: gloshdl.cxx:166
bool IsReadOnly() const
Definition: swblocks.cxx:491
bool IsSearchInAllCategories() const
void LeaveExtMode()
Definition: select.cxx:598
SwWrtShell * m_pWrtShell
Definition: gloshdl.hxx:40
OUString m_aCurGrp
Definition: gloshdl.hxx:38
bool Delete(sal_uInt16)
Definition: swblocks.cxx:284
bool InsertGlossary(const OUString &rName)
Definition: gloshdl.cxx:489
bool GetMacroTable(sal_uInt16 nIdx, SvxMacroTableDtor &rMacroTable)
Definition: swblocks.cxx:528
bool HasShortName(const OUString &rShortName) const
Definition: gloshdl.cxx:252
const SvxMacro * Get(SvMacroItemId nEvent) const
OUString const & GetGroupName(size_t)
Definition: glosdoc.cxx:137
weld::Window * GetFrameWeld() const
std::vector< OUString > const & GetPathArray() const
Definition: glosdoc.hxx:120
#define ERRCODE_NONE
bool RenameGroupDoc(const OUString &sOldGroup, OUString &sNewGroup, const OUString &rNewTitle)
Definition: glosdoc.cxx:196
void ClearGroups()
Definition: gloslst.cxx:437
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2552
sal_uInt16 GetIndex(const OUString &) const
Definition: swblocks.cxx:260
RET_OK
SfxViewFrame * m_pViewFrame
Definition: gloshdl.hxx:39
bool CanInsert()
Definition: wrtsh1.cxx:2007
bool IsExtMode() const
Definition: wrtsh.hxx:157
#define GLOS_DELIM
Definition: glosdoc.hxx:41
void GetMacros(const OUString &rShortName, SvxMacro &rStart, SvxMacro &rEnd, SwTextBlocks *pGlossary=nullptr)
Definition: gloshdl.cxx:558
bool IsEndWrd()
Definition: wrtsh1.cxx:191
OUString GetShortName(sal_uInt16) const
Definition: swblocks.cxx:270
void RenameGroup(const OUString &rOld, OUString &rNew, const OUString &rNewTitle)
Definition: gloshdl.cxx:173
bool SetMacroTable(sal_uInt16 nIdx, const SvxMacroTableDtor &rMacroTable)
Definition: swblocks.cxx:536
bool IsAddMode() const
Definition: wrtsh.hxx:162
virtual VclPtr< AbstractSwSelGlossaryDlg > CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName)=0
bool FindGroupName(OUString &rGroup)
Definition: gloshdl.cxx:650
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
bool NewGlossary(const OUString &rName, const OUString &rShortName, bool bApiCall=false, bool bNoAttr=false)
Definition: gloshdl.cxx:263
void SetFilter(const std::shared_ptr< const SfxFilter > &pFilter)
bool NewGroupDoc(OUString &rGroupName, const OUString &rTitle)
Definition: glosdoc.cxx:176
bool HasGlossaries(const Reader &)
Definition: shellio.cxx:642
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
bool ImportGlossaries(const OUString &rName)
Definition: gloshdl.cxx:668
bool DelGroupDoc(std::u16string_view)
Definition: glosdoc.cxx:248
SwGlossaries & m_rStatGlossaries
Definition: gloshdl.hxx:37
SwGlossaryList * GetGlossaryList()
Definition: initui.cxx:174