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