summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2021-01-24 22:17:49 -0900
committerJim Raykowski <raykowj@gmail.com>2021-03-02 22:49:03 +0100
commit5480d9237af1cf25ac464bf49ba364a757fcf6f5 (patch)
treec082c6e96279c10ed6c4243f6bb590a6b29612b7
parent9ccbf716ba16effb356c97c992d2cd738c44f767 (diff)
tdf#114567 tdf#138934 Hyperlink-Target in Doc Headings expand/collapse
Provides parent child expand/collapse for Headings in the Hyperlink- Target in Document dialog target treeview Change-Id: I8cc57b4cbf3830cec76d64a0ef587e199c39e360 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109930 Tested-by: Jenkins Reviewed-by: Jim Raykowski <raykowj@gmail.com>
-rw-r--r--cui/source/dialogs/hlmarkwn.cxx48
-rw-r--r--cui/source/inc/hlmarkwn.hxx2
-rw-r--r--sw/inc/unotxdoc.hxx5
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx47
4 files changed, 81 insertions, 21 deletions
diff --git a/cui/source/dialogs/hlmarkwn.cxx b/cui/source/dialogs/hlmarkwn.cxx
index 8996c0e6790c..cdc1039cab18 100644
--- a/cui/source/dialogs/hlmarkwn.cxx
+++ b/cui/source/dialogs/hlmarkwn.cxx
@@ -283,6 +283,9 @@ bool SvxHlinkDlgMarkWnd::RefreshFromDoc(const OUString& aURL)
// 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;
+
int nEntries=0;
const uno::Sequence< OUString > aNames( xLinks->getElementNames() );
const sal_Int32 nLinks = aNames.getLength();
@@ -331,7 +334,50 @@ int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess >
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));
std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator());
- mxLbTree->insert(pParentEntry, -1, &aStrDisplayname, &sId, nullptr, nullptr, false, xEntry.get());
+ 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("ActualOutlineName");
+ OUString sActualOutlineName;
+ aAny >>= sActualOutlineName;
+
+ // get the headings outline level
+ aAny = xTarget->getPropertyValue("OutlineLevel");
+ sal_Int32 nOutlineLevel;
+ aAny >>= nOutlineLevel;
+
+ // 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();
+
+ mxLbTree->insert(aHeadingsParentEntryStack.top().first.get(), -1,
+ &sActualOutlineName, &sId, nullptr, nullptr, false,
+ xEntry.get());
+
+ // push if the inserted entry is a child
+ if (nOutlineLevel > aHeadingsParentEntryStack.top().second)
+ aHeadingsParentEntryStack.push(
+ std::pair(std::move(xEntry), nOutlineLevel));
+ }
+ else
+ {
+ mxLbTree->insert(pParentEntry, -1, &aStrDisplayname, &sId, nullptr,
+ nullptr, false, xEntry.get());
+ }
+ }
+ else
+ {
+ mxLbTree->insert(pParentEntry, -1, &aStrDisplayname, &sId, nullptr, nullptr,
+ false, xEntry.get());
+ }
try
{
diff --git a/cui/source/inc/hlmarkwn.hxx b/cui/source/inc/hlmarkwn.hxx
index 9552bc10097c..d88dddab208d 100644
--- a/cui/source/inc/hlmarkwn.hxx
+++ b/cui/source/inc/hlmarkwn.hxx
@@ -30,8 +30,6 @@ class SvxHyperlinkTabPageBase;
class SvxHlinkDlgMarkWnd : public weld::GenericDialogController
{
private:
- friend class SvxHlmarkTreeLBox;
-
SvxHyperlinkTabPageBase* mpParent;
sal_uInt16 mnError;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index df6309d7125e..4dbb35b01ec8 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -558,9 +558,12 @@ class SwXOutlineTarget final : public cppu::WeakImplHelper
{
const SfxItemPropertySet* m_pPropSet;
OUString m_sOutlineText;
+ OUString m_sActualText;
+ const sal_Int32 m_nOutlineLevel;
public:
- SwXOutlineTarget(const OUString& rOutlineText);
+ SwXOutlineTarget(const OUString& rOutlineText, const rtl::OUString &rActualText,
+ const sal_Int32 nOutlineLevel);
virtual ~SwXOutlineTarget() override;
//XPropertySet
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index ec2b23aeb6fc..ea00f9a18f25 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -162,6 +162,8 @@
#include <svx/svdpage.hxx>
+#include <IDocumentOutlineNodes.hxx>
+
#define TWIPS_PER_PIXEL 15
using namespace ::com::sun::star;
@@ -1022,10 +1024,11 @@ static sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, bool& bException)
return nRet;
}
-static OUString lcl_CreateOutlineString( size_t nIndex,
- const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
+static OUString lcl_CreateOutlineString(const size_t nIndex, const SwDoc* pDoc)
{
OUStringBuffer sEntry;
+ const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
+ const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
const SwTextNode * pTextNd = rOutlineNodes[ nIndex ]->GetTextNode();
SwNumberTree::tNumberVector aNumVector = pTextNd->GetNumberVector();
if( pOutlRule && pTextNd->GetNumRule())
@@ -1039,8 +1042,9 @@ static OUString lcl_CreateOutlineString( size_t nIndex,
sEntry.append(OUString::number( nVal ));
sEntry.append(".");
}
- sEntry.append( rOutlineNodes[ nIndex ]->
- GetTextNode()->GetExpandText(nullptr) );
+ OUString sOutlineText = pDoc->getIDocumentOutlineNodes().getOutlineText(
+ nIndex, pDoc->GetDocShell()->GetWrtShell()->GetLayout(), false);
+ sEntry.append(sOutlineText);
return sEntry.makeStringAndClear();
}
@@ -4047,11 +4051,14 @@ Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
for (size_t i = 0; i < nOutlineCount && !bFound; ++i)
{
- const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
- const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
- if(sParam == lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
+ if(sParam == lcl_CreateOutlineString(i, pDoc))
{
- Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
+ OUString sOutlineText =
+ pDoc->getIDocumentOutlineNodes().getOutlineText(
+ i, pDoc->GetDocShell()->GetWrtShell()->GetLayout());
+ sal_Int32 nOutlineLevel = pDoc->getIDocumentOutlineNodes().getOutlineLevel(i);
+ Reference<XPropertySet> xOutline =
+ new SwXOutlineTarget(sParam, sOutlineText, nOutlineLevel);
aRet <<= xOutline;
bFound = true;
}
@@ -4107,10 +4114,9 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames()
const size_t nOutlineCount = rOutlineNodes.size();
aRet.realloc(nOutlineCount);
OUString* pResArr = aRet.getArray();
- const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
for (size_t i = 0; i < nOutlineCount; ++i)
{
- OUString sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule) + "|outline";
+ OUString sEntry = lcl_CreateOutlineString(i, pDoc) + "|outline";
pResArr[i] = sEntry;
}
}
@@ -4165,10 +4171,7 @@ sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
for (size_t i = 0; i < nOutlineCount && !bRet; ++i)
{
- const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
- const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
- if(sParam ==
- lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
+ if(sParam == lcl_CreateOutlineString(i, pDoc))
{
bRet = true;
}
@@ -4314,9 +4317,12 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames()
return aRet;
}
-SwXOutlineTarget::SwXOutlineTarget(const OUString& rOutlineText) :
+SwXOutlineTarget::SwXOutlineTarget(const OUString& rOutlineText, const OUString& rActualText,
+ const sal_Int32 nOutlineLevel) :
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
- m_sOutlineText(rOutlineText)
+ m_sOutlineText(rOutlineText),
+ m_sActualText(rActualText),
+ m_nOutlineLevel(nOutlineLevel)
{
}
@@ -4338,9 +4344,16 @@ void SwXOutlineTarget::setPropertyValue(
Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
{
- if(rPropertyName != UNO_LINK_DISPLAY_NAME)
+ if (rPropertyName != UNO_LINK_DISPLAY_NAME && rPropertyName != "ActualOutlineName" &&
+ rPropertyName != "OutlineLevel")
throw UnknownPropertyException(rPropertyName);
+ if (rPropertyName == "ActualOutlineName")
+ return Any(m_sActualText);
+
+ if (rPropertyName == "OutlineLevel")
+ return Any(m_nOutlineLevel);
+
return Any(m_sOutlineText);
}