20 #include <dialmgr.hxx>
27 #include <com/sun/star/awt/XBitmap.hpp>
28 #include <com/sun/star/frame/Desktop.hpp>
29 #include <com/sun/star/beans/NamedValue.hpp>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <com/sun/star/document/XLinkTargetSupplier.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/io/IOException.hpp>
37 #include <strings.hrc>
49 OUString aUStrLinkname;
52 TargetData (
const OUString& aUStrLName,
bool bTarget)
56 aUStrLinkname = aUStrLName;
65 : GenericDialogController(pParentDialog,
"cui/ui/hyperlinkmarkdialog.ui",
"HyperlinkMark")
68 , mxBtApply(m_xBuilder->weld_button(
"ok"))
69 , mxBtClose(m_xBuilder->weld_button(
"close"))
70 , mxLbTree(m_xBuilder->weld_tree_view(
"TreeListBox"))
71 , mxError(m_xBuilder->weld_label(
"error"))
89 OUString aStrMessage =
CuiResId( RID_SVXSTR_HYPDLG_ERR_LERR_NOENTRIES );
90 mxError->set_label(aStrMessage);
96 OUString aStrMessage =
CuiResId( RID_SVXSTR_HYPDLG_ERR_LERR_DOCNOTOPEN );
97 mxError->set_label(aStrMessage);
111 sal_uInt16 nOldError =
mnError;
125 m_xDialog->window_move(rNewPos.X(), rNewPos.Y());
131 std::deque<OUString> &rLastSelectedPath)
133 OUString sTitle(rLastSelectedPath.front());
134 rLastSelectedPath.pop_front();
135 if (sTitle.isEmpty())
139 if (sTitle == rLbTree.
get_text(*pEntry))
143 if (!rLastSelectedPath.empty())
148 SelectPath(pEntry, rLbTree, rLastSelectedPath);
158 #define TG_SETTING_MANAGER "TargetInDocument"
159 #define TG_SETTING_LASTMARK "LastSelectedMark"
160 #define TG_SETTING_LASTPATH "LastSelectedPath"
164 bool bSelectedEntry =
false;
166 OUString sLastSelectedMark;
167 std::deque<OUString> aLastSelectedPath;
169 if (aViewSettings.
Exists())
175 uno::Sequence<OUString> aTmp;
177 aLastSelectedPath = comphelper::sequenceToContainer< std::deque<OUString> >(aTmp);
181 if (!sLastSelectedMark.isEmpty())
185 if (!bSelectedEntry && !aLastSelectedPath.empty())
187 std::deque<OUString> aTmpSelectedPath(aLastSelectedPath);
188 std::unique_ptr<weld::TreeIter> xEntry(
mxLbTree->make_iterator());
189 if (!
mxLbTree->get_iter_first(*xEntry))
191 SelectPath(xEntry.get(), *
mxLbTree, aTmpSelectedPath);
204 sal_Int32
nPos = aStrURL.indexOf(
'#');
212 bool bSelectedEntry =
false;
216 OUString aStrMark = aStrURL.copy(nPos+1);
230 uno::Reference< lang::XComponent > xComp;
232 if( !aURL.isEmpty() )
239 uno::Sequence< beans::PropertyValue > aArg(1);
240 aArg.getArray()[0].Name =
"Hidden";
241 aArg.getArray()[0].Value <<=
true;
242 xComp = xDesktop->loadComponentFromURL( aURL,
"_blank", 0, aArg );
244 catch(
const io::IOException& )
248 catch(
const lang::IllegalArgumentException& )
257 xComp = xDesktop->getCurrentComponent();
262 uno::Reference< document::XLinkTargetSupplier > xLTS( xComp, uno::UNO_QUERY );
266 if(
FillTree( xLTS->getLinks() ) == 0 )
272 if ( !aURL.isEmpty() )
277 if( !aURL.isEmpty() )
287 const uno::Sequence< OUString > aNames( xLinks->getElementNames() );
288 const sal_Int32 nLinks = aNames.getLength();
289 const OUString* pNames = aNames.getConstArray();
291 const OUString aProp_LinkDisplayName(
"LinkDisplayName" );
292 const OUString aProp_LinkTarget(
"com.sun.star.document.LinkTarget" );
293 const OUString aProp_LinkDisplayBitmap(
"LinkDisplayBitmap" );
294 for( sal_Int32
i = 0;
i < nLinks;
i++ )
297 OUString aLink( *pNames++ );
302 aAny = xLinks->getByName( aLink );
304 catch(
const uno::Exception&)
313 uno::Reference< beans::XPropertySet >
xTarget;
315 if( aAny >>= xTarget )
320 aAny = xTarget->getPropertyValue( aProp_LinkDisplayName );
321 OUString aDisplayName;
322 aAny >>= aDisplayName;
323 OUString aStrDisplayname ( aDisplayName );
326 uno::Reference< lang::XServiceInfo > xSI( xTarget, uno::UNO_QUERY );
327 bool bIsTarget = xSI->supportsService( aProp_LinkTarget );
330 TargetData *
pData =
new TargetData ( aLink, bIsTarget );
331 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));
333 std::unique_ptr<weld::TreeIter> xEntry(
mxLbTree->make_iterator());
334 mxLbTree->insert(pParentEntry, -1, &aStrDisplayname, &sId,
nullptr,
nullptr,
false, xEntry.get());
339 uno::Reference< awt::XBitmap >
340 aXBitmap( xTarget->getPropertyValue( aProp_LinkDisplayBitmap ), uno::UNO_QUERY );
348 catch(
const css::uno::Exception&)
354 uno::Reference< document::XLinkTargetSupplier > xLTS( xTarget, uno::UNO_QUERY );
356 nEntries +=
FillTree( xLTS->getLinks(), xEntry.get() );
358 catch(
const css::uno::Exception&)
370 std::unique_ptr<weld::TreeIter> xEntry =
mxLbTree->make_iterator();
371 bool bEntry =
mxLbTree->get_iter_first(*xEntry);
375 TargetData* pUserData =
reinterpret_cast<TargetData*
>(
mxLbTree->get_id(*xEntry).toInt64());
378 bEntry =
mxLbTree->iter_next(*xEntry);
388 std::unique_ptr<weld::TreeIter> xEntry =
mxLbTree->make_iterator();
389 bool bEntry =
mxLbTree->get_iter_first(*xEntry);
391 while (bEntry && !bFound)
393 TargetData* pUserData =
reinterpret_cast<TargetData*
>(
mxLbTree->get_id(*xEntry).toInt64());
394 if (aStrName == pUserData->aUStrLinkname)
397 bEntry =
mxLbTree->iter_next(*xEntry);
409 std::unique_ptr<weld::TreeIter> xEntry =
FindEntry(aStrMark);
420 ClickApplyHdl_Impl(*mxBtApply);
426 std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
427 bool bEntry = mxLbTree->get_cursor(xEntry.get());
430 TargetData*
pData =
reinterpret_cast<TargetData*
>(mxLbTree->get_id(*xEntry).toInt64());
431 if (pData->bIsTarget)
433 mpParent->SetMarkStr(pData->aUStrLinkname);
441 std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
442 bool bEntry = mxLbTree->get_cursor(xEntry.get());
445 TargetData* pUserData =
reinterpret_cast<TargetData*
>(mxLbTree->get_id(*xEntry).toInt64());
446 OUString sLastSelectedMark = pUserData->aUStrLinkname;
448 std::deque<OUString> aLastSelectedPath;
451 if (mxLbTree->get_row_expanded(*xEntry))
452 aLastSelectedPath.push_front(OUString());
455 aLastSelectedPath.push_front(mxLbTree->get_text(*xEntry));
456 bEntry = mxLbTree->iter_parent(*xEntry);
459 uno::Sequence< beans::NamedValue > aSettings
#define LINK(Instance, Class, Member)
std::shared_ptr< weld::Dialog > m_xDialog
std::unique_ptr< weld::Button > mxBtApply
std::unique_ptr< ContentProperties > pData
int FillTree(const css::uno::Reference< css::container::XNameAccess > &xLinks, const weld::TreeIter *pParentEntry=nullptr)
virtual ~SvxHlinkDlgMarkWnd() override
Reference< XInterface > xTarget
void MoveTo(const Point &rNewPos)
std::unique_ptr< weld::TreeIter > FindEntry(std::u16string_view aStrName)
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
void RefreshTree(const OUString &aStrURL)
#define TG_SETTING_MANAGER
static BitmapEx GetBitmap(const css::uno::Reference< css::awt::XBitmap > &rxBitmap)
void RestoreLastSelection()
sal_uInt16 SetError(sal_uInt16 nError)
IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, DoubleClickApplyHdl_Impl, weld::TreeView &, bool)
bool RefreshFromDoc(const OUString &aURL)
void SetUserData(const css::uno::Sequence< css::beans::NamedValue > &lData)
virtual OUString get_text(int row, int col=-1) const =0
virtual void expand_row(const TreeIter &rIter)=0
OUString CuiResId(const char *pKey)
virtual bool iter_children(TreeIter &rIter) const =0
#define TG_SETTING_LASTPATH
RegionData_Impl * mpParent
std::unique_ptr< weld::Label > mxError
virtual void select(int pos)=0
bool SelectEntry(std::u16string_view aStrMark)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
#define TG_SETTING_LASTMARK
Reference< XExecutableDialog > m_xDialog
Reference< XComponentContext > getProcessComponentContext()
css::uno::Any GetUserItem(const OUString &sName) const
SvxHlinkDlgMarkWnd(weld::Window *pParentDialog, SvxHyperlinkTabPageBase *pParentPage)
std::unique_ptr< weld::Button > mxBtClose
virtual bool iter_next_sibling(TreeIter &rIter) const =0
std::unique_ptr< weld::TreeView > mxLbTree
virtual void scroll_to_row(int row)=0