Update ooo320-m1
[ooovba.git] / svx / inc / unoedhlp.hxx
blob8e63b8a8b57afe002788d4d653d70032a58f391a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoedhlp.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_UNOEDHLP_HXX
32 #define _SVX_UNOEDHLP_HXX
34 #include <memory>
35 #include <tools/solar.h>
36 #include <svtools/textdata.hxx>
37 #include <svtools/hint.hxx>
38 #include <tools/gen.hxx>
39 #include "svx/svxdllapi.h"
41 struct EENotify;
42 class EditEngine;
44 #define EDITSOURCE_HINT_PARASMOVED 20
45 #define EDITSOURCE_HINT_SELECTIONCHANGED 21
47 /** Extends TextHint by two additional parameters which are necessary
48 for the EDITSOURCE_HINT_PARASMOVED hint. TextHint's value in this
49 case denotes the destination position, the two parameters the
50 start and the end of the moved paragraph range.
52 class SVX_DLLPUBLIC SvxEditSourceHint : public TextHint
54 private:
55 ULONG mnStart;
56 ULONG mnEnd;
58 public:
59 TYPEINFO();
60 SvxEditSourceHint( ULONG nId );
61 SvxEditSourceHint( ULONG nId, ULONG nValue, ULONG nStart=0, ULONG nEnd=0 );
63 ULONG GetValue() const;
64 ULONG GetStartValue() const;
65 ULONG GetEndValue() const;
66 void SetValue( ULONG n );
67 void SetStartValue( ULONG n );
68 void SetEndValue( ULONG n );
71 /** Helper class for common functionality in edit sources
73 class SVX_DLLPUBLIC SvxEditSourceHelper
75 public:
77 /** Translates EditEngine notifications into broadcastable hints
79 @param aNotify
80 Notification object send by the EditEngine.
82 @return the translated hint
84 static ::std::auto_ptr<SfxHint> EENotification2Hint( EENotify* aNotify );
86 /** Calculate attribute run for EditEngines
88 Please note that the range returned is half-open: [nStartIndex,nEndIndex)
90 @param nStartIndex
91 Herein, the start index of the range of similar attributes is returned
93 @param nEndIndex
94 Herein, the end index (exclusive) of the range of similar attributes is returned
96 @param rEE
97 The EditEngine to query for attributes
99 @param nPara
100 The paragraph the following index value is to be interpreted in
102 @param nIndex
103 The character index from which the range of similar attributed characters is requested
105 @return sal_True, if the range has been successfully determined
107 static sal_Bool GetAttributeRun( USHORT& nStartIndex, USHORT& nEndIndex, const EditEngine& rEE, USHORT nPara, USHORT nIndex );
109 /** Convert point from edit engine to user coordinate space
111 As the edit engine internally keeps vertical text unrotated,
112 all internal edit engine methods return their stuff unrotated,
113 too. This method rotates and shifts given point appropriately,
114 if vertical writing is on.
116 @param rPoint
117 Point to transform
119 @param rEESize
120 Paper size of the edit engine
122 @param bIsVertical
123 Whether output text is vertical or not
125 @return the possibly transformed point
127 static Point EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical );
129 /** Convert point from user to edit engine coordinate space
131 As the edit engine internally keeps vertical text unrotated,
132 all internal edit engine methods return their stuff unrotated,
133 too. This method rotates and shifts given point appropriately,
134 if vertical writing is on.
136 @param rPoint
137 Point to transform
139 @param rEESize
140 Paper size of the edit engine
142 @param bIsVertical
143 Whether output text is vertical or not
145 @return the possibly transformed point
147 static Point UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical );
149 /** Convert rect from edit engine to user coordinate space
151 As the edit engine internally keeps vertical text unrotated,
152 all internal edit engine methods return their stuff unrotated,
153 too. This method rotates and shifts given rect appropriately,
154 if vertical writing is on.
156 @param rRect
157 Rectangle to transform
159 @param rEESize
160 Paper size of the edit engine
162 @param bIsVertical
163 Whether output text is vertical or not
165 @return the possibly transformed rect
167 static Rectangle EEToUserSpace( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
169 /** Convert rect from user to edit engine coordinate space
171 As the edit engine internally keeps vertical text unrotated,
172 all internal edit engine methods return their stuff unrotated,
173 too. This method rotates and shifts given rect appropriately,
174 if vertical writing is on.
176 @param rRect
177 Rectangle to transform
179 @param rEESize
180 Paper size of the edit engine
182 @param bIsVertical
183 Whether output text is vertical or not
185 @return the possibly transformed rect
187 static Rectangle UserSpaceToEE( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
191 #endif