/src/libreoffice/include/editeng/unoedhlp.hxx
Line | Count | Source |
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 <vcl/textdata.hxx> |
25 | | #include <svl/hint.hxx> |
26 | | #include <tools/gen.hxx> |
27 | | #include <editeng/editengdllapi.h> |
28 | | |
29 | | struct EENotify; |
30 | | class EditEngine; |
31 | | |
32 | | /** Extends TextHint by two additional parameters which are necessary |
33 | | for the SfxHintId::EditSourceParasMoved hint. TextHint's value in this |
34 | | case denotes the destination position, the two parameters the |
35 | | start and the end of the moved paragraph range. |
36 | | */ |
37 | | class SAL_DLLPUBLIC_RTTI SvxEditSourceHint : public TextHint |
38 | | { |
39 | | private: |
40 | | sal_Int32 mnStart; |
41 | | sal_Int32 mnEnd; |
42 | | |
43 | | public: |
44 | | SvxEditSourceHint( SfxHintId nId ); |
45 | | SvxEditSourceHint( SfxHintId nId, sal_Int32 nValue, sal_Int32 nStart, sal_Int32 nEnd ); |
46 | | |
47 | | using TextHint::GetValue; |
48 | 0 | sal_Int32 GetStartValue() const { return mnStart;} |
49 | 0 | sal_Int32 GetEndValue() const { return mnEnd;} |
50 | | }; |
51 | | class SvxEditSourceHintEndPara final : public SvxEditSourceHint |
52 | | { |
53 | | public: |
54 | 0 | SvxEditSourceHintEndPara() : SvxEditSourceHint(SfxHintId::EditSourceSelectionChanged) {} |
55 | | }; |
56 | | /** Helper class for common functionality in edit sources |
57 | | */ |
58 | | class EDITENG_DLLPUBLIC SvxEditSourceHelper |
59 | | { |
60 | | public: |
61 | | |
62 | | /** Translates EditEngine notifications into broadcastable hints |
63 | | |
64 | | @param aNotify |
65 | | Notification object sent by the EditEngine. |
66 | | |
67 | | @return the translated hint |
68 | | */ |
69 | | static ::std::unique_ptr<SfxHint> EENotification2Hint( EENotify const * aNotify ); |
70 | | |
71 | | /** Calculate attribute run for EditEngines |
72 | | |
73 | | Please note that the range returned is half-open: [nStartIndex,nEndIndex) |
74 | | |
75 | | @param nStartIndex |
76 | | Herein, the start index of the range of similar attributes is returned |
77 | | |
78 | | @param nEndIndex |
79 | | Herein, the end index (exclusive) of the range of similar attributes is returned |
80 | | |
81 | | @param rEE |
82 | | The EditEngine to query for attributes |
83 | | |
84 | | @param nPara |
85 | | The paragraph the following index value is to be interpreted in |
86 | | |
87 | | @param nIndex |
88 | | The character index from which the range of similar attributed characters is requested |
89 | | */ |
90 | | static void GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, const EditEngine& rEE, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell = false); |
91 | | |
92 | | /** Convert point from edit engine to user coordinate space |
93 | | |
94 | | As the edit engine internally keeps vertical text unrotated, |
95 | | all internal edit engine methods return their stuff unrotated, |
96 | | too. This method rotates and shifts given point appropriately, |
97 | | if vertical writing is on. |
98 | | |
99 | | @param rPoint |
100 | | Point to transform |
101 | | |
102 | | @param rEESize |
103 | | Paper size of the edit engine |
104 | | |
105 | | @param bIsVertical |
106 | | Whether output text is vertical or not |
107 | | |
108 | | @return the possibly transformed point |
109 | | */ |
110 | | static Point EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical ); |
111 | | |
112 | | /** Convert point from user to edit engine coordinate space |
113 | | |
114 | | As the edit engine internally keeps vertical text unrotated, |
115 | | all internal edit engine methods return their stuff unrotated, |
116 | | too. This method rotates and shifts given point appropriately, |
117 | | if vertical writing is on. |
118 | | |
119 | | @param rPoint |
120 | | Point to transform |
121 | | |
122 | | @param rEESize |
123 | | Paper size of the edit engine |
124 | | |
125 | | @param bIsVertical |
126 | | Whether output text is vertical or not |
127 | | |
128 | | @return the possibly transformed point |
129 | | */ |
130 | | static Point UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical ); |
131 | | |
132 | | /** Convert rect from edit engine to user coordinate space |
133 | | |
134 | | As the edit engine internally keeps vertical text unrotated, |
135 | | all internal edit engine methods return their stuff unrotated, |
136 | | too. This method rotates and shifts given rect appropriately, |
137 | | if vertical writing is on. |
138 | | |
139 | | @param rRect |
140 | | Rectangle to transform |
141 | | |
142 | | @param rEESize |
143 | | Paper size of the edit engine |
144 | | |
145 | | @param bIsVertical |
146 | | Whether output text is vertical or not |
147 | | |
148 | | @return the possibly transformed rect |
149 | | */ |
150 | | static tools::Rectangle EEToUserSpace( const tools::Rectangle& rRect, const Size& rEESize, bool bIsVertical ); |
151 | | |
152 | | }; |
153 | | |
154 | | #endif |
155 | | |
156 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |