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_UNOEDHLP_HXX 25 #define _SVX_UNOEDHLP_HXX 26 27 #include <memory> 28 #include <tools/solar.h> 29 #include <svtools/textdata.hxx> 30 #include <svl/hint.hxx> 31 #include <tools/gen.hxx> 32 #include "editeng/editengdllapi.h" 33 34 struct EENotify; 35 class EditEngine; 36 37 #define EDITSOURCE_HINT_PARASMOVED 20 38 #define EDITSOURCE_HINT_SELECTIONCHANGED 21 39 40 /** Extends TextHint by two additional parameters which are necessary 41 for the EDITSOURCE_HINT_PARASMOVED hint. TextHint's value in this 42 case denotes the destination position, the two parameters the 43 start and the end of the moved paragraph range. 44 */ 45 class EDITENG_DLLPUBLIC SvxEditSourceHint : public TextHint 46 { 47 private: 48 sal_uLong mnStart; 49 sal_uLong mnEnd; 50 51 public: 52 TYPEINFO(); 53 SvxEditSourceHint( sal_uLong nId ); 54 SvxEditSourceHint( sal_uLong nId, sal_uLong nValue, sal_uLong nStart=0, sal_uLong nEnd=0 ); 55 56 sal_uLong GetValue() const; 57 sal_uLong GetStartValue() const; 58 sal_uLong GetEndValue() const; 59 void SetValue( sal_uLong n ); 60 void SetStartValue( sal_uLong n ); 61 void SetEndValue( sal_uLong n ); 62 }; 63 64 /** Helper class for common functionality in edit sources 65 */ 66 class EDITENG_DLLPUBLIC SvxEditSourceHelper 67 { 68 public: 69 70 /** Translates EditEngine notifications into broadcastable hints 71 72 @param aNotify 73 Notification object send by the EditEngine. 74 75 @return the translated hint 76 */ 77 static ::std::auto_ptr<SfxHint> EENotification2Hint( EENotify* aNotify ); 78 79 /** Calculate attribute run for EditEngines 80 81 Please note that the range returned is half-open: [nStartIndex,nEndIndex) 82 83 @param nStartIndex 84 Herein, the start index of the range of similar attributes is returned 85 86 @param nEndIndex 87 Herein, the end index (exclusive) of the range of similar attributes is returned 88 89 @param rEE 90 The EditEngine to query for attributes 91 92 @param nPara 93 The paragraph the following index value is to be interpreted in 94 95 @param nIndex 96 The character index from which the range of similar attributed characters is requested 97 98 @return sal_True, if the range has been successfully determined 99 */ 100 static sal_Bool GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_uInt16 nPara, sal_uInt16 nIndex ); 101 102 /** Convert point from edit engine to user coordinate space 103 104 As the edit engine internally keeps vertical text unrotated, 105 all internal edit engine methods return their stuff unrotated, 106 too. This method rotates and shifts given point appropriately, 107 if vertical writing is on. 108 109 @param rPoint 110 Point to transform 111 112 @param rEESize 113 Paper size of the edit engine 114 115 @param bIsVertical 116 Whether output text is vertical or not 117 118 @return the possibly transformed point 119 */ 120 static Point EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical ); 121 122 /** Convert point from user to edit engine coordinate space 123 124 As the edit engine internally keeps vertical text unrotated, 125 all internal edit engine methods return their stuff unrotated, 126 too. This method rotates and shifts given point appropriately, 127 if vertical writing is on. 128 129 @param rPoint 130 Point to transform 131 132 @param rEESize 133 Paper size of the edit engine 134 135 @param bIsVertical 136 Whether output text is vertical or not 137 138 @return the possibly transformed point 139 */ 140 static Point UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical ); 141 142 /** Convert rect from edit engine to user coordinate space 143 144 As the edit engine internally keeps vertical text unrotated, 145 all internal edit engine methods return their stuff unrotated, 146 too. This method rotates and shifts given rect appropriately, 147 if vertical writing is on. 148 149 @param rRect 150 Rectangle to transform 151 152 @param rEESize 153 Paper size of the edit engine 154 155 @param bIsVertical 156 Whether output text is vertical or not 157 158 @return the possibly transformed rect 159 */ 160 static Rectangle EEToUserSpace( const Rectangle& rRect, const Size& rEESize, bool bIsVertical ); 161 162 /** Convert rect from user to edit engine coordinate space 163 164 As the edit engine internally keeps vertical text unrotated, 165 all internal edit engine methods return their stuff unrotated, 166 too. This method rotates and shifts given rect appropriately, 167 if vertical writing is on. 168 169 @param rRect 170 Rectangle to transform 171 172 @param rEESize 173 Paper size of the edit engine 174 175 @param bIsVertical 176 Whether output text is vertical or not 177 178 @return the possibly transformed rect 179 */ 180 static Rectangle UserSpaceToEE( const Rectangle& rRect, const Size& rEESize, bool bIsVertical ); 181 182 }; 183 184 #endif 185 186