Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / editeng / unoedprx.hxx
blob475cd158934b98541eb0c1177200fa636b5e1bc3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_EDITENG_UNOEDPRX_HXX
21 #define INCLUDED_EDITENG_UNOEDPRX_HXX
23 #include <config_options.h>
24 #include <memory>
25 #include <svl/SfxBroadcaster.hxx>
26 #include <tools/fontenum.hxx>
27 #include <editeng/unoedsrc.hxx>
29 #include <editeng/editdata.hxx>
30 #include <editeng/editengdllapi.h>
32 class SvxAccessibleTextAdapter final : public SvxTextForwarder
34 public:
35 SvxAccessibleTextAdapter();
36 virtual ~SvxAccessibleTextAdapter() override;
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;
47 sal_Int32 CalcEditEngineIndex( sal_Int32 nPara, sal_Int32 nLogicalIndex );
49 virtual SfxItemState GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const override;
50 virtual SfxItemState GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const override;
52 virtual void QuickInsertText( const OUString& rText, const ESelection& rSel ) override;
53 virtual void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ) override;
54 virtual void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) override;
55 virtual void QuickInsertLineBreak( const ESelection& rSel ) override;
57 virtual SfxItemPool* GetPool() const override;
59 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;
60 virtual void FieldClicked( const SvxFieldItem& rField ) override;
62 virtual bool IsValid() const override;
64 virtual LanguageType GetLanguage( sal_Int32, sal_Int32 ) const override;
65 virtual sal_Int32 GetFieldCount( sal_Int32 nPara ) const override;
66 virtual EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const override;
67 virtual EBulletInfo GetBulletInfo( sal_Int32 nPara ) const override;
68 virtual tools::Rectangle GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const override;
69 virtual tools::Rectangle GetParaBounds( sal_Int32 nPara ) const override;
70 virtual MapMode GetMapMode() const override;
71 virtual OutputDevice* GetRefDevice() const override;
72 virtual bool GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_Int32& nIndex ) const override;
73 virtual bool GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const override;
74 virtual bool GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell = false ) const override;
75 virtual sal_Int32 GetLineCount( sal_Int32 nPara ) const override;
76 virtual sal_Int32 GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const override;
77 virtual void GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const override;
78 virtual sal_Int32 GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const override;
80 virtual bool Delete( const ESelection& ) override;
81 virtual bool InsertText( const OUString&, const ESelection& ) override;
82 virtual bool QuickFormatDoc( bool bFull = false ) override;
83 virtual sal_Int16 GetDepth( sal_Int32 nPara ) const override;
84 virtual bool SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth ) override;
86 virtual const SfxItemSet* GetEmptyItemSetPtr() override;
88 // implementation functions for XParagraphAppend and XTextPortionAppend
89 // (not needed for accessibility, only for new import API)
90 virtual void AppendParagraph() override;
91 virtual sal_Int32 AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet ) override;
93 //XTextCopy
94 virtual void CopyText(const SvxTextForwarder& rSource) override;
96 void SetForwarder( SvxTextForwarder& );
97 bool HaveImageBullet( sal_Int32 nPara ) const;
98 bool HaveTextBullet( sal_Int32 nPara ) const;
100 /** Query whether all text in given selection is editable
102 @return sal_True if every character in the given selection can
103 be changed, and sal_False if e.g. a field or a bullet is
104 contained therein.
106 bool IsEditable( const ESelection& rSelection ) const;
108 private:
109 SvxTextForwarder* mpTextForwarder;
112 class SvxAccessibleTextEditViewAdapter final : public SvxEditViewForwarder
114 public:
116 SvxAccessibleTextEditViewAdapter();
117 virtual ~SvxAccessibleTextEditViewAdapter() override;
119 // SvxViewForwarder interface
120 virtual bool IsValid() const override;
121 virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const override;
122 virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const override;
124 // SvxEditViewForwarder interface
125 virtual bool GetSelection( ESelection& rSelection ) const override;
126 virtual bool SetSelection( const ESelection& rSelection ) override;
127 virtual bool Copy() override;
128 virtual bool Cut() override;
129 virtual bool Paste() override;
131 void SetForwarder( SvxEditViewForwarder&, SvxAccessibleTextAdapter& );
133 private:
134 SvxEditViewForwarder* mpViewForwarder;
135 SvxAccessibleTextAdapter* mpTextForwarder;
138 class UNLESS_MERGELIBS(EDITENG_DLLPUBLIC) SvxEditSourceAdapter final : public SvxEditSource
140 public:
141 SvxEditSourceAdapter();
142 virtual ~SvxEditSourceAdapter() override;
144 virtual std::unique_ptr<SvxEditSource> Clone() const override;
145 virtual SvxTextForwarder* GetTextForwarder() override;
146 SvxAccessibleTextAdapter* GetTextForwarderAdapter(); // covariant return types don't work on MSVC
147 virtual SvxViewForwarder* GetViewForwarder() override;
148 virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate = false ) override;
149 SvxAccessibleTextEditViewAdapter* GetEditViewForwarderAdapter( bool bCreate ); // covariant return types don't work on MSVC
150 virtual void UpdateData() override;
151 virtual SfxBroadcaster& GetBroadcaster() const override;
153 void SetEditSource( ::std::unique_ptr< SvxEditSource > && pAdaptee );
155 bool IsValid() const { return mbEditSourceValid;}
157 private:
158 SvxEditSourceAdapter( const SvxEditSourceAdapter& ) = delete;
159 SvxEditSourceAdapter& operator= ( const SvxEditSourceAdapter& ) = delete;
161 ::std::unique_ptr< SvxEditSource > mpAdaptee;
163 SvxAccessibleTextAdapter maTextAdapter;
164 SvxAccessibleTextEditViewAdapter maEditViewAdapter;
166 mutable SfxBroadcaster maDummyBroadcaster;
168 bool mbEditSourceValid;
171 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */