LibreOffice Module sw (master)  1
glossary.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 <hintids.hxx>
21 
22 #include <o3tl/any.hxx>
23 #include <vcl/menu.hxx>
24 #include <vcl/weld.hxx>
25 #include <vcl/help.hxx>
26 #include <vcl/builderfactory.hxx>
27 #include <svl/stritem.hxx>
28 #include <svl/macitem.hxx>
29 #include <unotools/pathoptions.hxx>
30 #include <unotools/lingucfg.hxx>
31 #include <sfx2/request.hxx>
32 #include <sfx2/fcontnr.hxx>
33 #include <sfx2/docfilt.hxx>
34 
35 #include <svx/svxdlg.hxx>
36 #include <svx/dialogs.hrc>
37 #include <editeng/acorrcfg.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <unocrsr.hxx>
40 #include <unotools.hxx>
42 #include <ucbhelper/content.hxx>
43 #include <com/sun/star/text/AutoTextContainer.hpp>
44 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
45 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
46 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
47 #include <svl/urihelper.hxx>
48 #include <unotools/charclass.hxx>
49 #include <vcl/treelistentry.hxx>
50 #include <swwait.hxx>
51 #include <swtypes.hxx>
52 #include <wrtsh.hxx>
53 #include <view.hxx>
54 #include <basesh.hxx>
55 #include <glossary.hxx>
56 #include <gloshdl.hxx>
57 #include <glosbib.hxx>
58 #include <initui.hxx>
59 #include <glosdoc.hxx>
60 #include <macassgn.hxx>
61 #include <swevent.hxx>
62 #include <docsh.hxx>
63 #include <shellio.hxx>
64 
65 #include <cmdid.h>
66 #include <swerror.h>
67 #include <globals.hrc>
68 #include <swmodule.hxx>
69 #include <sfx2/filedlghelper.hxx>
70 
71 #include <memory>
72 
73 #include <strings.hrc>
74 #include <iodetect.hxx>
75 
76 #include <officecfg/Office/Writer.hxx>
77 
78 using namespace ::com::sun::star;
79 using namespace ::com::sun::star::lang;
80 using namespace ::com::sun::star::uno;
81 using namespace ::com::sun::star::text;
82 using namespace ::com::sun::star::ucb;
83 using namespace ::com::sun::star::ui::dialogs;
84 using namespace ::ucbhelper;
85 using namespace ::sfx2;
86 
87 static OUString lcl_GetValidShortCut( const OUString& rName )
88 {
89  const sal_Int32 nSz = rName.getLength();
90 
91  if ( 0 == nSz )
92  return rName;
93 
94  sal_Int32 nStart = 1;
95  while( rName[nStart-1]==' ' && nStart < nSz )
96  nStart++;
97 
98  OUStringBuffer aBuf;
99  aBuf.append(rName[nStart-1]);
100 
101  for( ; nStart < nSz; ++nStart )
102  {
103  if( rName[nStart-1]==' ' && rName[nStart]!=' ')
104  aBuf.append(rName[nStart]);
105  }
106  return aBuf.makeStringAndClear();
107 }
108 
110 {
111  OUString sGroupName;
112  sal_uInt16 nPathIdx;
113  bool bReadonly;
114 
116  : nPathIdx(0),
117  bReadonly(false) {}
118 };
119 
120 // dialog for new block name
122 {
125 
126  std::unique_ptr<weld::Entry> m_xNewName;
127  std::unique_ptr<weld::Entry> m_xNewShort;
128  std::unique_ptr<weld::Button> m_xOk;
129  std::unique_ptr<weld::Entry> m_xOldName;
130  std::unique_ptr<weld::Entry> m_xOldShort;
131 
132 protected:
133  DECL_LINK(Modify, weld::Entry&, void);
134  DECL_LINK(Rename, weld::Button&, void);
135  DECL_LINK(TextFilterHdl, OUString&, bool);
136 
137 public:
139  const OUString& rOldName,
140  const OUString& rOldShort);
141 
142  OUString GetNewName() const { return m_xNewName->get_text(); }
143  OUString GetNewShort() const { return m_xNewShort->get_text(); }
144 };
145 
146 IMPL_LINK(SwNewGlosNameDlg, TextFilterHdl, OUString&, rTest, bool)
147 {
148  rTest = m_aNoSpaceFilter.filter(rTest);
149  return true;
150 }
151 
152 SwNewGlosNameDlg::SwNewGlosNameDlg(SwGlossaryDlg* pParent, const OUString& rOldName, const OUString& rOldShort)
153  : GenericDialogController(pParent->GetFrameWeld(), "modules/swriter/ui/renameautotextdialog.ui", "RenameAutoTextDialog")
154  , m_pParent(pParent)
155  , m_xNewName(m_xBuilder->weld_entry("newname"))
156  , m_xNewShort(m_xBuilder->weld_entry("newsc"))
157  , m_xOk(m_xBuilder->weld_button("ok"))
158  , m_xOldName(m_xBuilder->weld_entry("oldname"))
159  , m_xOldShort(m_xBuilder->weld_entry("oldsc"))
160 {
161  m_xNewShort->connect_insert_text(LINK(this, SwNewGlosNameDlg, TextFilterHdl));
162 
163  m_xOldName->set_text(rOldName);
164  m_xOldShort->set_text(rOldShort);
165  m_xNewName->connect_changed(LINK(this, SwNewGlosNameDlg, Modify ));
166  m_xNewShort->connect_changed(LINK(this, SwNewGlosNameDlg, Modify ));
167  m_xOk->connect_clicked(LINK(this, SwNewGlosNameDlg, Rename ));
168  m_xNewName->grab_focus();
169 }
170 
171 // query / set currently set group
173 {
174  if( !::GetCurrGlosGroup().isEmpty() )
176  return SwGlossaries::GetDefName();
177 }
178 
179 void SwGlossaryDlg::SetActGroup(const OUString &rGrp)
180 {
181  ::SetCurrGlosGroup(rGrp);
182 }
183 
185  SwGlossaryHdl * pGlosHdl, SwWrtShell *pWrtShell)
186  : SvxStandardDialog(&pViewFrame->GetWindow(), "AutoTextDialog",
187  "modules/swriter/ui/autotext.ui")
188  , m_sReadonlyPath(SwResId(STR_READONLY_PATH))
189  , m_pGlossaryHdl(pGlosHdl)
190  , m_bResume(false)
191  , m_bSelection(pWrtShell->IsSelection())
192  , m_bReadOnly(false)
193  , m_bIsOld(false)
194  , m_bIsDocReadOnly(false)
195  , m_pShell(pWrtShell)
196 {
197  get(m_pInsertTipCB, "inserttip");
198  get(m_pNameED, "name");
199  get(m_pShortNameLbl, "shortnameft");
200  get(m_pShortNameEdit, "shortname");
202  get(m_pCategoryBox, "category");
203  get(m_pFileRelCB, "relfile");
204  get(m_pNetRelCB, "relnet");
205  get(m_pInsertBtn, "insert");
206  get(m_pBibBtn, "categories");
207  get(m_pPathBtn, "path");
208  get(m_pExampleWIN, "example");
209  get(m_pEditBtn, "autotext");
210 
211  SvtLinguConfig aLocalLinguConfig;
212 
213  PopupMenu *pMenu = m_pEditBtn->GetPopupMenu();
214  assert(pMenu);
215  pMenu->SetActivateHdl(LINK(this,SwGlossaryDlg,EnableHdl));
216  pMenu->SetSelectHdl(LINK(this,SwGlossaryDlg,MenuHdl));
217  m_pEditBtn->SetSelectHdl(LINK(this,SwGlossaryDlg,EditHdl));
218  m_pPathBtn->SetClickHdl(LINK(this, SwGlossaryDlg, PathHdl));
219 
220  m_pNameED->SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
221  m_pShortNameEdit->SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
222 
223  m_pCategoryBox->SetDoubleClickHdl(LINK(this,SwGlossaryDlg, NameDoubleClick));
224  m_pCategoryBox->SetSelectHdl(LINK(this,SwGlossaryDlg,GrpSelect));
225  m_pCategoryBox->SetDeleteHdl(LINK(this,SwGlossaryDlg,DeleteHdl));
226  m_pBibBtn->SetClickHdl(LINK(this,SwGlossaryDlg,BibHdl));
227 
228  m_pInsertBtn->SetClickHdl(LINK(this,SwGlossaryDlg,InsertHdl));
229 
230  ShowPreview();
231 
234  if( m_bIsDocReadOnly )
235  m_pInsertBtn->Enable(false);
236  m_pNameED->GrabFocus();
239  m_pCategoryBox->SetHighlightRange(); // select over full width
241 
242  Init();
243 }
244 
246 {
247  disposeOnce();
248 }
249 
251 {
253  m_pExampleFrame.reset();
255  m_pNameED.clear();
260  m_pNetRelCB.clear();
263  m_pEditBtn.clear();
264  m_pBibBtn.clear();
265  m_pPathBtn.clear();
267 }
268 
269 namespace
270 {
271 
272 OUString getCurrentGlossary()
273 {
274  const OUString sTemp{ ::GetCurrGlosGroup() };
275 
276  // the zeroth path is not being recorded!
277  if (sTemp.getToken(1, GLOS_DELIM).startsWith("0"))
278  return sTemp.getToken(0, GLOS_DELIM);
279 
280  return sTemp;
281 }
282 
283 }
284 
285 // select new group
286 IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox, void )
287 {
288  SvTreeListEntry* pEntry = pBox->FirstSelected();
289  if(!pEntry)
290  return;
291  SvTreeListEntry* pParent = pBox->GetParent(pEntry) ? pBox->GetParent(pEntry) : pEntry;
292  GroupUserData* pGroupData = static_cast<GroupUserData*>(pParent->GetUserData());
293  ::SetCurrGlosGroup(pGroupData->sGroupName
294  + OUStringLiteral1(GLOS_DELIM)
295  + OUString::number(pGroupData->nPathIdx));
296  m_pGlossaryHdl->SetCurGroup(::GetCurrGlosGroup());
297  // set current text block
298  m_bReadOnly = m_pGlossaryHdl->IsReadOnly();
299  EnableShortName( !m_bReadOnly );
300  m_pEditBtn->Enable(!m_bReadOnly);
301  m_bIsOld = m_pGlossaryHdl->IsOld();
302  if( pParent != pEntry)
303  {
304  OUString aName(pBox->GetEntryText(pEntry));
305  m_pNameED->SetText(aName);
306  m_pShortNameEdit->SetText(*static_cast<OUString*>(pEntry->GetUserData()));
307  m_pInsertBtn->Enable( !m_bIsDocReadOnly);
308  ShowAutoText(::GetCurrGlosGroup(), m_pShortNameEdit->GetText());
309  }
310  else
311  {
312  m_pNameED->SetText("");
313  m_pShortNameEdit->SetText("");
314  m_pShortNameEdit->Enable(false);
315  ShowAutoText("", "");
316  }
317  // update controls
318  NameModify(*m_pShortNameEdit);
319  if( SfxRequest::HasMacroRecorder( m_pShell->GetView().GetViewFrame() ) )
320  {
321  SfxRequest aReq( m_pShell->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY );
322  aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, getCurrentGlossary()));
323  aReq.Done();
324  }
325  Invalidate(InvalidateFlags::Update);
326 }
327 
329 {
330  const OUString aGlosName(m_pShortNameEdit->GetText());
331  if (!aGlosName.isEmpty())
332  {
333  m_pGlossaryHdl->InsertGlossary(aGlosName);
334  }
336  {
338  aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, getCurrentGlossary()));
339  aReq.AppendItem(SfxStringItem(FN_PARAM_1, aGlosName));
340  aReq.Done();
341  }
342 }
343 
345 {
346  m_pShortNameLbl->Enable(bOn);
347  m_pShortNameEdit->Enable(bOn);
348 }
349 
350 // does the title exist in the selected group?
352  const OUString& rShort)
353 {
354  // look for possible entry in TreeListBox
356  if(pEntry)
357  {
358  if(m_pCategoryBox->GetParent(pEntry))
359  pEntry = m_pCategoryBox->GetParent(pEntry);
360  sal_uInt32 nChildCount = m_pCategoryBox->GetChildCount( pEntry );
361  for(sal_uInt32 i = 0; i < nChildCount; i++)
362  {
363  SvTreeListEntry* pChild = m_pCategoryBox->GetEntry( pEntry, i );
364  if (rBlock == m_pCategoryBox->GetEntryText(pChild) &&
365  (rShort.isEmpty() ||
366  rShort==*static_cast<OUString*>(pChild->GetUserData()))
367  )
368  {
369  return pChild;
370  }
371  }
372  }
373  return nullptr;
374 }
375 
376 IMPL_LINK( SwGlossaryDlg, NameModify, Edit&, rEdit, void )
377 {
378  const OUString aName(m_pNameED->GetText());
379  bool bNameED = &rEdit == m_pNameED;
380  if( aName.isEmpty() )
381  {
382  if(bNameED)
383  m_pShortNameEdit->SetText(aName);
384  m_pInsertBtn->Enable(false);
385  return;
386  }
387  const bool bNotFound = !DoesBlockExist(aName, bNameED ? OUString() : rEdit.GetText());
388  if(bNameED)
389  {
390  // did the text get in to the Listbox in the Edit with a click?
391  if(bNotFound)
392  {
393  m_pShortNameEdit->SetText( lcl_GetValidShortCut( aName ) );
394  EnableShortName();
395  }
396  else
397  {
398  m_pShortNameEdit->SetText(m_pGlossaryHdl->GetGlossaryShortName(aName));
399  EnableShortName(!m_bReadOnly);
400  }
401  m_pInsertBtn->Enable(!bNotFound && !m_bIsDocReadOnly);
402  }
403  else
404  {
405  //ShortNameEdit
406  if(!bNotFound)
407  {
408  m_pInsertBtn->Enable(!m_bIsDocReadOnly);
409  }
410  }
411 }
412 
413 IMPL_LINK( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, pBox, bool )
414 {
415  SvTreeListEntry* pEntry = pBox->FirstSelected();
416  if(pBox->GetParent(pEntry) && !m_bIsDocReadOnly)
417  EndDialog( RET_OK );
418  return false;
419 }
420 
421 IMPL_LINK( SwGlossaryDlg, EnableHdl, Menu *, pMn, bool )
422 {
423  SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
424 
425  const OUString aEditText(m_pNameED->GetText());
426  const bool bHasEntry = !aEditText.isEmpty() && !m_pShortNameEdit->GetText().isEmpty();
427  const bool bExists = nullptr != DoesBlockExist(aEditText, m_pShortNameEdit->GetText());
428  const bool bIsGroup = pEntry && !m_pCategoryBox->GetParent(pEntry);
429  pMn->EnableItem("new", m_bSelection && bHasEntry && !bExists);
430  pMn->EnableItem("newtext", m_bSelection && bHasEntry && !bExists);
431  pMn->EnableItem("copy", bExists && !bIsGroup);
432  pMn->EnableItem("replace", m_bSelection && bExists && !bIsGroup && !m_bIsOld );
433  pMn->EnableItem("replacetext", m_bSelection && bExists && !bIsGroup && !m_bIsOld );
434  pMn->EnableItem("edit", bExists && !bIsGroup );
435  pMn->EnableItem("rename", bExists && !bIsGroup );
436  pMn->EnableItem("delete", bExists && !bIsGroup );
437  pMn->EnableItem("macro", bExists && !bIsGroup && !m_bIsOld &&
438  !m_pGlossaryHdl->IsReadOnly() );
439  pMn->EnableItem("import", bIsGroup && !m_bIsOld && !m_pGlossaryHdl->IsReadOnly() );
440  return true;
441 }
442 
443 IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn, bool )
444 {
445  OString sItemIdent(pMn->GetCurItemIdent());
446 
447  if (sItemIdent == "replace")
448  {
449  m_pGlossaryHdl->NewGlossary(m_pNameED->GetText(),
450  m_pShortNameEdit->GetText());
451  }
452  else if (sItemIdent == "replacetext")
453  {
454  m_pGlossaryHdl->NewGlossary(m_pNameED->GetText(),
455  m_pShortNameEdit->GetText(),
456  false, true);
457  }
458  else if (sItemIdent == "new" || sItemIdent == "newtext")
459  {
460  bool bNoAttr = sItemIdent == "newtext";
461 
462  const OUString aStr(m_pNameED->GetText());
463  const OUString aShortName(m_pShortNameEdit->GetText());
464  if(m_pGlossaryHdl->HasShortName(aShortName))
465  {
466  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
467  VclMessageType::Info, VclButtonsType::Ok,
468  SwResId(STR_DOUBLE_SHORTNAME)));
469  xInfoBox->run();
470  m_pShortNameEdit->SetSelection(Selection(0, SELECTION_MAX));
471  m_pShortNameEdit->GrabFocus();
472  return true;
473  }
474  if(m_pGlossaryHdl->NewGlossary(aStr, aShortName, false, bNoAttr ))
475  {
476  SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
477  if(m_pCategoryBox->GetParent(pEntry))
478  pEntry = m_pCategoryBox->GetParent(pEntry);
479 
480  SvTreeListEntry* pChild = m_pCategoryBox->InsertEntry(aStr, pEntry);
481  pChild->SetUserData(new OUString(aShortName));
482  m_pNameED->SetText(aStr);
483  m_pShortNameEdit->SetText(aShortName);
484  NameModify(*m_pNameED); // for toggling the buttons
485 
486  if( SfxRequest::HasMacroRecorder( m_pShell->GetView().GetViewFrame() ) )
487  {
488  SfxRequest aReq(m_pShell->GetView().GetViewFrame(), FN_NEW_GLOSSARY);
489  aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, getCurrentGlossary()));
490  aReq.AppendItem(SfxStringItem(FN_PARAM_1, aShortName));
491  aReq.AppendItem(SfxStringItem(FN_PARAM_2, aStr));
492  aReq.Done();
493  }
494  }
495  }
496  else if (sItemIdent == "copy")
497  {
498  m_pGlossaryHdl->CopyToClipboard(*m_pShell, m_pShortNameEdit->GetText());
499  }
500  else if (sItemIdent == "rename")
501  {
502  m_pShortNameEdit->SetText(m_pGlossaryHdl->GetGlossaryShortName(m_pNameED->GetText()));
503  SwNewGlosNameDlg aNewNameDlg(this, m_pNameED->GetText(), m_pShortNameEdit->GetText());
504  if (aNewNameDlg.run() == RET_OK && m_pGlossaryHdl->Rename(m_pShortNameEdit->GetText(),
505  aNewNameDlg.GetNewShort(),
506  aNewNameDlg.GetNewName()))
507  {
508  SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
509  SvTreeListEntry* pNewEntry = m_pCategoryBox->InsertEntry(
510  aNewNameDlg.GetNewName(), m_pCategoryBox->GetParent(pEntry));
511  pNewEntry->SetUserData(new OUString(aNewNameDlg.GetNewShort()));
512  delete static_cast<OUString*>(pEntry->GetUserData());
513  m_pCategoryBox->GetModel()->Remove(pEntry);
514  m_pCategoryBox->Select(pNewEntry);
515  m_pCategoryBox->MakeVisible(pNewEntry);
516  }
517  GrpSelect(m_pCategoryBox);
518  }
519  else if (sItemIdent == "delete")
520  {
521  DeleteEntry();
522  }
523  else if (sItemIdent == "macro")
524  {
526 
527  SvxMacro aStart(OUString(), OUString(), STARBASIC);
528  SvxMacro aEnd(OUString(), OUString(), STARBASIC);
529  m_pGlossaryHdl->GetMacros(m_pShortNameEdit->GetText(), aStart, aEnd );
530 
531  SvxMacroItem aItem(RES_FRMMACRO);
532  if( aStart.HasMacro() )
533  aItem.SetMacro( SvMacroItemId::SwStartInsGlossary, aStart );
534  if( aEnd.HasMacro() )
535  aItem.SetMacro( SvMacroItemId::SwEndInsGlossary, aEnd );
536 
537  aSet.Put( aItem );
539 
540  const SfxPoolItem* pItem;
543  m_pShell->GetView().GetViewFrame()->GetFrame().GetFrameInterface() ));
544  if ( pMacroDlg && pMacroDlg->Execute() == RET_OK &&
545  SfxItemState::SET == pMacroDlg->GetOutputItemSet()->GetItemState( RES_FRMMACRO, false, &pItem ) )
546  {
547  const SvxMacroTableDtor& rTable = static_cast<const SvxMacroItem*>(pItem)->GetMacroTable();
548  m_pGlossaryHdl->SetMacros( m_pShortNameEdit->GetText(),
549  rTable.Get( SvMacroItemId::SwStartInsGlossary ),
550  rTable.Get( SvMacroItemId::SwEndInsGlossary ) );
551  }
552  }
553  else if (sItemIdent == "import")
554  {
555  // call the FileOpenDialog do find WinWord - Files with templates
556  FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE,
557  FileDialogFlags::NONE, GetFrameWeld());
558  uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
559 
560  SvtPathOptions aPathOpt;
561  xFP->setDisplayDirectory(aPathOpt.GetWorkPath() );
562 
563  uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
564  SfxFilterMatcher aMatcher( SwDocShell::Factory().GetFactoryName() );
565  SfxFilterMatcherIter aIter( aMatcher );
566  std::shared_ptr<const SfxFilter> pFilter = aIter.First();
567  while ( pFilter )
568  {
569  if( pFilter->GetUserData() == FILTER_WW8 )
570  {
571  xFltMgr->appendFilter( pFilter->GetUIName(),
572  pFilter->GetWildcard().getGlob() );
573  xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
574  }
575  else if( pFilter->GetUserData() == FILTER_DOCX )
576  {
577  xFltMgr->appendFilter( pFilter->GetUIName(),
578  pFilter->GetWildcard().getGlob() );
579  xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
580  }
581 
582  pFilter = aIter.Next();
583  }
584 
585  if( aDlgHelper.Execute() == ERRCODE_NONE )
586  {
587  if( m_pGlossaryHdl->ImportGlossaries( xFP->getSelectedFiles().getConstArray()[0] ))
588  Init();
589  else
590  {
591  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
592  VclMessageType::Info, VclButtonsType::Ok,
593  SwResId(STR_NO_GLOSSARIES)));
594  xInfoBox->run();
595  }
596  }
597  }
598  else
599  {
600  return false;
601  }
602  return true;
603 }
604 
605 // dialog manage regions
607 {
608  SwGlossaries* pGloss = ::GetGlossaries();
609  if( pGloss->IsGlosPathErr() )
610  pGloss->ShowError();
611  else
612  {
613  //check if at least one glossary path is write enabled
614  SvtPathOptions aPathOpt;
615  const OUString& sGlosPath( aPathOpt.GetAutoTextPath() );
616  bool bIsWritable = false;
617  sal_Int32 nIdx {sGlosPath.isEmpty() ? -1 : 0};
618  while (nIdx>=0)
619  {
620  const OUString sPath = URIHelper::SmartRel2Abs(
621  INetURLObject(), sGlosPath.getToken(0, ';', nIdx),
623  try
624  {
625  Content aTestContent( sPath,
626  uno::Reference< XCommandEnvironment >(),
628  Any aAny = aTestContent.getPropertyValue( "IsReadOnly" );
629  if(aAny.hasValue())
630  {
631  bIsWritable = !*o3tl::doAccess<bool>(aAny);
632  }
633  }
634  catch (const Exception&)
635  {
636  }
637  if(bIsWritable)
638  break;
639  }
640  if(bIsWritable)
641  {
642 
643  SwGlossaryGroupDlg aDlg(GetFrameWeld(), pGloss->GetPathArray(), m_pGlossaryHdl);
644  if (aDlg.run() == RET_OK)
645  {
646  Init();
647  //if new groups were created - select one of them
648  const OUString sNewGroup = aDlg.GetCreatedGroupName();
649  SvTreeListEntry* pEntry = m_pCategoryBox->First();
650  while (!sNewGroup.isEmpty() && pEntry)
651  {
652  if(!m_pCategoryBox->GetParent(pEntry))
653  {
654  GroupUserData* pGroupData = static_cast<GroupUserData*>(pEntry->GetUserData());
655  const OUString sGroup = pGroupData->sGroupName
656  + OUStringLiteral1(GLOS_DELIM)
657  + OUString::number(pGroupData->nPathIdx);
658  if(sGroup == sNewGroup)
659  {
660  m_pCategoryBox->Select(pEntry);
661  m_pCategoryBox->MakeVisible(pEntry);
662  GrpSelect(m_pCategoryBox);
663  break;
664  }
665  }
666  pEntry = m_pCategoryBox->Next(pEntry);
667  }
668 
669  }
670  }
671  else
672  {
673  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
674  VclMessageType::Question, VclButtonsType::YesNo,
675  m_sReadonlyPath));
676  if (RET_YES == xBox->run())
677  PathHdl(m_pPathBtn);
678  }
679  }
680 }
681 
682 // initialisation; from Ctor and after editing regions
684 {
685  m_pCategoryBox->SetUpdateMode( false );
687  // display text block regions
688  const size_t nCnt = m_pGlossaryHdl->GetGroupCnt();
689  SvTreeListEntry* pSelEntry = nullptr;
690  const OUString sSelStr(::GetCurrGlosGroup().getToken(0, GLOS_DELIM));
691  const sal_Int32 nSelPath = ::GetCurrGlosGroup().getToken(1, GLOS_DELIM).toInt32();
692  // #i66304# - "My AutoText" comes from mytexts.bau, but should be translated
693  const OUString sMyAutoTextEnglish("My AutoText");
694  const OUString sMyAutoTextTranslated(SwResId(STR_MY_AUTOTEXT));
695  for(size_t nId = 0; nId < nCnt; ++nId )
696  {
697  OUString sTitle;
698  OUString sGroupName(m_pGlossaryHdl->GetGroupName(nId, &sTitle));
699  if(sGroupName.isEmpty())
700  continue;
701  sal_Int32 nIdx{ 0 };
702  const OUString sName{ sGroupName.getToken( 0, GLOS_DELIM, nIdx ) };
703  if(sTitle.isEmpty())
704  sTitle = sName;
705  if(sTitle == sMyAutoTextEnglish)
706  sTitle = sMyAutoTextTranslated;
707  SvTreeListEntry* pEntry = m_pCategoryBox->InsertEntry( sTitle );
708  const sal_Int32 nPath = sGroupName.getToken( 0, GLOS_DELIM, nIdx ).toInt32();
709 
710  GroupUserData* pData = new GroupUserData;
711  pData->sGroupName = sName;
712  pData->nPathIdx = static_cast< sal_uInt16 >(nPath);
713  pData->bReadonly = m_pGlossaryHdl->IsReadOnly(&sGroupName);
714 
715  pEntry->SetUserData(pData);
716  if(sSelStr == pData->sGroupName && nSelPath == nPath)
717  pSelEntry = pEntry;
718 
719  // fill entries for the groups
720  {
721  m_pGlossaryHdl->SetCurGroup(sGroupName, false, true);
722  const sal_uInt16 nCount = m_pGlossaryHdl->GetGlossaryCnt();
723  for(sal_uInt16 i = 0; i < nCount; ++i)
724  {
726  m_pGlossaryHdl->GetGlossaryName(i), pEntry);
727  pChild->SetUserData(new OUString(m_pGlossaryHdl->GetGlossaryShortName(i)));
728  }
729  }
730  }
731  // set current group and display text blocks
732  if(!pSelEntry)
733  {
734  //find a non-readonly group
735  SvTreeListEntry* pSearch = m_pCategoryBox->First();
736  while(pSearch)
737  {
738  if(!m_pCategoryBox->GetParent(pSearch))
739  {
740  GroupUserData* pData = static_cast<GroupUserData*>(pSearch->GetUserData());
741  if(!pData->bReadonly)
742  {
743  pSelEntry = pSearch;
744  break;
745  }
746  }
747  pSearch = m_pCategoryBox->Next(pSearch);
748  }
749  if(!pSelEntry)
750  pSelEntry = m_pCategoryBox->GetEntry(0);
751  }
752  if(pSelEntry)
753  {
754  m_pCategoryBox->Expand(pSelEntry);
755  m_pCategoryBox->Select(pSelEntry);
756  m_pCategoryBox->MakeVisible(pSelEntry);
757  GrpSelect(m_pCategoryBox);
758  }
759  //JP 16.11.99: the SvxTreeListBox has a Bug. The Box don't recalc the
760  // outputsize, when all entries are inserted. The result is, that
761  // the Focus/Highlight rectangle is to large and painted over the
762  // HScrollbar. -> Fix: call the resize
764 
766  m_pCategoryBox->SetUpdateMode( true );
768 
769  const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
770  m_pFileRelCB->Check( rCfg.IsSaveRelFile() );
771  m_pFileRelCB->SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
772  m_pNetRelCB->Check( rCfg.IsSaveRelNet() );
773  m_pNetRelCB->SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
775  m_pInsertTipCB->Enable(!officecfg::Office::Writer::AutoFunction::Text::ShowToolTip::isReadOnly());
776  m_pInsertTipCB->SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
777 }
778 
780 {
781 // EndDialog must not be called in MenuHdl
782  if (m_pEditBtn->GetCurItemIdent() == "edit")
783  {
784  std::unique_ptr<SwTextBlocks> pGroup = ::GetGlossaries()->GetGroupDoc ( GetCurrGrpName () );
785  pGroup.reset();
786  EndDialog(RET_EDIT);
787  }
788 }
789 
790 // KeyInput for ShortName - Edits without Spaces
791 IMPL_LINK( SwNewGlosNameDlg, Modify, weld::Entry&, rBox, void )
792 {
793  OUString aName(m_xNewName->get_text());
794  SwGlossaryDlg* pDlg = m_pParent;
795  if (&rBox == m_xNewName.get())
796  m_xNewShort->set_text(lcl_GetValidShortCut(aName));
797 
798  bool bEnable = !aName.isEmpty() && !m_xNewShort->get_text().isEmpty() &&
799  (!pDlg->DoesBlockExist(aName, m_xNewShort->get_text())
800  || aName == m_xOldName->get_text());
801  m_xOk->set_sensitive(bEnable);
802 }
803 
805 {
806  SwGlossaryDlg* pDlg = m_pParent;
807  OUString sNew = GetAppCharClass().uppercase(m_xNewShort->get_text());
808  if (pDlg->m_pGlossaryHdl->HasShortName(m_xNewShort->get_text())
809  && sNew != m_xOldShort->get_text())
810  {
811  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
812  VclMessageType::Info, VclButtonsType::Ok,
813  SwResId(STR_DOUBLE_SHORTNAME)));
814  xBox->run();
815  m_xNewShort->grab_focus();
816  }
817  else
818  m_xDialog->response(RET_OK);
819 }
820 
821 IMPL_LINK( SwGlossaryDlg, CheckBoxHdl, Button *, pBox, void )
822 {
824  bool bCheck = static_cast<CheckBox*>(pBox)->IsChecked();
825  if (pBox == m_pInsertTipCB)
826  rCfg.SetAutoTextTip(bCheck);
827  else if(pBox == m_pFileRelCB)
828  rCfg.SetSaveRelFile(bCheck);
829  else
830  rCfg.SetSaveRelNet(bCheck);
831  rCfg.Commit();
832 }
833 
834 // TreeListBox for groups and blocks
836  : SvTreeListBox(pParent, nBits)
837  , sReadonly(SwResId(SW_STR_READONLY)),
838  pDragEntry(nullptr)
839 {
840  SetDragDropMode( DragDropMode::CTRL_MOVE|DragDropMode::CTRL_COPY );
841 }
842 
844 {
845  return LogicToPixel(Size(212, 84), MapMode(MapUnit::MapAppFont));
846 }
847 
848 VCL_BUILDER_FACTORY_ARGS(SwGlTreeListBox, WB_BORDER | WB_TABSTOP)
849 
850 void SwGlTreeListBox::Clear()
851 {
852  SvTreeListEntry* pEntry = First();
853  while(pEntry)
854  {
855  if(GetParent(pEntry))
856  delete static_cast<OUString*>(pEntry->GetUserData());
857  else
858  delete static_cast<GroupUserData*>(pEntry->GetUserData());
859  pEntry = Next(pEntry);
860  }
862 }
863 
865 {
866  Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
867  SvTreeListEntry* pEntry = GetEntry( aPos );
868  // there's only help for groups' names
869  if(pEntry)
870  {
871  SvLBoxTab* pTab;
872  SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
873  if(pItem)
874  {
875  aPos = GetEntryPosition( pEntry );
876  Size aSize(pItem->GetSize( this, pEntry ));
877  aPos.setX( GetTabPos( pEntry, pTab ) );
878 
879  if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
880  aSize.setWidth( GetSizePixel().Width() - aPos.X() );
881  aPos = OutputToScreenPixel(aPos);
882  tools::Rectangle aItemRect( aPos, aSize );
883  OUString sMsg;
884  if(!GetParent(pEntry))
885  {
886  GroupUserData* pData = static_cast<GroupUserData*>(pEntry->GetUserData());
887  const std::vector<OUString> & rPathArr = ::GetGlossaries()->GetPathArray();
888  if( !rPathArr.empty() )
889  {
890  INetURLObject aTmp(rPathArr[pData->nPathIdx]
891  + "/"
892  + pData->sGroupName
894  sMsg = aTmp.GetPath();
895 
896  if(pData->bReadonly)
897  {
898  sMsg += " (" + sReadonly + ")";
899  }
900  }
901  }
902  else
903  sMsg = *static_cast<OUString*>(pEntry->GetUserData());
904  Help::ShowQuickHelp( this, aItemRect, sMsg,
905  QuickHelpFlags::Left|QuickHelpFlags::VCenter );
906  }
907  }
908 }
909 
911  TransferDataContainer& /*rContainer*/,
912  SvTreeListEntry* pEntry )
913 {
914  DragDropMode eRet;
915  pDragEntry = pEntry;
916  if(!GetParent(pEntry))
917  eRet = DragDropMode::NONE;
918  else
919  {
920  SwGlossaryDlg* pDlg = static_cast<SwGlossaryDlg*>(GetParentDialog());
921  SvTreeListEntry* pParent = GetParent(pEntry);
922 
923  GroupUserData* pGroupData = static_cast<GroupUserData*>(pParent->GetUserData());
924  OUString sEntry = pGroupData->sGroupName
925  + OUStringLiteral1(GLOS_DELIM)
926  + OUString::number(pGroupData->nPathIdx);
927  sal_Int8 nDragOption = DND_ACTION_COPY;
928  eRet = DragDropMode::CTRL_COPY;
929  if(!pDlg->m_pGlossaryHdl->IsReadOnly(&sEntry))
930  {
931  eRet |= DragDropMode::CTRL_MOVE;
932  nDragOption |= DND_ACTION_MOVE;
933  }
934  SetDragOptions( nDragOption );
935  }
936  return eRet;
937 }
938 
940 {
941  // TODO: Readonly - check still missing!
942  SvTreeListEntry* pSrcParent = GetParent(pEntry) ? GetParent(pEntry) : pEntry;
943  SvTreeListEntry* pDestParent =
945  return pDestParent != pSrcParent;
946 
947 }
948 
950  SvTreeListEntry* pEntry,
951  SvTreeListEntry*& /*rpNewParent*/,
952  sal_uLong& /*rNewChildPos*/
953  )
954 {
955  return NotifyCopyingOrMoving(pTarget, pEntry, true);
956 }
957 
959  SvTreeListEntry* pEntry,
960  SvTreeListEntry*& /*rpNewParent*/,
961  sal_uLong& /*rNewChildPos*/
962  )
963 {
964  return NotifyCopyingOrMoving(pTarget, pEntry, false);
965 }
966 
968  SvTreeListEntry* pTarget,
969  SvTreeListEntry* pEntry,
970  bool bIsMove)
971 {
972  pDragEntry = nullptr;
973  // 1. move in different groups?
974  // 2. allowed to write to both groups?
975  if(!pTarget) // move to the beginning
976  {
977  pTarget = GetEntry(0);
978  }
979  SvTreeListEntry* pSrcParent = GetParent(pEntry);
980  SvTreeListEntry* pDestParent =
981  GetParent(pTarget) ? GetParent(pTarget) : pTarget;
982  if(pDestParent != pSrcParent)
983  {
984  SwGlossaryDlg* pDlg = static_cast<SwGlossaryDlg*>(GetParentDialog());
985  SwWait aWait( *pDlg->m_pShell->GetView().GetDocShell(), true );
986 
987  GroupUserData* pGroupData = static_cast<GroupUserData*>(pSrcParent->GetUserData());
988  OUString sSourceGroup = pGroupData->sGroupName
989  + OUStringLiteral1(GLOS_DELIM)
990  + OUString::number(pGroupData->nPathIdx);
991 
992  pDlg->m_pGlossaryHdl->SetCurGroup(sSourceGroup);
993  OUString sTitle(GetEntryText(pEntry));
994  OUString sShortName(*static_cast<OUString*>(pEntry->GetUserData()));
995 
996  GroupUserData* pDestData = static_cast<GroupUserData*>(pDestParent->GetUserData());
997  OUString sDestName = pDestData->sGroupName
998  + OUStringLiteral1(GLOS_DELIM)
999  + OUString::number(pDestData->nPathIdx);
1000 
1001  const bool bRet = pDlg->m_pGlossaryHdl->CopyOrMove( sSourceGroup, sShortName,
1002  sDestName, sTitle, bIsMove );
1003  if(bRet)
1004  {
1005  SvTreeListEntry* pChild = InsertEntry(sTitle, pDestParent);
1006  pChild->SetUserData(new OUString(sShortName));
1007  if (bIsMove)
1008  {
1009  GetModel()->Remove(pEntry);
1010  }
1011  }
1012  }
1013  return TRISTATE_FALSE; // otherwise the entry is being set automatically
1014 }
1015 
1017 {
1018  Invalidate(InvalidateFlags::Update);
1020 }
1021 
1023 {
1024  if(m_aDeleteHdl.IsSet() && rKEvt.GetKeyCode().GetCode() == KEY_DELETE)
1025  {
1026  m_aDeleteHdl.Call(nullptr);
1027  return;
1028  }
1029  SvTreeListBox::KeyInput( rKEvt );
1030 }
1031 
1033 {
1035  if(pEntry)
1036  {
1037  pEntry =
1038  m_pCategoryBox->GetParent(pEntry) ? m_pCategoryBox->GetParent(pEntry) : pEntry;
1039  GroupUserData* pGroupData = static_cast<GroupUserData*>(pEntry->GetUserData());
1040  return pGroupData->sGroupName + OUStringLiteral1(GLOS_DELIM) + OUString::number(pGroupData->nPathIdx);
1041  }
1042  return OUString();
1043 }
1044 
1046 {
1049  SvtPathOptions aPathOpt;
1050  const OUString sGlosPath( aPathOpt.GetAutoTextPath() );
1051  pDlg->SetPath(sGlosPath);
1052  if(RET_OK == pDlg->Execute())
1053  {
1054  const OUString sTmp(pDlg->GetPath());
1055  if(sTmp != sGlosPath)
1056  {
1057  aPathOpt.SetAutoTextPath( sTmp );
1058  ::GetGlossaries()->UpdateGlosPath( true );
1059  Init();
1060  }
1061  }
1062 }
1063 
1065 {
1066  EndDialog(RET_OK);
1067 }
1068 
1070 {
1071  DeleteEntry();
1072 }
1073 
1075 {
1076  //create example
1077  if (!m_pExampleFrame)
1078  {
1079  Link<SwOneExampleFrame&,void> aLink(LINK(this, SwGlossaryDlg, PreviewLoadedHdl));
1081  EX_SHOW_ONLINE_LAYOUT, &aLink ));
1082  }
1083 
1085 };
1086 
1088 {
1089  ResumeShowAutoText();
1090 }
1091 
1092 void SwGlossaryDlg::ShowAutoText(const OUString& rGroup, const OUString& rShortName)
1093 {
1094  if(m_pExampleWIN->IsVisible())
1095  {
1096  SetResumeData(rGroup, rShortName);
1097  //try to make an Undo()
1098  m_pExampleFrame->ClearDocument();
1099  }
1100 }
1101 
1103 {
1104  OUString sGroup;
1105  OUString sShortName;
1106  if(GetResumeData(sGroup, sShortName) && m_pExampleWIN->IsVisible())
1107  {
1108  if(!m_xAutoText.is())
1109  {
1110  //now the AutoText ListBoxes have to be filled
1111  m_xAutoText = text::AutoTextContainer::create( comphelper::getProcessComponentContext() );
1112  }
1113 
1114  uno::Reference< XTextCursor > & xCursor = m_pExampleFrame->GetTextCursor();
1115  if(xCursor.is())
1116  {
1117  if (!sShortName.isEmpty())
1118  {
1119  uno::Any aGroup = m_xAutoText->getByName(sGroup);
1120  uno::Reference< XAutoTextGroup > xGroup;
1121  if((aGroup >>= xGroup) && xGroup->hasByName(sShortName))
1122  {
1123  uno::Any aEntry(xGroup->getByName(sShortName));
1124  uno::Reference< XAutoTextEntry > xEntry;
1125  aEntry >>= xEntry;
1126  uno::Reference< XTextRange > xRange(xCursor, uno::UNO_QUERY);
1127  xEntry->applyTo(xRange);
1128  }
1129  }
1130  }
1131  }
1132  m_bResume = false;
1133 }
1134 
1136 {
1138 
1139  const OUString aTitle(m_pNameED->GetText());
1140  const OUString aShortName(m_pShortNameEdit->GetText());
1141  SvTreeListEntry* pChild = DoesBlockExist(aTitle, aShortName);
1142  SvTreeListEntry* pParent = pChild ? m_pCategoryBox->GetParent(pChild) : nullptr;
1143  const bool bExists = nullptr != pChild;
1144  const bool bIsGroup = pEntry && !pParent;
1145 
1146  std::unique_ptr<weld::MessageDialog> xQuery(Application::CreateMessageDialog(GetFrameWeld(),
1147  VclMessageType::Question, VclButtonsType::YesNo,
1148  SwResId(STR_QUERY_DELETE)));
1149  if (bExists && !bIsGroup && RET_YES == xQuery->run())
1150  {
1151  if (!aTitle.isEmpty() && m_pGlossaryHdl->DelGlossary(aShortName))
1152  {
1153  OSL_ENSURE(pChild, "entry not found!");
1154  m_pCategoryBox->Select(pParent);
1155  m_pCategoryBox->GetModel()->Remove(pChild);
1156  m_pNameED->SetText(OUString());
1157  NameModify(*m_pNameED);
1158  }
1159  }
1160 }
1161 
1162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ExpandedHdl() override
Definition: glossary.cxx:1016
const short RET_EDIT
Definition: gloshdl.cxx:63
SfxViewFrame * GetViewFrame() const
bool GetResumeData(OUString &rGroup, OUString &rShortName)
Definition: glossary.hxx:144
long Width() const
virtual DragDropMode NotifyStartDrag(TransferDataContainer &rContainer, SvTreeListEntry *) override
Definition: glossary.cxx:910
VclPtr< CheckBox > m_pFileRelCB
Definition: glossary.hxx:96
VclPtr< SwGlossaryDlg > m_pParent
Definition: glossary.cxx:124
#define KEY_DELETE
static SvxAutoCorrCfg & Get()
VclPtr< CheckBox > m_pInsertTipCB
Definition: glossary.hxx:90
void Init()
void SetUserData(void *pPtr)
std::shared_ptr< const SfxFilter > Next()
sal_uInt16 GetGlossaryCnt()
Definition: gloshdl.cxx:246
#define DND_ACTION_COPY
void SetClickHdl(const Link< Button *, void > &rLink)
std::unique_ptr< weld::Entry > m_xOldShort
Definition: glossary.cxx:130
virtual TriState NotifyMoving(SvTreeListEntry *pTarget, SvTreeListEntry *pEntry, SvTreeListEntry *&rpNewParent, sal_uLong &rNewChildPos) override
Definition: glossary.cxx:949
OUString sGroupName
Definition: glossary.cxx:111
virtual void dispose() override
Definition: glossary.cxx:250
virtual const SfxItemSet * GetOutputItemSet() const =0
virtual SvTreeListEntry * InsertEntry(const OUString &rText, SvTreeListEntry *pParent=nullptr, bool bChildrenOnDemand=false, sal_uLong nPos=TREELIST_APPEND, void *pUserData=nullptr, SvLBoxButtonKind eButtonKind=SvLBoxButtonKind::EnabledCheckbox)
signed char sal_Int8
SvTreeList * GetModel() const
WinBits const WB_HASBUTTONSATROOT
void SetSortMode(SvSortMode eMode)
virtual Size GetOptimalSize() const override
Definition: glossary.cxx:843
VclPtr< Edit > m_pNameED
Definition: glossary.hxx:91
OUString GetGlossaryShortName(const OUString &rName)
Definition: gloshdl.cxx:264
const Size & GetSize(const SvTreeListBox *pView, const SvTreeListEntry *pEntry) const
void SetDoubleClickHdl(const Link< SvTreeListBox *, bool > &rNewHdl)
bool m_bIsDocReadOnly
Definition: glossary.hxx:118
static SvxAbstractDialogFactory * Create()
sal_uIntPtr sal_uLong
void SetDragOptions(sal_Int8 nOptions)
SvLBoxItem * GetItem(SvTreeListEntry *, long nX, SvLBoxTab **ppTab)
void ShowAutoText(const OUString &rGroup, const OUString &rShortName)
Definition: glossary.cxx:1092
std::shared_ptr< const SfxFilter > First()
virtual Size GetSizePixel() const
virtual VclPtr< SfxAbstractDialog > CreateEventConfigDialog(weld::Widget *pParent, const SfxItemSet &rAttr, const css::uno::Reference< css::frame::XFrame > &rFrame)=0
TriState NotifyCopyingOrMoving(SvTreeListEntry *pTarget, SvTreeListEntry *pEntry, bool bIsMove)
Definition: glossary.cxx:967
aBuf
virtual ~SwGlossaryDlg() override
Definition: glossary.cxx:245
sal_Int16 nId
bool DelGlossary(const OUString &)
Definition: gloshdl.cxx:329
sal_uInt16 GetCode() const
void SetSaveRelNet(bool bSet)
std::unique_ptr< SwTextBlocks > GetGroupDoc(const OUString &rName, bool bCreate=false)
Definition: glosdoc.cxx:158
static OUString GetExtension()
Definition: glosdoc.cxx:419
WinBits const WB_VSCROLL
bool IsGlosPathErr()
Definition: glosdoc.hxx:119
static void SetActGroup(const OUString &rNewGroup)
Definition: glossary.cxx:179
std::unique_ptr< weld::Button > m_xOk
Definition: glossary.cxx:128
static OUString lcl_GetValidShortCut(const OUString &rName)
Definition: glossary.cxx:87
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: glossary.cxx:864
Dialog * GetParentDialog() const
const OUString sReadonly
Definition: glossary.hxx:47
VclPtr< SwGlTreeListBox > m_pCategoryBox
Definition: glossary.hxx:95
void SetUpdateMode(bool)
virtual void ExpandedHdl()
size_t GetGroupCnt() const
Definition: gloshdl.cxx:145
void MakeVisible(SvTreeListEntry *pEntry)
IMPL_LINK_NOARG(SwGlossaryDlg, BibHdl, Button *, void)
Definition: glossary.cxx:606
TextFilter m_aNoSpaceFilter
Definition: glossary.cxx:123
IMPL_LINK(SwNewGlosNameDlg, TextFilterHdl, OUString &, rTest, bool)
Definition: glossary.cxx:146
#define DND_ACTION_MOVE
Used by the UI to modify the document model.
Definition: wrtsh.hxx:86
bool HasMacro() const
virtual bool NotifyAcceptDrop(SvTreeListEntry *) override
Definition: glossary.cxx:939
sal_Int64 WinBits
SvTreeListEntry * GetParent() const
const SwView & GetView() const
Definition: wrtsh.hxx:424
RET_YES
virtual void SetModifyHdl(const Link< Edit &, void > &rLink)
void Enable(bool bEnable=true, bool bChild=true)
DragDropMode
void setX(long nX)
SvTreeListEntry * FirstSelected() const
WinBits const WB_HSCROLL
VclPtr< PushButton > m_pPathBtn
Definition: glossary.hxx:102
void SetDragDropMode(DragDropMode)
virtual void KeyInput(const KeyEvent &rKEvt) override
SwNewGlosNameDlg(SwGlossaryDlg *pParent, const OUString &rOldName, const OUString &rOldShort)
Definition: glossary.cxx:152
void SetCurGroup(const OUString &aGrp, bool bApi=false, bool bAlwaysCreateNew=false)
Definition: gloshdl.cxx:101
static bool HasMacroRecorder(SfxViewFrame const *pFrame)
SW_DLLPUBLIC SwGlossaries * GetGlossaries()
Definition: initui.cxx:175
SortAscending
void SetSelectHdl(const Link< SvTreeListBox *, void > &rNewHdl)
SwGlossaryHdl * m_pGlossaryHdl
Definition: glossary.hxx:109
static SfxEventNamesItem AddEvents(DlgEventType eType)
Definition: macassgn.cxx:43
VclPtr< PushButton > m_pInsertBtn
Definition: glossary.hxx:99
sal_uInt16 nPathIdx
Definition: glossary.cxx:112
virtual TriState NotifyCopying(SvTreeListEntry *pTarget, SvTreeListEntry *pEntry, SvTreeListEntry *&rpNewParent, sal_uLong &rNewChildPos) override
Definition: glossary.cxx:958
static OUString GetCurrGroup()
Definition: glossary.cxx:172
void Update()
const Point & GetMousePosPixel() const
VclPtr< vcl::Window > m_pExampleWIN
Definition: glossary.hxx:98
void ShowError()
Definition: glosdoc.cxx:412
OUString GetGlossaryName(sal_uInt16)
Definition: gloshdl.cxx:251
#define FN_INSERT_GLOSSARY
Definition: cmdid.h:561
void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff)
SwGlTreeListBox(vcl::Window *pParent, WinBits nBits)
Definition: glossary.cxx:835
void SetSelectHdl(const Link< Menu *, bool > &rLink)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
virtual void Apply() override
Definition: glossary.cxx:328
const SvTreeListEntry * GetParent(const SvTreeListEntry *pEntry) const
bool Remove(const SvTreeListEntry *pEntry)
PopupMenu * GetPopupMenu() const
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
SvTreeListEntry * pDragEntry
Definition: glossary.hxx:49
OUString GetNewName() const
Definition: glossary.cxx:142
SwGlossaryDlg(SfxViewFrame const *pViewFrame, SwGlossaryHdl *pGlosHdl, SwWrtShell *pWrtShell)
Definition: glossary.cxx:184
OUString sName
bool IsAutoTextTip() const
int i
virtual void Resize() override
TRISTATE_FALSE
#define FILTER_DOCX
Definition: iodetect.hxx:38
virtual OUString GetText() const override
void * GetUserData() const
static OUString GetDefName()
Definition: glosdoc.cxx:91
DECL_LINK(Modify, weld::Entry &, void)
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
weld::Window * GetFrameWeld(SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
OUString GetCurrGrpName() const
Definition: glossary.cxx:1032
bool IsReadOnly(const OUString *=nullptr) const
Definition: gloshdl.cxx:653
OUString GetGroupName(size_t, OUString *pTitle)
Definition: gloshdl.cxx:150
virtual VclPtr< AbstractSvxMultiPathDialog > CreateSvxPathSelectDialog(weld::Window *pParent)=0
SvTreeListEntry * DoesBlockExist(const OUString &sBlock, const OUString &rShort)
Definition: glossary.cxx:351
void SetTextFilter(TextFilter *pFilter)
std::unique_ptr< weld::Entry > m_xNewName
Definition: glossary.cxx:126
void SetNodeDefaultImages()
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
virtual sal_IntPtr GetTabPos(SvTreeListEntry *, SvLBoxTab *)
bool IsSaveRelFile() const
Shell * m_pShell
SwWrtShell * m_pShell
Definition: glossary.hxx:120
virtual OUString GetEntryText(SvTreeListEntry *pEntry) const
bool HasReadonlySel() const
Definition: crsrsh.cxx:3227
WinBits const WB_SORT
void Check(bool bCheck=true)
virtual bool Expand(SvTreeListEntry *pParent)
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: glossary.cxx:1022
Point ScreenToOutputPixel(const Point &rPos) const
void GrabFocus()
void EnableShortName(bool bOn=true)
Definition: glossary.cxx:344
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
vcl::Window * GetParent() const
void SetSelectHdl(const Link< MenuButton *, void > &rLink)
void SetDeleteHdl(const Link< SwGlTreeListBox *, void > &rLink)
Definition: glossary.hxx:81
long X() const
void SetStyle(WinBits nStyle)
void UpdateGlosPath(bool bFull)
Definition: glosdoc.cxx:348
SwDocShell * GetDocShell()
Definition: view.cxx:1115
void SetMacro(SvMacroItemId nEvent, const SvxMacro &)
bool IsReadOnly() const
#define FILTER_WW8
WinWord 97 filter.
Definition: iodetect.hxx:33
Point GetEntryPosition(SvTreeListEntry *) const
std::unique_ptr< weld::Entry > m_xOldName
Definition: glossary.cxx:129
VclPtr< PushButton > m_pBibBtn
Definition: glossary.hxx:101
void SetSaveRelFile(bool bSet)
sal_Int32 getToken(const Context &rContext, const sal_Char *pToken)
Point LogicToPixel(const Point &rLogicPt) const
SvTreeListEntry * Next(SvTreeListEntry *pEntry) const
void ShowPreview()
Definition: glossary.cxx:1074
SW_DLLPUBLIC const OUString & GetCurrGlosGroup()
Definition: initui.cxx:52
SvTreeListEntry * First() const
void ResumeShowAutoText()
Definition: glossary.cxx:1102
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE) override
const OUString & GetWorkPath() const
bool InsertGlossary(const OUString &rName)
Definition: gloshdl.cxx:517
const vcl::KeyCode & GetKeyCode() const
bool HasShortName(const OUString &rShortName) const
Definition: gloshdl.cxx:281
Link< SwGlTreeListBox *, void > m_aDeleteHdl
Definition: glossary.hxx:51
css::uno::Reference< css::text::XAutoTextContainer2 > m_xAutoText
Definition: glossary.hxx:106
const SvxMacro * Get(SvMacroItemId nEvent) const
weld::Entry & rEdit
#define FN_SET_ACT_GLOSSARY
Definition: cmdid.h:563
OUString GetPath() const
SW_DLLPUBLIC void SetCurrGlosGroup(const OUString &sStr)
Definition: initui.cxx:57
std::vector< OUString > const & GetPathArray() const
Definition: glosdoc.hxx:120
#define ERRCODE_NONE
std::unique_ptr< weld::Entry > m_xNewShort
Definition: glossary.cxx:127
void Resort()
bool IsVisible() const
SvTreeListEntry * GetEntry(SvTreeListEntry *pParent, sal_uLong nPos) const
RET_OK
VclPtr< MenuButton > m_pEditBtn
Definition: glossary.hxx:100
Reference< XComponentContext > getProcessComponentContext()
VCL_BUILDER_FACTORY_ARGS(OpenDocumentButton,"com.sun.star.sdb.OfficeDatabaseDocument")
VclPtr< CheckBox > m_pNetRelCB
Definition: glossary.hxx:97
const OUString & GetAutoTextPath() const
#define GLOS_DELIM
Definition: glosdoc.hxx:41
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
void SetAutoTextTip(bool bSet)
void DeleteEntry()
Definition: glossary.cxx:1135
OUString GetNewShort() const
Definition: glossary.cxx:143
OString const aName
WinBits const WB_HASBUTTONS
void SetResumeData(const OUString &rGroup, const OUString &rShortName)
Definition: glossary.hxx:146
#define SELECTION_MAX
bool IsSaveRelNet() const
sal_uLong GetChildCount(SvTreeListEntry const *pParent) const
TextFilter m_aNoSpaceFilter
Definition: glossary.hxx:93
void AppendItem(const SfxPoolItem &)
VclPtr< FixedText > m_pShortNameLbl
Definition: glossary.hxx:92
WinBits GetStyle() const
Point OutputToScreenPixel(const Point &rPos) const
virtual bool Select(SvTreeListEntry *pEntry, bool bSelect=true)
void SetActivateHdl(const Link< Menu *, bool > &rLink)
virtual void SetText(const OUString &rStr) override
#define RES_FRMMACRO
Definition: hintids.hxx:213
TriState
CharClass & GetAppCharClass()
Definition: init.cxx:740
std::unique_ptr< SwOneExampleFrame > m_pExampleFrame
Definition: glossary.hxx:107
#define EX_SHOW_ONLINE_LAYOUT
Definition: unotools.hxx:46
STARBASIC
WinBits const WB_CLIPCHILDREN
aStr
#define FN_NEW_GLOSSARY
Definition: cmdid.h:562
bool CopyOrMove(const OUString &rSourceGroupName, OUString &rSourceShortName, const OUString &rDestGroupName, const OUString &rLongName, bool bMove)
Definition: gloshdl.cxx:205
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
VclPtr< Edit > m_pShortNameEdit
Definition: glossary.hxx:94