summaryrefslogtreecommitdiff
path: root/sw/inc/textcontentcontrol.hxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-11-08 08:14:41 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-11-08 16:39:03 +0100
commita14b2db9acdae043d54b0e5b8dab881fe9ed3c06 (patch)
tree2e45b0c04e39c82ad075468e73ae718cab7cc525 /sw/inc/textcontentcontrol.hxx
parent657ddc1a8631418f39f587e448954ec47996cf75 (diff)
sw: introduce a manager for content controls
The VBA API for content controls can access e.g. the 3rd content control in the document, see <https://learn.microsoft.com/en-us/office/vba/api/word.contentcontrols>. To support something similar, first we need to track the content controls in the document, otherwise getting the Nth element of that list would require scanning the entire document, which would be slow. SwContentControlManager::m_aContentControls is a plain vector, because an o3tl::sorted_vector would require sorting at insert time, but our content controls are typically first created and only later inserted, and we want to use the insert position as the comparison key when sorting. This just keeps track of content controls (visible in the doc model XML dump), somewhat similar to sw::MetaFieldManager or SwFootnoteIdxs. UNO API to actually expose this is not yet added. (cherry picked from commit ad950f10dc382ea169f94a0c301ca8c424e7103e) Change-Id: I3f75334ffef684afc2c05a1bbdb7f247876d27ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142462 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/inc/textcontentcontrol.hxx')
-rw-r--r--sw/inc/textcontentcontrol.hxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/sw/inc/textcontentcontrol.hxx b/sw/inc/textcontentcontrol.hxx
index 1c445d812099..dc7d210f79a6 100644
--- a/sw/inc/textcontentcontrol.hxx
+++ b/sw/inc/textcontentcontrol.hxx
@@ -20,15 +20,19 @@
#include "txatbase.hxx"
+class SwContentControlManager;
class SwFormatContentControl;
/// SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
class SW_DLLPUBLIC SwTextContentControl final : public SwTextAttrNesting
{
- SwTextContentControl(SwFormatContentControl& rAttr, sal_Int32 nStart, sal_Int32 nEnd);
+ SwContentControlManager* m_pManager;
+
+ SwTextContentControl(SwContentControlManager* pManager, SwFormatContentControl& rAttr,
+ sal_Int32 nStart, sal_Int32 nEnd);
public:
- static SwTextContentControl* CreateTextContentControl(SwTextNode* pTargetTextNode,
+ static SwTextContentControl* CreateTextContentControl(SwDoc& rDoc, SwTextNode* pTargetTextNode,
SwFormatContentControl& rAttr,
sal_Int32 nStart, sal_Int32 nEnd,
bool bIsCopy);
@@ -37,7 +41,22 @@ public:
void ChgTextNode(SwTextNode* pNode);
+ SwTextNode* GetTextNode() const;
+
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
};
+/// Knows all the text content controls in the document.
+class SW_DLLPUBLIC SwContentControlManager
+{
+ /// Non-owning reference to text content controls.
+ std::vector<SwTextContentControl*> m_aContentControls;
+
+public:
+ SwContentControlManager();
+ void Insert(SwTextContentControl* pTextContentControl);
+ void Erase(SwTextContentControl* pTextContentControl);
+ void dumpAsXml(xmlTextWriterPtr pWriter) const;
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */