1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SVX_UNOEDPRX_HXX 25 #define _SVX_UNOEDPRX_HXX 26 27 #include <memory> 28 #include <svl/brdcst.hxx> 29 #include <editeng/unoedsrc.hxx> 30 31 #include <editeng/editdata.hxx> 32 #include "editeng/editengdllapi.h" 33 34 class SvxAccessibleTextAdapter : public SvxTextForwarder 35 { 36 public: 37 SvxAccessibleTextAdapter(); 38 virtual ~SvxAccessibleTextAdapter(); 39 40 virtual sal_uInt32 GetParagraphCount() const; 41 virtual sal_uInt16 GetTextLen( sal_uInt32 nParagraph ) const; 42 virtual String GetText( const ESelection& rSel ) const; 43 virtual SfxItemSet GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib = 0 ) const; 44 virtual SfxItemSet GetParaAttribs( sal_uInt32 nPara ) const; 45 virtual void SetParaAttribs( sal_uInt32 nPara, const SfxItemSet& rSet ); 46 virtual void RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich ); 47 virtual void GetPortions( sal_uInt32 nPara, SvUShorts& rList ) const; 48 49 virtual sal_Int32 CalcLogicalIndex( sal_uInt32 nPara, sal_uInt16 nEEIndex ); 50 virtual sal_uInt16 CalcEditEngineIndex( sal_uInt32 nPara, sal_Int32 nLogicalIndex ); 51 52 virtual sal_uInt16 GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const; 53 virtual sal_uInt16 GetItemState( sal_uInt32 nPara, sal_uInt16 nWhich ) const; 54 55 virtual void QuickInsertText( const String& rText, const ESelection& rSel ); 56 virtual void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ); 57 virtual void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ); 58 virtual void QuickInsertLineBreak( const ESelection& rSel ); 59 60 virtual SfxItemPool* GetPool() const; 61 62 virtual XubString CalcFieldValue( const SvxFieldItem& rField, sal_uInt32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor ); 63 virtual void FieldClicked( const SvxFieldItem& rField, sal_uInt32 nPara, xub_StrLen nPos ); 64 65 virtual sal_Bool IsValid() const; 66 67 virtual LanguageType GetLanguage( sal_uInt32 nPara, sal_uInt16 nIndex ) const; 68 virtual sal_uInt16 GetFieldCount( sal_uInt32 nPara ) const; 69 virtual EFieldInfo GetFieldInfo( sal_uInt32 nPara, sal_uInt16 nField ) const; 70 virtual EBulletInfo GetBulletInfo( sal_uInt32 nPara ) const; 71 virtual Rectangle GetCharBounds( sal_uInt32 nPara, sal_uInt16 nIndex ) const; 72 virtual Rectangle GetParaBounds( sal_uInt32 nPara ) const; 73 virtual MapMode GetMapMode() const; 74 virtual OutputDevice* GetRefDevice() const; 75 virtual sal_Bool GetIndexAtPoint( const Point&, sal_uInt32& nPara, sal_uInt16& nIndex ) const; 76 virtual sal_Bool GetWordIndices( sal_uInt32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const; 77 virtual void SetUpdateModeForAcc( sal_Bool bUp); 78 virtual sal_Bool GetUpdateModeForAcc() const; 79 virtual sal_Bool GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_uInt32 nPara, sal_uInt16 nIndex, sal_Bool bInCell = sal_False ) const; 80 virtual sal_uInt16 GetLineCount( sal_uInt32 nPara ) const; 81 virtual sal_uInt16 GetLineLen( sal_uInt32 nPara, sal_uInt16 nLine ) const; 82 virtual void GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt32 nParagraph, sal_uInt16 nLine ) const; 83 virtual sal_uInt16 GetLineNumberAtIndex( sal_uInt32 nPara, sal_uInt16 nIndex ) const; 84 85 virtual sal_Bool Delete( const ESelection& ); 86 virtual sal_Bool InsertText( const String&, const ESelection& ); 87 virtual sal_Bool QuickFormatDoc( sal_Bool bFull=sal_False ); 88 virtual sal_Int16 GetDepth( sal_uInt32 nPara ) const; 89 virtual sal_Bool SetDepth( sal_uInt32 nPara, sal_Int16 nNewDepth ); 90 91 virtual const SfxItemSet* GetEmptyItemSetPtr(); 92 93 // implementation functions for XParagraphAppend and XTextPortionAppend 94 // (not needed for accessibility, only for new import API) 95 virtual void AppendParagraph(); 96 virtual xub_StrLen AppendTextPortion( sal_uInt32 nPara, const String &rText, const SfxItemSet &rSet ); 97 98 //XTextCopy 99 virtual void CopyText(const SvxTextForwarder& rSource); 100 101 void SetForwarder( SvxTextForwarder& ); 102 sal_Bool HaveImageBullet( sal_uInt32 nPara ) const; 103 sal_Bool HaveTextBullet( sal_uInt32 nPara ) const; 104 105 /** Query whether all text in given selection is editable 106 107 @return sal_True if every character in the given selection can 108 be changed, and sal_False if e.g. a field or a bullet is 109 contained therein. 110 */ 111 sal_Bool IsEditable( const ESelection& rSelection ); 112 113 private: 114 SvxTextForwarder* mrTextForwarder; 115 }; 116 117 class SvxAccessibleTextEditViewAdapter : public SvxEditViewForwarder 118 { 119 public: 120 121 SvxAccessibleTextEditViewAdapter(); 122 virtual ~SvxAccessibleTextEditViewAdapter(); 123 124 // SvxViewForwarder interface 125 virtual sal_Bool IsValid() const; 126 virtual Rectangle GetVisArea() const; 127 virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const; 128 virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const; 129 130 // SvxEditViewForwarder interface 131 virtual sal_Bool GetSelection( ESelection& rSelection ) const; 132 virtual sal_Bool SetSelection( const ESelection& rSelection ); 133 virtual sal_Bool Copy(); 134 virtual sal_Bool Cut(); 135 virtual sal_Bool Paste(); 136 137 void SetForwarder( SvxEditViewForwarder&, SvxAccessibleTextAdapter& ); 138 139 private: 140 SvxEditViewForwarder* mrViewForwarder; 141 SvxAccessibleTextAdapter* mrTextForwarder; 142 }; 143 144 class EDITENG_DLLPUBLIC SvxEditSourceAdapter : public SvxEditSource 145 { 146 public: 147 SvxEditSourceAdapter(); 148 ~SvxEditSourceAdapter(); 149 150 virtual SvxEditSource* Clone() const; 151 virtual SvxTextForwarder* GetTextForwarder(); 152 SvxAccessibleTextAdapter* GetTextForwarderAdapter(); // covariant return types don't work on MSVC 153 virtual SvxViewForwarder* GetViewForwarder(); 154 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False ); 155 SvxAccessibleTextEditViewAdapter* GetEditViewForwarderAdapter( sal_Bool bCreate = sal_False ); // covariant return types don't work on MSVC 156 virtual void UpdateData(); 157 virtual SfxBroadcaster& GetBroadcaster() const; 158 159 void SetEditSource( ::std::auto_ptr< SvxEditSource > pAdaptee ); 160 sal_Bool IsValid() const; 161 162 private: 163 // declared, but not defined 164 SvxEditSourceAdapter( const SvxEditSourceAdapter& ); 165 SvxEditSourceAdapter& operator= ( const SvxEditSourceAdapter& ); 166 167 ::std::auto_ptr< SvxEditSource > mpAdaptee; 168 169 SvxAccessibleTextAdapter maTextAdapter; 170 SvxAccessibleTextEditViewAdapter maEditViewAdapter; 171 172 mutable SfxBroadcaster maDummyBroadcaster; 173 174 sal_Bool mbEditSourceValid; 175 }; 176 177 #endif 178