1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoedhlp.hxx,v $
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
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"
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
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
77 /** Translates EditEngine notifications into broadcastable hints
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)
91 Herein, the start index of the range of similar attributes is returned
94 Herein, the end index (exclusive) of the range of similar attributes is returned
97 The EditEngine to query for attributes
100 The paragraph the following index value is to be interpreted in
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.
120 Paper size of the edit engine
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.
140 Paper size of the edit engine
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.
157 Rectangle to transform
160 Paper size of the edit engine
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.
177 Rectangle to transform
180 Paper size of the edit engine
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
);