make ValueTransfer easier to understand
[LibreOffice.git] / include / editeng / unoedprx.hxx
blobf1db61fe9b63d8f373a5b1a90fa75ade13567a8c
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 <editeng/unoedsrc.hxx>
28 #include <editeng/editdata.hxx>
29 #include <editeng/editengdllapi.h>
31 class SvxAccessibleTextAdapter final : public SvxTextForwarder
33 public:
34 SvxAccessibleTextAdapter();
35 virtual ~SvxAccessibleTextAdapter() override;
37 virtual sal_Int32 GetParagraphCount() const override;
38 virtual sal_Int32 GetTextLen( sal_Int32 nParagraph ) const override;
39 virtual OUString GetText( const ESelection& rSel ) const override;
40 virtual SfxItemSet GetAttribs( const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib = EditEngineAttribs::All ) const override;
41 virtual SfxItemSet GetParaAttribs( sal_Int32 nPara ) const override;
42 virtual void SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) override;
43 virtual void RemoveAttribs( const ESelection& rSelection ) override;
44 virtual void GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const override;
46 sal_Int32 CalcEditEngineIndex( sal_Int32 nPara, sal_Int32 nLogicalIndex );
48 virtual SfxItemState GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const override;
49 virtual SfxItemState GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const override;
51 virtual void QuickInsertText( const OUString& rText, const ESelection& rSel ) override;
52 virtual void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ) override;
53 virtual void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) override;
54 virtual void QuickInsertLineBreak( const ESelection& rSel ) override;
56 virtual SfxItemPool* GetPool() const override;
58 virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor ) override;
59 virtual void FieldClicked( const SvxFieldItem& rField ) override;
61 virtual bool IsValid() const override;
63 virtual LanguageType GetLanguage( sal_Int32, sal_Int32 ) const override;
64 virtual sal_Int32 GetFieldCount( sal_Int32 nPara ) const override;
65 virtual EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const override;
66 virtual EBulletInfo GetBulletInfo( sal_Int32 nPara ) const override;
67 virtual tools::Rectangle GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const override;
68 virtual tools::Rectangle GetParaBounds( sal_Int32 nPara ) const override;
69 virtual MapMode GetMapMode() const override;
70 virtual OutputDevice* GetRefDevice() const override;
71 virtual bool GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_Int32& nIndex ) const override;
72 virtual bool GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const override;
73 virtual bool GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell = false ) const override;
74 virtual sal_Int32 GetLineCount( sal_Int32 nPara ) const override;
75 virtual sal_Int32 GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const override;
76 virtual void GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const override;
77 virtual sal_Int32 GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const override;
79 virtual bool Delete( const ESelection& ) override;
80 virtual bool InsertText( const OUString&, const ESelection& ) override;
81 virtual bool QuickFormatDoc( bool bFull = false ) override;
82 virtual sal_Int16 GetDepth( sal_Int32 nPara ) const override;
83 virtual bool SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth ) override;
85 virtual const SfxItemSet* GetEmptyItemSetPtr() override;
87 // implementation functions for XParagraphAppend and XTextPortionAppend
88 // (not needed for accessibility, only for new import API)
89 virtual void AppendParagraph() override;
90 virtual sal_Int32 AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet ) override;
92 //XTextCopy
93 virtual void CopyText(const SvxTextForwarder& rSource) override;
95 void SetForwarder( SvxTextForwarder& );
96 bool HaveImageBullet( sal_Int32 nPara ) const;
97 bool HaveTextBullet( sal_Int32 nPara ) const;
99 /** Query whether all text in given selection is editable
101 @return sal_True if every character in the given selection can
102 be changed, and sal_False if e.g. a field or a bullet is
103 contained therein.
105 bool IsEditable( const ESelection& rSelection ) const;
107 private:
108 SvxTextForwarder* mpTextForwarder;
111 class SvxAccessibleTextEditViewAdapter final : public SvxEditViewForwarder
113 public:
115 SvxAccessibleTextEditViewAdapter();
116 virtual ~SvxAccessibleTextEditViewAdapter() override;
118 // SvxViewForwarder interface
119 virtual bool IsValid() const override;
120 virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const override;
121 virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const override;
123 // SvxEditViewForwarder interface
124 virtual bool GetSelection( ESelection& rSelection ) const override;
125 virtual bool SetSelection( const ESelection& rSelection ) override;
126 virtual bool Copy() override;
127 virtual bool Cut() override;
128 virtual bool Paste() override;
130 void SetForwarder( SvxEditViewForwarder&, SvxAccessibleTextAdapter& );
132 private:
133 SvxEditViewForwarder* mpViewForwarder;
134 SvxAccessibleTextAdapter* mpTextForwarder;
137 class UNLESS_MERGELIBS(EDITENG_DLLPUBLIC) SvxEditSourceAdapter final : public SvxEditSource
139 public:
140 SvxEditSourceAdapter();
141 virtual ~SvxEditSourceAdapter() override;
143 virtual std::unique_ptr<SvxEditSource> Clone() const override;
144 virtual SvxTextForwarder* GetTextForwarder() override;
145 SvxAccessibleTextAdapter* GetTextForwarderAdapter(); // covariant return types don't work on MSVC
146 virtual SvxViewForwarder* GetViewForwarder() override;
147 virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate = false ) override;
148 SvxAccessibleTextEditViewAdapter* GetEditViewForwarderAdapter( bool bCreate ); // covariant return types don't work on MSVC
149 virtual void UpdateData() override;
150 virtual SfxBroadcaster& GetBroadcaster() const override;
152 void SetEditSource( ::std::unique_ptr< SvxEditSource > && pAdaptee );
154 bool IsValid() const { return mbEditSourceValid;}
156 private:
157 SvxEditSourceAdapter( const SvxEditSourceAdapter& ) = delete;
158 SvxEditSourceAdapter& operator= ( const SvxEditSourceAdapter& ) = delete;
160 ::std::unique_ptr< SvxEditSource > mpAdaptee;
162 SvxAccessibleTextAdapter maTextAdapter;
163 SvxAccessibleTextEditViewAdapter maEditViewAdapter;
165 mutable SfxBroadcaster maDummyBroadcaster;
167 bool mbEditSourceValid;
170 #endif
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */