Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/inc/unotxvw.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_SOURCE_UIBASE_INC_UNOTXVW_HXX
20
#define INCLUDED_SW_SOURCE_UIBASE_INC_UNOTXVW_HXX
21
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>
46
47
#include <sfx2/objsh.hxx>
48
49
class SdrObject;
50
class SwView;
51
class SwXViewSettings;
52
class SwXTextViewCursor;
53
54
typedef cppu::ImplInheritanceHelper<
55
            SfxBaseController,
56
            css::view::XSelectionSupplier,
57
            css::lang::XServiceInfo,
58
            css::view::XFormLayerAccess,
59
            css::text::XTextViewCursorSupplier,
60
            css::text::XTextViewTextRangeSupplier,
61
            css::text::XRubySelection,
62
            css::view::XViewSettingsSupplier,
63
            css::beans::XPropertySet,
64
            css::datatransfer::XTransferableSupplier,
65
            css::datatransfer::XTransferableTextSupplier,
66
            css::qa::XDumper> SwXTextView_Base;
67
class SwXTextView final : public SwXTextView_Base
68
{
69
    ::comphelper::OInterfaceContainerHelper3<css::view::XSelectionChangeListener> m_SelChangedListeners;
70
71
    SwView*                     m_pView;
72
    const SfxItemPropertySet*   m_pPropSet;   // property map for SwXTextView properties
73
                                        // (not related to mxViewSettings!)
74
75
    rtl::Reference< SwXViewSettings >     mxViewSettings;
76
    rtl::Reference< SwXTextViewCursor >   mxTextViewCursor;
77
78
    SdrObject* GetControl(
79
        const css::uno::Reference< css::awt::XControlModel > & Model,
80
        css::uno::Reference< css::awt::XControl >& xToFill  );
81
82
    virtual ~SwXTextView() override;
83
public:
84
    SwXTextView(SwView* pSwView);
85
86
    //XSelectionSupplier
87
    virtual css::uno::Any SAL_CALL getSelection() override;
88
    virtual sal_Bool SAL_CALL select(const css::uno::Any& rInterface) override;
89
    virtual void SAL_CALL addSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > & xListener) override;
90
    virtual void SAL_CALL removeSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > & xListener) override;
91
92
    // XFormLayerAccess
93
    virtual css::uno::Reference< css::form::runtime::XFormController > SAL_CALL getFormController( const css::uno::Reference< css::form::XForm >& Form ) override;
94
    virtual sal_Bool SAL_CALL isFormDesignMode(  ) override;
95
    virtual void SAL_CALL setFormDesignMode( sal_Bool DesignMode ) override;
96
97
    // XControlAccess
98
    virtual css::uno::Reference< css::awt::XControl >  SAL_CALL getControl(const css::uno::Reference< css::awt::XControlModel > & Model) override;
99
100
    //XTextViewCursorSupplier
101
    virtual css::uno::Reference< css::text::XTextViewCursor >  SAL_CALL getViewCursor() override;
102
103
    // XTextViewTextRangeSupplier
104
    virtual css::uno::Reference<css::text::XTextRange>
105
        SAL_CALL createTextRangeByPixelPosition(const css::awt::Point& rPixelPosition) override;
106
107
    //XViewSettings
108
    virtual css::uno::Reference< css::beans::XPropertySet >  SAL_CALL getViewSettings() override;
109
110
    //XRubySelection
111
    virtual css::uno::Sequence<
112
            css::uno::Sequence< css::beans::PropertyValue > > SAL_CALL getRubyList( sal_Bool bAutomatic ) override;
113
114
    virtual void SAL_CALL setRubyList(
115
        const css::uno::Sequence<
116
        css::uno::Sequence< css::beans::PropertyValue > >& RubyList, sal_Bool bAutomatic ) override;
117
118
    //XPropertySet
119
    virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) override;
120
    virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
121
    virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
122
    virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
123
    virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
124
    virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
125
    virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
126
127
    //XServiceInfo
128
    virtual OUString SAL_CALL getImplementationName() override;
129
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
130
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
131
132
    //XTransferableSupplier
133
    virtual css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getTransferable(  ) override;
134
    virtual void SAL_CALL insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans ) override;
135
136
    // XTransferableTextSupplier
137
    virtual css::uno::Reference<css::datatransfer::XTransferable> SAL_CALL getTransferableForTextRange(css::uno::Reference<css::text::XTextRange> const& xTextRange) override;
138
139
    // XDumper
140
    OUString SAL_CALL dump(const OUString& rKind) override;
141
142
    void                    NotifySelChanged();
143
    void                    NotifyDBChanged();
144
145
0
    SwView*                 GetView() {return m_pView;}
146
    void                    Invalidate();
147
148
    // temporary document used for PDF export of selections/multi-selections
149
    SfxObjectShellLock      BuildTmpSelectionDoc();
150
};
151
152
typedef cppu::ImplInheritanceHelper<
153
                            OTextCursorHelper,
154
                            css::text::XTextViewCursor,
155
                            css::lang::XServiceInfo,
156
                            css::text::XPageCursor,
157
                            css::view::XScreenCursor,
158
                            css::view::XViewCursor,
159
                            css::view::XLineCursor,
160
                            css::beans::XPropertyState
161
                            > SwXTextViewCursor_Base;
162
163
class SwXTextViewCursor final: public SwXTextViewCursor_Base
164
{
165
    SwView*                         m_pView;
166
    const SfxItemPropertySet*       m_pPropSet;
167
    bool        IsTextSelection( bool bAllowTables = true ) const;
168
    virtual     ~SwXTextViewCursor() override;
169
170
public:
171
    SwXTextViewCursor(SwView* pVw);
172
173
    //XTextViewCursor
174
    virtual sal_Bool SAL_CALL isVisible() override;
175
    virtual void SAL_CALL setVisible(sal_Bool bVisible) override;
176
    virtual css::awt::Point SAL_CALL getPosition() override;
177
178
    //XTextCursor - new
179
    virtual void SAL_CALL collapseToStart() override;
180
    virtual void SAL_CALL collapseToEnd() override;
181
    virtual sal_Bool SAL_CALL isCollapsed() override;
182
    virtual sal_Bool SAL_CALL goLeft( sal_Int16 nCount, sal_Bool bExpand ) override;
183
    virtual sal_Bool SAL_CALL goRight( sal_Int16 nCount, sal_Bool bExpand ) override;
184
    virtual void SAL_CALL gotoStart( sal_Bool bExpand ) override;
185
    virtual void SAL_CALL gotoEnd( sal_Bool bExpand ) override;
186
    virtual void SAL_CALL gotoRange( const css::uno::Reference< css::text::XTextRange >& xRange, sal_Bool bExpand ) override;
187
188
    //XPageCursor
189
    virtual sal_Bool SAL_CALL jumpToFirstPage() override;
190
    virtual sal_Bool SAL_CALL jumpToLastPage() override;
191
    virtual sal_Bool SAL_CALL jumpToPage(sal_Int16 nPage) override;
192
    virtual sal_Bool SAL_CALL jumpToNextPage() override;
193
    virtual sal_Bool SAL_CALL jumpToPreviousPage() override;
194
    virtual sal_Bool SAL_CALL jumpToEndOfPage() override;
195
    virtual sal_Bool SAL_CALL jumpToStartOfPage() override;
196
    virtual sal_Int16 SAL_CALL getPage() override;
197
198
    //XTextRange
199
    virtual css::uno::Reference< css::text::XText >  SAL_CALL getText() override;
200
    virtual css::uno::Reference< css::text::XTextRange > SAL_CALL  getStart() override;
201
    virtual css::uno::Reference< css::text::XTextRange > SAL_CALL   getEnd() override;
202
    virtual OUString SAL_CALL  getString() override;
203
    virtual void SAL_CALL  setString(const OUString& aString) override;
204
205
    //XScreenCursor
206
    virtual sal_Bool SAL_CALL screenDown() override;
207
    virtual sal_Bool SAL_CALL screenUp() override;
208
209
    //XViewCursor
210
    virtual sal_Bool SAL_CALL goDown(sal_Int16 nCount, sal_Bool bExpand) override;
211
    virtual sal_Bool SAL_CALL goUp(sal_Int16 nCount, sal_Bool bExpand) override;
212
213
    //XLineCursor
214
    virtual sal_Bool SAL_CALL isAtStartOfLine() override;
215
    virtual sal_Bool SAL_CALL isAtEndOfLine() override;
216
    virtual void SAL_CALL gotoEndOfLine(sal_Bool bExpand) override;
217
    virtual void SAL_CALL gotoStartOfLine(sal_Bool bExpand) override;
218
219
    //XPropertySet
220
    virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) override;
221
    virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
222
    virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
223
    virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
224
    virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
225
    virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
226
    virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
227
228
    //XPropertyState
229
    virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
230
    virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
231
    virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
232
    virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
233
234
    //XServiceInfo
235
    virtual OUString SAL_CALL getImplementationName() override;
236
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
237
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
238
239
0
    void    Invalidate(){m_pView = nullptr;}
240
241
    // ITextCursorHelper
242
    virtual const SwPaM*        GetPaM() const override;
243
    virtual SwPaM*              GetPaM() override;
244
    virtual const SwDoc*        GetDoc() const override;
245
    virtual SwDoc*              GetDoc() override;
246
};
247
248
#endif
249
250
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */