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_SOURCE_UIBASE_INC_UNOTXVW_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_UNOTXVW_HXX
22 #include <sfx2/sfxbasecontroller.hxx>
23 #include <comphelper/interfacecontainer3.hxx>
24 #include <com/sun/star/text/XTextViewCursor.hpp>
25 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
26 #include <com/sun/star/text/XTextViewTextRangeSupplier.hpp>
27 #include <com/sun/star/text/XRubySelection.hpp>
28 #include <com/sun/star/view/XFormLayerAccess.hpp>
29 #include <com/sun/star/view/XScreenCursor.hpp>
30 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
31 #include <com/sun/star/view/XSelectionSupplier.hpp>
32 #include <com/sun/star/view/XLineCursor.hpp>
33 #include <com/sun/star/view/XViewCursor.hpp>
34 #include <com/sun/star/text/XPageCursor.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/beans/XPropertySetInfo.hpp>
37 #include <com/sun/star/beans/XPropertyState.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/datatransfer/XTransferableSupplier.hpp>
40 #include <com/sun/star/datatransfer/XTransferableTextSupplier.hpp>
41 #include <com/sun/star/qa/XDumper.hpp>
42 #include <cppuhelper/implbase.hxx>
43 #include <svl/itemprop.hxx>
44 #include <TextCursorHelper.hxx>
45 #include <comphelper/uno3.hxx>
47 #include <sfx2/objsh.hxx>
52 typedef cppu::ImplInheritanceHelper
<
54 css::view::XSelectionSupplier
,
55 css::lang::XServiceInfo
,
56 css::view::XFormLayerAccess
,
57 css::text::XTextViewCursorSupplier
,
58 css::text::XTextViewTextRangeSupplier
,
59 css::text::XRubySelection
,
60 css::view::XViewSettingsSupplier
,
61 css::beans::XPropertySet
,
62 css::datatransfer::XTransferableSupplier
,
63 css::datatransfer::XTransferableTextSupplier
,
64 css::qa::XDumper
> SwXTextView_Base
;
65 class SwXTextView final
: public SwXTextView_Base
67 ::comphelper::OInterfaceContainerHelper3
<css::view::XSelectionChangeListener
> m_SelChangedListeners
;
70 const SfxItemPropertySet
* m_pPropSet
; // property map for SwXTextView properties
71 // (not related to mxViewSettings!)
73 css::uno::Reference
< css::beans::XPropertySet
> mxViewSettings
;
74 css::uno::Reference
< css::text::XTextViewCursor
> mxTextViewCursor
;
76 SdrObject
* GetControl(
77 const css::uno::Reference
< css::awt::XControlModel
> & Model
,
78 css::uno::Reference
< css::awt::XControl
>& xToFill
);
80 virtual ~SwXTextView() override
;
82 SwXTextView(SwView
* pSwView
);
85 virtual css::uno::Any SAL_CALL
getSelection() override
;
86 virtual sal_Bool SAL_CALL
select(const css::uno::Any
& rInterface
) override
;
87 virtual void SAL_CALL
addSelectionChangeListener(const css::uno::Reference
< css::view::XSelectionChangeListener
> & xListener
) override
;
88 virtual void SAL_CALL
removeSelectionChangeListener(const css::uno::Reference
< css::view::XSelectionChangeListener
> & xListener
) override
;
91 virtual css::uno::Reference
< css::form::runtime::XFormController
> SAL_CALL
getFormController( const css::uno::Reference
< css::form::XForm
>& Form
) override
;
92 virtual sal_Bool SAL_CALL
isFormDesignMode( ) override
;
93 virtual void SAL_CALL
setFormDesignMode( sal_Bool DesignMode
) override
;
96 virtual css::uno::Reference
< css::awt::XControl
> SAL_CALL
getControl(const css::uno::Reference
< css::awt::XControlModel
> & Model
) override
;
98 //XTextViewCursorSupplier
99 virtual css::uno::Reference
< css::text::XTextViewCursor
> SAL_CALL
getViewCursor() override
;
101 // XTextViewTextRangeSupplier
102 virtual css::uno::Reference
<css::text::XTextRange
>
103 SAL_CALL
createTextRangeByPixelPosition(const css::awt::Point
& rPixelPosition
) override
;
106 virtual css::uno::Reference
< css::beans::XPropertySet
> SAL_CALL
getViewSettings() override
;
109 virtual css::uno::Sequence
<
110 css::uno::Sequence
< css::beans::PropertyValue
> > SAL_CALL
getRubyList( sal_Bool bAutomatic
) override
;
112 virtual void SAL_CALL
setRubyList(
113 const css::uno::Sequence
<
114 css::uno::Sequence
< css::beans::PropertyValue
> >& RubyList
, sal_Bool bAutomatic
) override
;
117 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
118 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
119 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
120 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
121 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
122 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
123 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
126 virtual OUString SAL_CALL
getImplementationName() override
;
127 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
128 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
130 //XTransferableSupplier
131 virtual css::uno::Reference
< css::datatransfer::XTransferable
> SAL_CALL
getTransferable( ) override
;
132 virtual void SAL_CALL
insertTransferable( const css::uno::Reference
< css::datatransfer::XTransferable
>& xTrans
) override
;
134 // XTransferableTextSupplier
135 virtual css::uno::Reference
<css::datatransfer::XTransferable
> SAL_CALL
getTransferableForTextRange(css::uno::Reference
<css::text::XTextRange
> const& xTextRange
) override
;
138 OUString SAL_CALL
dump(const OUString
& rKind
) override
;
140 void NotifySelChanged();
141 void NotifyDBChanged();
143 SwView
* GetView() {return m_pView
;}
146 // temporary document used for PDF export of selections/multi-selections
147 SfxObjectShellLock
BuildTmpSelectionDoc();
150 typedef cppu::WeakImplHelper
<
151 css::text::XTextViewCursor
,
152 css::lang::XServiceInfo
,
153 css::text::XPageCursor
,
154 css::view::XScreenCursor
,
155 css::view::XViewCursor
,
156 css::view::XLineCursor
,
157 css::beans::XPropertySet
,
158 css::beans::XPropertyState
159 > SwXTextViewCursor_Base
;
161 class SwXTextViewCursor final
: public SwXTextViewCursor_Base
, public OTextCursorHelper
164 const SfxItemPropertySet
* m_pPropSet
;
165 bool IsTextSelection( bool bAllowTables
= true ) const;
166 virtual ~SwXTextViewCursor() override
;
169 SwXTextViewCursor(SwView
* pVw
);
172 virtual sal_Bool SAL_CALL
isVisible() override
;
173 virtual void SAL_CALL
setVisible(sal_Bool bVisible
) override
;
174 virtual css::awt::Point SAL_CALL
getPosition() override
;
177 virtual void SAL_CALL
collapseToStart() override
;
178 virtual void SAL_CALL
collapseToEnd() override
;
179 virtual sal_Bool SAL_CALL
isCollapsed() override
;
180 virtual sal_Bool SAL_CALL
goLeft( sal_Int16 nCount
, sal_Bool bExpand
) override
;
181 virtual sal_Bool SAL_CALL
goRight( sal_Int16 nCount
, sal_Bool bExpand
) override
;
182 virtual void SAL_CALL
gotoStart( sal_Bool bExpand
) override
;
183 virtual void SAL_CALL
gotoEnd( sal_Bool bExpand
) override
;
184 virtual void SAL_CALL
gotoRange( const css::uno::Reference
< css::text::XTextRange
>& xRange
, sal_Bool bExpand
) override
;
187 virtual sal_Bool SAL_CALL
jumpToFirstPage() override
;
188 virtual sal_Bool SAL_CALL
jumpToLastPage() override
;
189 virtual sal_Bool SAL_CALL
jumpToPage(sal_Int16 nPage
) override
;
190 virtual sal_Bool SAL_CALL
jumpToNextPage() override
;
191 virtual sal_Bool SAL_CALL
jumpToPreviousPage() override
;
192 virtual sal_Bool SAL_CALL
jumpToEndOfPage() override
;
193 virtual sal_Bool SAL_CALL
jumpToStartOfPage() override
;
194 virtual sal_Int16 SAL_CALL
getPage() override
;
197 virtual css::uno::Reference
< css::text::XText
> SAL_CALL
getText() override
;
198 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getStart() override
;
199 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getEnd() override
;
200 virtual OUString SAL_CALL
getString() override
;
201 virtual void SAL_CALL
setString(const OUString
& aString
) override
;
204 virtual sal_Bool SAL_CALL
screenDown() override
;
205 virtual sal_Bool SAL_CALL
screenUp() override
;
208 virtual sal_Bool SAL_CALL
goDown(sal_Int16 nCount
, sal_Bool bExpand
) override
;
209 virtual sal_Bool SAL_CALL
goUp(sal_Int16 nCount
, sal_Bool bExpand
) override
;
212 virtual sal_Bool SAL_CALL
isAtStartOfLine() override
;
213 virtual sal_Bool SAL_CALL
isAtEndOfLine() override
;
214 virtual void SAL_CALL
gotoEndOfLine(sal_Bool bExpand
) override
;
215 virtual void SAL_CALL
gotoStartOfLine(sal_Bool bExpand
) override
;
218 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
219 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
220 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
221 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
222 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
223 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
224 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
227 virtual css::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) override
;
228 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
229 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
230 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
233 virtual OUString SAL_CALL
getImplementationName() override
;
234 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
235 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
237 void Invalidate(){m_pView
= nullptr;}
240 virtual const SwPaM
* GetPaM() const override
;
241 virtual SwPaM
* GetPaM() override
;
242 virtual const SwDoc
* GetDoc() const override
;
243 virtual SwDoc
* GetDoc() override
;
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */