xref: /aoo41x/main/editeng/inc/editeng/unoedhlp.hxx (revision 9b8096d0)
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 //IAccessibility2 Implementation 2009-----
64 class SvxEditSourceHintEndPara :public SvxEditSourceHint
65 {
66 public:
67 	TYPEINFO();
68 	SvxEditSourceHintEndPara( sal_uInt32 nId )
69 		:SvxEditSourceHint(nId) {}
70 	SvxEditSourceHintEndPara( sal_uInt32 nId, sal_uInt32 nValue, sal_uInt32 nStart=0, sal_uInt32 nEnd=0 )
71 		:SvxEditSourceHint(nId,nValue,nStart){ (void)nEnd; }
72 };
73 //-----IAccessibility2 Implementation 2009
74 /** Helper class for common functionality in edit sources
75  */
76 class EDITENG_DLLPUBLIC SvxEditSourceHelper
77 {
78 public:
79 
80     /** Translates EditEngine notifications into broadcastable hints
81 
82     	@param aNotify
83         Notification object send by the EditEngine.
84 
85         @return the translated hint
86      */
87     static ::std::auto_ptr<SfxHint> EENotification2Hint( EENotify* aNotify );
88 
89     /** Calculate attribute run for EditEngines
90 
91     	Please note that the range returned is half-open: [nStartIndex,nEndIndex)
92 
93     	@param nStartIndex
94         Herein, the start index of the range of similar attributes is returned
95 
96     	@param nEndIndex
97         Herein, the end index (exclusive) of the range of similar attributes is returned
98 
99         @param rEE
100         The EditEngine to query for attributes
101 
102         @param nPara
103         The paragraph the following index value is to be interpreted in
104 
105         @param nIndex
106         The character index from which the range of similar attributed characters is requested
107 
108         @return sal_True, if the range has been successfully determined
109      */
110 	//IAccessibility2 Implementation 2009-----
111     //static sal_Bool GetAttributeRun( USHORT& nStartIndex, USHORT& nEndIndex, const EditEngine& rEE, USHORT nPara, USHORT nIndex );
112     static sal_Bool GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_uInt16 nPara, sal_uInt16 nIndex, sal_Bool bInCell=sal_False );
113 	//-----IAccessibility2 Implementation 2009
114 
115     /** Convert point from edit engine to user coordinate space
116 
117     	As the edit engine internally keeps vertical text unrotated,
118     	all internal edit engine methods return their stuff unrotated,
119     	too. This method rotates and shifts given point appropriately,
120     	if vertical writing is on.
121 
122         @param rPoint
123         Point to transform
124 
125         @param rEESize
126         Paper size of the edit engine
127 
128         @param  bIsVertical
129         Whether output text is vertical or not
130 
131         @return the possibly transformed point
132      */
133     static Point EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical );
134 
135     /** Convert point from user to edit engine coordinate space
136 
137     	As the edit engine internally keeps vertical text unrotated,
138     	all internal edit engine methods return their stuff unrotated,
139     	too. This method rotates and shifts given point appropriately,
140     	if vertical writing is on.
141 
142         @param rPoint
143         Point to transform
144 
145         @param rEESize
146         Paper size of the edit engine
147 
148         @param  bIsVertical
149         Whether output text is vertical or not
150 
151         @return the possibly transformed point
152      */
153     static Point UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical );
154 
155     /** Convert rect from edit engine to user coordinate space
156 
157     	As the edit engine internally keeps vertical text unrotated,
158     	all internal edit engine methods return their stuff unrotated,
159     	too. This method rotates and shifts given rect appropriately,
160     	if vertical writing is on.
161 
162         @param rRect
163         Rectangle to transform
164 
165         @param rEESize
166         Paper size of the edit engine
167 
168         @param  bIsVertical
169         Whether output text is vertical or not
170 
171         @return the possibly transformed rect
172      */
173     static Rectangle EEToUserSpace( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
174 
175     /** Convert rect from user to edit engine coordinate space
176 
177     	As the edit engine internally keeps vertical text unrotated,
178     	all internal edit engine methods return their stuff unrotated,
179     	too. This method rotates and shifts given rect appropriately,
180     	if vertical writing is on.
181 
182         @param rRect
183         Rectangle to transform
184 
185         @param rEESize
186         Paper size of the edit engine
187 
188         @param  bIsVertical
189         Whether output text is vertical or not
190 
191         @return the possibly transformed rect
192      */
193     static Rectangle UserSpaceToEE( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
194 
195 };
196 
197 #endif
198 
199