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 _SVX_UNOEDHLP_HXX
21 : #define _SVX_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();
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 :
57 : /** Helper class for common functionality in edit sources
58 : */
59 : class EDITENG_DLLPUBLIC SvxEditSourceHelper
60 : {
61 : public:
62 :
63 : /** Translates EditEngine notifications into broadcastable hints
64 :
65 : @param aNotify
66 : Notification object send by the EditEngine.
67 :
68 : @return the translated hint
69 : */
70 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
71 : static ::std::auto_ptr<SfxHint> EENotification2Hint( EENotify* aNotify );
72 : SAL_WNODEPRECATED_DECLARATIONS_POP
73 :
74 : /** Calculate attribute run for EditEngines
75 :
76 : Please note that the range returned is half-open: [nStartIndex,nEndIndex)
77 :
78 : @param nStartIndex
79 : Herein, the start index of the range of similar attributes is returned
80 :
81 : @param nEndIndex
82 : Herein, the end index (exclusive) of the range of similar attributes is returned
83 :
84 : @param rEE
85 : The EditEngine to query for attributes
86 :
87 : @param nPara
88 : The paragraph the following index value is to be interpreted in
89 :
90 : @param nIndex
91 : The character index from which the range of similar attributed characters is requested
92 :
93 : @return sal_True, if the range has been successfully determined
94 : */
95 : static sal_Bool GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_Int32 nPara, sal_uInt16 nIndex );
96 :
97 : /** Convert point from edit engine to user coordinate space
98 :
99 : As the edit engine internally keeps vertical text unrotated,
100 : all internal edit engine methods return their stuff unrotated,
101 : too. This method rotates and shifts given point appropriately,
102 : if vertical writing is on.
103 :
104 : @param rPoint
105 : Point to transform
106 :
107 : @param rEESize
108 : Paper size of the edit engine
109 :
110 : @param bIsVertical
111 : Whether output text is vertical or not
112 :
113 : @return the possibly transformed point
114 : */
115 : static Point EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical );
116 :
117 : /** Convert point from user to edit engine coordinate space
118 :
119 : As the edit engine internally keeps vertical text unrotated,
120 : all internal edit engine methods return their stuff unrotated,
121 : too. This method rotates and shifts given point appropriately,
122 : if vertical writing is on.
123 :
124 : @param rPoint
125 : Point to transform
126 :
127 : @param rEESize
128 : Paper size of the edit engine
129 :
130 : @param bIsVertical
131 : Whether output text is vertical or not
132 :
133 : @return the possibly transformed point
134 : */
135 : static Point UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical );
136 :
137 : /** Convert rect from edit engine to user coordinate space
138 :
139 : As the edit engine internally keeps vertical text unrotated,
140 : all internal edit engine methods return their stuff unrotated,
141 : too. This method rotates and shifts given rect appropriately,
142 : if vertical writing is on.
143 :
144 : @param rRect
145 : Rectangle to transform
146 :
147 : @param rEESize
148 : Paper size of the edit engine
149 :
150 : @param bIsVertical
151 : Whether output text is vertical or not
152 :
153 : @return the possibly transformed rect
154 : */
155 : static Rectangle EEToUserSpace( const Rectangle& rRect, const Size& rEESize, bool bIsVertical );
156 :
157 : };
158 :
159 : #endif
160 :
161 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|