29#include <com/sun/star/awt/XBitmap.hpp>
30#include <com/sun/star/frame/Desktop.hpp>
31#include <com/sun/star/beans/NamedValue.hpp>
32#include <com/sun/star/beans/PropertyValue.hpp>
33#include <com/sun/star/document/XLinkTargetSupplier.hpp>
34#include <com/sun/star/beans/XPropertySet.hpp>
35#include <com/sun/star/io/IOException.hpp>
53 OUString aUStrLinkname;
56 TargetData (
const OUString& aUStrLName,
bool bTarget)
60 aUStrLinkname = aUStrLName;
69 : GenericDialogController(pParentDialog,
"cui/ui/hyperlinkmarkdialog.ui",
"HyperlinkMark")
72 , mxBtApply(m_xBuilder->weld_button(
"ok"))
73 , mxBtClose(m_xBuilder->weld_button(
"close"))
74 , mxLbTree(m_xBuilder->weld_tree_view(
"TreeListBox"))
75 , mxError(m_xBuilder->weld_label(
"error"))
93 OUString aStrMessage =
CuiResId( RID_CUISTR_HYPDLG_ERR_LERR_NOENTRIES );
94 mxError->set_label(aStrMessage);
100 OUString aStrMessage =
CuiResId( RID_CUISTR_HYPDLG_ERR_LERR_DOCNOTOPEN );
101 mxError->set_label(aStrMessage);
115 sal_uInt16 nOldError =
mnError;
135 std::deque<OUString> &rLastSelectedPath)
137 OUString sTitle(rLastSelectedPath.front());
138 rLastSelectedPath.pop_front();
139 if (sTitle.isEmpty())
143 if (sTitle == rLbTree.
get_text(*pEntry))
147 if (!rLastSelectedPath.empty())
152 SelectPath(pEntry, rLbTree, rLastSelectedPath);
168 bool bSelectedEntry =
false;
170 OUString sLastSelectedMark;
171 std::deque<OUString> aLastSelectedPath;
173 if (aViewSettings.
Exists())
181 aLastSelectedPath = comphelper::sequenceToContainer< std::deque<OUString> >(aTmp);
185 if (!sLastSelectedMark.isEmpty())
189 if (!bSelectedEntry && !aLastSelectedPath.empty())
191 std::deque<OUString> aTmpSelectedPath(aLastSelectedPath);
192 std::unique_ptr<weld::TreeIter> xEntry(
mxLbTree->make_iterator());
193 if (!
mxLbTree->get_iter_first(*xEntry))
195 SelectPath(xEntry.get(), *
mxLbTree, aTmpSelectedPath);
208 sal_Int32
nPos = aStrURL.indexOf(
'#');
216 bool bSelectedEntry =
false;
220 OUString aStrMark = aStrURL.copy(
nPos+1);
236 if( !
aURL.isEmpty() )
244 xComp = xDesktop->loadComponentFromURL(
aURL,
"_blank", 0, aArg );
246 catch(
const io::IOException& )
250 catch(
const lang::IllegalArgumentException& )
259 xComp = xDesktop->getCurrentComponent();
268 if(
FillTree( xLTS->getLinks() ) == 0 )
274 if ( !
aURL.isEmpty() )
279 if( !
aURL.isEmpty() )
289 std::stack<std::pair<std::unique_ptr<weld::TreeIter>,
const sal_Int32>> aHeadingsParentEntryStack;
293 const sal_Int32 nLinks = aNames.getLength();
294 const OUString* pNames = aNames.getConstArray();
296 static constexpr OUStringLiteral aProp_LinkDisplayName(
u"LinkDisplayName" );
297 static constexpr OUStringLiteral aProp_LinkTarget(
u"com.sun.star.document.LinkTarget" );
298 static constexpr OUStringLiteral aProp_LinkDisplayBitmap(
u"LinkDisplayBitmap" );
299 for( sal_Int32
i = 0;
i < nLinks;
i++ )
302 OUString aLink( *pNames++ );
307 aAny = xLinks->getByName( aLink );
309 catch(
const uno::Exception&)
325 aAny =
xTarget->getPropertyValue( aProp_LinkDisplayName );
326 OUString aDisplayName;
327 aAny >>= aDisplayName;
328 OUString aStrDisplayname ( aDisplayName );
332 bool bIsTarget = xSI->supportsService( aProp_LinkTarget );
335 TargetData *
pData =
new TargetData ( aLink, bIsTarget );
338 std::unique_ptr<weld::TreeIter> xEntry(
mxLbTree->make_iterator());
341 OUString sContentType =
mxLbTree->get_text(*pParentEntry);
342 if (sContentType ==
"Headings")
344 if (aHeadingsParentEntryStack.empty())
345 aHeadingsParentEntryStack.push(
346 std::pair(
mxLbTree->make_iterator(pParentEntry), -1));
349 aAny =
xTarget->getPropertyValue(
"ActualOutlineName");
350 OUString sActualOutlineName;
351 aAny >>= sActualOutlineName;
354 aAny =
xTarget->getPropertyValue(
"OutlineLevel");
355 sal_Int32 nOutlineLevel = *o3tl::doAccess<sal_Int32>(aAny);
359 while (nOutlineLevel <= aHeadingsParentEntryStack.top().second)
360 aHeadingsParentEntryStack.pop();
362 mxLbTree->insert(aHeadingsParentEntryStack.top().first.get(), -1,
363 &sActualOutlineName, &
sId,
nullptr,
nullptr,
false,
367 if (nOutlineLevel > aHeadingsParentEntryStack.top().second)
368 aHeadingsParentEntryStack.push(
369 std::pair(
mxLbTree->make_iterator(xEntry.get()), nOutlineLevel));
373 mxLbTree->insert(pParentEntry, -1, &aStrDisplayname, &
sId,
nullptr,
374 nullptr,
false, xEntry.get());
379 mxLbTree->insert(pParentEntry, -1, &aStrDisplayname, &
sId,
nullptr,
nullptr,
380 false, xEntry.get());
387 aXBitmap(
xTarget->getPropertyValue( aProp_LinkDisplayBitmap ), uno::UNO_QUERY );
395 catch(
const css::uno::Exception&)
403 nEntries +=
FillTree( xLTS->getLinks(), xEntry.get() );
405 catch(
const css::uno::Exception&)
417 std::unique_ptr<weld::TreeIter> xEntry =
mxLbTree->make_iterator();
418 bool bEntry =
mxLbTree->get_iter_first(*xEntry);
422 TargetData* pUserData = weld::fromId<TargetData*>(
mxLbTree->get_id(*xEntry));
425 bEntry =
mxLbTree->iter_next(*xEntry);
435 std::unique_ptr<weld::TreeIter> xEntry =
mxLbTree->make_iterator();
436 bool bEntry =
mxLbTree->get_iter_first(*xEntry);
438 while (bEntry && !bFound)
440 TargetData* pUserData = weld::fromId<TargetData*>(
mxLbTree->get_id(*xEntry));
441 if (aStrName == pUserData->aUStrLinkname)
444 bEntry =
mxLbTree->iter_next(*xEntry);
456 std::unique_ptr<weld::TreeIter> xEntry =
FindEntry(aStrMark);
466 ClickApplyHdl_Impl(*mxBtApply);
472 std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
473 bool bEntry = mxLbTree->get_cursor(xEntry.get());
476 TargetData*
pData = weld::fromId<TargetData*>(mxLbTree->get_id(*xEntry));
477 if (
pData->bIsTarget)
487 std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
488 bool bEntry = mxLbTree->get_cursor(xEntry.get());
491 TargetData* pUserData = weld::fromId<TargetData*>(mxLbTree->get_id(*xEntry));
492 OUString sLastSelectedMark = pUserData->aUStrLinkname;
494 std::deque<OUString> aLastSelectedPath;
497 if (mxLbTree->get_row_expanded(*xEntry))
498 aLastSelectedPath.push_front(OUString());
501 aLastSelectedPath.push_front(mxLbTree->get_text(*xEntry));
502 bEntry = mxLbTree->iter_parent(*xEntry);
Reference< XExecutableDialog > m_xDialog
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
css::uno::Any GetUserItem(const OUString &sName) const
void SetUserData(const css::uno::Sequence< css::beans::NamedValue > &lData)
void RestoreLastSelection()
bool RefreshFromDoc(const OUString &aURL)
std::unique_ptr< weld::Label > mxError
std::unique_ptr< weld::Button > mxBtClose
int FillTree(const css::uno::Reference< css::container::XNameAccess > &xLinks, const weld::TreeIter *pParentEntry=nullptr)
SvxHlinkDlgMarkWnd(weld::Window *pParentDialog, SvxHyperlinkTabPageBase *pParentPage)
std::unique_ptr< weld::TreeIter > FindEntry(std::u16string_view aStrName)
void RefreshTree(const OUString &aStrURL)
bool SelectEntry(std::u16string_view aStrMark)
std::unique_ptr< weld::Button > mxBtApply
virtual ~SvxHlinkDlgMarkWnd() override
void MoveTo(const Point &rNewPos)
std::unique_ptr< weld::TreeView > mxLbTree
sal_uInt16 SetError(sal_uInt16 nError)
static BitmapEx GetBitmap(const css::uno::Reference< css::awt::XBitmap > &rxBitmap)
std::shared_ptr< weld::Dialog > m_xDialog
virtual void scroll_to_row(int row)=0
virtual void expand_row(const TreeIter &rIter)=0
virtual OUString get_text(int row, int col=-1) const=0
virtual bool iter_next_sibling(TreeIter &rIter) const=0
virtual void select(int pos)=0
virtual bool iter_children(TreeIter &rIter) const=0
OUString CuiResId(TranslateId aKey)
RegionData_Impl * mpParent
Reference< XInterface > xTarget
IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, DoubleClickApplyHdl_Impl, weld::TreeView &, bool)
constexpr OUStringLiteral TG_SETTING_LASTMARK
constexpr OUStringLiteral TG_SETTING_LASTPATH
constexpr OUStringLiteral TG_SETTING_MANAGER
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
OUString toId(const void *pValue)