1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_UNOFRAME_HXX
20 #define INCLUDED_SW_INC_UNOFRAME_HXX
22 #include <com/sun/star/beans/XPropertyState.hpp>
23 #include <com/sun/star/container/XNamed.hpp>
24 #include <com/sun/star/container/XEnumerationAccess.hpp>
25 #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
26 #include <com/sun/star/text/XTextFrame.hpp>
27 #include <com/sun/star/drawing/XShape.hpp>
28 #include <com/sun/star/util/XModifyListener.hpp>
29 #include <com/sun/star/document/XEventsSupplier.hpp>
31 #include <cppuhelper/implbase.hxx>
32 #include <svl/listener.hxx>
34 #include "flyenum.hxx"
36 #include "unotext.hxx"
43 class SfxItemPropertySet
;
44 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XModel
; } } } }
46 class BaseFrameProperties_Impl
;
47 class SwXFrame
: public cppu::WeakImplHelper
49 css::lang::XServiceInfo
,
50 css::lang::XUnoTunnel
,
51 css::beans::XPropertySet
,
52 css::beans::XPropertyState
,
54 css::container::XNamed
,
55 css::text::XTextContent
61 ::sw::UnoImplPtr
<Impl
> m_pImpl
;
62 SwFrameFormat
* m_pFrameFormat
;
64 const SfxItemPropertySet
* m_pPropSet
;
67 const FlyCntType eType
;
69 // Descriptor-interface
70 std::unique_ptr
<BaseFrameProperties_Impl
> m_pProps
;
74 sal_Int64 m_nDrawAspect
;
75 sal_Int64 m_nVisibleAreaWidth
;
76 sal_Int64 m_nVisibleAreaHeight
;
77 css::uno::Reference
<css::text::XText
> m_xParentText
;
78 void DisposeInternal();
81 css::uno::Reference
< css::beans::XPropertySet
> mxStyleData
;
82 css::uno::Reference
< css::container::XNameAccess
> mxStyleFamily
;
83 virtual void Notify(const SfxHint
&) override
;
85 virtual ~SwXFrame() override
;
87 SwXFrame(FlyCntType eSet
,
88 const SfxItemPropertySet
* pPropSet
,
89 SwDoc
*pDoc
); //Descriptor-If
90 SwXFrame(SwFrameFormat
& rFrameFormat
, FlyCntType eSet
,
91 const SfxItemPropertySet
* pPropSet
);
93 template<class Interface
, class Impl
>
94 static css::uno::Reference
<Interface
>
95 CreateXFrame(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
);
98 static const css::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
101 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
105 virtual OUString SAL_CALL
getName() override
;
106 virtual void SAL_CALL
setName(const OUString
& Name_
) override
;
109 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
110 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
111 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
112 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
113 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
114 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
115 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
118 virtual css::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) override
;
119 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
120 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
121 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
124 virtual css::awt::Point SAL_CALL
getPosition( ) override
;
125 virtual void SAL_CALL
setPosition( const css::awt::Point
& aPosition
) override
;
126 virtual css::awt::Size SAL_CALL
getSize( ) override
;
127 virtual void SAL_CALL
setSize( const css::awt::Size
& aSize
) override
;
130 virtual OUString SAL_CALL
getShapeType() override
;
132 //Base implementation
134 virtual void SAL_CALL
dispose() override
;
135 virtual void SAL_CALL
addEventListener(const css::uno::Reference
<css::lang::XEventListener
>& xListener
) override
;
136 virtual void SAL_CALL
removeEventListener(const css::uno::Reference
<css::lang::XEventListener
>& xListener
) override
;
139 virtual void SAL_CALL
attach(const css::uno::Reference
<css::text::XTextRange
>& xTextRange
) override
;
140 virtual css::uno::Reference
<css::text::XTextRange
> SAL_CALL
getAnchor() override
;
143 virtual OUString SAL_CALL
getImplementationName() override
;
144 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
145 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
147 /// @throws css::lang::IllegalArgumentException
148 /// @throws css::uno::RuntimeException
149 void attachToRange(css::uno::Reference
<css::text::XTextRange
> const& xTextRange
,
150 SwPaM
const* pCopySource
= nullptr);
152 const SwFrameFormat
* GetFrameFormat() const
153 { return m_pFrameFormat
; }
154 SwFrameFormat
* GetFrameFormat()
155 { return m_pFrameFormat
; }
157 FlyCntType
GetFlyCntType()const {return eType
;}
159 bool IsDescriptor() const {return bIsDescriptor
;}
160 void ResetDescriptor();
161 //copy text from a given source PaM
162 void SetSelection(SwPaM
& rCopySource
);
163 static SdrObject
*GetOrCreateSdrObject(SwFlyFrameFormat
&rFormat
);
166 typedef cppu::WeakImplHelper
168 css::text::XTextFrame
,
169 css::container::XEnumerationAccess
,
170 css::document::XEventsSupplier
172 SwXTextFrameBaseClass
;
174 class SwXTextFrame final
: public SwXTextFrameBaseClass
,
178 friend class SwXFrame
; // just for CreateXFrame
180 virtual const SwStartNode
*GetStartNode() const override
;
182 virtual css::uno::Reference
< css::text::XTextCursor
>
183 CreateCursor() override
;
185 virtual ~SwXTextFrame() override
;
187 SwXTextFrame(SwDoc
*pDoc
);
188 SwXTextFrame(SwFrameFormat
& rFormat
);
191 static SW_DLLPUBLIC
css::uno::Reference
<css::text::XTextFrame
>
192 CreateXTextFrame(SwDoc
& rDoc
, SwFrameFormat
* pFrameFormat
);
194 // FIXME: EVIL HACK: make available for SwXFrame::attachToRange
195 using SwXText::SetDoc
;
197 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
198 virtual void SAL_CALL
acquire( ) throw() override
;
199 virtual void SAL_CALL
release( ) throw() override
;
202 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
203 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) override
;
206 virtual css::uno::Reference
< css::text::XText
> SAL_CALL
getText() override
;
209 virtual css::uno::Reference
< css::text::XTextCursor
> SAL_CALL
createTextCursor() override
;
210 virtual css::uno::Reference
< css::text::XTextCursor
> SAL_CALL
createTextCursorByRange(const css::uno::Reference
< css::text::XTextRange
> & aTextPosition
) override
;
212 //XEnumerationAccess - frueher XParagraphEnumerationAccess
213 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration() override
;
216 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
217 virtual sal_Bool SAL_CALL
hasElements( ) override
;
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
;
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
;
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
;
234 virtual css::uno::Reference
< css::container::XNameReplace
> SAL_CALL
getEvents( ) override
;
237 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
240 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
243 typedef cppu::ImplInheritanceHelper
245 css::document::XEventsSupplier
247 SwXTextGraphicObjectBaseClass
;
248 class SwXTextGraphicObject final
: public SwXTextGraphicObjectBaseClass
250 friend class SwXFrame
; // just for CreateXFrame
252 virtual ~SwXTextGraphicObject() override
;
254 SwXTextGraphicObject( SwDoc
*pDoc
);
255 SwXTextGraphicObject(SwFrameFormat
& rFormat
);
259 static css::uno::Reference
<css::text::XTextContent
>
260 CreateXTextGraphicObject(SwDoc
& rDoc
, SwFrameFormat
* pFrameFormat
);
263 virtual OUString SAL_CALL
getImplementationName() override
;
264 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
265 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
268 virtual css::uno::Reference
< css::container::XNameReplace
> SAL_CALL
getEvents( ) override
;
271 typedef cppu::ImplInheritanceHelper
273 css::document::XEmbeddedObjectSupplier2
,
274 css::document::XEventsSupplier
275 > SwXTextEmbeddedObjectBaseClass
;
277 class SwXTextEmbeddedObject final
: public SwXTextEmbeddedObjectBaseClass
279 css::uno::Reference
<css::util::XModifyListener
> m_xOLEListener
;
281 friend class SwXFrame
; // just for CreateXFrame
283 virtual ~SwXTextEmbeddedObject() override
;
285 SwXTextEmbeddedObject( SwDoc
*pDoc
);
286 SwXTextEmbeddedObject(SwFrameFormat
& rFormat
);
290 static css::uno::Reference
<css::text::XTextContent
>
291 CreateXTextEmbeddedObject(SwDoc
& rDoc
, SwFrameFormat
* pFrameFormat
);
293 //XEmbeddedObjectSupplier2
294 virtual css::uno::Reference
< css::lang::XComponent
> SAL_CALL
getEmbeddedObject() override
;
295 virtual css::uno::Reference
< css::embed::XEmbeddedObject
> SAL_CALL
getExtendedControlOverEmbeddedObject() override
;
296 virtual ::sal_Int64 SAL_CALL
getAspect() override
;
297 virtual void SAL_CALL
setAspect( ::sal_Int64 _aspect
) override
;
298 virtual css::uno::Reference
< css::graphic::XGraphic
> SAL_CALL
getReplacementGraphic() override
;
301 virtual OUString SAL_CALL
getImplementationName() override
;
302 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
303 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
306 virtual css::uno::Reference
< css::container::XNameReplace
> SAL_CALL
getEvents( ) override
;
309 class SwXOLEListener final
: public cppu::WeakImplHelper
<css::util::XModifyListener
>, public SvtListener
311 SwFormat
* m_pOLEFormat
;
312 css::uno::Reference
<css::frame::XModel
> m_xOLEModel
;
315 SwXOLEListener(SwFormat
& rOLEFormat
, css::uno::Reference
< css::frame::XModel
> const & xOLE
);
316 virtual ~SwXOLEListener() override
;
318 // css::lang::XEventListener
319 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
321 // css::util::XModifyListener
322 virtual void SAL_CALL
modified( const css::lang::EventObject
& aEvent
) override
;
324 virtual void Notify( const SfxHint
& ) override
;
329 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */