LibreOffice Module editeng (master) 1
unoedprx.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#ifndef INCLUDED_EDITENG_UNOEDPRX_HXX
21#define INCLUDED_EDITENG_UNOEDPRX_HXX
22
23#include <config_options.h>
24#include <memory>
26#include <tools/fontenum.hxx>
27#include <editeng/unoedsrc.hxx>
28
29#include <editeng/editdata.hxx>
31
33{
34public:
36 virtual ~SvxAccessibleTextAdapter() override;
37
38 virtual sal_Int32 GetParagraphCount() const override;
39 virtual sal_Int32 GetTextLen( sal_Int32 nParagraph ) const override;
40 virtual OUString GetText( const ESelection& rSel ) const override;
41 virtual SfxItemSet GetAttribs( const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib = EditEngineAttribs::All ) const override;
42 virtual SfxItemSet GetParaAttribs( sal_Int32 nPara ) const override;
43 virtual void SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) override;
44 virtual void RemoveAttribs( const ESelection& rSelection ) override;
45 virtual void GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const override;
46
47 sal_Int32 CalcEditEngineIndex( sal_Int32 nPara, sal_Int32 nLogicalIndex );
48
49 virtual OUString GetStyleSheet(sal_Int32 nPara) const override;
50 virtual void SetStyleSheet(sal_Int32 nPara, const OUString& rStyleName) override;
51
52 virtual SfxItemState GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const override;
53 virtual SfxItemState GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const override;
54
55 virtual void QuickInsertText( const OUString& rText, const ESelection& rSel ) override;
56 virtual void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ) override;
57 virtual void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) override;
58 virtual void QuickInsertLineBreak( const ESelection& rSel ) override;
59
60 virtual SfxItemPool* GetPool() const override;
61
62 virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor, std::optional<FontLineStyle>& rpFldLineStyle ) override;
63 virtual void FieldClicked( const SvxFieldItem& rField ) override;
64
65 virtual bool IsValid() const override;
66
67 virtual LanguageType GetLanguage( sal_Int32, sal_Int32 ) const override;
68 virtual sal_Int32 GetFieldCount( sal_Int32 nPara ) const override;
69 virtual EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const override;
70 virtual EBulletInfo GetBulletInfo( sal_Int32 nPara ) const override;
71 virtual tools::Rectangle GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const override;
72 virtual tools::Rectangle GetParaBounds( sal_Int32 nPara ) const override;
73 virtual MapMode GetMapMode() const override;
74 virtual OutputDevice* GetRefDevice() const override;
75 virtual bool GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_Int32& nIndex ) const override;
76 virtual bool GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const override;
77 virtual bool GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell = false ) const override;
78 virtual sal_Int32 GetLineCount( sal_Int32 nPara ) const override;
79 virtual sal_Int32 GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const override;
80 virtual void GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const override;
81 virtual sal_Int32 GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const override;
82
83 virtual bool Delete( const ESelection& ) override;
84 virtual bool InsertText( const OUString&, const ESelection& ) override;
85 virtual bool QuickFormatDoc( bool bFull = false ) override;
86 virtual sal_Int16 GetDepth( sal_Int32 nPara ) const override;
87 virtual bool SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth ) override;
88
89 virtual const SfxItemSet* GetEmptyItemSetPtr() override;
90
91 // implementation functions for XParagraphAppend and XTextPortionAppend
92 // (not needed for accessibility, only for new import API)
93 virtual void AppendParagraph() override;
94 virtual sal_Int32 AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet ) override;
95
96 //XTextCopy
97 virtual void CopyText(const SvxTextForwarder& rSource) override;
98
100 bool HaveImageBullet( sal_Int32 nPara ) const;
101 bool HaveTextBullet( sal_Int32 nPara ) const;
102
109 bool IsEditable( const ESelection& rSelection ) const;
110
111private:
113};
114
116{
117public:
118
120 virtual ~SvxAccessibleTextEditViewAdapter() override;
121
122 // SvxViewForwarder interface
123 virtual bool IsValid() const override;
124 virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const override;
125 virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const override;
126
127 // SvxEditViewForwarder interface
128 virtual bool GetSelection( ESelection& rSelection ) const override;
129 virtual bool SetSelection( const ESelection& rSelection ) override;
130 virtual bool Copy() override;
131 virtual bool Cut() override;
132 virtual bool Paste() override;
133
135
136private:
139};
140
141class UNLESS_MERGELIBS(EDITENG_DLLPUBLIC) SvxEditSourceAdapter final : public SvxEditSource
142{
143public:
144 SvxEditSourceAdapter();
145 virtual ~SvxEditSourceAdapter() override;
146
147 virtual std::unique_ptr<SvxEditSource> Clone() const override;
148 virtual SvxTextForwarder* GetTextForwarder() override;
149 SvxAccessibleTextAdapter* GetTextForwarderAdapter(); // covariant return types don't work on MSVC
150 virtual SvxViewForwarder* GetViewForwarder() override;
151 virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate = false ) override;
152 SvxAccessibleTextEditViewAdapter* GetEditViewForwarderAdapter( bool bCreate ); // covariant return types don't work on MSVC
153 virtual void UpdateData() override;
154 virtual SfxBroadcaster& GetBroadcaster() const override;
155
156 void SetEditSource( ::std::unique_ptr< SvxEditSource > && pAdaptee );
157
158 bool IsValid() const { return mbEditSourceValid;}
159
160private:
161 SvxEditSourceAdapter( const SvxEditSourceAdapter& ) = delete;
162 SvxEditSourceAdapter& operator= ( const SvxEditSourceAdapter& ) = delete;
163
164 ::std::unique_ptr< SvxEditSource > mpAdaptee;
165
166 SvxAccessibleTextAdapter maTextAdapter;
167 SvxAccessibleTextEditViewAdapter maEditViewAdapter;
168
169 mutable SfxBroadcaster maDummyBroadcaster;
170
171 bool mbEditSourceValid;
172};
173
174#endif
175
176/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel) override
Definition: unoedprx.cxx:596
virtual bool QuickFormatDoc(bool bFull=false) override
Updates the formatting.
Definition: unoedprx.cxx:1026
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rpTxtColor, std::optional< Color > &rpFldColor, std::optional< FontLineStyle > &rpFldLineStyle) override
Definition: unoedprx.cxx:630
virtual LanguageType GetLanguage(sal_Int32, sal_Int32) const override
Query language of character at given position on the underlying edit engine.
Definition: unoedprx.cxx:663
virtual SfxItemSet GetParaAttribs(sal_Int32 nPara) const override
Definition: unoedprx.cxx:508
virtual bool Delete(const ESelection &) override
Delete given text range and reformat text.
Definition: unoedprx.cxx:1000
virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const override
Definition: unoedprx.cxx:423
virtual void RemoveAttribs(const ESelection &rSelection) override
Definition: unoedprx.cxx:522
virtual void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList) const override
Definition: unoedprx.cxx:526
virtual sal_Int32 GetFieldCount(sal_Int32 nPara) const override
Query number of fields in the underlying edit engine.
Definition: unoedprx.cxx:674
virtual OUString GetText(const ESelection &rSel) const override
Definition: unoedprx.cxx:431
virtual EBulletInfo GetBulletInfo(sal_Int32 nPara) const override
Query information regarding bullets for given paragraph on the underlying edit engine.
Definition: unoedprx.cxx:688
virtual MapMode GetMapMode() const override
Query the map mode of the underlying EditEngine/Outliner.
Definition: unoedprx.cxx:774
virtual SfxItemSet GetAttribs(const ESelection &rSel, EditEngineAttribs nOnlyHardAttrib=EditEngineAttribs::All) const override
Definition: unoedprx.cxx:495
virtual void GetLineBoundaries(sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine) const override
Query bounds of line in paragraph.
Definition: unoedprx.cxx:990
virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &rSet) override
Definition: unoedprx.cxx:515
bool HaveTextBullet(sal_Int32 nPara) const
Definition: unoedprx.cxx:1061
virtual void QuickInsertLineBreak(const ESelection &rSel) override
Definition: unoedprx.cxx:610
bool IsEditable(const ESelection &rSelection) const
Query whether all text in given selection is editable.
Definition: unoedprx.cxx:1070
sal_Int32 CalcEditEngineIndex(sal_Int32 nPara, sal_Int32 nLogicalIndex)
Definition: unoedprx.cxx:644
virtual bool GetWordIndices(sal_Int32 nPara, sal_Int32 nIndex, sal_Int32 &nStart, sal_Int32 &nEnd) const override
Get the start and the end index of the word at the given index.
Definition: unoedprx.cxx:859
virtual void SetStyleSheet(sal_Int32 nPara, const OUString &rStyleName) override
Definition: unoedprx.cxx:540
virtual bool GetIndexAtPoint(const Point &, sal_Int32 &nPara, sal_Int32 &nIndex) const override
Query paragraph and character index of the character at the given point.
Definition: unoedprx.cxx:788
virtual bool InsertText(const OUString &, const ESelection &) override
Insert/Replace given text in given range and reformat text.
Definition: unoedprx.cxx:1013
SvxTextForwarder * mpTextForwarder
Definition: unoedprx.hxx:112
virtual bool GetAttributeRun(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell=false) const override
Query range of similar attributes.
Definition: unoedprx.cxx:909
virtual bool IsValid() const override
Query state of forwarder.
Definition: unoedprx.cxx:653
virtual void FieldClicked(const SvxFieldItem &rField) override
Definition: unoedprx.cxx:637
virtual SfxItemState GetItemState(const ESelection &rSel, sal_uInt16 nWhich) const override
Definition: unoedprx.cxx:547
virtual void AppendParagraph() override
Definition: unoedprx.cxx:1094
virtual bool SetDepth(sal_Int32 nPara, sal_Int16 nNewDepth) override
Set the outline depth of given paragraph.
Definition: unoedprx.cxx:1040
virtual EFieldInfo GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const override
Query information for given field number in the underlying edit engine.
Definition: unoedprx.cxx:681
virtual sal_Int32 GetLineCount(sal_Int32 nPara) const override
Query number of lines in the formatted paragraph.
Definition: unoedprx.cxx:957
virtual tools::Rectangle GetCharBounds(sal_Int32 nPara, sal_Int32 nIndex) const override
Query the bounding rectangle of the given character.
Definition: unoedprx.cxx:695
virtual sal_Int32 AppendTextPortion(sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet) override
Definition: unoedprx.cxx:1099
virtual sal_Int32 GetLineNumberAtIndex(sal_Int32 nPara, sal_Int32 nIndex) const override
Query the line number for an index in the paragraphs text.
Definition: unoedprx.cxx:995
virtual SfxItemPool * GetPool() const override
Definition: unoedprx.cxx:623
virtual sal_Int16 GetDepth(sal_Int32 nPara) const override
Get the outline depth of given paragraph.
Definition: unoedprx.cxx:1033
virtual void CopyText(const SvxTextForwarder &rSource) override
Definition: unoedprx.cxx:1104
virtual tools::Rectangle GetParaBounds(sal_Int32 nPara) const override
Query the bounding rectangle of the given paragraph.
Definition: unoedprx.cxx:753
virtual OutputDevice * GetRefDevice() const override
Query the reference output device of the underlying EditEngine/Outliner.
Definition: unoedprx.cxx:781
virtual OUString GetStyleSheet(sal_Int32 nPara) const override
Definition: unoedprx.cxx:533
virtual sal_Int32 GetParagraphCount() const override
Definition: unoedprx.cxx:416
virtual const SfxItemSet * GetEmptyItemSetPtr() override
Definition: unoedprx.cxx:1088
virtual ~SvxAccessibleTextAdapter() override
Definition: unoedprx.cxx:412
bool HaveImageBullet(sal_Int32 nPara) const
Definition: unoedprx.cxx:1052
void SetForwarder(SvxTextForwarder &)
Definition: unoedprx.cxx:1047
virtual sal_Int32 GetLineLen(sal_Int32 nPara, sal_Int32 nLine) const override
Query line length.
Definition: unoedprx.cxx:964
virtual void QuickInsertText(const OUString &rText, const ESelection &rSel) override
Definition: unoedprx.cxx:568
virtual void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel) override
Definition: unoedprx.cxx:582
virtual Point PixelToLogic(const Point &rPoint, const MapMode &rMapMode) const override
Convert from screen to logical, EditEngine-relative coordinates.
Definition: unoedprx.cxx:1136
void SetForwarder(SvxEditViewForwarder &, SvxAccessibleTextAdapter &)
Definition: unoedprx.cxx:1202
SvxEditViewForwarder * mpViewForwarder
Definition: unoedprx.hxx:137
virtual ~SvxAccessibleTextEditViewAdapter() override
Definition: unoedprx.cxx:1115
virtual bool IsValid() const override
Query state of forwarder.
Definition: unoedprx.cxx:1119
virtual bool Cut() override
Cut current selection to clipboard.
Definition: unoedprx.cxx:1188
virtual Point LogicToPixel(const Point &rPoint, const MapMode &rMapMode) const override
Convert from logical, EditEngine-relative coordinates to screen coordinates.
Definition: unoedprx.cxx:1129
virtual bool Paste() override
Paste clipboard into current selection.
Definition: unoedprx.cxx:1195
virtual bool SetSelection(const ESelection &rSelection) override
Set selection in view.
Definition: unoedprx.cxx:1168
SvxAccessibleTextAdapter * mpTextForwarder
Definition: unoedprx.hxx:138
virtual bool GetSelection(ESelection &rSelection) const override
Query current selection.
Definition: unoedprx.cxx:1143
virtual bool Copy() override
Copy current selection to clipboard.
Definition: unoedprx.cxx:1181
Wrapper class for unified EditEngine/Outliner access.
Definition: unoedsrc.hxx:56
virtual SvxTextForwarder * GetTextForwarder()=0
Query the text forwarder.
virtual void UpdateData()=0
Write back data to model.
virtual std::unique_ptr< SvxEditSource > Clone() const =0
Returns a new reference to the same object. This is a shallow copy.
virtual SvxEditViewForwarder * GetEditViewForwarder(bool bCreate=false)
Query the edit view forwarder.
Definition: unoedsrc.cxx:63
SvxEditSource & operator=(SvxEditSource const &)=default
virtual SvxViewForwarder * GetViewForwarder()
Query the view forwarder.
Definition: unoedsrc.cxx:58
virtual SfxBroadcaster & GetBroadcaster() const
Returns broadcaster the underlying edit engine's events are sent from.
Definition: unoedsrc.cxx:68
Encapsulates EditView and OutlinerView for the purpose of unified EditEngine/Outliner access.
Definition: unoedsrc.hxx:493
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
Contains an EditEngine or an Outliner and unifies access to them.
Definition: unoedsrc.hxx:142
Encapsulates the document view for the purpose of unified EditEngine/Outliner access.
Definition: unoedsrc.hxx:452
EditEngineAttribs
values for: SfxItemSet GetAttribs( const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib = EditEn...
sal_Int32 nIndex
sal_uInt16 nPos
SfxItemState
static SfxItemSet & rSet