2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-04 11:25:41 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
#include <linkdlg.hxx>
|
2021-10-15 16:33:00 +02:00
|
|
|
#include <o3tl/safeint.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
2022-08-17 17:09:09 +02:00
|
|
|
#include <comphelper/diagnose_ex.hxx>
|
2019-04-01 15:53:57 +01:00
|
|
|
#include <tools/debug.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <tools/urlobj.hxx>
|
2015-01-14 10:21:20 +01:00
|
|
|
#include <vcl/idle.hxx>
|
2019-04-02 10:20:38 +01:00
|
|
|
#include <vcl/timer.hxx>
|
|
|
|
#include <vcl/weld.hxx>
|
2021-03-12 12:29:52 +00:00
|
|
|
#include <vcl/weldutils.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2017-06-11 20:56:30 +01:00
|
|
|
#include <strings.hrc>
|
2021-06-21 12:30:34 +01:00
|
|
|
#include <sfx2/filedlghelper.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <sfx2/linkmgr.hxx>
|
|
|
|
#include <sfx2/linksrc.hxx>
|
|
|
|
#include <sfx2/lnkbase.hxx>
|
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
|
2013-03-29 07:29:34 -07:00
|
|
|
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
|
2021-12-31 16:52:16 +01:00
|
|
|
#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
|
2013-03-29 07:29:34 -07:00
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
|
2009-11-02 20:49:14 +01:00
|
|
|
#include <dialmgr.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
using namespace sfx2;
|
2013-03-29 07:29:34 -07:00
|
|
|
using namespace ::com::sun::star;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
|
|
|
namespace {
|
|
|
|
|
2014-08-04 08:42:38 +09:00
|
|
|
class SvBaseLinkMemberList {
|
|
|
|
private:
|
|
|
|
std::vector<SvBaseLink*> mLinks;
|
|
|
|
|
2012-08-06 11:59:47 +02:00
|
|
|
public:
|
|
|
|
~SvBaseLinkMemberList()
|
|
|
|
{
|
2018-02-27 22:34:17 +01:00
|
|
|
for (auto const& link : mLinks)
|
2012-08-06 11:59:47 +02:00
|
|
|
{
|
2018-02-27 22:34:17 +01:00
|
|
|
if( link )
|
|
|
|
link->ReleaseRef();
|
2012-08-06 11:59:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-04 08:42:38 +09:00
|
|
|
size_t size() const { return mLinks.size(); }
|
|
|
|
|
|
|
|
SvBaseLink *operator[](size_t i) const { return mLinks[i]; }
|
2012-08-06 11:59:47 +02:00
|
|
|
|
2014-08-04 08:42:38 +09:00
|
|
|
void push_back(SvBaseLink* p)
|
|
|
|
{
|
|
|
|
mLinks.push_back(p);
|
2014-10-02 14:37:06 +02:00
|
|
|
p->AddFirstRef();
|
2014-08-04 08:42:38 +09:00
|
|
|
}
|
2012-08-06 11:59:47 +02:00
|
|
|
};
|
2009-10-31 00:36:06 +01:00
|
|
|
|
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
|
|
|
}
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
SvBaseLinksDlg::SvBaseLinksDlg(weld::Window * pParent, LinkManager* pMgr, bool bHtmlMode)
|
|
|
|
: GenericDialogController(pParent, "cui/ui/baselinksdialog.ui", "BaseLinksDialog")
|
|
|
|
, aStrAutolink( CuiResId( STR_AUTOLINK ) )
|
|
|
|
, aStrManuallink( CuiResId( STR_MANUALLINK ) )
|
|
|
|
, aStrBrokenlink( CuiResId( STR_BROKENLINK ) )
|
|
|
|
, aStrCloselinkmsg( CuiResId( STR_CLOSELINKMSG ) )
|
|
|
|
, aStrCloselinkmsgMulti( CuiResId( STR_CLOSELINKMSG_MULTI ) )
|
|
|
|
, aStrWaitinglink( CuiResId( STR_WAITINGLINK ) )
|
|
|
|
, pLinkMgr( nullptr )
|
|
|
|
, aUpdateIdle("cui SvBaseLinksDlg UpdateIdle")
|
|
|
|
, m_xTbLinks(m_xBuilder->weld_tree_view("TB_LINKS"))
|
|
|
|
, m_xFtFullFileName(m_xBuilder->weld_link_button("FULL_FILE_NAME"))
|
|
|
|
, m_xFtFullSourceName(m_xBuilder->weld_label("FULL_SOURCE_NAME"))
|
|
|
|
, m_xFtFullTypeName(m_xBuilder->weld_label("FULL_TYPE_NAME"))
|
|
|
|
, m_xRbAutomatic(m_xBuilder->weld_radio_button("AUTOMATIC"))
|
|
|
|
, m_xRbManual(m_xBuilder->weld_radio_button("MANUAL"))
|
|
|
|
, m_xPbUpdateNow(m_xBuilder->weld_button("UPDATE_NOW"))
|
|
|
|
, m_xPbChangeSource(m_xBuilder->weld_button("CHANGE_SOURCE"))
|
|
|
|
, m_xPbBreakLink(m_xBuilder->weld_button("BREAK_LINK"))
|
|
|
|
, m_xVirDev(VclPtr<VirtualDevice>::Create())
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
// expand the point size of the desired font to the equivalent pixel size
|
2021-03-12 12:29:52 +00:00
|
|
|
weld::SetPointFont(*m_xVirDev, m_xTbLinks->get_font());
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->set_size_request(m_xTbLinks->get_approximate_digit_width() * 90,
|
|
|
|
m_xTbLinks->get_height_rows(12));
|
|
|
|
|
|
|
|
m_xTbLinks->set_selection_mode(SelectionMode::Multiple);
|
|
|
|
|
2021-10-15 16:33:00 +02:00
|
|
|
std::vector<int> aWidths
|
|
|
|
{
|
|
|
|
o3tl::narrowing<int>(m_xTbLinks->get_approximate_digit_width() * 30),
|
|
|
|
o3tl::narrowing<int>(m_xTbLinks->get_approximate_digit_width() * 20),
|
|
|
|
o3tl::narrowing<int>(m_xTbLinks->get_approximate_digit_width() * 20)
|
|
|
|
};
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->set_column_fixed_widths(aWidths);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// UpdateTimer for DDE-/Grf-links, which are waited for
|
2017-01-23 19:37:51 +01:00
|
|
|
aUpdateIdle.SetInvokeHandler( LINK( this, SvBaseLinksDlg, UpdateWaitingHdl ) );
|
2017-01-04 12:06:42 +01:00
|
|
|
aUpdateIdle.SetPriority( TaskPriority::LOWEST );
|
2012-06-27 13:27:03 +02:00
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->connect_changed( LINK( this, SvBaseLinksDlg, LinksSelectHdl ) );
|
|
|
|
m_xTbLinks->connect_row_activated( LINK( this, SvBaseLinksDlg, LinksDoubleClickHdl ) );
|
2021-05-20 09:40:45 +01:00
|
|
|
m_xRbAutomatic->connect_toggled( LINK( this, SvBaseLinksDlg, ToggleHdl ) );
|
|
|
|
m_xRbManual->connect_toggled( LINK( this, SvBaseLinksDlg, ToggleHdl ) );
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xPbUpdateNow->connect_clicked( LINK( this, SvBaseLinksDlg, UpdateNowClickHdl ) );
|
|
|
|
m_xPbChangeSource->connect_clicked( LINK( this, SvBaseLinksDlg, ChangeSourceClickHdl ) );
|
2009-10-31 00:36:06 +01:00
|
|
|
if(!bHtmlMode)
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xPbBreakLink->connect_clicked( LINK( this, SvBaseLinksDlg, BreakLinkClickHdl ) );
|
2009-10-31 00:36:06 +01:00
|
|
|
else
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xPbBreakLink->hide();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
SetManager( pMgr );
|
|
|
|
}
|
|
|
|
|
|
|
|
SvBaseLinksDlg::~SvBaseLinksDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|* SvBaseLinksDlg::Handler()
|
|
|
|
*************************************************************************/
|
2019-02-10 14:59:03 +00:00
|
|
|
IMPL_LINK(SvBaseLinksDlg, LinksSelectHdl, weld::TreeView&, rTreeView, void)
|
|
|
|
{
|
|
|
|
LinksSelectHdl(&rTreeView);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvBaseLinksDlg::LinksSelectHdl(weld::TreeView* pSvTabListBox)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
const int nSelectionCount = pSvTabListBox ?
|
|
|
|
pSvTabListBox->count_selected_rows() : 0;
|
|
|
|
if (nSelectionCount > 1)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-04-15 17:50:21 +02:00
|
|
|
// possibly deselect old entries in case of multi-selection
|
2019-02-10 14:59:03 +00:00
|
|
|
int nSelEntry = pSvTabListBox->get_selected_index();
|
2022-02-04 09:13:52 +00:00
|
|
|
SvBaseLink* pLink = weld::fromId<SvBaseLink*>(pSvTabListBox->get_id(nSelEntry));
|
2020-03-30 15:11:55 +02:00
|
|
|
SvBaseLinkObjectType nObjectType = pLink->GetObjType();
|
|
|
|
if(!isClientFileType(nObjectType))
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
pSvTabListBox->unselect_all();
|
|
|
|
pSvTabListBox->select(nSelEntry);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
std::vector<int> aRows = pSvTabListBox->get_selected_rows();
|
|
|
|
for (auto nEntry : aRows)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2022-02-04 09:13:52 +00:00
|
|
|
pLink = weld::fromId<SvBaseLink*>(pSvTabListBox->get_id(nEntry));
|
2017-03-29 04:54:21 +00:00
|
|
|
DBG_ASSERT(pLink, "Where is the Link?");
|
2014-03-28 10:33:03 +00:00
|
|
|
if (!pLink)
|
|
|
|
continue;
|
2020-03-30 15:11:55 +02:00
|
|
|
if( !isClientFileType(pLink->GetObjType()) )
|
2019-02-10 14:59:03 +00:00
|
|
|
pSvTabListBox->unselect(nEntry);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xPbUpdateNow->set_sensitive(true);
|
|
|
|
m_xRbAutomatic->set_sensitive(false);
|
|
|
|
m_xRbManual->set_active(true);
|
|
|
|
m_xRbManual->set_sensitive(false);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
int nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLink* pLink = GetSelEntry( &nPos );
|
|
|
|
if( !pLink )
|
2015-09-07 09:35:04 +02:00
|
|
|
return;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xPbUpdateNow->set_sensitive(true);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-08-26 15:22:55 +02:00
|
|
|
OUString sType, sLink;
|
2015-11-10 10:13:27 +01:00
|
|
|
OUString *pLinkNm = &sLink, *pFilter = nullptr;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2020-04-01 13:05:01 +02:00
|
|
|
if( isClientFileType(pLink->GetObjType()) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xRbAutomatic->set_sensitive(false);
|
|
|
|
m_xRbManual->set_active(true);
|
|
|
|
m_xRbManual->set_sensitive(false);
|
2020-03-30 15:11:55 +02:00
|
|
|
if( SvBaseLinkObjectType::ClientGraphic == pLink->GetObjType() )
|
2016-02-17 13:14:50 +02:00
|
|
|
{
|
|
|
|
pLinkNm = nullptr;
|
|
|
|
pFilter = &sLink;
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xRbAutomatic->set_sensitive(true);
|
|
|
|
m_xRbManual->set_sensitive(true);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2015-03-23 14:23:01 +02:00
|
|
|
if( SfxLinkUpdateMode::ALWAYS == pLink->GetUpdateMode() )
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xRbAutomatic->set_active(true);
|
2009-10-31 00:36:06 +01:00
|
|
|
else
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xRbManual->set_active(true);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2013-08-26 15:22:55 +02:00
|
|
|
OUString aFileName;
|
2015-04-13 13:50:56 +02:00
|
|
|
sfx2::LinkManager::GetDisplayNames( pLink, &sType, &aFileName, pLinkNm, pFilter );
|
2016-12-05 08:47:18 +02:00
|
|
|
aFileName = INetURLObject::decode(aFileName, INetURLObject::DecodeMechanism::Unambiguous);
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xFtFullFileName->set_label( aFileName );
|
|
|
|
m_xFtFullFileName->set_uri( aFileName );
|
|
|
|
m_xFtFullSourceName->set_label( sLink );
|
|
|
|
m_xFtFullTypeName->set_label( sType );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-05 18:36:38 +01:00
|
|
|
IMPL_LINK_NOARG( SvBaseLinksDlg, LinksDoubleClickHdl, weld::TreeView&, bool )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
ChangeSourceClickHdl(*m_xPbChangeSource);
|
2019-10-05 18:36:38 +01:00
|
|
|
return true;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2021-05-20 17:27:49 +01:00
|
|
|
IMPL_LINK(SvBaseLinksDlg, ToggleHdl, weld::Toggleable&, rButton, void)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2021-05-20 09:40:45 +01:00
|
|
|
if (!rButton.get_active())
|
|
|
|
return;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
int nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLink* pLink = GetSelEntry( &nPos );
|
2021-05-20 09:40:45 +01:00
|
|
|
|
|
|
|
if (m_xRbAutomatic->get_active())
|
|
|
|
{
|
|
|
|
if( pLink && !isClientFileType( pLink->GetObjType() ) &&
|
|
|
|
SfxLinkUpdateMode::ALWAYS != pLink->GetUpdateMode() )
|
|
|
|
SetType( *pLink, nPos, SfxLinkUpdateMode::ALWAYS );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( pLink && !isClientFileType( pLink->GetObjType() ) &&
|
|
|
|
SfxLinkUpdateMode::ONCALL != pLink->GetUpdateMode())
|
|
|
|
SetType( *pLink, nPos, SfxLinkUpdateMode::ONCALL );
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
IMPL_LINK_NOARG(SvBaseLinksDlg, UpdateNowClickHdl, weld::Button&, void)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
std::vector< SvBaseLink* > aLnkArr;
|
2014-03-01 03:13:28 +01:00
|
|
|
std::vector< sal_Int16 > aPosArr;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
std::vector<int> aRows = m_xTbLinks->get_selected_rows();
|
|
|
|
for (int nFndPos : aRows)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2022-02-04 09:13:52 +00:00
|
|
|
aLnkArr.push_back( weld::fromId<SvBaseLink*>( m_xTbLinks->get_id(nFndPos) ) );
|
2019-02-10 14:59:03 +00:00
|
|
|
aPosArr.push_back( nFndPos );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
if( aLnkArr.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( size_t n = 0; n < aLnkArr.size(); ++n )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
tools::SvRef<SvBaseLink> xLink = aLnkArr[ n ];
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
// first look for the entry in the array
|
|
|
|
for(const auto & i : pLinkMgr->GetLinks())
|
|
|
|
if( xLink == i )
|
|
|
|
{
|
|
|
|
SetType( *xLink, aPosArr[ n ], xLink->GetUpdateMode() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
// if somebody is of the opinion to swap his links (SD)
|
|
|
|
LinkManager* pNewMgr = pLinkMgr;
|
|
|
|
pLinkMgr = nullptr;
|
|
|
|
SetManager( pNewMgr );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
|
2022-02-04 09:13:52 +00:00
|
|
|
OUString sId = weld::toId(aLnkArr[0]);
|
2020-04-17 14:48:19 +02:00
|
|
|
int nE = m_xTbLinks->find_id(sId);
|
|
|
|
if (nE == -1)
|
|
|
|
nE = m_xTbLinks->get_selected_index();
|
|
|
|
int nSelEntry = m_xTbLinks->get_selected_index();
|
|
|
|
if (nE != nSelEntry)
|
|
|
|
m_xTbLinks->unselect(nSelEntry);
|
|
|
|
m_xTbLinks->select(nE);
|
|
|
|
m_xTbLinks->scroll_to_row(nE);
|
2010-10-05 15:39:06 -04:00
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
pNewMgr->CloseCachedComps();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
IMPL_LINK_NOARG(SvBaseLinksDlg, ChangeSourceClickHdl, weld::Button&, void)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
std::vector<int> aRows = m_xTbLinks->get_selected_rows();
|
|
|
|
if (aRows.size() > 1)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-03-29 07:29:34 -07:00
|
|
|
try
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2021-06-21 12:30:34 +01:00
|
|
|
uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker = sfx2::createFolderPicker(
|
|
|
|
comphelper::getProcessComponentContext(), m_xDialog.get());
|
2013-03-29 07:29:34 -07:00
|
|
|
|
2013-08-26 15:22:55 +02:00
|
|
|
OUString sType, sFile, sLinkName;
|
|
|
|
OUString sFilter;
|
2022-02-04 09:13:52 +00:00
|
|
|
SvBaseLink* pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(aRows[0]));
|
2015-10-20 11:45:07 +02:00
|
|
|
sfx2::LinkManager::GetDisplayNames( pLink, &sType, &sFile );
|
2013-03-29 07:29:34 -07:00
|
|
|
INetURLObject aUrl(sFile);
|
2015-04-02 18:32:36 +02:00
|
|
|
if(aUrl.GetProtocol() == INetProtocol::File)
|
2013-03-29 07:29:34 -07:00
|
|
|
{
|
|
|
|
OUString sOldPath(aUrl.PathToFileName());
|
2019-06-20 23:07:30 +10:00
|
|
|
sal_Int32 nLen = aUrl.GetLastName().getLength();
|
2013-03-29 07:29:34 -07:00
|
|
|
sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
|
|
|
|
xFolderPicker->setDisplayDirectory(sOldPath);
|
|
|
|
}
|
|
|
|
if (xFolderPicker->execute() == ui::dialogs::ExecutableDialogResults::OK)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-03-29 07:29:34 -07:00
|
|
|
OUString aPath = xFolderPicker->getDirectory();
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
for (auto nRow : aRows)
|
2013-03-29 07:29:34 -07:00
|
|
|
{
|
2022-02-04 09:13:52 +00:00
|
|
|
pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nRow));
|
2013-03-29 07:29:34 -07:00
|
|
|
DBG_ASSERT(pLink,"Where is the link?");
|
2014-03-28 10:32:19 +00:00
|
|
|
if (!pLink)
|
|
|
|
continue;
|
2015-04-13 13:50:56 +02:00
|
|
|
sfx2::LinkManager::GetDisplayNames( pLink, &sType, &sFile, &sLinkName, &sFilter );
|
2013-03-29 07:29:34 -07:00
|
|
|
INetURLObject aUrl_(sFile);
|
2015-04-02 18:32:36 +02:00
|
|
|
INetURLObject aUrl2(aPath, INetProtocol::File);
|
2013-03-29 07:29:34 -07:00
|
|
|
aUrl2.insertName( aUrl_.getName() );
|
2013-08-26 15:22:55 +02:00
|
|
|
OUString sNewLinkName;
|
2015-11-10 10:13:27 +01:00
|
|
|
MakeLnkName( sNewLinkName, nullptr ,
|
2016-12-05 08:47:18 +02:00
|
|
|
aUrl2.GetMainURL(INetURLObject::DecodeMechanism::ToIUri), sLinkName, &sFilter);
|
2013-03-29 07:29:34 -07:00
|
|
|
pLink->SetLinkSourceName( sNewLinkName );
|
|
|
|
pLink->Update();
|
|
|
|
}
|
|
|
|
if( pLinkMgr->GetPersist() )
|
|
|
|
pLinkMgr->GetPersist()->SetModified();
|
|
|
|
LinkManager* pNewMgr = pLinkMgr;
|
2015-11-10 10:13:27 +01:00
|
|
|
pLinkMgr = nullptr;
|
2013-03-29 07:29:34 -07:00
|
|
|
SetManager( pNewMgr );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2013-03-29 07:29:34 -07:00
|
|
|
}
|
2019-06-14 15:29:00 +02:00
|
|
|
catch (const uno::Exception &)
|
2013-03-29 07:29:34 -07:00
|
|
|
{
|
2019-06-14 15:29:00 +02:00
|
|
|
TOOLS_WARN_EXCEPTION("cui.dialogs", "SvBaseLinksDlg");
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
int nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLink* pLink = GetSelEntry( &nPos );
|
2013-08-23 17:23:52 +02:00
|
|
|
if ( pLink && !pLink->GetLinkSourceName().isEmpty() )
|
2019-02-10 14:59:03 +00:00
|
|
|
pLink->Edit(m_xDialog.get(), LINK(this, SvBaseLinksDlg, EndEditHdl));
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
IMPL_LINK_NOARG( SvBaseLinksDlg, BreakLinkClickHdl, weld::Button&, void )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2014-04-16 11:39:08 +02:00
|
|
|
bool bModified = false;
|
2019-02-10 14:59:03 +00:00
|
|
|
if (m_xTbLinks->count_selected_rows() <= 1)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
int nPos;
|
2015-10-27 08:55:31 +02:00
|
|
|
tools::SvRef<SvBaseLink> xLink = GetSelEntry( &nPos );
|
2017-01-25 12:03:58 +02:00
|
|
|
if( !xLink.is() )
|
2015-08-19 09:11:34 +02:00
|
|
|
return;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
|
2018-02-23 09:35:08 +00:00
|
|
|
VclMessageType::Question, VclButtonsType::YesNo,
|
|
|
|
aStrCloselinkmsg));
|
|
|
|
xQueryBox->set_default_response(RET_YES);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2018-02-23 09:35:08 +00:00
|
|
|
if (RET_YES == xQueryBox->run())
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->remove(nPos);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// close object, if it's still existing
|
2020-03-30 15:11:55 +02:00
|
|
|
bool bNewLnkMgr = SvBaseLinkObjectType::ClientFile == xLink->GetObjType();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// tell the link that it will be resolved!
|
2009-10-31 00:36:06 +01:00
|
|
|
xLink->Closed();
|
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// if somebody has forgotten to deregister himself
|
2017-01-25 12:03:58 +02:00
|
|
|
if( xLink.is() )
|
2016-10-12 20:04:41 +02:00
|
|
|
pLinkMgr->Remove( xLink.get() );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
if( bNewLnkMgr )
|
|
|
|
{
|
2010-01-13 22:25:07 +01:00
|
|
|
LinkManager* pNewMgr = pLinkMgr;
|
2015-11-10 10:13:27 +01:00
|
|
|
pLinkMgr = nullptr;
|
2009-10-31 00:36:06 +01:00
|
|
|
SetManager( pNewMgr );
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->set_cursor(nPos ? --nPos : 0);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2014-04-16 11:39:08 +02:00
|
|
|
bModified = true;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
|
2018-02-23 09:35:08 +00:00
|
|
|
VclMessageType::Question, VclButtonsType::YesNo,
|
|
|
|
aStrCloselinkmsgMulti));
|
|
|
|
xQueryBox->set_default_response(RET_YES);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2018-02-23 09:35:08 +00:00
|
|
|
if (RET_YES == xQueryBox->run())
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
std::vector<int> aRows = m_xTbLinks->get_selected_rows();
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLinkMemberList aLinkList;
|
2019-02-10 14:59:03 +00:00
|
|
|
for (auto nRow : aRows)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2022-02-04 09:13:52 +00:00
|
|
|
SvBaseLink* pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nRow));
|
2019-02-10 14:59:03 +00:00
|
|
|
if (pLink)
|
|
|
|
aLinkList.push_back(pLink);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2019-02-10 14:59:03 +00:00
|
|
|
std::sort(aRows.begin(), aRows.end());
|
|
|
|
for (auto it = aRows.rbegin(); it != aRows.rend(); ++it)
|
|
|
|
m_xTbLinks->remove(*it);
|
|
|
|
for (size_t i = 0; i < aLinkList.size(); ++i)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2015-10-27 08:55:31 +02:00
|
|
|
tools::SvRef<SvBaseLink> xLink = aLinkList[i];
|
2012-04-15 17:50:21 +02:00
|
|
|
// tell the link that it will be resolved!
|
2009-10-31 00:36:06 +01:00
|
|
|
xLink->Closed();
|
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// if somebody has forgotten to deregister himself
|
2016-10-12 20:04:41 +02:00
|
|
|
pLinkMgr->Remove( xLink.get() );
|
2014-04-16 11:39:08 +02:00
|
|
|
bModified = true;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2012-04-15 17:50:21 +02:00
|
|
|
// then remove all selected entries
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-17 14:48:19 +02:00
|
|
|
if(!bModified)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!m_xTbLinks->n_children())
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
m_xRbAutomatic->set_sensitive(false);
|
|
|
|
m_xRbManual->set_sensitive(false);
|
|
|
|
m_xPbUpdateNow->set_sensitive(false);
|
|
|
|
m_xPbChangeSource->set_sensitive(false);
|
|
|
|
m_xPbBreakLink->set_sensitive(false);
|
2019-02-10 14:59:03 +00:00
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
m_xFtFullSourceName->set_label( "" );
|
|
|
|
m_xFtFullTypeName->set_label( "" );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2020-04-17 14:48:19 +02:00
|
|
|
if( pLinkMgr && pLinkMgr->GetPersist() )
|
|
|
|
pLinkMgr->GetPersist()->SetModified();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2017-01-23 19:37:51 +01:00
|
|
|
IMPL_LINK_NOARG( SvBaseLinksDlg, UpdateWaitingHdl, Timer*, void )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->freeze();
|
|
|
|
for (int nPos = m_xTbLinks->n_children(); nPos; --nPos)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2022-02-04 09:13:52 +00:00
|
|
|
tools::SvRef<SvBaseLink> xLink( weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nPos)) );
|
2017-01-25 12:03:58 +02:00
|
|
|
if( xLink.is() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString sCur( ImplGetStateStr( *xLink ) ),
|
2019-02-10 14:59:03 +00:00
|
|
|
sOld( m_xTbLinks->get_text(nPos, 3) );
|
2009-10-31 00:36:06 +01:00
|
|
|
if( sCur != sOld )
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->set_text(nPos, sCur, 3);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->thaw();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK( SvBaseLinksDlg, EndEditHdl, sfx2::SvBaseLink&, _rLink, void )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
int nPos;
|
2009-12-10 18:00:39 +01:00
|
|
|
GetSelEntry( &nPos );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
if( !_rLink.WasLastEditOK() )
|
|
|
|
return;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
// StarImpress/Draw swap the LinkObjects themselves!
|
|
|
|
// So search for the link in the manager; if it does not exist
|
|
|
|
// anymore, fill the list completely new. Otherwise only the
|
|
|
|
// edited link needs to be refreshed.
|
|
|
|
bool bLinkFnd = false;
|
|
|
|
for( size_t n = pLinkMgr->GetLinks().size(); n; )
|
|
|
|
if( &_rLink == &(*pLinkMgr->GetLinks()[ --n ]) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
bLinkFnd = true;
|
|
|
|
break;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2020-04-17 14:48:19 +02:00
|
|
|
|
|
|
|
if( bLinkFnd )
|
|
|
|
{
|
|
|
|
m_xTbLinks->remove(nPos);
|
|
|
|
int nToUnselect = m_xTbLinks->get_selected_index();
|
|
|
|
InsertEntry(_rLink, nPos, true);
|
|
|
|
if (nToUnselect != -1)
|
|
|
|
m_xTbLinks->unselect(nToUnselect);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2020-04-17 14:48:19 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LinkManager* pNewMgr = pLinkMgr;
|
|
|
|
pLinkMgr = nullptr;
|
|
|
|
SetManager( pNewMgr );
|
|
|
|
}
|
|
|
|
if (pLinkMgr && pLinkMgr->GetPersist())
|
|
|
|
pLinkMgr->GetPersist()->SetModified();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString SvBaseLinksDlg::ImplGetStateStr( const SvBaseLink& rLnk )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString sRet;
|
2009-10-31 00:36:06 +01:00
|
|
|
if( !rLnk.GetObj() )
|
2016-10-18 13:00:45 +02:00
|
|
|
sRet = aStrBrokenlink;
|
2009-10-31 00:36:06 +01:00
|
|
|
else if( rLnk.GetObj()->IsPending() )
|
|
|
|
{
|
2016-10-18 13:00:45 +02:00
|
|
|
sRet = aStrWaitinglink;
|
|
|
|
aUpdateIdle.Start();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2015-03-23 14:23:01 +02:00
|
|
|
else if( SfxLinkUpdateMode::ALWAYS == rLnk.GetUpdateMode() )
|
2016-10-18 13:00:45 +02:00
|
|
|
sRet = aStrAutolink;
|
2009-10-31 00:36:06 +01:00
|
|
|
else
|
2016-10-18 13:00:45 +02:00
|
|
|
sRet = aStrManuallink;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
2010-01-13 22:25:07 +01:00
|
|
|
void SvBaseLinksDlg::SetManager( LinkManager* pNewMgr )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
if( pLinkMgr == pNewMgr )
|
|
|
|
return;
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
if (pNewMgr)
|
|
|
|
{
|
2012-04-15 17:50:21 +02:00
|
|
|
// update has to be stopped before clear
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->freeze();
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->clear();
|
2009-10-31 00:36:06 +01:00
|
|
|
pLinkMgr = pNewMgr;
|
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
if( !pLinkMgr )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SvBaseLinks& rLnks = const_cast<SvBaseLinks&>(pLinkMgr->GetLinks());
|
|
|
|
for( size_t n = 0; n < rLnks.size(); ++n )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
tools::SvRef<SvBaseLink>& rLinkRef = rLnks[ n ];
|
|
|
|
if( !rLinkRef.is() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
rLnks.erase( rLnks.begin() + n );
|
|
|
|
--n;
|
|
|
|
continue;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2020-04-17 14:48:19 +02:00
|
|
|
if( rLinkRef->IsVisible() )
|
|
|
|
InsertEntry( *rLinkRef );
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
m_xTbLinks->thaw();
|
2019-02-10 14:59:03 +00:00
|
|
|
|
2020-04-17 14:48:19 +02:00
|
|
|
if( !rLnks.empty() )
|
|
|
|
{
|
|
|
|
m_xTbLinks->set_cursor(0);
|
|
|
|
m_xTbLinks->select(0);
|
|
|
|
LinksSelectHdl( nullptr );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
void SvBaseLinksDlg::InsertEntry(const SvBaseLink& rLink, int nPos, bool bSelect)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
OUString sFileNm, sLinkNm, sTypeNm, sFilter;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2015-04-13 13:50:56 +02:00
|
|
|
sfx2::LinkManager::GetDisplayNames( &rLink, &sTypeNm, &sFileNm, &sLinkNm, &sFilter );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
auto nWidthPixel = m_xTbLinks->get_column_width(0);
|
|
|
|
OUString aTxt = m_xVirDev->GetEllipsisString(sFileNm, nWidthPixel, DrawTextFlags::PathEllipsis);
|
2015-04-02 18:32:36 +02:00
|
|
|
INetURLObject aPath( sFileNm, INetProtocol::File );
|
2019-08-21 16:55:47 +02:00
|
|
|
OUString aFileName = aPath.getName(
|
|
|
|
INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::Unambiguous);
|
2009-12-10 18:00:39 +01:00
|
|
|
|
2013-09-26 08:30:52 +02:00
|
|
|
if( aFileName.getLength() > aTxt.getLength() )
|
2009-10-31 00:36:06 +01:00
|
|
|
aTxt = aFileName;
|
2018-01-12 10:23:31 +00:00
|
|
|
else if (!aFileName.isEmpty() && aTxt.indexOf(aFileName, aTxt.getLength() - aFileName.getLength()) == -1)
|
2009-10-31 00:36:06 +01:00
|
|
|
// filename not in string
|
|
|
|
aTxt = aFileName;
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
if (nPos == -1)
|
|
|
|
nPos = m_xTbLinks->n_children();
|
2019-02-18 12:11:08 +00:00
|
|
|
m_xTbLinks->insert(nPos);
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->set_text(nPos, aTxt, 0);
|
2022-02-04 09:13:52 +00:00
|
|
|
m_xTbLinks->set_id(nPos, weld::toId(&rLink));
|
2020-03-30 15:11:55 +02:00
|
|
|
if( SvBaseLinkObjectType::ClientGraphic == rLink.GetObjType() )
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->set_text(nPos, sFilter, 1);
|
2009-10-31 00:36:06 +01:00
|
|
|
else
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->set_text(nPos, sLinkNm, 1);
|
|
|
|
m_xTbLinks->set_text(nPos, sTypeNm, 2);
|
|
|
|
m_xTbLinks->set_text(nPos, ImplGetStateStr(rLink), 3);
|
|
|
|
if (bSelect)
|
|
|
|
m_xTbLinks->select(nPos);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
SvBaseLink* SvBaseLinksDlg::GetSelEntry(int* pPos)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
int nPos = m_xTbLinks->get_selected_index();
|
|
|
|
if (nPos != -1)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2019-02-10 14:59:03 +00:00
|
|
|
if (pPos)
|
2009-10-31 00:36:06 +01:00
|
|
|
*pPos = nPos;
|
2022-02-04 09:13:52 +00:00
|
|
|
return weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nPos));
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2015-11-10 10:13:27 +01:00
|
|
|
return nullptr;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2019-02-10 14:59:03 +00:00
|
|
|
void SvBaseLinksDlg::SetType(SvBaseLink& rLink,
|
|
|
|
int nSelPos,
|
|
|
|
SfxLinkUpdateMode nType)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
rLink.SetUpdateMode( nType );
|
|
|
|
rLink.Update();
|
2019-02-10 14:59:03 +00:00
|
|
|
m_xTbLinks->set_text(nSelPos, ImplGetStateStr(rLink), 3);
|
|
|
|
if (pLinkMgr->GetPersist())
|
2009-10-31 00:36:06 +01:00
|
|
|
pLinkMgr->GetPersist()->SetModified();
|
|
|
|
}
|
|
|
|
|
2017-07-31 15:13:12 +02:00
|
|
|
void SvBaseLinksDlg::SetActLink( SvBaseLink const * pLink )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
if( !pLinkMgr )
|
|
|
|
return;
|
|
|
|
|
|
|
|
const SvBaseLinks& rLnks = pLinkMgr->GetLinks();
|
|
|
|
int nSelect = 0;
|
|
|
|
for(const auto & rLinkRef : rLnks)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
// #109573# only visible links have been inserted into the TreeListBox,
|
|
|
|
// invisible ones have to be skipped here
|
|
|
|
if( rLinkRef->IsVisible() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
if( pLink == rLinkRef.get() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2020-04-17 14:48:19 +02:00
|
|
|
m_xTbLinks->select(nSelect);
|
|
|
|
LinksSelectHdl( nullptr );
|
|
|
|
return ;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2020-04-17 14:48:19 +02:00
|
|
|
++nSelect;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|