39#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
40#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
51class SvBaseLinkMemberList {
53 std::vector<SvBaseLink*> mLinks;
56 ~SvBaseLinkMemberList()
58 for (
auto const& link : mLinks)
65 size_t size()
const {
return mLinks.size(); }
67 SvBaseLink *operator[](
size_t i)
const {
return mLinks[
i]; }
79 : GenericDialogController(pParent,
"cui/ui/baselinksdialog.ui",
"BaseLinksDialog")
80 , aStrAutolink(
CuiResId( STR_AUTOLINK ) )
81 , aStrManuallink(
CuiResId( STR_MANUALLINK ) )
82 , aStrBrokenlink(
CuiResId( STR_BROKENLINK ) )
83 , aStrCloselinkmsg(
CuiResId( STR_CLOSELINKMSG ) )
84 , aStrCloselinkmsgMulti(
CuiResId( STR_CLOSELINKMSG_MULTI ) )
85 , aStrWaitinglink(
CuiResId( STR_WAITINGLINK ) )
87 , aUpdateIdle(
"cui SvBaseLinksDlg UpdateIdle")
88 , m_xTbLinks(m_xBuilder->weld_tree_view(
"TB_LINKS"))
89 , m_xFtFullFileName(m_xBuilder->weld_link_button(
"FULL_FILE_NAME"))
90 , m_xFtFullSourceName(m_xBuilder->weld_label(
"FULL_SOURCE_NAME"))
91 , m_xFtFullTypeName(m_xBuilder->weld_label(
"FULL_TYPE_NAME"))
92 , m_xRbAutomatic(m_xBuilder->weld_radio_button(
"AUTOMATIC"))
93 , m_xRbManual(m_xBuilder->weld_radio_button(
"MANUAL"))
94 , m_xPbUpdateNow(m_xBuilder->weld_button(
"UPDATE_NOW"))
95 , m_xPbChangeSource(m_xBuilder->weld_button(
"CHANGE_SOURCE"))
96 , m_xPbBreakLink(m_xBuilder->weld_button(
"BREAK_LINK"))
104 m_xTbLinks->set_selection_mode(SelectionMode::Multiple);
106 std::vector<int> aWidths
108 o3tl::narrowing<int>(
m_xTbLinks->get_approximate_digit_width() * 30),
109 o3tl::narrowing<int>(
m_xTbLinks->get_approximate_digit_width() * 20),
110 o3tl::narrowing<int>(
m_xTbLinks->get_approximate_digit_width() * 20)
141 LinksSelectHdl(&rTreeView);
146 const int nSelectionCount = pSvTabListBox ?
148 if (nSelectionCount > 1)
157 pSvTabListBox->
select(nSelEntry);
162 for (
auto nEntry : aRows)
164 pLink = weld::fromId<SvBaseLink*>(pSvTabListBox->
get_id(nEntry));
187 OUString
sType, sLink;
188 OUString *pLinkNm = &sLink, *pFilter =
nullptr;
224 ChangeSourceClickHdl(*m_xPbChangeSource);
230 if (!rButton.get_active())
236 if (m_xRbAutomatic->get_active())
240 SetType( *
pLink,
nPos, SfxLinkUpdateMode::ALWAYS );
246 SetType( *
pLink,
nPos, SfxLinkUpdateMode::ONCALL );
252 std::vector< SvBaseLink* > aLnkArr;
253 std::vector< sal_Int16 > aPosArr;
255 std::vector<int> aRows = m_xTbLinks->get_selected_rows();
256 for (
int nFndPos : aRows)
258 aLnkArr.push_back( weld::fromId<SvBaseLink*>( m_xTbLinks->get_id(nFndPos) ) );
259 aPosArr.push_back( nFndPos );
262 if( aLnkArr.empty() )
265 for(
size_t n = 0;
n < aLnkArr.size(); ++
n )
270 for(
const auto &
i : pLinkMgr->GetLinks())
273 SetType( *xLink, aPosArr[
n ], xLink->GetUpdateMode() );
281 SetManager( pNewMgr );
285 int nE = m_xTbLinks->find_id(
sId);
287 nE = m_xTbLinks->get_selected_index();
288 int nSelEntry = m_xTbLinks->get_selected_index();
290 m_xTbLinks->unselect(nSelEntry);
291 m_xTbLinks->select(nE);
292 m_xTbLinks->scroll_to_row(nE);
299 std::vector<int> aRows = m_xTbLinks->get_selected_rows();
300 if (aRows.size() > 1)
307 OUString
sType, sFile, sLinkName;
309 SvBaseLink*
pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(aRows[0]));
316 sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
317 xFolderPicker->setDisplayDirectory(sOldPath);
319 if (xFolderPicker->execute() == ui::dialogs::ExecutableDialogResults::OK)
321 OUString aPath = xFolderPicker->getDirectory();
323 for (
auto nRow : aRows)
325 pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nRow));
333 OUString sNewLinkName;
339 if( pLinkMgr->GetPersist() )
340 pLinkMgr->GetPersist()->SetModified();
343 SetManager( pNewMgr );
346 catch (
const uno::Exception &)
362 bool bModified =
false;
363 if (m_xTbLinks->count_selected_rows() <= 1)
371 VclMessageType::Question, VclButtonsType::YesNo,
373 xQueryBox->set_default_response(
RET_YES);
375 if (
RET_YES == xQueryBox->run())
377 m_xTbLinks->remove(
nPos);
380 bool bNewLnkMgr = SvBaseLinkObjectType::ClientFile == xLink->GetObjType();
387 pLinkMgr->Remove( xLink.
get() );
393 SetManager( pNewMgr );
394 m_xTbLinks->set_cursor(
nPos ? --
nPos : 0);
402 VclMessageType::Question, VclButtonsType::YesNo,
403 aStrCloselinkmsgMulti));
404 xQueryBox->set_default_response(
RET_YES);
406 if (
RET_YES == xQueryBox->run())
408 std::vector<int> aRows = m_xTbLinks->get_selected_rows();
409 SvBaseLinkMemberList aLinkList;
410 for (
auto nRow : aRows)
412 SvBaseLink*
pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nRow));
414 aLinkList.push_back(
pLink);
416 std::sort(aRows.begin(), aRows.end());
417 for (
auto it = aRows.rbegin(); it != aRows.rend(); ++it)
418 m_xTbLinks->remove(*it);
419 for (
size_t i = 0;
i < aLinkList.size(); ++
i)
426 pLinkMgr->Remove( xLink.
get() );
435 if (!m_xTbLinks->n_children())
437 m_xRbAutomatic->set_sensitive(
false);
438 m_xRbManual->set_sensitive(
false);
439 m_xPbUpdateNow->set_sensitive(
false);
440 m_xPbChangeSource->set_sensitive(
false);
441 m_xPbBreakLink->set_sensitive(
false);
443 m_xFtFullSourceName->set_label(
"" );
444 m_xFtFullTypeName->set_label(
"" );
446 if( pLinkMgr && pLinkMgr->GetPersist() )
447 pLinkMgr->GetPersist()->SetModified();
452 m_xTbLinks->freeze();
458 OUString sCur( ImplGetStateStr( *xLink ) ),
459 sOld( m_xTbLinks->get_text(
nPos, 3) );
461 m_xTbLinks->set_text(
nPos, sCur, 3);
470 GetSelEntry( &
nPos );
472 if( !_rLink.WasLastEditOK() )
479 bool bLinkFnd =
false;
480 for(
size_t n = pLinkMgr->GetLinks().size();
n; )
481 if( &_rLink == &(*pLinkMgr->GetLinks()[ --
n ]) )
489 m_xTbLinks->remove(
nPos);
490 int nToUnselect = m_xTbLinks->get_selected_index();
491 InsertEntry(_rLink,
nPos,
true);
492 if (nToUnselect != -1)
493 m_xTbLinks->unselect(nToUnselect);
499 SetManager( pNewMgr );
501 if (pLinkMgr && pLinkMgr->GetPersist())
502 pLinkMgr->GetPersist()->SetModified();
541 for(
size_t n = 0;
n < rLnks.size(); ++
n )
546 rLnks.erase( rLnks.begin() +
n );
550 if( rLinkRef->IsVisible() )
566 OUString sFileNm, sLinkNm, sTypeNm, sFilter;
570 auto nWidthPixel =
m_xTbLinks->get_column_width(0);
571 OUString aTxt =
m_xVirDev->GetEllipsisString(sFileNm, nWidthPixel, DrawTextFlags::PathEllipsis);
573 OUString aFileName = aPath.
getName(
576 if( aFileName.getLength() > aTxt.getLength() )
578 else if (!aFileName.isEmpty() && aTxt.indexOf(aFileName, aTxt.getLength() - aFileName.getLength()) == -1)
587 if( SvBaseLinkObjectType::ClientGraphic == rLink.
GetObjType() )
627 for(
const auto & rLinkRef : rLnks)
631 if( rLinkRef->IsVisible() )
633 if(
pLink == rLinkRef.get() )
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool insertName(std::u16string_view rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString PathToFileName() const
INetProtocol GetProtocol() const
virtual void Start(bool bStartTimer=true) override
virtual void SetModified(bool bModified=true)
std::unique_ptr< weld::LinkButton > m_xFtFullFileName
std::unique_ptr< weld::RadioButton > m_xRbManual
std::unique_ptr< weld::Label > m_xFtFullTypeName
void SetManager(sfx2::LinkManager *)
OUString ImplGetStateStr(const sfx2::SvBaseLink &)
SvBaseLinksDlg(weld::Window *pParent, sfx2::LinkManager *, bool bHtml)
void SetType(sfx2::SvBaseLink &rLink, int nPos, SfxLinkUpdateMode nType)
std::unique_ptr< weld::TreeView > m_xTbLinks
void LinksSelectHdl(weld::TreeView *pTreeView)
void InsertEntry(const sfx2::SvBaseLink &rLink, int nPos=-1, bool bSelect=false)
std::unique_ptr< weld::RadioButton > m_xRbAutomatic
std::unique_ptr< weld::Button > m_xPbUpdateNow
sfx2::LinkManager * pLinkMgr
void SetActLink(sfx2::SvBaseLink const *pLink)
virtual ~SvBaseLinksDlg() override
ScopedVclPtr< VirtualDevice > m_xVirDev
std::unique_ptr< weld::Button > m_xPbChangeSource
sfx2::SvBaseLink * GetSelEntry(int *pPos)
std::unique_ptr< weld::Button > m_xPbBreakLink
std::unique_ptr< weld::Label > m_xFtFullSourceName
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
SfxObjectShell * GetPersist() const
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
const SvBaseLinks & GetLinks() const
void SetUpdateMode(SfxLinkUpdateMode)
SfxLinkUpdateMode GetUpdateMode() const
void SetLinkSourceName(const OUString &rName)
const OUString & GetLinkSourceName() const
virtual void Edit(weld::Window *, const Link< SvBaseLink &, void > &rEndEditHdl)
SvLinkSource * GetObj() const
SvBaseLinkObjectType GetObjType() const
virtual bool IsPending() const
virtual void select(int pos)=0
virtual void unselect(int pos)=0
virtual std::vector< int > get_selected_rows() const=0
virtual int get_selected_index() const=0
virtual int count_selected_rows() const=0
virtual OUString get_id(int pos) const=0
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define LINK(Instance, Class, Member)
IMPL_LINK(SvBaseLinksDlg, LinksSelectHdl, weld::TreeView &, rTreeView, void)
IMPL_LINK_NOARG(SvBaseLinksDlg, LinksDoubleClickHdl, weld::TreeView &, bool)
Reference< XComponentContext > getProcessComponentContext()
constexpr bool isClientFileType(SvBaseLinkObjectType t)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
std::vector< tools::SvRef< SvBaseLink > > SvBaseLinks
void MakeLnkName(OUString &rName, const OUString *pType, std::u16string_view rFile, std::u16string_view rLink, const OUString *pFilter)
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
OUString toId(const void *pValue)