Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_EDITENG_UNOEDHLP_HXX
21 : #define INCLUDED_EDITENG_UNOEDHLP_HXX
22 :
23 : #include <memory>
24 : #include <tools/solar.h>
25 : #include <vcl/textdata.hxx>
26 : #include <svl/hint.hxx>
27 : #include <tools/gen.hxx>
28 : #include <editeng/editengdllapi.h>
29 :
30 : struct EENotify;
31 : class EditEngine;
32 :
33 : #define EDITSOURCE_HINT_PARASMOVED 20
34 : #define EDITSOURCE_HINT_SELECTIONCHANGED 21
35 :
36 : /** Extends TextHint by two additional parameters which are necessary
37 : for the EDITSOURCE_HINT_PARASMOVED hint. TextHint's value in this
38 : case denotes the destination position, the two parameters the
39 : start and the end of the moved paragraph range.
40 : */
41 0 : class EDITENG_DLLPUBLIC SvxEditSourceHint : public TextHint
42 : {
43 : private:
44 : sal_Int32 mnStart;
45 : sal_Int32 mnEnd;
46 :
47 : public:
48 : TYPEINFO_OVERRIDE();
49 : SvxEditSourceHint( sal_uLong nId );
50 : SvxEditSourceHint( sal_uLong nId, sal_uLong nValue, sal_Int32 nStart=0, sal_Int32 nEnd=0 );
51 :
52 : sal_uLong GetValue() const;
53 : sal_Int32 GetStartValue() const;
54 : sal_Int32 GetEndValue() const;
55 : };
56 0 : class SvxEditSourceHintEndPara :public SvxEditSourceHint
57 : {
58 : public:
59 : TYPEINFO_OVERRIDE();
60 0 : SvxEditSourceHintEndPara( sal_uInt32 nId )
61 0 : :SvxEditSourceHint(nId) {}
62 : SvxEditSourceHintEndPara( sal_uInt32 nId, sal_uInt32 nValue, sal_uInt32 nStart=0, sal_uInt32 nEnd=0 )
63 : :SvxEditSourceHint(nId,nValue,nStart){ (void)nEnd; }
64 : };
65 : /** Helper class for common functionality in edit sources
66 : */
67 : class EDITENG_DLLPUBLIC SvxEditSourceHelper
68 : {
69 : public:
70 :
71 : /** Translates EditEngine notifications into broadcastable hints
72 :
73 : @param aNotify
74 : Notification object send by the EditEngine.
75 :
76 : @return the translated hint
77 : */
78 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
79 : static ::std::auto_ptr<SfxHint> EENotification2Hint( EENotify* aNotify );
80 : SAL_WNODEPRECATED_DECLARATIONS_POP
81 :
82 : /** Calculate attribute run for EditEngines
83 :
84 : Please note that the range returned is half-open: [nStartIndex,nEndIndex)
85 :
86 : @param nStartIndex
87 : Herein, the start index of the range of similar attributes is returned
88 :
89 : @param nEndIndex
90 : Herein, the end index (exclusive) of the range of similar attributes is returned
91 :
92 : @param rEE
93 : The EditEngine to query for attributes
94 :
95 : @param nPara
96 : The paragraph the following index value is to be interpreted in
97 :
98 : @param nIndex
99 : The character index from which the range of similar attributed characters is requested
100 :
101 : @return true, if the range has been successfully determined
102 : */
103 : static bool GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, const EditEngine& rEE, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell = false);
104 :
105 : /** Convert point from edit engine to user coordinate space
106 :
107 : As the edit engine internally keeps vertical text unrotated,
108 : all internal edit engine methods return their stuff unrotated,
109 : too. This method rotates and shifts given point appropriately,
110 : if vertical writing is on.
111 :
112 : @param rPoint
113 : Point to transform
114 :
115 : @param rEESize
116 : Paper size of the edit engine
117 :
118 : @param bIsVertical
119 : Whether output text is vertical or not
120 :
121 : @return the possibly transformed point
122 : */
123 : static Point EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical );
124 :
125 : /** Convert point from user to edit engine coordinate space
126 :
127 : As the edit engine internally keeps vertical text unrotated,
128 : all internal edit engine methods return their stuff unrotated,
129 : too. This method rotates and shifts given point appropriately,
130 : if vertical writing is on.
131 :
132 : @param rPoint
133 : Point to transform
134 :
135 : @param rEESize
136 : Paper size of the edit engine
137 :
138 : @param bIsVertical
139 : Whether output text is vertical or not
140 :
141 : @return the possibly transformed point
142 : */
143 : static Point UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical );
144 :
145 : /** Convert rect from edit engine to user coordinate space
146 :
147 : As the edit engine internally keeps vertical text unrotated,
148 : all internal edit engine methods return their stuff unrotated,
149 : too. This method rotates and shifts given rect appropriately,
150 : if vertical writing is on.
151 :
152 : @param rRect
153 : Rectangle to transform
154 :
155 : @param rEESize
156 : Paper size of the edit engine
157 :
158 : @param bIsVertical
159 : Whether output text is vertical or not
160 :
161 : @return the possibly transformed rect
162 : */
163 : static Rectangle EEToUserSpace( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
164 :
165 : };
166 :
167 : #endif
168 :
169 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|