xref: /aoo41x/main/editeng/inc/editeng/unoedhlp.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SVX_UNOEDHLP_HXX
29 #define _SVX_UNOEDHLP_HXX
30 
31 #include <memory>
32 #include <tools/solar.h>
33 #include <svtools/textdata.hxx>
34 #include <svl/hint.hxx>
35 #include <tools/gen.hxx>
36 #include "editeng/editengdllapi.h"
37 
38 struct EENotify;
39 class EditEngine;
40 
41 #define EDITSOURCE_HINT_PARASMOVED			20
42 #define EDITSOURCE_HINT_SELECTIONCHANGED	21
43 
44 /** Extends TextHint by two additional parameters which are necessary
45     for the EDITSOURCE_HINT_PARASMOVED hint. TextHint's value in this
46     case denotes the destination position, the two parameters the
47     start and the end of the moved paragraph range.
48  */
49 class EDITENG_DLLPUBLIC SvxEditSourceHint : public TextHint
50 {
51 private:
52 	sal_uLong 	mnStart;
53 	sal_uLong 	mnEnd;
54 
55 public:
56 			TYPEINFO();
57 			SvxEditSourceHint( sal_uLong nId );
58 			SvxEditSourceHint( sal_uLong nId, sal_uLong nValue, sal_uLong nStart=0, sal_uLong nEnd=0 );
59 
60 	sal_uLong 	GetValue() const;
61     sal_uLong	GetStartValue() const;
62     sal_uLong	GetEndValue() const;
63 	void	SetValue( sal_uLong n );
64 	void	SetStartValue( sal_uLong n );
65 	void	SetEndValue( sal_uLong n );
66 };
67 
68 /** Helper class for common functionality in edit sources
69  */
70 class EDITENG_DLLPUBLIC SvxEditSourceHelper
71 {
72 public:
73 
74     /** Translates EditEngine notifications into broadcastable hints
75 
76     	@param aNotify
77         Notification object send by the EditEngine.
78 
79         @return the translated hint
80      */
81     static ::std::auto_ptr<SfxHint> EENotification2Hint( EENotify* aNotify );
82 
83     /** Calculate attribute run for EditEngines
84 
85     	Please note that the range returned is half-open: [nStartIndex,nEndIndex)
86 
87     	@param nStartIndex
88         Herein, the start index of the range of similar attributes is returned
89 
90     	@param nEndIndex
91         Herein, the end index (exclusive) of the range of similar attributes is returned
92 
93         @param rEE
94         The EditEngine to query for attributes
95 
96         @param nPara
97         The paragraph the following index value is to be interpreted in
98 
99         @param nIndex
100         The character index from which the range of similar attributed characters is requested
101 
102         @return sal_True, if the range has been successfully determined
103      */
104     static sal_Bool GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_uInt16 nPara, sal_uInt16 nIndex );
105 
106     /** Convert point from edit engine to user coordinate space
107 
108     	As the edit engine internally keeps vertical text unrotated,
109     	all internal edit engine methods return their stuff unrotated,
110     	too. This method rotates and shifts given point appropriately,
111     	if vertical writing is on.
112 
113         @param rPoint
114         Point to transform
115 
116         @param rEESize
117         Paper size of the edit engine
118 
119         @param  bIsVertical
120         Whether output text is vertical or not
121 
122         @return the possibly transformed point
123      */
124     static Point EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical );
125 
126     /** Convert point from user to edit engine coordinate space
127 
128     	As the edit engine internally keeps vertical text unrotated,
129     	all internal edit engine methods return their stuff unrotated,
130     	too. This method rotates and shifts given point appropriately,
131     	if vertical writing is on.
132 
133         @param rPoint
134         Point to transform
135 
136         @param rEESize
137         Paper size of the edit engine
138 
139         @param  bIsVertical
140         Whether output text is vertical or not
141 
142         @return the possibly transformed point
143      */
144     static Point UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical );
145 
146     /** Convert rect from edit engine to user coordinate space
147 
148     	As the edit engine internally keeps vertical text unrotated,
149     	all internal edit engine methods return their stuff unrotated,
150     	too. This method rotates and shifts given rect appropriately,
151     	if vertical writing is on.
152 
153         @param rRect
154         Rectangle to transform
155 
156         @param rEESize
157         Paper size of the edit engine
158 
159         @param  bIsVertical
160         Whether output text is vertical or not
161 
162         @return the possibly transformed rect
163      */
164     static Rectangle EEToUserSpace( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
165 
166     /** Convert rect from user to edit engine coordinate space
167 
168     	As the edit engine internally keeps vertical text unrotated,
169     	all internal edit engine methods return their stuff unrotated,
170     	too. This method rotates and shifts given rect appropriately,
171     	if vertical writing is on.
172 
173         @param rRect
174         Rectangle to transform
175 
176         @param rEESize
177         Paper size of the edit engine
178 
179         @param  bIsVertical
180         Whether output text is vertical or not
181 
182         @return the possibly transformed rect
183      */
184     static Rectangle UserSpaceToEE( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
185 
186 };
187 
188 #endif
189 
190