/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
// tdf#149935 - remember last used position and size
SvtViewOptions aDlgOpt(EViewType::Dialog, m_xDialog->get_help_id()); if (aDlgOpt.Exists())
m_xDialog->set_window_state(aDlgOpt.GetWindowState());
}
SvxHlinkDlgMarkWnd::~SvxHlinkDlgMarkWnd()
{
ClearTree(); // tdf#149935 - remember last used position and size
SvtViewOptions aDlgOpt(EViewType::Dialog, m_xDialog->get_help_id());
aDlgOpt.SetWindowState(m_xDialog->get_window_state(vcl::WindowDataMask::PosSize));
}
OUString sLastSelectedMark;
std::deque<OUString> aLastSelectedPath;
SvtViewOptions aViewSettings( EViewType::Dialog, TG_SETTING_MANAGER ); if (aViewSettings.Exists())
{ //Maybe we might want to have some sort of mru list and keep a mapping //per document, rather than the current reuse of "the last thing //selected, regardless of the document"
aViewSettings.GetUserItem(TG_SETTING_LASTMARK) >>= sLastSelectedMark;
uno::Sequence<OUString> aTmp;
aViewSettings.GetUserItem(TG_SETTING_LASTPATH) >>= aTmp;
aLastSelectedPath = comphelper::sequenceToContainer< std::deque<OUString> >(aTmp);
} //fallback to previous entry selected the last time we executed this dialog. //First see if the exact mark exists and re-use that if (!sLastSelectedMark.isEmpty())
bSelectedEntry = SelectEntry(sLastSelectedMark); //Otherwise just select the closest path available //now to what was available at dialog close time if (!bSelectedEntry && !aLastSelectedPath.empty())
{
std::deque<OUString> aTmpSelectedPath(std::move(aLastSelectedPath));
std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator()); if (!mxLbTree->get_iter_first(*xEntry))
xEntry.reset();
SelectPath(xEntry.get(), *mxLbTree, aTmpSelectedPath);
}
}
// Interface to refresh tree void SvxHlinkDlgMarkWnd::RefreshTree (const OUString& aStrURL)
{
OUString aUStrURL;
// Fill Tree-Control int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess >& xLinks, const weld::TreeIter* pParentEntry )
{ // used to create the Headings outline parent children tree view relation
std::stack<std::pair<std::unique_ptr<weld::TreeIter>, const sal_Int32>> aHeadingsParentEntryStack;
try
{
aAny = xLinks->getByName( aLink );
} catch(const uno::Exception&)
{ // if the name of the target was invalid (like empty headings) // no object can be provided continue;
}
uno::Reference< beans::XPropertySet > xTarget;
if( aAny >>= xTarget )
{ try
{ // get name to display
aAny = xTarget->getPropertyValue( aProp_LinkDisplayName );
OUString aDisplayName;
aAny >>= aDisplayName;
OUString aStrDisplayname ( aDisplayName );
// is it a target ?
uno::Reference< lang::XServiceInfo > xSI( xTarget, uno::UNO_QUERY ); bool bIsTarget = xSI->supportsService( aProp_LinkTarget );
std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator()); if (pParentEntry)
{
OUString sContentType = mxLbTree->get_text(*pParentEntry); if (sContentType == "Headings")
{ if (aHeadingsParentEntryStack.empty())
aHeadingsParentEntryStack.push(
std::pair(mxLbTree->make_iterator(pParentEntry), -1));
// get the headings name to display
aAny = xTarget->getPropertyValue(u"ActualOutlineName"_ustr);
OUString sActualOutlineName;
aAny >>= sActualOutlineName;
// get the headings outline level
aAny = xTarget->getPropertyValue(u"OutlineLevel"_ustr);
sal_Int32 nOutlineLevel = *o3tl::doAccess<sal_Int32>(aAny);
// pop until the top of stack entry has an outline level less than // the to be inserted heading outline level while (nOutlineLevel <= aHeadingsParentEntryStack.top().second)
aHeadingsParentEntryStack.pop();
// Click on Apply-Button / Double-click on item in tree
IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, DoubleClickApplyHdl_Impl, weld::TreeView&, bool)
{
ClickApplyHdl_Impl(*mxBtApply); returntrue;
}
std::deque<OUString> aLastSelectedPath; //If the bottommost entry is expanded but nothing //underneath it is selected leave a dummy entry if (mxLbTree->get_row_expanded(*xEntry))
aLastSelectedPath.push_front(OUString()); while (bEntry)
{
aLastSelectedPath.push_front(mxLbTree->get_text(*xEntry));
bEntry = mxLbTree->iter_parent(*xEntry);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.