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/beans/XPropertySet.hpp>
27#include <com/sun/star/container/XChild.hpp>
28#include <com/sun/star/container/XEnumerationAccess.hpp>
29#include <com/sun/star/text/XTextContent.hpp>
30#include <com/sun/star/text/XTextField.hpp>
31#include <com/sun/star/beans/XPropertySet.hpp>
32
34
35#include <unobaseclass.hxx>
36#include <unocoll.hxx>
37
38typedef std::deque<css::uno::Reference<css::text::XTextRange>> TextRangeList_t;
39
40class SwPaM;
41class SwTextNode;
44
50 : public cppu::WeakImplHelper<css::lang::XServiceInfo, css::container::XEnumerationAccess,
51 css::text::XTextContent, css::text::XText,
52 css::beans::XPropertySet>
53{
54 class Impl;
56
57protected:
58 void AttachImpl(const css::uno::Reference<css::text::XTextRange>& xTextRange,
59 sal_uInt16 nWhich);
60
61 ~SwXContentControl() override;
62
65
66 SwXContentControl(SwDoc* pDoc, SwContentControl* pContentControl,
67 const css::uno::Reference<css::text::XText>& xParentText,
68 std::unique_ptr<const TextRangeList_t> pPortions);
69
71
72public:
75 const css::uno::Reference<css::text::XText>& xParentText = nullptr,
76 std::unique_ptr<const TextRangeList_t>&& pPortions
77 = std::unique_ptr<const TextRangeList_t>());
78
80
82 bool SetContentRange(SwTextNode*& rpNode, sal_Int32& rStart, sal_Int32& rEnd) const;
83 const css::uno::Reference<css::text::XText>& GetParentText() const;
84
85 // XServiceInfo
86 OUString SAL_CALL getImplementationName() override;
87 sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
88 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
89
90 // XComponent
91 void SAL_CALL dispose() override;
92 void SAL_CALL
93 addEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
94 void SAL_CALL
95 removeEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
96
97 // XElementAccess
98 css::uno::Type SAL_CALL getElementType() override;
99 sal_Bool SAL_CALL hasElements() override;
100
101 // XEnumerationAccess
102 css::uno::Reference<css::container::XEnumeration> SAL_CALL createEnumeration() override;
103
104 // XTextContent
105 void SAL_CALL attach(const css::uno::Reference<css::text::XTextRange>& xTextRange) override;
106 css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
107
108 // XTextRange
109 css::uno::Reference<css::text::XText> SAL_CALL getText() override;
110 css::uno::Reference<css::text::XTextRange> SAL_CALL getStart() override;
111 css::uno::Reference<css::text::XTextRange> SAL_CALL getEnd() override;
112 OUString SAL_CALL getString() override;
113 void SAL_CALL setString(const OUString& rString) override;
114
115 // XSimpleText
116 css::uno::Reference<css::text::XTextCursor> SAL_CALL createTextCursor() override;
117 css::uno::Reference<css::text::XTextCursor> SAL_CALL createTextCursorByRange(
118 const css::uno::Reference<css::text::XTextRange>& xTextPosition) override;
119 void SAL_CALL insertString(const css::uno::Reference<css::text::XTextRange>& xRange,
120 const OUString& aString, sal_Bool bAbsorb) override;
121 void SAL_CALL insertControlCharacter(const css::uno::Reference<css::text::XTextRange>& xRange,
122 sal_Int16 nControlCharacter, sal_Bool bAbsorb) override;
123
124 // XText
125 void SAL_CALL insertTextContent(const css::uno::Reference<css::text::XTextRange>& xRange,
126 const css::uno::Reference<css::text::XTextContent>& xContent,
127 sal_Bool bAbsorb) override;
128 void SAL_CALL
129 removeTextContent(const css::uno::Reference<css::text::XTextContent>& xContent) override;
130
131 // XPropertySet
132 css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
133 void SAL_CALL setPropertyValue(const OUString& rPropertyName,
134 const css::uno::Any& rValue) override;
135 css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override;
136 void SAL_CALL addPropertyChangeListener(
137 const OUString& rPropertyName,
138 const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override;
139 void SAL_CALL removePropertyChangeListener(
140 const OUString& rPropertyName,
141 const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override;
142 void SAL_CALL addVetoableChangeListener(
143 const OUString& rPropertyName,
144 const css::uno::Reference<css::beans::XVetoableChangeListener>& xListener) override;
145 void SAL_CALL removeVetoableChangeListener(
146 const OUString& rPropertyName,
147 const css::uno::Reference<css::beans::XVetoableChangeListener>& xListener) override;
148};
149
151class SwXContentControls final : public cppu::WeakImplHelper<css::container::XIndexAccess>,
152 public SwUnoCollection
153{
154 ~SwXContentControls() override;
155
156public:
158
159 // XIndexAccess
160 sal_Int32 SAL_CALL getCount() override;
161 css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
162
163 // XElementAccess
164 css::uno::Type SAL_CALL getElementType() override;
165 sal_Bool SAL_CALL hasElements() override;
166};
167
168/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Stores the properties of a content control.
Definition: doc.hxx:197
SfxPoolItem subclass that wraps an SwContentControl.
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
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 >())
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
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