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