summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2021-05-15 22:58:04 -0800
committerJim Raykowski <raykowj@gmail.com>2021-05-19 08:35:41 +0200
commitaa56f1338450b2362ce0191b0107d512ebb497c9 (patch)
treeef2e45cfcfc1833da1284c9357a6437ddf60a80f
parentd8813b799343ae846a320d829e20e3f5f4ecb3a4 (diff)
tdf#137741 tdf#142258 Improve naming of Sw Navigator Field entries
Change-Id: Ibdfe2797f67e30e590b4d1b0b12e9e5639dacba6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115669 Tested-by: Jenkins Reviewed-by: Jim Raykowski <raykowj@gmail.com>
-rw-r--r--sw/source/uibase/utlui/content.cxx63
1 files changed, 48 insertions, 15 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index bfdf00e7aff9..f7b6adc04eb8 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -753,7 +753,8 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
{
// sorted list of all fields - meaning in the order they are in the document model
SetGetExpFields aSrtLst;
- const SwFieldTypes& rFieldTypes = *m_pWrtShell->GetDoc()->getIDocumentFieldsAccess().GetFieldTypes();
+ const SwFieldTypes& rFieldTypes =
+ *m_pWrtShell->GetDoc()->getIDocumentFieldsAccess().GetFieldTypes();
const size_t nSize = rFieldTypes.size();
for (size_t i = 0; i < nSize; ++i)
{
@@ -766,10 +767,14 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
{
const SwTextNode& rTextNode = pTextField->GetTextNode();
const SwContentFrame* pCFrame =
- rTextNode.getLayoutFrame(rTextNode.GetDoc().getIDocumentLayoutAccess().GetCurrentLayout());
+ rTextNode.getLayoutFrame(rTextNode.GetDoc().
+ getIDocumentLayoutAccess().
+ GetCurrentLayout());
if (pCFrame)
{
- std::unique_ptr<SetGetExpField> pNew(new SetGetExpField(SwNodeIndex(rTextNode), pTextField));
+ std::unique_ptr<SetGetExpField>
+ pNew(new SetGetExpField(SwNodeIndex(rTextNode),
+ pTextField));
aSrtLst.insert(std::move(pNew));
}
}
@@ -780,25 +785,53 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
const SwTextField* pTextField = aSrtLst[i]->GetTextField();
const SwFormatField& rFormatField = pTextField->GetFormatField();
const SwField* pField = rFormatField.GetField();
- OUString sFieldName = pField->GetFieldName();
if (pField->GetTypeId() == SwFieldTypesEnum::Postit)
- {
- OUString sEntry(static_cast<const SwPostItField*>(pField)->GetText());
- sEntry = RemoveNewline(sEntry);
- sFieldName = sFieldName + " - " + sEntry;
- }
- else if (pField->GetTypeId() == SwFieldTypesEnum::DocumentStatistics)
+ continue;
+ OUString sExpandedField(pField->ExpandField(true, m_pWrtShell->GetLayout()));
+ if (!sExpandedField.isEmpty())
+ sExpandedField = u" - " + sExpandedField;
+ OUString sText = pField->GetDescription() + u" - " + pField->GetFieldName()
+ + sExpandedField;
+ if (pField->GetTypeId() == SwFieldTypesEnum::DocumentStatistics)
{
SwFieldMgr aFieldMgr(m_pWrtShell);
std::vector<OUString> aLst;
aFieldMgr.GetSubTypes(SwFieldTypesEnum::DocumentStatistics, aLst);
- const SwDocStatField* pDocStatField = static_cast<const SwDocStatField*>(pField);
OUString sSubType;
- if (pDocStatField->GetSubType() < aLst.size())
- sSubType = aLst[pDocStatField->GetSubType()] + " - ";
- sFieldName = sFieldName + " - " + sSubType + pDocStatField->ExpandField(true, nullptr);
+ if (pField->GetSubType() < aLst.size())
+ sSubType = u" - " + aLst[pField->GetSubType()];
+ sText = pField->GetDescription() + u" - " + pField->GetFieldName() + sSubType
+ + sExpandedField;
+ }
+ else if (pField->GetTypeId() == SwFieldTypesEnum::GetRef)
+ {
+ OUString sExpandedTextOfReferencedTextNode;
+ if (const SwGetRefField* pRefField(dynamic_cast<const SwGetRefField*>(pField));
+ pRefField)
+ {
+ if (pRefField->IsRefToHeadingCrossRefBookmark() ||
+ pRefField->IsRefToNumItemCrossRefBookmark())
+ {
+ sExpandedTextOfReferencedTextNode = u" - " +
+ pRefField->GetExpandedTextOfReferencedTextNode(*m_pWrtShell->
+ GetLayout());
+ if (sExpandedTextOfReferencedTextNode.getLength() > 80)
+ {
+ sExpandedTextOfReferencedTextNode =
+ OUString::Concat(
+ sExpandedTextOfReferencedTextNode.subView(0, 80)) +
+ u"...";
+ }
+ }
+ else
+ {
+ sExpandedTextOfReferencedTextNode = u" - " + pRefField->GetSetRefName();
+ }
+ }
+ sText = pField->GetDescription() + sExpandedTextOfReferencedTextNode;
}
- std::unique_ptr<SwTextFieldContent> pCnt(new SwTextFieldContent(this, sFieldName, &rFormatField, i));
+ std::unique_ptr<SwTextFieldContent> pCnt(new SwTextFieldContent(this, sText,
+ &rFormatField, i));
m_pMember->insert(std::move(pCnt));
}
m_nMemberCount = m_pMember->size();