LibreOffice Module cui (master)  1
linkdlg.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 <linkdlg.hxx>
21 #include <vcl/svapp.hxx>
22 
23 #include <tools/diagnose_ex.h>
24 #include <tools/debug.hxx>
25 #include <tools/urlobj.hxx>
26 #include <vcl/idle.hxx>
27 #include <vcl/timer.hxx>
28 #include <vcl/weld.hxx>
29 #include <vcl/window.hxx>
30 
31 #include <strings.hrc>
32 #include <sfx2/linkmgr.hxx>
33 #include <sfx2/linksrc.hxx>
34 #include <sfx2/lnkbase.hxx>
35 #include <sfx2/objsh.hxx>
36 
37 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
38 #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
40 
41 #include <dialmgr.hxx>
42 
43 
44 using namespace sfx2;
45 using namespace ::com::sun::star;
46 
47 namespace {
48 
49 class SvBaseLinkMemberList {
50 private:
51  std::vector<SvBaseLink*> mLinks;
52 
53 public:
54  ~SvBaseLinkMemberList()
55  {
56  for (auto const& link : mLinks)
57  {
58  if( link )
59  link->ReleaseRef();
60  }
61  }
62 
63  size_t size() const { return mLinks.size(); }
64 
65  SvBaseLink *operator[](size_t i) const { return mLinks[i]; }
66 
67  void push_back(SvBaseLink* p)
68  {
69  mLinks.push_back(p);
70  p->AddFirstRef();
71  }
72 };
73 
74 }
75 
76 SvBaseLinksDlg::SvBaseLinksDlg(weld::Window * pParent, LinkManager* pMgr, bool bHtmlMode)
77  : GenericDialogController(pParent, "cui/ui/baselinksdialog.ui", "BaseLinksDialog")
78  , aStrAutolink( CuiResId( STR_AUTOLINK ) )
79  , aStrManuallink( CuiResId( STR_MANUALLINK ) )
80  , aStrBrokenlink( CuiResId( STR_BROKENLINK ) )
81  , aStrCloselinkmsg( CuiResId( STR_CLOSELINKMSG ) )
82  , aStrCloselinkmsgMulti( CuiResId( STR_CLOSELINKMSG_MULTI ) )
83  , aStrWaitinglink( CuiResId( STR_WAITINGLINK ) )
84  , pLinkMgr( nullptr )
85  , aUpdateIdle("cui SvBaseLinksDlg UpdateIdle")
86  , m_xTbLinks(m_xBuilder->weld_tree_view("TB_LINKS"))
87  , m_xFtFullFileName(m_xBuilder->weld_link_button("FULL_FILE_NAME"))
88  , m_xFtFullSourceName(m_xBuilder->weld_label("FULL_SOURCE_NAME"))
89  , m_xFtFullTypeName(m_xBuilder->weld_label("FULL_TYPE_NAME"))
90  , m_xRbAutomatic(m_xBuilder->weld_radio_button("AUTOMATIC"))
91  , m_xRbManual(m_xBuilder->weld_radio_button("MANUAL"))
92  , m_xPbUpdateNow(m_xBuilder->weld_button("UPDATE_NOW"))
93  , m_xPbChangeSource(m_xBuilder->weld_button("CHANGE_SOURCE"))
94  , m_xPbBreakLink(m_xBuilder->weld_button("BREAK_LINK"))
95  , m_xVirDev(VclPtr<VirtualDevice>::Create())
96 {
97  // expand the point size of the desired font to the equivalent pixel size
98  if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice()))
99  pDefaultDevice->SetPointFont(*m_xVirDev, m_xTbLinks->get_font());
100  m_xTbLinks->set_size_request(m_xTbLinks->get_approximate_digit_width() * 90,
101  m_xTbLinks->get_height_rows(12));
102 
103  m_xTbLinks->set_selection_mode(SelectionMode::Multiple);
104 
105  std::vector<int> aWidths;
106  aWidths.push_back(m_xTbLinks->get_approximate_digit_width() * 30);
107  aWidths.push_back(m_xTbLinks->get_approximate_digit_width() * 20);
108  aWidths.push_back(m_xTbLinks->get_approximate_digit_width() * 20);
109  m_xTbLinks->set_column_fixed_widths(aWidths);
110 
111  // UpdateTimer for DDE-/Grf-links, which are waited for
112  aUpdateIdle.SetInvokeHandler( LINK( this, SvBaseLinksDlg, UpdateWaitingHdl ) );
113  aUpdateIdle.SetPriority( TaskPriority::LOWEST );
114 
115  m_xTbLinks->connect_changed( LINK( this, SvBaseLinksDlg, LinksSelectHdl ) );
116  m_xTbLinks->connect_row_activated( LINK( this, SvBaseLinksDlg, LinksDoubleClickHdl ) );
117  m_xRbAutomatic->connect_clicked( LINK( this, SvBaseLinksDlg, AutomaticClickHdl ) );
118  m_xRbManual->connect_clicked( LINK( this, SvBaseLinksDlg, ManualClickHdl ) );
119  m_xPbUpdateNow->connect_clicked( LINK( this, SvBaseLinksDlg, UpdateNowClickHdl ) );
120  m_xPbChangeSource->connect_clicked( LINK( this, SvBaseLinksDlg, ChangeSourceClickHdl ) );
121  if(!bHtmlMode)
122  m_xPbBreakLink->connect_clicked( LINK( this, SvBaseLinksDlg, BreakLinkClickHdl ) );
123  else
124  m_xPbBreakLink->hide();
125 
126  SetManager( pMgr );
127 }
128 
130 {
131 }
132 
133 /*************************************************************************
134 |* SvBaseLinksDlg::Handler()
135 *************************************************************************/
136 IMPL_LINK(SvBaseLinksDlg, LinksSelectHdl, weld::TreeView&, rTreeView, void)
137 {
138  LinksSelectHdl(&rTreeView);
139 }
140 
142 {
143  const int nSelectionCount = pSvTabListBox ?
144  pSvTabListBox->count_selected_rows() : 0;
145  if (nSelectionCount > 1)
146  {
147  // possibly deselect old entries in case of multi-selection
148  int nSelEntry = pSvTabListBox->get_selected_index();
149  SvBaseLink* pLink = reinterpret_cast<SvBaseLink*>(pSvTabListBox->get_id(nSelEntry).toInt64());
150  SvBaseLinkObjectType nObjectType = pLink->GetObjType();
151  if(!isClientFileType(nObjectType))
152  {
153  pSvTabListBox->unselect_all();
154  pSvTabListBox->select(nSelEntry);
155  }
156  else
157  {
158  std::vector<int> aRows = pSvTabListBox->get_selected_rows();
159  for (auto nEntry : aRows)
160  {
161  pLink = reinterpret_cast<SvBaseLink*>(pSvTabListBox->get_id(nEntry).toInt64());
162  DBG_ASSERT(pLink, "Where is the Link?");
163  if (!pLink)
164  continue;
165  if( !isClientFileType(pLink->GetObjType()) )
166  pSvTabListBox->unselect(nEntry);
167  }
168  }
169 
170  m_xPbUpdateNow->set_sensitive(true);
171  m_xRbAutomatic->set_sensitive(false);
172  m_xRbManual->set_active(true);
173  m_xRbManual->set_sensitive(false);
174  }
175  else
176  {
177  int nPos;
178  SvBaseLink* pLink = GetSelEntry( &nPos );
179  if( !pLink )
180  return;
181 
182  m_xPbUpdateNow->set_sensitive(true);
183 
184  OUString sType, sLink;
185  OUString *pLinkNm = &sLink, *pFilter = nullptr;
186 
187  if( isClientFileType(pLink->GetObjType()) )
188  {
189  m_xRbAutomatic->set_sensitive(false);
190  m_xRbManual->set_active(true);
191  m_xRbManual->set_sensitive(false);
192  if( SvBaseLinkObjectType::ClientGraphic == pLink->GetObjType() )
193  {
194  pLinkNm = nullptr;
195  pFilter = &sLink;
196  }
197  }
198  else
199  {
200  m_xRbAutomatic->set_sensitive(true);
201  m_xRbManual->set_sensitive(true);
202 
203  if( SfxLinkUpdateMode::ALWAYS == pLink->GetUpdateMode() )
204  m_xRbAutomatic->set_active(true);
205  else
206  m_xRbManual->set_active(true);
207  }
208 
209  OUString aFileName;
210  sfx2::LinkManager::GetDisplayNames( pLink, &sType, &aFileName, pLinkNm, pFilter );
212  m_xFtFullFileName->set_label( aFileName );
213  m_xFtFullFileName->set_uri( aFileName );
214  m_xFtFullSourceName->set_label( sLink );
215  m_xFtFullTypeName->set_label( sType );
216  }
217 }
218 
219 IMPL_LINK_NOARG( SvBaseLinksDlg, LinksDoubleClickHdl, weld::TreeView&, bool )
220 {
221  ChangeSourceClickHdl(*m_xPbChangeSource);
222  return true;
223 }
224 
225 IMPL_LINK_NOARG( SvBaseLinksDlg, AutomaticClickHdl, weld::Button&, void )
226 {
227  int nPos;
228  SvBaseLink* pLink = GetSelEntry( &nPos );
229  if( pLink && !isClientFileType( pLink->GetObjType() ) &&
230  SfxLinkUpdateMode::ALWAYS != pLink->GetUpdateMode() )
231  SetType( *pLink, nPos, SfxLinkUpdateMode::ALWAYS );
232 }
233 
234 IMPL_LINK_NOARG( SvBaseLinksDlg, ManualClickHdl, weld::Button&, void )
235 {
236  int nPos;
237  SvBaseLink* pLink = GetSelEntry( &nPos );
238  if( pLink && !isClientFileType( pLink->GetObjType() ) &&
239  SfxLinkUpdateMode::ONCALL != pLink->GetUpdateMode())
240  SetType( *pLink, nPos, SfxLinkUpdateMode::ONCALL );
241 }
242 
243 IMPL_LINK_NOARG(SvBaseLinksDlg, UpdateNowClickHdl, weld::Button&, void)
244 {
245  std::vector< SvBaseLink* > aLnkArr;
246  std::vector< sal_Int16 > aPosArr;
247 
248  std::vector<int> aRows = m_xTbLinks->get_selected_rows();
249  for (int nFndPos : aRows)
250  {
251  aLnkArr.push_back( reinterpret_cast<SvBaseLink*>( m_xTbLinks->get_id(nFndPos).toInt64() ) );
252  aPosArr.push_back( nFndPos );
253  }
254 
255  if( !aLnkArr.empty() )
256  {
257  for( size_t n = 0; n < aLnkArr.size(); ++n )
258  {
259  tools::SvRef<SvBaseLink> xLink = aLnkArr[ n ];
260 
261  // first look for the entry in the array
262  for(const auto & i : pLinkMgr->GetLinks())
263  if( xLink == i )
264  {
265  SetType( *xLink, aPosArr[ n ], xLink->GetUpdateMode() );
266  break;
267  }
268  }
269 
270  // if somebody is of the opinion to swap his links (SD)
271  LinkManager* pNewMgr = pLinkMgr;
272  pLinkMgr = nullptr;
273  SetManager( pNewMgr );
274 
275 
276  OUString sId = OUString::number(reinterpret_cast<sal_Int64>(aLnkArr[0]));
277  int nE = m_xTbLinks->find_id(sId);
278  if (nE == -1)
279  nE = m_xTbLinks->get_selected_index();
280  int nSelEntry = m_xTbLinks->get_selected_index();
281  if (nE != nSelEntry)
282  m_xTbLinks->unselect(nSelEntry);
283  m_xTbLinks->select(nE);
284  m_xTbLinks->scroll_to_row(nE);
285 
286  pNewMgr->CloseCachedComps();
287  }
288 }
289 
290 IMPL_LINK_NOARG(SvBaseLinksDlg, ChangeSourceClickHdl, weld::Button&, void)
291 {
292  std::vector<int> aRows = m_xTbLinks->get_selected_rows();
293  if (aRows.size() > 1)
294  {
295  try
296  {
297  uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker = ui::dialogs::FolderPicker::create(comphelper::getProcessComponentContext());
298 
299  OUString sType, sFile, sLinkName;
300  OUString sFilter;
301  SvBaseLink* pLink = reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(aRows[0]).toInt64());
302  sfx2::LinkManager::GetDisplayNames( pLink, &sType, &sFile );
303  INetURLObject aUrl(sFile);
304  if(aUrl.GetProtocol() == INetProtocol::File)
305  {
306  OUString sOldPath(aUrl.PathToFileName());
307  sal_Int32 nLen = aUrl.GetLastName().getLength();
308  sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
309  xFolderPicker->setDisplayDirectory(sOldPath);
310  }
311  if (xFolderPicker->execute() == ui::dialogs::ExecutableDialogResults::OK)
312  {
313  OUString aPath = xFolderPicker->getDirectory();
314 
315  for (auto nRow : aRows)
316  {
317  pLink = reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(nRow).toInt64());
318  DBG_ASSERT(pLink,"Where is the link?");
319  if (!pLink)
320  continue;
321  sfx2::LinkManager::GetDisplayNames( pLink, &sType, &sFile, &sLinkName, &sFilter );
322  INetURLObject aUrl_(sFile);
323  INetURLObject aUrl2(aPath, INetProtocol::File);
324  aUrl2.insertName( aUrl_.getName() );
325  OUString sNewLinkName;
326  MakeLnkName( sNewLinkName, nullptr ,
327  aUrl2.GetMainURL(INetURLObject::DecodeMechanism::ToIUri), sLinkName, &sFilter);
328  pLink->SetLinkSourceName( sNewLinkName );
329  pLink->Update();
330  }
331  if( pLinkMgr->GetPersist() )
332  pLinkMgr->GetPersist()->SetModified();
333  LinkManager* pNewMgr = pLinkMgr;
334  pLinkMgr = nullptr;
335  SetManager( pNewMgr );
336  }
337  }
338  catch (const uno::Exception &)
339  {
340  TOOLS_WARN_EXCEPTION("cui.dialogs", "SvBaseLinksDlg");
341  }
342  }
343  else
344  {
345  int nPos;
346  SvBaseLink* pLink = GetSelEntry( &nPos );
347  if ( pLink && !pLink->GetLinkSourceName().isEmpty() )
348  pLink->Edit(m_xDialog.get(), LINK(this, SvBaseLinksDlg, EndEditHdl));
349  }
350 }
351 
352 IMPL_LINK_NOARG( SvBaseLinksDlg, BreakLinkClickHdl, weld::Button&, void )
353 {
354  bool bModified = false;
355  if (m_xTbLinks->count_selected_rows() <= 1)
356  {
357  int nPos;
358  tools::SvRef<SvBaseLink> xLink = GetSelEntry( &nPos );
359  if( !xLink.is() )
360  return;
361 
362  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
363  VclMessageType::Question, VclButtonsType::YesNo,
364  aStrCloselinkmsg));
365  xQueryBox->set_default_response(RET_YES);
366 
367  if (RET_YES == xQueryBox->run())
368  {
369  m_xTbLinks->remove(nPos);
370 
371  // close object, if it's still existing
372  bool bNewLnkMgr = SvBaseLinkObjectType::ClientFile == xLink->GetObjType();
373 
374  // tell the link that it will be resolved!
375  xLink->Closed();
376 
377  // if somebody has forgotten to deregister himself
378  if( xLink.is() )
379  pLinkMgr->Remove( xLink.get() );
380 
381  if( bNewLnkMgr )
382  {
383  LinkManager* pNewMgr = pLinkMgr;
384  pLinkMgr = nullptr;
385  SetManager( pNewMgr );
386  m_xTbLinks->set_cursor(nPos ? --nPos : 0);
387  }
388  bModified = true;
389  }
390  }
391  else
392  {
393  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
394  VclMessageType::Question, VclButtonsType::YesNo,
395  aStrCloselinkmsgMulti));
396  xQueryBox->set_default_response(RET_YES);
397 
398  if (RET_YES == xQueryBox->run())
399  {
400  std::vector<int> aRows = m_xTbLinks->get_selected_rows();
401  SvBaseLinkMemberList aLinkList;
402  for (auto nRow : aRows)
403  {
404  SvBaseLink* pLink = reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(nRow).toInt64());
405  if (pLink)
406  aLinkList.push_back(pLink);
407  }
408  std::sort(aRows.begin(), aRows.end());
409  for (auto it = aRows.rbegin(); it != aRows.rend(); ++it)
410  m_xTbLinks->remove(*it);
411  for (size_t i = 0; i < aLinkList.size(); ++i)
412  {
413  tools::SvRef<SvBaseLink> xLink = aLinkList[i];
414  // tell the link that it will be resolved!
415  xLink->Closed();
416 
417  // if somebody has forgotten to deregister himself
418  pLinkMgr->Remove( xLink.get() );
419  bModified = true;
420  }
421  // then remove all selected entries
422  }
423  }
424  if(bModified)
425  {
426  if (!m_xTbLinks->n_children())
427  {
428  m_xRbAutomatic->set_sensitive(false);
429  m_xRbManual->set_sensitive(false);
430  m_xPbUpdateNow->set_sensitive(false);
431  m_xPbChangeSource->set_sensitive(false);
432  m_xPbBreakLink->set_sensitive(false);
433 
434  m_xFtFullSourceName->set_label( "" );
435  m_xFtFullTypeName->set_label( "" );
436  }
437  if( pLinkMgr && pLinkMgr->GetPersist() )
438  pLinkMgr->GetPersist()->SetModified();
439  }
440 }
441 
442 IMPL_LINK_NOARG( SvBaseLinksDlg, UpdateWaitingHdl, Timer*, void )
443 {
444  m_xTbLinks->freeze();
445  for (int nPos = m_xTbLinks->n_children(); nPos; --nPos)
446  {
447  tools::SvRef<SvBaseLink> xLink( reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(nPos).toInt64()) );
448  if( xLink.is() )
449  {
450  OUString sCur( ImplGetStateStr( *xLink ) ),
451  sOld( m_xTbLinks->get_text(nPos, 3) );
452  if( sCur != sOld )
453  m_xTbLinks->set_text(nPos, sCur, 3);
454  }
455  }
456  m_xTbLinks->thaw();
457 }
458 
459 IMPL_LINK( SvBaseLinksDlg, EndEditHdl, sfx2::SvBaseLink&, _rLink, void )
460 {
461  int nPos;
462  GetSelEntry( &nPos );
463 
464  if( _rLink.WasLastEditOK() )
465  {
466  // StarImpress/Draw swap the LinkObjects themselves!
467  // So search for the link in the manager; if it does not exist
468  // anymore, fill the list completely new. Otherwise only the
469  // edited link needs to be refreshed.
470  bool bLinkFnd = false;
471  for( size_t n = pLinkMgr->GetLinks().size(); n; )
472  if( &_rLink == &(*pLinkMgr->GetLinks()[ --n ]) )
473  {
474  bLinkFnd = true;
475  break;
476  }
477 
478  if( bLinkFnd )
479  {
480  m_xTbLinks->remove(nPos);
481  int nToUnselect = m_xTbLinks->get_selected_index();
482  InsertEntry(_rLink, nPos, true);
483  if (nToUnselect != -1)
484  m_xTbLinks->unselect(nToUnselect);
485  }
486  else
487  {
488  LinkManager* pNewMgr = pLinkMgr;
489  pLinkMgr = nullptr;
490  SetManager( pNewMgr );
491  }
492  if (pLinkMgr && pLinkMgr->GetPersist())
493  pLinkMgr->GetPersist()->SetModified();
494  }
495 }
496 
498 {
499  OUString sRet;
500  if( !rLnk.GetObj() )
501  sRet = aStrBrokenlink;
502  else if( rLnk.GetObj()->IsPending() )
503  {
504  sRet = aStrWaitinglink;
505  aUpdateIdle.Start();
506  }
507  else if( SfxLinkUpdateMode::ALWAYS == rLnk.GetUpdateMode() )
508  sRet = aStrAutolink;
509  else
510  sRet = aStrManuallink;
511 
512  return sRet;
513 }
514 
516 {
517  if( pLinkMgr == pNewMgr )
518  return;
519 
520  if (pNewMgr)
521  {
522  // update has to be stopped before clear
523  m_xTbLinks->freeze();
524  }
525 
526  m_xTbLinks->clear();
527  pLinkMgr = pNewMgr;
528 
529  if( pLinkMgr )
530  {
531  SvBaseLinks& rLnks = const_cast<SvBaseLinks&>(pLinkMgr->GetLinks());
532  for( size_t n = 0; n < rLnks.size(); ++n )
533  {
534  tools::SvRef<SvBaseLink>& rLinkRef = rLnks[ n ];
535  if( !rLinkRef.is() )
536  {
537  rLnks.erase( rLnks.begin() + n );
538  --n;
539  continue;
540  }
541  if( rLinkRef->IsVisible() )
542  InsertEntry( *rLinkRef );
543  }
544 
545  m_xTbLinks->thaw();
546 
547  if( !rLnks.empty() )
548  {
549  m_xTbLinks->set_cursor(0);
550  m_xTbLinks->select(0);
551  LinksSelectHdl( nullptr );
552  }
553  }
554 }
555 
556 void SvBaseLinksDlg::InsertEntry(const SvBaseLink& rLink, int nPos, bool bSelect)
557 {
558  OUString sFileNm, sLinkNm, sTypeNm, sFilter;
559 
560  sfx2::LinkManager::GetDisplayNames( &rLink, &sTypeNm, &sFileNm, &sLinkNm, &sFilter );
561 
562  auto nWidthPixel = m_xTbLinks->get_column_width(0);
563  OUString aTxt = m_xVirDev->GetEllipsisString(sFileNm, nWidthPixel, DrawTextFlags::PathEllipsis);
564  INetURLObject aPath( sFileNm, INetProtocol::File );
565  OUString aFileName = aPath.getName(
567 
568  if( aFileName.getLength() > aTxt.getLength() )
569  aTxt = aFileName;
570  else if (!aFileName.isEmpty() && aTxt.indexOf(aFileName, aTxt.getLength() - aFileName.getLength()) == -1)
571  // filename not in string
572  aTxt = aFileName;
573 
574  if (nPos == -1)
575  nPos = m_xTbLinks->n_children();
576  m_xTbLinks->insert(nPos);
577  m_xTbLinks->set_text(nPos, aTxt, 0);
578  m_xTbLinks->set_id(nPos, OUString::number(reinterpret_cast<sal_Int64>(&rLink)));
579  if( SvBaseLinkObjectType::ClientGraphic == rLink.GetObjType() )
580  m_xTbLinks->set_text(nPos, sFilter, 1);
581  else
582  m_xTbLinks->set_text(nPos, sLinkNm, 1);
583  m_xTbLinks->set_text(nPos, sTypeNm, 2);
584  m_xTbLinks->set_text(nPos, ImplGetStateStr(rLink), 3);
585  if (bSelect)
586  m_xTbLinks->select(nPos);
587 }
588 
590 {
591  int nPos = m_xTbLinks->get_selected_index();
592  if (nPos != -1)
593  {
594  if (pPos)
595  *pPos = nPos;
596  return reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(nPos).toInt64());
597  }
598  return nullptr;
599 }
600 
602  int nSelPos,
603  SfxLinkUpdateMode nType)
604 {
605  rLink.SetUpdateMode( nType );
606  rLink.Update();
607  m_xTbLinks->set_text(nSelPos, ImplGetStateStr(rLink), 3);
608  if (pLinkMgr->GetPersist())
610 }
611 
613 {
614  if( pLinkMgr )
615  {
616  const SvBaseLinks& rLnks = pLinkMgr->GetLinks();
617  int nSelect = 0;
618  for(const auto & rLinkRef : rLnks)
619  {
620  // #109573# only visible links have been inserted into the TreeListBox,
621  // invisible ones have to be skipped here
622  if( rLinkRef->IsVisible() )
623  {
624  if( pLink == rLinkRef.get() )
625  {
626  m_xTbLinks->select(nSelect);
627  LinksSelectHdl( nullptr );
628  return ;
629  }
630  ++nSelect;
631  }
632  }
633  }
634 }
635 
636 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool is() const
virtual int count_selected_rows() const =0
void SetType(sfx2::SvBaseLink &rLink, int nPos, SfxLinkUpdateMode nType)
Definition: linkdlg.cxx:601
OUString aStrWaitinglink
Definition: linkdlg.hxx:44
void unselect_all()
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
virtual void SetModified(bool bModified=true)
std::unique_ptr< weld::Button > m_xPbUpdateNow
Definition: linkdlg.hxx:54
IMPL_LINK(SvBaseLinksDlg, LinksSelectHdl, weld::TreeView &, rTreeView, void)
Definition: linkdlg.cxx:136
sal_Int64 n
virtual bool IsPending() const
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
constexpr bool isClientFileType(SvBaseLinkObjectType t)
SfxObjectShell * GetPersist() const
void SetActLink(sfx2::SvBaseLink const *pLink)
Definition: linkdlg.cxx:612
OUString PathToFileName() const
static OutputDevice * GetDefaultDevice()
RET_YES
std::unique_ptr< weld::RadioButton > m_xRbManual
Definition: linkdlg.hxx:53
virtual void Start() override
sfx2::SvBaseLink * GetSelEntry(int *pPos)
Definition: linkdlg.cxx:589
virtual OUString get_id(int pos) const =0
bool insertName(OUString const &rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
virtual ~SvBaseLinksDlg() override
Definition: linkdlg.cxx:129
T * get() const
#define TOOLS_WARN_EXCEPTION(area, stream)
OptionalString sType
#define DBG_ASSERT(sCon, aError)
const SvBaseLinks & GetLinks() const
int i
virtual int get_selected_index() const =0
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
std::unique_ptr< weld::Label > m_xFtFullSourceName
Definition: linkdlg.hxx:50
std::unique_ptr< weld::Label > m_xFtFullTypeName
Definition: linkdlg.hxx:51
SvBaseLinkObjectType
std::unique_ptr< weld::Button > m_xPbBreakLink
Definition: linkdlg.hxx:56
virtual void unselect(int pos)=0
size
std::unique_ptr< weld::Button > m_xPbChangeSource
Definition: linkdlg.hxx:55
void SetManager(sfx2::LinkManager *)
Definition: linkdlg.cxx:515
IMPL_LINK_NOARG(SvBaseLinksDlg, LinksDoubleClickHdl, weld::TreeView &, bool)
Definition: linkdlg.cxx:219
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
SvBaseLinksDlg(weld::Window *pParent, sfx2::LinkManager *, bool bHtml)
Definition: linkdlg.cxx:76
virtual void select(int pos)=0
std::vector< tools::SvRef< SvBaseLink > > SvBaseLinks
std::unique_ptr< weld::TreeView > m_xTbLinks
Definition: linkdlg.hxx:48
void InsertEntry(const sfx2::SvBaseLink &rLink, int nPos=-1, bool bSelect=false)
Definition: linkdlg.cxx:556
void MakeLnkName(OUString &rName, const OUString *pType, const OUString &rFile, const OUString &rLink, const OUString *pFilter)
SvBaseLink * pLink
INetProtocol GetProtocol() const
OUString aStrAutolink
Definition: linkdlg.hxx:39
virtual std::vector< int > get_selected_rows() const =0
Reference< XExecutableDialog > m_xDialog
OUString aStrBrokenlink
Definition: linkdlg.hxx:41
Reference< XComponentContext > getProcessComponentContext()
sfx2::LinkManager * pLinkMgr
Definition: linkdlg.hxx:45
void SetInvokeHandler(const Link< Timer *, void > &rLink)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
void LinksSelectHdl(weld::TreeView *pTreeView)
Definition: linkdlg.cxx:141
std::unique_ptr< weld::LinkButton > m_xFtFullFileName
Definition: linkdlg.hxx:49
OUString sId
ScopedVclPtr< VirtualDevice > m_xVirDev
Definition: linkdlg.hxx:58
void SetPriority(TaskPriority ePriority)
Idle aUpdateIdle
Definition: linkdlg.hxx:46
OUString ImplGetStateStr(const sfx2::SvBaseLink &)
Definition: linkdlg.cxx:497
std::unique_ptr< weld::RadioButton > m_xRbAutomatic
Definition: linkdlg.hxx:52
SfxLinkUpdateMode
sal_uInt16 nPos
OUString aStrManuallink
Definition: linkdlg.hxx:40
static OUString decode(OUString const &rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)