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 
34 #include <cppuhelper/implbase.hxx>
35 
36 #include <unobaseclass.hxx>
37 
38 typedef std::deque<css::uno::Reference<css::text::XTextRange>> TextRangeList_t;
39 
40 class SwPaM;
41 class SwTextNode;
42 class SwContentControl;
43 
49  : public cppu::WeakImplHelper<css::lang::XUnoTunnel, css::lang::XServiceInfo,
50  css::container::XEnumerationAccess, css::text::XTextContent,
51  css::text::XText, css::beans::XPropertySet>
52 {
53 public:
54  class Impl;
55 
56 protected:
58 
59  void AttachImpl(const css::uno::Reference<css::text::XTextRange>& xTextRange,
60  sal_uInt16 nWhich);
61 
62  ~SwXContentControl() override;
63 
64  SwXContentControl(const SwXContentControl&) = delete;
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 
71  SwXContentControl(SwDoc* pDoc);
72 
73 public:
74  static css::uno::Reference<css::text::XTextContent>
75  CreateXContentControl(SwContentControl& rContentControl,
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 
80  static css::uno::Reference<css::text::XTextContent> CreateXContentControl(SwDoc& rDoc);
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 
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::text::XText > SAL_CALL getText() override
bool SetContentRange(SwTextNode *&rpNode, sal_Int32 &rStart, sal_Int32 &rEnd) const
Initializes params with position of the attribute content (without CH_TXTATR).
The inner part SwXContentControl, which is deleted with a locked SolarMutex.
void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
const css::uno::Reference< css::text::XText > & GetParentText() const
Definition: doc.hxx:187
Stores the properties of a content control.
SwXContentControl(const SwXContentControl &)=delete
std::deque< css::uno::Reference< css::text::XTextRange > > TextRangeList_t
css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
sw::UnoImplPtr< Impl > m_pImpl
void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &Identifier) override
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
void SAL_CALL setString(const OUString &rString) override
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::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
static css::uno::Reference< css::text::XTextContent > 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 >())
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &xTextPosition) override
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
OUString SAL_CALL getString() override
UNO API wrapper around an SwContentControl, exposed as the com.sun.star.text.ContentControl service...
unsigned char sal_Bool
void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
css::uno::Type SAL_CALL getElementType() override
css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
SwXContentControl & operator=(const SwXContentControl &)=delete
void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
void AttachImpl(const css::uno::Reference< css::text::XTextRange > &xTextRange, sal_uInt16 nWhich)
OUString SAL_CALL getImplementationName() override
sal_Bool SAL_CALL hasElements() override
void SAL_CALL dispose() override