/src/libreoffice/sw/inc/unoframe.hxx
Line | Count | Source |
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 | | #ifndef INCLUDED_SW_INC_UNOFRAME_HXX |
20 | | #define INCLUDED_SW_INC_UNOFRAME_HXX |
21 | | |
22 | | #include "swdllapi.h" |
23 | | #include <com/sun/star/beans/XPropertyState.hpp> |
24 | | #include <com/sun/star/container/XNamed.hpp> |
25 | | #include <com/sun/star/container/XEnumerationAccess.hpp> |
26 | | #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> |
27 | | #include <com/sun/star/text/XTextFrame.hpp> |
28 | | #include <com/sun/star/drawing/XShape.hpp> |
29 | | #include <com/sun/star/util/XModifyListener.hpp> |
30 | | #include <com/sun/star/document/XEventsSupplier.hpp> |
31 | | |
32 | | #include <comphelper/interfacecontainer4.hxx> |
33 | | #include <cppuhelper/implbase.hxx> |
34 | | #include <sal/types.h> |
35 | | #include <svl/listener.hxx> |
36 | | |
37 | | #include "flyenum.hxx" |
38 | | #include "frmfmt.hxx" |
39 | | #include "unotext.hxx" |
40 | | |
41 | | #include <memory> |
42 | | #include <mutex> |
43 | | |
44 | | class SdrObject; |
45 | | class SwDoc; |
46 | | class SwFormat; |
47 | | class SwUnoInternalPaM; |
48 | | class SfxItemPropertySet; |
49 | | class SwXOLEListener; |
50 | | struct SwXParagraphEnumeration; |
51 | | namespace com::sun::star::frame { class XModel; } |
52 | | |
53 | | class BaseFrameProperties_Impl; |
54 | | class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwXFrame : public cppu::WeakImplHelper |
55 | | < |
56 | | css::lang::XServiceInfo, |
57 | | css::beans::XPropertySet, |
58 | | css::beans::XPropertyState, |
59 | | css::drawing::XShape, |
60 | | css::container::XNamed, |
61 | | css::text::XTextContent |
62 | | >, |
63 | | public SvtListener |
64 | | { |
65 | | private: |
66 | | std::mutex m_Mutex; // just for OInterfaceContainerHelper4 |
67 | | ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_EventListeners; |
68 | | SwFrameFormat* m_pFrameFormat; |
69 | | |
70 | | const SfxItemPropertySet* m_pPropSet; |
71 | | SwDoc* m_pDoc; |
72 | | |
73 | | const FlyCntType m_eType; |
74 | | |
75 | | // Descriptor-interface |
76 | | std::unique_ptr<BaseFrameProperties_Impl> m_pProps; |
77 | | bool m_bIsDescriptor; |
78 | | UIName m_sName; |
79 | | |
80 | | sal_Int64 m_nDrawAspect; |
81 | | sal_Int64 m_nVisibleAreaWidth; |
82 | | sal_Int64 m_nVisibleAreaHeight; |
83 | | css::uno::Reference<SwXText> m_xParentText; |
84 | | css::uno::Reference< css::beans::XPropertySet > mxStyleData; |
85 | | css::uno::Reference< css::container::XNameAccess > mxStyleFamily; |
86 | | |
87 | | void DisposeInternal(); |
88 | | |
89 | | protected: |
90 | | virtual void Notify(const SfxHint&) override; |
91 | | |
92 | | virtual ~SwXFrame() override; |
93 | | |
94 | | SwXFrame(FlyCntType eSet, |
95 | | const SfxItemPropertySet* pPropSet, |
96 | | SwDoc *pDoc ); //Descriptor-If |
97 | | SwXFrame(SwFrameFormat& rFrameFormat, FlyCntType eSet, |
98 | | const SfxItemPropertySet* pPropSet); |
99 | | |
100 | | template<class Impl> |
101 | | static rtl::Reference<Impl> |
102 | | CreateXFrame(SwDoc & rDoc, SwFrameFormat *const pFrameFormat); |
103 | | |
104 | | public: |
105 | | |
106 | | //XNamed |
107 | | SW_DLLPUBLIC virtual OUString SAL_CALL getName() override; |
108 | | SW_DLLPUBLIC virtual void SAL_CALL setName(const OUString& Name_) override; |
109 | | |
110 | | //XPropertySet |
111 | | virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; |
112 | | SW_DLLPUBLIC virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; |
113 | | virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; |
114 | | virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; |
115 | | virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; |
116 | | virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; |
117 | | virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; |
118 | | |
119 | | //XPropertyState |
120 | | virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override; |
121 | | virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; |
122 | | virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; |
123 | | virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; |
124 | | |
125 | | //XShape |
126 | | virtual css::awt::Point SAL_CALL getPosition( ) override; |
127 | | virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override; |
128 | | virtual css::awt::Size SAL_CALL getSize( ) override; |
129 | | virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override; |
130 | | |
131 | | //XShapeDescriptor |
132 | | virtual OUString SAL_CALL getShapeType() override; |
133 | | |
134 | | //Base implementation |
135 | | //XComponent |
136 | | virtual void SAL_CALL dispose() override; |
137 | | virtual void SAL_CALL addEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override; |
138 | | virtual void SAL_CALL removeEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override; |
139 | | |
140 | | // XTextContent |
141 | | virtual void SAL_CALL attach(const css::uno::Reference<css::text::XTextRange>& xTextRange) override; |
142 | | virtual css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override; |
143 | | |
144 | | //XServiceInfo |
145 | | virtual OUString SAL_CALL getImplementationName() override; |
146 | | virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; |
147 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
148 | | |
149 | | /// @throws css::lang::IllegalArgumentException |
150 | | /// @throws css::uno::RuntimeException |
151 | | void attachToRange(css::uno::Reference<css::text::XTextRange> const& xTextRange, |
152 | | SwPaM const* pCopySource = nullptr); |
153 | | |
154 | | SW_DLLPUBLIC rtl::Reference< SwXTextRange > getSwAnchor(); |
155 | | |
156 | | const SwFrameFormat* GetFrameFormat() const |
157 | 22.6k | { return m_pFrameFormat; } |
158 | | SwFrameFormat* GetFrameFormat() |
159 | 740k | { return m_pFrameFormat; } |
160 | | |
161 | 0 | FlyCntType GetFlyCntType()const {return m_eType;} |
162 | | |
163 | 620k | bool IsDescriptor() const {return m_bIsDescriptor;} |
164 | | void ResetDescriptor(); |
165 | | static SdrObject *GetOrCreateSdrObject(SwFlyFrameFormat &rFormat); |
166 | | }; |
167 | | |
168 | | typedef cppu::ImplInheritanceHelper |
169 | | < |
170 | | SwXFrame, |
171 | | css::text::XTextFrame, |
172 | | css::container::XEnumerationAccess, |
173 | | css::document::XEventsSupplier |
174 | | > |
175 | | SwXTextFrameBaseClass; |
176 | | |
177 | | class SAL_DLLPUBLIC_RTTI SwXTextFrame final : public SwXTextFrameBaseClass, |
178 | | public SwXText |
179 | | { |
180 | | friend class SwXFrame; // just for CreateXFrame |
181 | | |
182 | | virtual const SwStartNode *GetStartNode() const override; |
183 | | |
184 | | virtual ~SwXTextFrame() override; |
185 | | |
186 | | SwXTextFrame(SwDoc *pDoc); |
187 | | SwXTextFrame(SwFrameFormat& rFormat); |
188 | | |
189 | | public: |
190 | | static SW_DLLPUBLIC rtl::Reference<SwXTextFrame> |
191 | | CreateXTextFrame(SwDoc & rDoc, SwFrameFormat * pFrameFormat); |
192 | | |
193 | | // FIXME: EVIL HACK: make available for SwXFrame::attachToRange |
194 | | using SwXText::SetDoc; |
195 | | |
196 | | virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; |
197 | | virtual SW_DLLPUBLIC void SAL_CALL acquire( ) noexcept override; |
198 | | virtual SW_DLLPUBLIC void SAL_CALL release( ) noexcept override; |
199 | | |
200 | | //XTypeProvider |
201 | | virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; |
202 | | virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; |
203 | | |
204 | | //XTextFrame |
205 | | virtual SW_DLLPUBLIC css::uno::Reference< css::text::XText > SAL_CALL getText() override; |
206 | | |
207 | | //XText |
208 | | virtual rtl::Reference< SwXTextCursor > createXTextCursor() override; |
209 | | virtual rtl::Reference< SwXTextCursor > createXTextCursorByRange( |
210 | | const ::css::uno::Reference< ::css::text::XTextRange >& aTextPosition ) override; |
211 | | |
212 | | //XEnumerationAccess - was: XParagraphEnumerationAccess |
213 | | virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override; |
214 | | |
215 | | //XElementAccess |
216 | | virtual css::uno::Type SAL_CALL getElementType( ) override; |
217 | | virtual sal_Bool SAL_CALL hasElements( ) override; |
218 | | |
219 | | //XTextContent |
220 | | virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override; |
221 | | virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor( ) override final; |
222 | | |
223 | | //XComponent |
224 | | virtual void SAL_CALL dispose( ) override; |
225 | | virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; |
226 | | virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; |
227 | | |
228 | | //XServiceInfo |
229 | | virtual OUString SAL_CALL getImplementationName() override; |
230 | | virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; |
231 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
232 | | |
233 | | // XEventsSupplier |
234 | | virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override; |
235 | | |
236 | | //XPropertySet |
237 | | virtual SW_DLLPUBLIC css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; |
238 | | using SwXFrame::setPropertyValue; |
239 | | |
240 | | SW_DLLPUBLIC rtl::Reference< SwXParagraphEnumeration > createSwEnumeration(); |
241 | | |
242 | | private: |
243 | | rtl::Reference< SwXTextCursor > createXTextCursorByRangeImpl(SwFrameFormat& rFormat, SwUnoInternalPaM& rPam); |
244 | | }; |
245 | | |
246 | | typedef cppu::ImplInheritanceHelper |
247 | | < SwXFrame, |
248 | | css::document::XEventsSupplier |
249 | | > |
250 | | SwXTextGraphicObjectBaseClass; |
251 | | class SW_DLLPUBLIC SwXTextGraphicObject final : public SwXTextGraphicObjectBaseClass |
252 | | { |
253 | | friend class SwXFrame; // just for CreateXFrame |
254 | | |
255 | | virtual ~SwXTextGraphicObject() override; |
256 | | |
257 | | SwXTextGraphicObject( SwDoc *pDoc ); |
258 | | SwXTextGraphicObject(SwFrameFormat& rFormat); |
259 | | |
260 | | public: |
261 | | |
262 | | static rtl::Reference<SwXTextGraphicObject> |
263 | | CreateXTextGraphicObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat); |
264 | | |
265 | | //XServiceInfo |
266 | | virtual OUString SAL_CALL getImplementationName() override; |
267 | | virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; |
268 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
269 | | |
270 | | // XEventsSupplier |
271 | | virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override; |
272 | | }; |
273 | | |
274 | | typedef cppu::ImplInheritanceHelper |
275 | | < SwXFrame, |
276 | | css::document::XEmbeddedObjectSupplier2, |
277 | | css::document::XEventsSupplier |
278 | | > SwXTextEmbeddedObjectBaseClass; |
279 | | |
280 | | class SW_DLLPUBLIC SwXTextEmbeddedObject final : public SwXTextEmbeddedObjectBaseClass |
281 | | { |
282 | | rtl::Reference<SwXOLEListener> m_xOLEListener; |
283 | | |
284 | | friend class SwXFrame; // just for CreateXFrame |
285 | | |
286 | | virtual ~SwXTextEmbeddedObject() override; |
287 | | |
288 | | SwXTextEmbeddedObject( SwDoc *pDoc ); |
289 | | SwXTextEmbeddedObject(SwFrameFormat& rFormat); |
290 | | |
291 | | public: |
292 | | |
293 | | static rtl::Reference<SwXTextEmbeddedObject> |
294 | | CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat); |
295 | | |
296 | | //XEmbeddedObjectSupplier2 |
297 | | virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getEmbeddedObject() override; |
298 | | virtual css::uno::Reference< css::embed::XEmbeddedObject > SAL_CALL getExtendedControlOverEmbeddedObject() override; |
299 | | virtual ::sal_Int64 SAL_CALL getAspect() override; |
300 | | virtual void SAL_CALL setAspect( ::sal_Int64 _aspect ) override; |
301 | | virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getReplacementGraphic() override; |
302 | | |
303 | | //XServiceInfo |
304 | | virtual OUString SAL_CALL getImplementationName() override; |
305 | | virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; |
306 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
307 | | |
308 | | // XEventsSupplier |
309 | | virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override; |
310 | | }; |
311 | | |
312 | | class SwXOLEListener final : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener |
313 | | { |
314 | | SwFormat* m_pOLEFormat; |
315 | | css::uno::Reference<css::frame::XModel> m_xOLEModel; |
316 | | |
317 | | public: |
318 | | SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > xOLE); |
319 | | virtual ~SwXOLEListener() override; |
320 | | |
321 | | // css::lang::XEventListener |
322 | | virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; |
323 | | |
324 | | // css::util::XModifyListener |
325 | | virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; |
326 | | |
327 | | virtual void Notify( const SfxHint& ) override; |
328 | | }; |
329 | | |
330 | | #endif |
331 | | |
332 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |