xref: /aoo42x/main/editeng/inc/editeng/unoedhlp.hxx (revision 7a980842)
14c5491eaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
34c5491eaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
44c5491eaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
54c5491eaSAndrew Rist  * distributed with this work for additional information
64c5491eaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
74c5491eaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
84c5491eaSAndrew Rist  * "License"); you may not use this file except in compliance
94c5491eaSAndrew Rist  * with the License.  You may obtain a copy of the License at
104c5491eaSAndrew Rist  *
114c5491eaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
124c5491eaSAndrew Rist  *
134c5491eaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
144c5491eaSAndrew Rist  * software distributed under the License is distributed on an
154c5491eaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
164c5491eaSAndrew Rist  * KIND, either express or implied.  See the License for the
174c5491eaSAndrew Rist  * specific language governing permissions and limitations
184c5491eaSAndrew Rist  * under the License.
194c5491eaSAndrew Rist  *
204c5491eaSAndrew Rist  *************************************************************/
214c5491eaSAndrew Rist 
224c5491eaSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SVX_UNOEDHLP_HXX
25cdf0e10cSrcweir #define _SVX_UNOEDHLP_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <memory>
28cdf0e10cSrcweir #include <tools/solar.h>
29cdf0e10cSrcweir #include <svtools/textdata.hxx>
30cdf0e10cSrcweir #include <svl/hint.hxx>
31cdf0e10cSrcweir #include <tools/gen.hxx>
32cdf0e10cSrcweir #include "editeng/editengdllapi.h"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir struct EENotify;
35cdf0e10cSrcweir class EditEngine;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #define EDITSOURCE_HINT_PARASMOVED			20
38cdf0e10cSrcweir #define EDITSOURCE_HINT_SELECTIONCHANGED	21
39cdf0e10cSrcweir 
40cdf0e10cSrcweir /** Extends TextHint by two additional parameters which are necessary
41cdf0e10cSrcweir     for the EDITSOURCE_HINT_PARASMOVED hint. TextHint's value in this
42cdf0e10cSrcweir     case denotes the destination position, the two parameters the
43cdf0e10cSrcweir     start and the end of the moved paragraph range.
44cdf0e10cSrcweir  */
45cdf0e10cSrcweir class EDITENG_DLLPUBLIC SvxEditSourceHint : public TextHint
46cdf0e10cSrcweir {
47cdf0e10cSrcweir private:
48cdf0e10cSrcweir 	sal_uLong 	mnStart;
49cdf0e10cSrcweir 	sal_uLong 	mnEnd;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir public:
52cdf0e10cSrcweir 			TYPEINFO();
53cdf0e10cSrcweir 			SvxEditSourceHint( sal_uLong nId );
54cdf0e10cSrcweir 			SvxEditSourceHint( sal_uLong nId, sal_uLong nValue, sal_uLong nStart=0, sal_uLong nEnd=0 );
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	sal_uLong 	GetValue() const;
57cdf0e10cSrcweir     sal_uLong	GetStartValue() const;
58cdf0e10cSrcweir     sal_uLong	GetEndValue() const;
59cdf0e10cSrcweir 	void	SetValue( sal_uLong n );
60cdf0e10cSrcweir 	void	SetStartValue( sal_uLong n );
61cdf0e10cSrcweir 	void	SetEndValue( sal_uLong n );
62cdf0e10cSrcweir };
639b8096d0SSteve Yin class SvxEditSourceHintEndPara :public SvxEditSourceHint
649b8096d0SSteve Yin {
659b8096d0SSteve Yin public:
669b8096d0SSteve Yin 	TYPEINFO();
SvxEditSourceHintEndPara(sal_uInt32 nId)679b8096d0SSteve Yin 	SvxEditSourceHintEndPara( sal_uInt32 nId )
689b8096d0SSteve Yin 		:SvxEditSourceHint(nId) {}
SvxEditSourceHintEndPara(sal_uInt32 nId,sal_uInt32 nValue,sal_uInt32 nStart=0,sal_uInt32 nEnd=0)699b8096d0SSteve Yin 	SvxEditSourceHintEndPara( sal_uInt32 nId, sal_uInt32 nValue, sal_uInt32 nStart=0, sal_uInt32 nEnd=0 )
709b8096d0SSteve Yin 		:SvxEditSourceHint(nId,nValue,nStart){ (void)nEnd; }
719b8096d0SSteve Yin };
72cdf0e10cSrcweir /** Helper class for common functionality in edit sources
73cdf0e10cSrcweir  */
74cdf0e10cSrcweir class EDITENG_DLLPUBLIC SvxEditSourceHelper
75cdf0e10cSrcweir {
76cdf0e10cSrcweir public:
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     /** Translates EditEngine notifications into broadcastable hints
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     	@param aNotify
81cdf0e10cSrcweir         Notification object send by the EditEngine.
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         @return the translated hint
84cdf0e10cSrcweir      */
85cdf0e10cSrcweir     static ::std::auto_ptr<SfxHint> EENotification2Hint( EENotify* aNotify );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     /** Calculate attribute run for EditEngines
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     	Please note that the range returned is half-open: [nStartIndex,nEndIndex)
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     	@param nStartIndex
92cdf0e10cSrcweir         Herein, the start index of the range of similar attributes is returned
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     	@param nEndIndex
95cdf0e10cSrcweir         Herein, the end index (exclusive) of the range of similar attributes is returned
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         @param rEE
98cdf0e10cSrcweir         The EditEngine to query for attributes
99cdf0e10cSrcweir 
100cdf0e10cSrcweir         @param nPara
101cdf0e10cSrcweir         The paragraph the following index value is to be interpreted in
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         @param nIndex
104cdf0e10cSrcweir         The character index from which the range of similar attributed characters is requested
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         @return sal_True, if the range has been successfully determined
107cdf0e10cSrcweir      */
1089b8096d0SSteve Yin     //static sal_Bool GetAttributeRun( USHORT& nStartIndex, USHORT& nEndIndex, const EditEngine& rEE, USHORT nPara, USHORT nIndex );
109*7a980842SDamjanJovanovic     static sal_Bool GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_uInt32 nPara, sal_uInt16 nIndex, sal_Bool bInCell=sal_False );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     /** Convert point from edit engine to user coordinate space
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     	As the edit engine internally keeps vertical text unrotated,
114cdf0e10cSrcweir     	all internal edit engine methods return their stuff unrotated,
115cdf0e10cSrcweir     	too. This method rotates and shifts given point appropriately,
116cdf0e10cSrcweir     	if vertical writing is on.
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         @param rPoint
119cdf0e10cSrcweir         Point to transform
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         @param rEESize
122cdf0e10cSrcweir         Paper size of the edit engine
123cdf0e10cSrcweir 
124cdf0e10cSrcweir         @param  bIsVertical
125cdf0e10cSrcweir         Whether output text is vertical or not
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         @return the possibly transformed point
128cdf0e10cSrcweir      */
129cdf0e10cSrcweir     static Point EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     /** Convert point from user to edit engine coordinate space
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     	As the edit engine internally keeps vertical text unrotated,
134cdf0e10cSrcweir     	all internal edit engine methods return their stuff unrotated,
135cdf0e10cSrcweir     	too. This method rotates and shifts given point appropriately,
136cdf0e10cSrcweir     	if vertical writing is on.
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         @param rPoint
139cdf0e10cSrcweir         Point to transform
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         @param rEESize
142cdf0e10cSrcweir         Paper size of the edit engine
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         @param  bIsVertical
145cdf0e10cSrcweir         Whether output text is vertical or not
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         @return the possibly transformed point
148cdf0e10cSrcweir      */
149cdf0e10cSrcweir     static Point UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     /** Convert rect from edit engine to user coordinate space
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     	As the edit engine internally keeps vertical text unrotated,
154cdf0e10cSrcweir     	all internal edit engine methods return their stuff unrotated,
155cdf0e10cSrcweir     	too. This method rotates and shifts given rect appropriately,
156cdf0e10cSrcweir     	if vertical writing is on.
157cdf0e10cSrcweir 
158cdf0e10cSrcweir         @param rRect
159cdf0e10cSrcweir         Rectangle to transform
160cdf0e10cSrcweir 
161cdf0e10cSrcweir         @param rEESize
162cdf0e10cSrcweir         Paper size of the edit engine
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         @param  bIsVertical
165cdf0e10cSrcweir         Whether output text is vertical or not
166cdf0e10cSrcweir 
167cdf0e10cSrcweir         @return the possibly transformed rect
168cdf0e10cSrcweir      */
169cdf0e10cSrcweir     static Rectangle EEToUserSpace( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     /** Convert rect from user to edit engine coordinate space
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     	As the edit engine internally keeps vertical text unrotated,
174cdf0e10cSrcweir     	all internal edit engine methods return their stuff unrotated,
175cdf0e10cSrcweir     	too. This method rotates and shifts given rect appropriately,
176cdf0e10cSrcweir     	if vertical writing is on.
177cdf0e10cSrcweir 
178cdf0e10cSrcweir         @param rRect
179cdf0e10cSrcweir         Rectangle to transform
180cdf0e10cSrcweir 
181cdf0e10cSrcweir         @param rEESize
182cdf0e10cSrcweir         Paper size of the edit engine
183cdf0e10cSrcweir 
184cdf0e10cSrcweir         @param  bIsVertical
185cdf0e10cSrcweir         Whether output text is vertical or not
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         @return the possibly transformed rect
188cdf0e10cSrcweir      */
189cdf0e10cSrcweir     static Rectangle UserSpaceToEE( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir };
192cdf0e10cSrcweir 
193cdf0e10cSrcweir #endif
194cdf0e10cSrcweir 
195