26#include <com/sun/star/beans/XPropertyAccess.hpp>
53 const std::map<OUString, OUString>& rArguments)
56 OUString aCommandPrefix;
58 auto it = rArguments.find(
"type");
59 if (it != rArguments.end())
64 it = rArguments.find(
"commandPrefix");
65 if (it != rArguments.end())
67 aCommandPrefix = it->second;
76 auto pFieldmark =
dynamic_cast<sw::mark::IFieldmark*
>(*it);
78 if (pFieldmark->GetFieldname() != aType)
83 auto itParam = pFieldmark->GetParameters()->find(ODF_CODE_PARAM);
84 if (itParam == pFieldmark->GetParameters()->end())
91 if (!
aCommand.startsWith(aCommandPrefix))
97 rJsonWriter.
put(
"type", aType);
98 rJsonWriter.
put(
"command", aCommand);
109 const std::map<OUString, OUString>& rArguments)
112 OUString aCommandPrefix;
113 auto it = rArguments.find(
"type");
114 if (it != rArguments.end())
119 it = rArguments.find(
"commandPrefix");
120 if (it != rArguments.end())
122 aCommandPrefix = it->second;
129 auto typeNode = rJsonWriter.
startNode(
"field");
135 if (pFieldmark->GetFieldname() != aType)
140 auto itParam = pFieldmark->GetParameters()->find(ODF_CODE_PARAM);
141 if (itParam == pFieldmark->GetParameters()->end())
148 if (!
aCommand.startsWith(aCommandPrefix))
153 rJsonWriter.
put(
"type", aType);
154 rJsonWriter.
put(
"command", aCommand);
163 const std::map<OUString, OUString>& rArguments)
165 OUString aNamePrefix;
166 auto it = rArguments.find(
"namePrefix");
167 if (it != rArguments.end())
169 aNamePrefix = it->second;
172 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(pDocShell->
GetModel(),
174 uno::Reference<document::XDocumentProperties> xDP = xDPS->getDocumentProperties();
175 uno::Reference<beans::XPropertyAccess> xUDP(xDP->getUserDefinedProperties(), uno::UNO_QUERY);
176 auto aUDPs = comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(
177 xUDP->getPropertyValues());
179 for (
const auto& rUDP : aUDPs)
181 if (!rUDP.Name.startsWith(aNamePrefix))
186 if (rUDP.Value.getValueTypeClass() != uno::TypeClass_STRING)
192 rUDP.Value >>= aValue;
195 rJsonWriter.
put(
"name", rUDP.Name);
196 rJsonWriter.
put(
"type",
"string");
197 rJsonWriter.
put(
"value", aValue);
207 const std::map<OUString, OUString>& rArguments)
209 OUString aNamePrefix;
211 auto it = rArguments.find(
"namePrefix");
212 if (it != rArguments.end())
214 aNamePrefix = it->second;
223 if (!pMark->
GetName().startsWith(aNamePrefix))
239 const std::map<OUString, OUString>& rArguments)
241 OUString aNamePrefix;
243 auto it = rArguments.find(
"namePrefix");
244 if (it != rArguments.end())
246 aNamePrefix = it->second;
260 if (!pBookmark->
GetName().startsWith(aNamePrefix))
265 rJsonWriter.
put(
"name", pBookmark->
GetName());
275 const std::map<OUString, OUString>& rArguments)
279 auto it = rArguments.find(
"typeName");
280 if (it != rArguments.end())
282 aTypeName = it->second;
286 if (aTypeName !=
"SetRef")
291 OUString aNamePrefix;
293 auto it = rArguments.find(
"namePrefix");
294 if (it != rArguments.end())
296 aNamePrefix = it->second;
302 std::vector<const SwFormatRefMark*> aRefMarks;
308 std::sort(aRefMarks.begin(), aRefMarks.end(),
310 const SwTextRefMark* pTextRefMark1 = pMark1->GetTextRefMark();
311 const SwTextRefMark* pTextRefMark2 = pMark2->GetTextRefMark();
312 SwPosition aPos1(pTextRefMark1->GetTextNode(), pTextRefMark1->GetStart());
313 SwPosition aPos2(pTextRefMark2->GetTextNode(), pTextRefMark2->GetStart());
314 return aPos1 < aPos2;
317 for (
const auto& pRefMark : aRefMarks)
319 if (!pRefMark->GetRefName().startsWith(aNamePrefix))
325 rJsonWriter.
put(
"name", pRefMark->GetRefName());
336 const std::map<OUString, OUString>& rArguments)
340 auto it = rArguments.find(
"typeName");
341 if (it != rArguments.end())
343 aTypeName = it->second;
347 if (aTypeName !=
"SetRef")
352 OUString aNamePrefix;
354 auto it = rArguments.find(
"namePrefix");
355 if (it != rArguments.end())
357 aNamePrefix = it->second;
364 std::vector<SwTextAttr*> aAttrs
373 if (!rRefmark.
GetRefName().startsWith(aNamePrefix))
387 const std::map<OUString, OUString>& rArguments)
389 OUString aNamePrefix;
391 auto it = rArguments.find(
"namePrefix");
392 if (it != rArguments.end())
394 aNamePrefix = it->second;
402 if (!pSection->GetName().startsWith(aNamePrefix))
408 rJsonWriter.
put(
"name", pSection->GetName());
415 static const std::initializer_list<std::u16string_view> vForward
416 = {
u"TextFormFields",
u"TextFormField",
u"SetDocumentProperties",
417 u"Bookmarks",
u"Fields",
u"Sections",
418 u"Bookmark",
u"Field" };
420 return std::find(vForward.begin(), vForward.end(), rCommand) != vForward.end();
425 std::map<OUString, OUString>
aMap;
427 static constexpr OStringLiteral aTextFormFields(
".uno:TextFormFields");
428 static constexpr OStringLiteral aTextFormField(
".uno:TextFormField");
429 static constexpr OStringLiteral aSetDocumentProperties(
".uno:SetDocumentProperties");
430 static constexpr OStringLiteral aBookmarks(
".uno:Bookmarks");
431 static constexpr OStringLiteral aFields(
".uno:Fields");
432 static constexpr OStringLiteral aSections(
".uno:Sections");
433 static constexpr OStringLiteral aBookmark(
".uno:Bookmark");
434 static constexpr OStringLiteral aField(
".uno:Field");
438 sal_Int32 nParamIndex = 0;
453 OUString aDecodedValue
455 aMap[aKey] = aDecodedValue;
456 }
while (nParamIndex >= 0);
PropertiesInfo aProperties
Provides access to the marks of a document.
virtual const_iterator_t getFieldmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of fieldmarks.
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
virtual const_iterator_t getFieldmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of fieldmarks.
virtual sw::mark::IFieldmark * getInnerFieldmarkFor(const SwPosition &pos) const =0
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
virtual sw::mark::IMark * getOneInnermostBookmarkFor(const SwPosition &rPos) const =0
Get the innermost bookmark that contains rPos.
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString GetParam(rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
css::uno::Reference< css::frame::XModel3 > GetModel() const
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
SwDoc * GetDoc()
returns Doc. But be careful!
SwSectionFormats & GetSections()
sal_uInt16 GetRefMarks(std::vector< OUString > *=nullptr) const
IDocumentMarkAccess * getIDocumentMarkAccess()
const SwFormatRefMark * GetRefMark(std::u16string_view rName) const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
const SwPosition * GetPoint() const
SwTextNode is a paragraph in the document model.
std::vector< SwTextAttr * > GetTextAttrsAt(sal_Int32 const nIndex, sal_uInt16 const nWhich) const
get the innermost text attributes covering position nIndex.
Used by the UI to modify the document model.
void getCommandValues(tools::JsonWriter &rJsonWriter, std::string_view rCommand) override
bool supportsCommand(std::u16string_view rCommand) override
virtual const OUString & GetName() const =0
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
Sequence< PropertyValue > aArguments
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)
HashMap_OWString_Interface aMap
Marks a position in the document model.
sal_Int32 GetContentIndex() const