24#include <libxml/xmlwriter.h>
31#include <officecfg/Office/Common.hxx>
32#include <osl/diagnose.h>
50#include <unoprnms.hxx>
53#include <com/sun/star/beans/PropertyValues.hpp>
54#include <com/sun/star/uri/UriReferenceFactory.hpp>
61 : SimpleReferenceObject()
81 m_bSortByDocument(true),
92 return std::make_unique<SwAuthorityFieldType>(
m_pDoc);
97 for(SwAuthDataArr::size_type j = 0; j <
m_DataArr.size(); ++j)
110 assert(
false &&
"SwAuthorityFieldType::RemoveField: pEntry was not added previously");
123 if (*rpTemp == *pEntry)
137 std::vector<OUString>& rToFill )
const
146 std::u16string_view rIdentifier)
const
179 for( SwAuthDataArr::size_type nRet = 0; nRet <
m_DataArr.size(); ++nRet )
207 std::vector<std::unique_ptr<SwTOXSortTabBase>> aSortArr;
208 std::vector<std::unique_ptr<SwTOXSortTabBase>> aSortArrRLHidden;
209 std::vector<SwFormatField*> vFields;
213 const SwTextField* pTextField = pFormatField->GetTextField();
228 pTextNode = &rFieldTextNode;
229 if (pTextNode->
GetText().isEmpty()
235 auto const InsertImpl = [&pIntl, pTextNode, pFormatField]
236 (std::vector<std::unique_ptr<SwTOXSortTabBase>> & rSortArr)
238 std::unique_ptr<SwTOXAuthority> pNew(
241 for (
size_t i = 0;
i < rSortArr.size(); ++
i)
251 rSortArr.erase(rSortArr.begin() +
i);
260 while (j < rSortArr.size())
263 if (pNew->sort_lt(*pOld))
267 rSortArr.insert(rSortArr.begin() + j, std::move(pNew));
270 InsertImpl(aSortArr);
273 InsertImpl(aSortArrRLHidden);
277 for(
auto & pBase : aSortArr)
283 for (
auto & pBase : aSortArrRLHidden)
292 for (std::vector<sal_IntPtr>::size_type
i = 0;
i < rSequArr.size(); ++
i)
294 if (rSequArr[
i] == pAuthEntry)
312 sVal = OUString(uRet);
340 PropertyValue* pValue =
pValues[
i].getArray();
342 pValue[0].Value <<= sal_Int16(pKey->
eField);
363 const sal_Unicode uSet = !sTmp.isEmpty() ? sTmp[0] : 0;
386 css::lang::Locale aLocale;
387 if( rAny >>= aLocale )
394 Sequence<PropertyValues>
aSeq;
403 for(sal_Int32
i = 0;
i < nSize;
i++)
406 for(
const PropertyValue& rValue :
pValues[
i])
410 sal_Int16 nVal = -1; rValue.Value >>= nVal;
433 CallSwClientNotify(rHint);
445 OSL_FAIL(
"Sort key not found");
452 for(sal_uInt16
i = 0;
i < nKeyCount;
i++)
458 std::u16string_view rFieldContents )
460 , m_nTempSequencePos( -1 )
461 , m_nTempSequencePosRLHidden( -1 )
469 , m_xAuthEntry( pAuthEntry )
470 , m_nTempSequencePos( -1 )
471 , m_nTempSequencePosRLHidden( -1 )
495 sal_IntPtr & rnTempSequencePos(pLayout && pLayout->
IsHideRedlines()
499 if (0 <= rnTempSequencePos)
500 sRet += OUString::number(rnTempSequencePos);
516 sRet += OUStringChar(pAuthType->
GetSuffix());
528 sal_IntPtr & rnTempSequencePos(pLayout && pLayout->
IsHideRedlines()
532 if (0 <= rnTempSequencePos)
533 sRet += OUString::number(rnTempSequencePos);
547 return std::make_unique<SwAuthorityField>(pAuthType,
m_xAuthEntry.get());
564 return SwResId(STR_AUTHORITY_ENTRY);
571 std::unique_ptr<SwForm> pDefaultTOX;
575 pTOX = pDefaultTOX.get();
584 if (pIntl->IsNumeric(sText))
592 for (
const auto& rToken : aPattern)
594 switch (rToken.eTokenType)
603 aText += rToken.sText;
617 sTmp = sTmp.copy(0, sTmp.getLength() - 1);
650 GetTargetType() == SwAuthorityField::TargetType::UseDisplayURL
666 std::u16string_view aBaseURIScheme;
667 sal_Int32 nSep = aBaseURL.indexOf(
':');
670 aBaseURIScheme = aBaseURL.subView(0, nSep);
673 uno::Reference<uri::XUriReferenceFactory> xUriReferenceFactory
675 uno::Reference<uri::XUriReference> xUriRef;
678 xUriRef = xUriReferenceFactory->parse(sTmp);
680 catch (
const uno::Exception& rException)
683 "SwTOXAuthority::GetSourceURL: failed to parse url: " << rException.Message);
685 if (xUriRef.is() && xUriRef->getFragment().startsWith(
"page="))
687 xUriRef->clearFragment();
688 sTmp = xUriRef->getUriReference();
693 if (xUriRef.is() && bSaveRelFSys && xUriRef->getScheme() == aBaseURIScheme)
702 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwAuthorityField"));
705 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_xAuthEntry"));
706 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
m_xAuthEntry.get());
711 (void)xmlTextWriterEndElement(pWriter);
712 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_nTempSequencePos"));
713 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"value"),
715 (void)xmlTextWriterEndElement(pWriter);
716 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_nTempSequencePosRLHidden"));
717 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"value"),
719 (void)xmlTextWriterEndElement(pWriter);
721 (void)xmlTextWriterEndElement(pWriter);
727 "BibiliographicType",
764 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwAuthEntry"));
768 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_aAuthField"));
769 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"key"), BAD_CAST(
aFieldNames[
i]));
770 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"value"), BAD_CAST(
m_aAuthFields[
i].toUtf8().getStr()));
771 (void)xmlTextWriterEndElement(pWriter);
774 (void)xmlTextWriterEndElement(pWriter);
784 PropertyValue*
pValues = aRet.getArray();
790 pValues[
i].Value <<= sal_Int16(sField.toInt32());
799static sal_Int32
lcl_Find(std::u16string_view rFieldName)
812 Sequence <PropertyValue> aParam;
813 if(!(rAny >>= aParam))
818 OUString sToSet(sBuf.makeStringAndClear());
819 for(
const PropertyValue& rParam : std::as_const(aParam))
821 const sal_Int32 nFound =
lcl_Find(rParam.Name);
828 rParam.Value >>= nVal;
829 sContent = OUString::number(nVal);
832 rParam.Value >>= sContent;
848 if( pSrcTyp != pDstTyp )
const PropertyValue * pValues
const char *const aFieldNames[]
static sal_Int32 lcl_Find(std::u16string_view rFieldName)
virtual bool IsExpFieldsLocked() const =0
virtual const SwRootFrame * GetCurrentLayout() const =0
static OUString GetAbsURL(std::u16string_view rTheBaseURIRef, OUString const &rTheRelURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
static OUString GetRelURL(std::u16string_view rTheBaseURIRef, OUString const &rTheAbsURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
virtual OUString getDocumentBaseURL() const override
void dumpAsXml(xmlTextWriterPtr pWriter) const
OUString const & GetAuthorField(ToxAuthorityField ePos) const
OUString m_aAuthFields[AUTH_FIELD_END]
bool operator==(const SwAuthEntry &rComp) const
sal_uInt16 GetSequencePos(const SwAuthEntry *pAuthEntry, SwRootFrame const *pLayout)
std::vector< SwAuthEntry * > m_SequArrRLHidden
hidden redlines
std::vector< SwAuthEntry * > m_SequArr
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
const SwTOXSortKey * GetSortKey(sal_uInt16 nIdx) const
sal_Unicode GetPrefix() const
SwAuthEntry * AddField(std::u16string_view rFieldContents)
static OUString const & GetAuthTypeName(ToxAuthorityType eType)
OUString m_sSortAlgorithm
sal_Unicode GetSuffix() const
void RemoveField(const SwAuthEntry *nHandle)
void SetLanguage(LanguageType nLang)
virtual std::unique_ptr< SwFieldType > Copy() const override
virtual ~SwAuthorityFieldType() override
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId) override
std::unique_ptr< SwTOXInternational > CreateTOXInternational() const
SwAuthEntry * AppendField(const SwAuthEntry &rInsert)
appends a new entry (if new) and returns the copied entry
SwAuthorityFieldType(SwDoc *pDoc)
LanguageType GetLanguage() const
bool ChangeEntryContent(const SwAuthEntry *pNewEntry)
sal_uInt16 GetSortKeyCount() const
void SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey const nKeys[])
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const override
void GetAllEntryIdentifiers(std::vector< OUString > &rToFill) const
const OUString & GetSortAlgorithm() const
SwAuthEntry * GetEntryByIdentifier(std::u16string_view rIdentifier) const
void SetSortAlgorithm(const OUString &rSet)
Represents an inserted bibliography entry, created using Insert -> Table of Contents and Index -> Bib...
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId) override
OUString ExpandCitation(ToxAuthorityField eField, SwRootFrame const *pLayout) const
OUString GetRelativeURI() const
Returns relative URI for the URL.
sal_IntPtr m_nTempSequencePos
virtual void SetPar1(const OUString &rStr) override
virtual std::unique_ptr< SwField > Copy() const override
TargetType GetTargetType() const
Returns which target should be used when the entry (the standalone field, such as '[ASDF]',...
const OUString & GetFieldText(ToxAuthorityField eField) const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const override
OUString ConditionalExpandAuthIdentifier(SwRootFrame const *pLayout) const
For internal use only, in general continue using ExpandField() instead.
virtual SwFieldType * ChgTyp(SwFieldType *) override
Set new type (used for copying among documents).
SwAuthorityField(SwAuthorityFieldType *pType, std::u16string_view rFieldContents)
OUString GetAbsoluteURL() const
Returns absolute target URL in case there is one (GetTargetType() should be checked).
virtual ~SwAuthorityField() override
void dumpAsXml(xmlTextWriterPtr pWriter) const override
virtual OUString GetDescription() const override
SwAuthEntry * GetAuthEntry() const
sal_IntPtr m_nTempSequencePosRLHidden
hidden redlines
OUString GetAuthority(const SwRootFrame *pLayout, const SwForm *pTOX=nullptr) const
Returns the line matching the source's default row in the ToX.
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
rtl::Reference< SwAuthEntry > m_xAuthEntry
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
SwDocShell * GetDocShell()
Instances of SwFields and those derived from it occur 0 to n times.
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Base class of all fields.
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
SwFieldType * GetTyp() const
SwNodes & GetNodes()
Node is in which nodes-array/doc?
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
The root element of a Writer document layout.
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
SwTextNode & GetTextNode() const
SwTextNode * GetpTextNode() const
SwTextNode is a paragraph in the document model.
const OUString & GetText() const
struct _xmlTextWriter * xmlTextWriterPtr
const SwTextNode * GetBodyTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwFrame &rFrame)
Forward declaration: get "BodyTextNode" for exp.fld in Fly's headers/footers/footnotes.
LanguageType GetAppLanguage()
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
OUString setToken(const OUString &rIn, sal_Int32 nToken, sal_Unicode cTok, std::u16string_view rNewToken)
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0')
Reference< XComponentContext > getProcessComponentContext()
std::map< sal_Int32, std::shared_ptr< SetItemPropertyStorage > > PropertyValues
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
bool equalsAscii(std::u16string_view s1, std::string_view s2)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
sal_Int32 toInt32(std::u16string_view rStr)
Marks a position in the document model.
Represents one row in the bibliography table.
SwFormatField & GetFieldFormat()
Class for sorting directories.
virtual bool sort_lt(const SwTOXSortTabBase &)
virtual bool equivalent(const SwTOXSortTabBase &)
OUString SwResId(TranslateId aId)
#define TOX_STYLE_DELIMITER
std::vector< SwFormToken > SwFormTokens
Vector of tokens.
@ AUTH_FIELD_AUTHORITY_TYPE
#define FIELD_PROP_PROP_SEQ
#define FIELD_PROP_LOCALE
constexpr OUStringLiteral UNO_NAME_SORT_KEY
constexpr OUStringLiteral UNO_NAME_IS_SORT_ASCENDING