LibreOffice Module sw (master) 1
unocontentcontrol.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <memory>
23#include <deque>
24
25#include <com/sun/star/lang/XServiceInfo.hpp>
26#include <com/sun/star/lang/XUnoTunnel.hpp>
27#include <com/sun/star/beans/XPropertySet.hpp>
28#include <com/sun/star/container/XChild.hpp>
29#include <com/sun/star/container/XEnumerationAccess.hpp>
30#include <com/sun/star/text/XTextContent.hpp>
31#include <com/sun/star/text/XTextField.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
33
35
36#include <unobaseclass.hxx>
37#include <unocoll.hxx>
38
39typedef std::deque<css::uno::Reference<css::text::XTextRange>> TextRangeList_t;
40
41class SwPaM;
42class SwTextNode;
45
51 : public cppu::WeakImplHelper<css::lang::XUnoTunnel, css::lang::XServiceInfo,
52 css::container::XEnumerationAccess, css::text::XTextContent,
53 css::text::XText, css::beans::XPropertySet>
54{
55 class Impl;
57
58protected:
59 void AttachImpl(const css::uno::Reference<css::text::XTextRange>& xTextRange,
60 sal_uInt16 nWhich);
61
62 ~SwXContentControl() override;
63
66
67 SwXContentControl(SwDoc* pDoc, SwContentControl* pContentControl,
68 const css::uno::Reference<css::text::XText>& xParentText,
69 std::unique_ptr<const TextRangeList_t> pPortions);
70
72
73public:
76 const css::uno::Reference<css::text::XText>& xParentText = nullptr,
77 std::unique_ptr<const TextRangeList_t>&& pPortions
78 = std::unique_ptr<const TextRangeList_t>());
79
81
83 bool SetContentRange(SwTextNode*& rpNode, sal_Int32& rStart, sal_Int32& rEnd) const;
84 const css::uno::Reference<css::text::XText>& GetParentText() const;
85
86 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
87
88 // XUnoTunnel
89 sal_Int64 SAL_CALL getSomething(const css::uno::Sequence<sal_Int8>& Identifier) override;
90
91 // XServiceInfo
92 OUString SAL_CALL getImplementationName() override;
93 sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
94 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
95
96 // XComponent
97 void SAL_CALL dispose() override;
98 void SAL_CALL
99 addEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
100 void SAL_CALL
101 removeEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
102
103 // XElementAccess
104 css::uno::Type SAL_CALL getElementType() override;
105 sal_Bool SAL_CALL hasElements() override;
106
107 // XEnumerationAccess
108 css::uno::Reference<css::container::XEnumeration> SAL_CALL createEnumeration() override;
109
110 // XTextContent
111 void SAL_CALL attach(const css::uno::Reference<css::text::XTextRange>& xTextRange) override;
112 css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
113
114 // XTextRange
115 css::uno::Reference<css::text::XText> SAL_CALL getText() override;
116 css::uno::Reference<css::text::XTextRange> SAL_CALL getStart() override;
117 css::uno::Reference<css::text::XTextRange> SAL_CALL getEnd() override;
118 OUString SAL_CALL getString() override;
119 void SAL_CALL setString(const OUString& rString) override;
120
121 // XSimpleText
122 css::uno::Reference<css::text::XTextCursor> SAL_CALL createTextCursor() override;
123 css::uno::Reference<css::text::XTextCursor> SAL_CALL createTextCursorByRange(
124 const css::uno::Reference<css::text::XTextRange>& xTextPosition) override;
125 void SAL_CALL insertString(const css::uno::Reference<css::text::XTextRange>& xRange,
126 const OUString& aString, sal_Bool bAbsorb) override;
127 void SAL_CALL insertControlCharacter(const css::uno::Reference<css::text::XTextRange>& xRange,
128 sal_Int16 nControlCharacter, sal_Bool bAbsorb) override;
129
130 // XText
131 void SAL_CALL insertTextContent(const css::uno::Reference<css::text::XTextRange>& xRange,
132 const css::uno::Reference<css::text::XTextContent>& xContent,
133 sal_Bool bAbsorb) override;
134 void SAL_CALL
135 removeTextContent(const css::uno::Reference<css::text::XTextContent>& xContent) override;
136
137 // XPropertySet
138 css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
139 void SAL_CALL setPropertyValue(const OUString& rPropertyName,
140 const css::uno::Any& rValue) override;
141 css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override;
142 void SAL_CALL addPropertyChangeListener(
143 const OUString& rPropertyName,
144 const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override;
145 void SAL_CALL removePropertyChangeListener(
146 const OUString& rPropertyName,
147 const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override;
148 void SAL_CALL addVetoableChangeListener(
149 const OUString& rPropertyName,
150 const css::uno::Reference<css::beans::XVetoableChangeListener>& xListener) override;
151 void SAL_CALL removeVetoableChangeListener(
152 const OUString& rPropertyName,
153 const css::uno::Reference<css::beans::XVetoableChangeListener>& xListener) override;
154};
155
157class SwXContentControls final : public cppu::WeakImplHelper<css::container::XIndexAccess>,
158 public SwUnoCollection
159{
160 ~SwXContentControls() override;
161
162public:
164
165 // XIndexAccess
166 sal_Int32 SAL_CALL getCount() override;
167 css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
168
169 // XElementAccess
170 css::uno::Type SAL_CALL getElementType() override;
171 sal_Bool SAL_CALL hasElements() override;
172};
173
174/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Stores the properties of a content control.
Definition: doc.hxx:194
SfxPoolItem subclass that wraps an SwContentControl.
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
The inner part SwXContentControl, which is deleted with a locked SolarMutex.
UNO API wrapper around an SwContentControl, exposed as the com.sun.star.text.ContentControl service.
void SAL_CALL setString(const OUString &rString) override
SwXContentControl(SwDoc *pDoc, SwContentControl *pContentControl, const css::uno::Reference< css::text::XText > &xParentText, std::unique_ptr< const TextRangeList_t > pPortions)
void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &xTextPosition) override
void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
void SAL_CALL dispose() override
css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
static rtl::Reference< SwXContentControl > CreateXContentControl(SwContentControl &rContentControl, const css::uno::Reference< css::text::XText > &xParentText=nullptr, std::unique_ptr< const TextRangeList_t > &&pPortions=std::unique_ptr< const TextRangeList_t >())
sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &Identifier) override
void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
sal_Bool SAL_CALL hasElements() override
void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
SwXContentControl(const SwXContentControl &)=delete
void SAL_CALL insertTextContent(const css::uno::Reference< css::text::XTextRange > &xRange, const css::uno::Reference< css::text::XTextContent > &xContent, sal_Bool bAbsorb) override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
css::uno::Reference< css::text::XText > SAL_CALL getText() override
void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
bool SetContentRange(SwTextNode *&rpNode, sal_Int32 &rStart, sal_Int32 &rEnd) const
Initializes params with position of the attribute content (without CH_TXTATR).
css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
const css::uno::Reference< css::text::XText > & GetParentText() const
void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
css::uno::Type SAL_CALL getElementType() override
void AttachImpl(const css::uno::Reference< css::text::XTextRange > &xTextRange, sal_uInt16 nWhich)
sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
sw::UnoImplPtr< Impl > m_pImpl
void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
OUString SAL_CALL getString() override
SwXContentControl & operator=(const SwXContentControl &)=delete
css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
UNO wrapper around SwContentControlManager.
css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
sal_Bool SAL_CALL hasElements() override
SwXContentControls(SwDoc *pDoc)
css::uno::Type SAL_CALL getElementType() override
sal_Int32 SAL_CALL getCount() override
sal_Int32 nIndex
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
unsigned char sal_Bool
std::deque< css::uno::Reference< css::text::XTextRange > > TextRangeList_t