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 : #include <cstddef>
21 : #include <swpossizetabpage.hxx>
22 : #include <dialmgr.hxx>
23 : #include <svx/dlgutil.hxx>
24 : #include <svx/anchorid.hxx>
25 : #include <svl/aeitem.hxx>
26 : #include <svx/swframevalidation.hxx>
27 : #include <cuires.hrc>
28 : #include <sfx2/htmlmode.hxx>
29 : #include <svx/svdview.hxx>
30 : #include <svx/svdpagv.hxx>
31 : #include <svx/rectenum.hxx>
32 : #include <sal/macros.h>
33 : #include <com/sun/star/text/TextContentAnchorType.hpp>
34 : #include <com/sun/star/text/HoriOrientation.hpp>
35 : #include <com/sun/star/text/VertOrientation.hpp>
36 : #include <com/sun/star/text/RelOrientation.hpp>
37 : #include <svx/dialogs.hrc>
38 :
39 : using namespace ::com::sun::star::text;
40 : #define SwFPos SvxSwFramePosString
41 :
42 : struct FrmMap
43 : {
44 : SvxSwFramePosString::StringId eStrId;
45 : SvxSwFramePosString::StringId eMirrorStrId;
46 : short nAlign;
47 : sal_uLong nLBRelations;
48 : };
49 :
50 : struct RelationMap
51 : {
52 : SvxSwFramePosString::StringId eStrId;
53 : SvxSwFramePosString::StringId eMirrorStrId;
54 : sal_uLong nLBRelation;
55 : short nRelation;
56 : };
57 : struct StringIdPair_Impl
58 : {
59 : SvxSwFramePosString::StringId eHori;
60 : SvxSwFramePosString::StringId eVert;
61 : };
62 :
63 : #define LB_FRAME 0x00000001L // paragraph text area
64 : #define LB_PRTAREA 0x00000002L // paragraph text area + indents
65 : #define LB_VERT_FRAME 0x00000004L // vertical paragraph text area
66 : #define LB_VERT_PRTAREA 0x00000008L // vertical paragraph text area + indents
67 : #define LB_REL_FRM_LEFT 0x00000010L // left paragraph margin
68 : #define LB_REL_FRM_RIGHT 0x00000020L // right paragraph margin
69 :
70 : #define LB_REL_PG_LEFT 0x00000040L // left page margin
71 : #define LB_REL_PG_RIGHT 0x00000080L // right page margin
72 : #define LB_REL_PG_FRAME 0x00000100L // complete page
73 : #define LB_REL_PG_PRTAREA 0x00000200L // text area of page
74 :
75 : #define LB_FLY_REL_PG_LEFT 0x00000400L // left frame margin
76 : #define LB_FLY_REL_PG_RIGHT 0x00000800L // right frame margin
77 : #define LB_FLY_REL_PG_FRAME 0x00001000L // complete frame
78 : #define LB_FLY_REL_PG_PRTAREA 0x00002000L // frame interior
79 :
80 : #define LB_REL_BASE 0x00010000L // as char, relative to baseline
81 : #define LB_REL_CHAR 0x00020000L // as char, relative to character
82 : #define LB_REL_ROW 0x00040000L // as char, relative to line
83 :
84 : // #i22305#
85 : #define LB_FLY_VERT_FRAME 0x00100000L // vertical entire frame
86 : #define LB_FLY_VERT_PRTAREA 0x00200000L // vertical frame text area
87 :
88 : // #i22341#
89 : #define LB_VERT_LINE 0x00400000L // vertical text line
90 :
91 : static RelationMap aRelationMap[] =
92 : {
93 : {SwFPos::FRAME, SwFPos::FRAME, LB_FRAME, RelOrientation::FRAME},
94 : {SwFPos::PRTAREA, SwFPos::PRTAREA, LB_PRTAREA, RelOrientation::PRINT_AREA},
95 : {SwFPos::REL_PG_LEFT, SwFPos::MIR_REL_PG_LEFT, LB_REL_PG_LEFT, RelOrientation::PAGE_LEFT},
96 : {SwFPos::REL_PG_RIGHT, SwFPos::MIR_REL_PG_RIGHT, LB_REL_PG_RIGHT, RelOrientation::PAGE_RIGHT},
97 : {SwFPos::REL_FRM_LEFT, SwFPos::MIR_REL_FRM_LEFT, LB_REL_FRM_LEFT, RelOrientation::FRAME_LEFT},
98 : {SwFPos::REL_FRM_RIGHT, SwFPos::MIR_REL_FRM_RIGHT, LB_REL_FRM_RIGHT, RelOrientation::FRAME_RIGHT},
99 : {SwFPos::REL_PG_FRAME, SwFPos::REL_PG_FRAME, LB_REL_PG_FRAME, RelOrientation::PAGE_FRAME},
100 : {SwFPos::REL_PG_PRTAREA,SwFPos::REL_PG_PRTAREA, LB_REL_PG_PRTAREA, RelOrientation::PAGE_PRINT_AREA},
101 : {SwFPos::REL_CHAR, SwFPos::REL_CHAR, LB_REL_CHAR, RelOrientation::CHAR},
102 :
103 : {SwFPos::FLY_REL_PG_LEFT, SwFPos::FLY_MIR_REL_PG_LEFT, LB_FLY_REL_PG_LEFT, RelOrientation::PAGE_LEFT},
104 : {SwFPos::FLY_REL_PG_RIGHT, SwFPos::FLY_MIR_REL_PG_RIGHT, LB_FLY_REL_PG_RIGHT, RelOrientation::PAGE_RIGHT},
105 : {SwFPos::FLY_REL_PG_FRAME, SwFPos::FLY_REL_PG_FRAME, LB_FLY_REL_PG_FRAME, RelOrientation::PAGE_FRAME},
106 : {SwFPos::FLY_REL_PG_PRTAREA, SwFPos::FLY_REL_PG_PRTAREA, LB_FLY_REL_PG_PRTAREA, RelOrientation::PAGE_PRINT_AREA},
107 :
108 : {SwFPos::REL_BORDER, SwFPos::REL_BORDER, LB_VERT_FRAME, RelOrientation::FRAME},
109 : {SwFPos::REL_PRTAREA, SwFPos::REL_PRTAREA, LB_VERT_PRTAREA, RelOrientation::PRINT_AREA},
110 :
111 : // #i22305#
112 : {SwFPos::FLY_REL_PG_FRAME, SwFPos::FLY_REL_PG_FRAME, LB_FLY_VERT_FRAME, RelOrientation::FRAME},
113 : {SwFPos::FLY_REL_PG_PRTAREA, SwFPos::FLY_REL_PG_PRTAREA, LB_FLY_VERT_PRTAREA, RelOrientation::PRINT_AREA},
114 :
115 : // #i22341#
116 : {SwFPos::REL_LINE, SwFPos::REL_LINE, LB_VERT_LINE, RelOrientation::TEXT_LINE}
117 : };
118 :
119 : static RelationMap aAsCharRelationMap[] =
120 : {
121 : {SwFPos::REL_BASE, SwFPos::REL_BASE, LB_REL_BASE, RelOrientation::FRAME},
122 : {SwFPos::REL_CHAR, SwFPos::REL_CHAR, LB_REL_CHAR, RelOrientation::FRAME},
123 : {SwFPos::REL_ROW, SwFPos::REL_ROW, LB_REL_ROW, RelOrientation::FRAME}
124 : };
125 :
126 : /*--------------------------------------------------------------------
127 : Anchored at page
128 : --------------------------------------------------------------------*/
129 :
130 : #define HORI_PAGE_REL (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_PG_LEFT| \
131 : LB_REL_PG_RIGHT)
132 :
133 : static FrmMap aHPageMap[] =
134 : {
135 : {SwFPos::LEFT, SwFPos::MIR_LEFT, HoriOrientation::LEFT, HORI_PAGE_REL},
136 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, HoriOrientation::RIGHT, HORI_PAGE_REL},
137 : {SwFPos::CENTER_HORI,SwFPos::CENTER_HORI, HoriOrientation::CENTER, HORI_PAGE_REL},
138 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, HoriOrientation::NONE, HORI_PAGE_REL}
139 : };
140 :
141 : static FrmMap aHPageHtmlMap[] =
142 : {
143 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, HoriOrientation::NONE, LB_REL_PG_FRAME}
144 : };
145 :
146 : #define VERT_PAGE_REL (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
147 :
148 : static FrmMap aVPageMap[] =
149 : {
150 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, VERT_PAGE_REL},
151 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::BOTTOM, VERT_PAGE_REL},
152 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::CENTER, VERT_PAGE_REL},
153 : {SwFPos::FROMTOP, SwFPos::FROMTOP, VertOrientation::NONE, VERT_PAGE_REL}
154 : };
155 :
156 : static FrmMap aVPageHtmlMap[] =
157 : {
158 : {SwFPos::FROMTOP, SwFPos::FROMTOP, VertOrientation::NONE, LB_REL_PG_FRAME}
159 : };
160 :
161 : /*--------------------------------------------------------------------
162 : Anchored at frame
163 : --------------------------------------------------------------------*/
164 :
165 : #define HORI_FRAME_REL (LB_FLY_REL_PG_FRAME|LB_FLY_REL_PG_PRTAREA| \
166 : LB_FLY_REL_PG_LEFT|LB_FLY_REL_PG_RIGHT)
167 :
168 : static FrmMap aHFrameMap[] =
169 : {
170 : {SwFPos::LEFT, SwFPos::MIR_LEFT, HoriOrientation::LEFT, HORI_FRAME_REL},
171 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, HoriOrientation::RIGHT, HORI_FRAME_REL},
172 : {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, HoriOrientation::CENTER, HORI_FRAME_REL},
173 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, HoriOrientation::NONE, HORI_FRAME_REL}
174 : };
175 :
176 : static FrmMap aHFlyHtmlMap[] =
177 : {
178 : {SwFPos::LEFT, SwFPos::MIR_LEFT, HoriOrientation::LEFT, LB_FLY_REL_PG_FRAME},
179 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, HoriOrientation::NONE, LB_FLY_REL_PG_FRAME}
180 : };
181 :
182 : // #i18732# - own vertical alignment map for to frame anchored objects
183 : // #i22305#
184 : #define VERT_FRAME_REL (LB_VERT_FRAME|LB_FLY_VERT_PRTAREA)
185 :
186 : static FrmMap aVFrameMap[] =
187 : {
188 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, VERT_FRAME_REL},
189 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::BOTTOM, VERT_FRAME_REL},
190 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::CENTER, VERT_FRAME_REL},
191 : {SwFPos::FROMTOP, SwFPos::FROMTOP, VertOrientation::NONE, VERT_FRAME_REL}
192 : };
193 :
194 : static FrmMap aVFlyHtmlMap[] =
195 : {
196 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, LB_FLY_VERT_FRAME},
197 : {SwFPos::FROMTOP, SwFPos::FROMTOP, VertOrientation::NONE, LB_FLY_VERT_FRAME}
198 : };
199 :
200 : static FrmMap aVMultiSelectionMap[] =
201 : {
202 : {SwFPos::FROMTOP, SwFPos::FROMTOP, VertOrientation::NONE, 0}
203 : };
204 : static FrmMap aHMultiSelectionMap[] =
205 : {
206 : {SwFPos::FROMLEFT, SwFPos::FROMLEFT, HoriOrientation::NONE, 0}
207 : };
208 :
209 : /*--------------------------------------------------------------------
210 : Anchored at paragraph
211 : --------------------------------------------------------------------*/
212 :
213 : #define HORI_PARA_REL (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
214 : LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
215 : LB_REL_FRM_RIGHT)
216 :
217 : static FrmMap aHParaMap[] =
218 : {
219 : {SwFPos::LEFT, SwFPos::MIR_LEFT, HoriOrientation::LEFT, HORI_PARA_REL},
220 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, HoriOrientation::RIGHT, HORI_PARA_REL},
221 : {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, HoriOrientation::CENTER, HORI_PARA_REL},
222 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, HoriOrientation::NONE, HORI_PARA_REL}
223 : };
224 :
225 : #define HTML_HORI_PARA_REL (LB_FRAME|LB_PRTAREA)
226 :
227 : static FrmMap aHParaHtmlMap[] =
228 : {
229 : {SwFPos::LEFT, SwFPos::LEFT, HoriOrientation::LEFT, HTML_HORI_PARA_REL},
230 : {SwFPos::RIGHT, SwFPos::RIGHT, HoriOrientation::RIGHT, HTML_HORI_PARA_REL}
231 : };
232 :
233 : static FrmMap aHParaHtmlAbsMap[] =
234 : {
235 : {SwFPos::LEFT, SwFPos::MIR_LEFT, HoriOrientation::LEFT, HTML_HORI_PARA_REL},
236 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, HoriOrientation::RIGHT, HTML_HORI_PARA_REL}
237 : };
238 :
239 :
240 : #define VERT_PARA_REL (LB_VERT_FRAME|LB_VERT_PRTAREA| \
241 : LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
242 :
243 : static FrmMap aVParaMap[] =
244 : {
245 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, VERT_PARA_REL},
246 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::BOTTOM, VERT_PARA_REL},
247 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::CENTER, VERT_PARA_REL},
248 : {SwFPos::FROMTOP, SwFPos::FROMTOP, VertOrientation::NONE, VERT_PARA_REL}
249 : };
250 :
251 : static FrmMap aVParaHtmlMap[] =
252 : {
253 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, LB_VERT_PRTAREA}
254 : };
255 :
256 : /*--------------------------------------------------------------------
257 : Anchored at character
258 : --------------------------------------------------------------------*/
259 :
260 : #define HORI_CHAR_REL (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
261 : LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
262 : LB_REL_FRM_RIGHT|LB_REL_CHAR)
263 :
264 : static FrmMap aHCharMap[] =
265 : {
266 : {SwFPos::LEFT, SwFPos::MIR_LEFT, HoriOrientation::LEFT, HORI_CHAR_REL},
267 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, HoriOrientation::RIGHT, HORI_CHAR_REL},
268 : {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, HoriOrientation::CENTER, HORI_CHAR_REL},
269 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, HoriOrientation::NONE, HORI_CHAR_REL}
270 : };
271 :
272 : #define HTML_HORI_CHAR_REL (LB_FRAME|LB_PRTAREA|LB_REL_CHAR)
273 :
274 : static FrmMap aHCharHtmlMap[] =
275 : {
276 : {SwFPos::LEFT, SwFPos::LEFT, HoriOrientation::LEFT, HTML_HORI_CHAR_REL},
277 : {SwFPos::RIGHT, SwFPos::RIGHT, HoriOrientation::RIGHT, HTML_HORI_CHAR_REL}
278 : };
279 :
280 : static FrmMap aHCharHtmlAbsMap[] =
281 : {
282 : {SwFPos::LEFT, SwFPos::MIR_LEFT, HoriOrientation::LEFT, LB_PRTAREA|LB_REL_CHAR},
283 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, HoriOrientation::RIGHT, LB_PRTAREA},
284 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, HoriOrientation::NONE, LB_REL_PG_FRAME}
285 : };
286 :
287 : // #i18732# - allow vertical alignment at page areas
288 : // #i22341# - handle <LB_REL_CHAR> on its own
289 : #define VERT_CHAR_REL (LB_VERT_FRAME|LB_VERT_PRTAREA| \
290 : LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
291 :
292 : static FrmMap aVCharMap[] =
293 : {
294 : // #i22341#
295 : // introduce mappings for new vertical alignment at top of line <LB_VERT_LINE>
296 : // and correct mapping for vertical alignment at character for position <FROM_BOTTOM>
297 : // Note: Because of these adjustments the map becomes ambigous in its values
298 : // <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered
299 : // in the methods <SwFrmPage::FillRelLB(..)>, <SwFrmPage::GetAlignment(..)>
300 : // and <SwFrmPage::FillPosLB(..)>
301 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, VERT_CHAR_REL|LB_REL_CHAR},
302 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::BOTTOM, VERT_CHAR_REL|LB_REL_CHAR},
303 : {SwFPos::BELOW, SwFPos::BELOW, VertOrientation::CHAR_BOTTOM, LB_REL_CHAR},
304 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::CENTER, VERT_CHAR_REL|LB_REL_CHAR},
305 : {SwFPos::FROMTOP, SwFPos::FROMTOP, VertOrientation::NONE, VERT_CHAR_REL},
306 : {SwFPos::FROMBOTTOM, SwFPos::FROMBOTTOM, VertOrientation::NONE, LB_REL_CHAR|LB_VERT_LINE},
307 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::LINE_TOP, LB_VERT_LINE},
308 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::LINE_BOTTOM, LB_VERT_LINE},
309 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::LINE_CENTER, LB_VERT_LINE}
310 : };
311 :
312 :
313 : static FrmMap aVCharHtmlMap[] =
314 : {
315 : {SwFPos::BELOW, SwFPos::BELOW, VertOrientation::CHAR_BOTTOM, LB_REL_CHAR}
316 : };
317 :
318 : static FrmMap aVCharHtmlAbsMap[] =
319 : {
320 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, LB_REL_CHAR},
321 : {SwFPos::BELOW, SwFPos::BELOW, VertOrientation::CHAR_BOTTOM, LB_REL_CHAR}
322 : };
323 : /*--------------------------------------------------------------------
324 : anchored as character
325 : --------------------------------------------------------------------*/
326 :
327 : static FrmMap aVAsCharMap[] =
328 : {
329 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, LB_REL_BASE},
330 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::BOTTOM, LB_REL_BASE},
331 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::CENTER, LB_REL_BASE},
332 :
333 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::CHAR_TOP, LB_REL_CHAR},
334 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::CHAR_BOTTOM, LB_REL_CHAR},
335 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::CHAR_CENTER, LB_REL_CHAR},
336 :
337 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::LINE_TOP, LB_REL_ROW},
338 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::LINE_BOTTOM, LB_REL_ROW},
339 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::LINE_CENTER, LB_REL_ROW},
340 :
341 : {SwFPos::FROMBOTTOM, SwFPos::FROMBOTTOM, VertOrientation::NONE, LB_REL_BASE}
342 : };
343 :
344 : static FrmMap aVAsCharHtmlMap[] =
345 : {
346 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::TOP, LB_REL_BASE},
347 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::CENTER, LB_REL_BASE},
348 :
349 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::CHAR_TOP, LB_REL_CHAR},
350 :
351 : {SwFPos::TOP, SwFPos::TOP, VertOrientation::LINE_TOP, LB_REL_ROW},
352 : {SwFPos::BOTTOM, SwFPos::BOTTOM, VertOrientation::LINE_BOTTOM, LB_REL_ROW},
353 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, VertOrientation::LINE_CENTER, LB_REL_ROW}
354 : };
355 :
356 0 : static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap)
357 : {
358 0 : if( pMap )
359 : {
360 0 : if( pMap == aVParaHtmlMap )
361 0 : return SAL_N_ELEMENTS(aVParaHtmlMap);
362 0 : if( pMap == aVAsCharHtmlMap )
363 0 : return SAL_N_ELEMENTS( aVAsCharHtmlMap );
364 0 : if( pMap == aHParaHtmlMap )
365 0 : return SAL_N_ELEMENTS( aHParaHtmlMap );
366 0 : if( pMap == aHParaHtmlAbsMap )
367 0 : return SAL_N_ELEMENTS( aHParaHtmlAbsMap );
368 0 : if( pMap == aVPageMap )
369 0 : return SAL_N_ELEMENTS( aVPageMap );
370 0 : if( pMap == aVPageHtmlMap )
371 0 : return SAL_N_ELEMENTS( aVPageHtmlMap );
372 0 : if( pMap == aVAsCharMap )
373 0 : return SAL_N_ELEMENTS( aVAsCharMap );
374 0 : if( pMap == aVParaMap )
375 0 : return SAL_N_ELEMENTS( aVParaMap );
376 0 : if( pMap == aHParaMap )
377 0 : return SAL_N_ELEMENTS( aHParaMap );
378 0 : if( pMap == aHFrameMap )
379 0 : return SAL_N_ELEMENTS( aHFrameMap );
380 0 : if( pMap == aVFrameMap )
381 0 : return SAL_N_ELEMENTS( aVFrameMap );
382 0 : if( pMap == aHCharMap )
383 0 : return SAL_N_ELEMENTS( aHCharMap );
384 0 : if( pMap == aHCharHtmlMap )
385 0 : return SAL_N_ELEMENTS( aHCharHtmlMap );
386 0 : if( pMap == aHCharHtmlAbsMap )
387 0 : return SAL_N_ELEMENTS( aHCharHtmlAbsMap );
388 0 : if( pMap == aVCharMap )
389 0 : return SAL_N_ELEMENTS( aVCharMap );
390 0 : if( pMap == aVCharHtmlMap )
391 0 : return SAL_N_ELEMENTS( aVCharHtmlMap );
392 0 : if( pMap == aVCharHtmlAbsMap )
393 0 : return SAL_N_ELEMENTS( aVCharHtmlAbsMap );
394 0 : if( pMap == aHPageHtmlMap )
395 0 : return SAL_N_ELEMENTS( aHPageHtmlMap );
396 0 : if( pMap == aHFlyHtmlMap )
397 0 : return SAL_N_ELEMENTS( aHFlyHtmlMap );
398 0 : if( pMap == aVFlyHtmlMap )
399 0 : return SAL_N_ELEMENTS( aVFlyHtmlMap );
400 0 : if( pMap == aVMultiSelectionMap )
401 0 : return SAL_N_ELEMENTS( aVMultiSelectionMap );
402 0 : if( pMap == aHMultiSelectionMap )
403 0 : return SAL_N_ELEMENTS( aHMultiSelectionMap );
404 0 : return SAL_N_ELEMENTS(aHPageMap);
405 : }
406 0 : return 0;
407 : }
408 :
409 0 : static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(
410 : SvxSwFramePosString::StringId eStringId, sal_Bool bVertical, sal_Bool bRTL)
411 : {
412 : //special handling of STR_FROMLEFT
413 0 : if(SwFPos::FROMLEFT == eStringId)
414 : {
415 : eStringId = bVertical ?
416 : bRTL ? SwFPos::FROMBOTTOM : SwFPos::FROMTOP :
417 0 : bRTL ? SwFPos::FROMRIGHT : SwFPos::FROMLEFT;
418 0 : return eStringId;
419 : }
420 0 : if(bVertical)
421 : {
422 : //exchange horizontal strings with vertical strings and vice versa
423 : static const StringIdPair_Impl aHoriIds[] =
424 : {
425 : {SwFPos::LEFT, SwFPos::TOP},
426 : {SwFPos::RIGHT, SwFPos::BOTTOM},
427 : {SwFPos::CENTER_HORI, SwFPos::CENTER_VERT},
428 : {SwFPos::FROMTOP, SwFPos::FROMRIGHT},
429 : {SwFPos::REL_PG_LEFT, SwFPos::REL_PG_TOP},
430 : {SwFPos::REL_PG_RIGHT, SwFPos::REL_PG_BOTTOM} ,
431 : {SwFPos::REL_FRM_LEFT, SwFPos::REL_FRM_TOP},
432 : {SwFPos::REL_FRM_RIGHT, SwFPos::REL_FRM_BOTTOM}
433 : };
434 : static const StringIdPair_Impl aVertIds[] =
435 : {
436 : {SwFPos::TOP, SwFPos::RIGHT},
437 : {SwFPos::BOTTOM, SwFPos::LEFT },
438 : {SwFPos::CENTER_VERT, SwFPos::CENTER_HORI},
439 : {SwFPos::FROMTOP, SwFPos::FROMRIGHT },
440 : {SwFPos::REL_PG_TOP, SwFPos::REL_PG_LEFT },
441 : {SwFPos::REL_PG_BOTTOM, SwFPos::REL_PG_RIGHT } ,
442 : {SwFPos::REL_FRM_TOP, SwFPos::REL_FRM_LEFT },
443 : {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
444 : };
445 : sal_uInt16 nIndex;
446 0 : for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex)
447 : {
448 0 : if(aHoriIds[nIndex].eHori == eStringId)
449 : {
450 0 : eStringId = aHoriIds[nIndex].eVert;
451 0 : return eStringId;
452 : }
453 : }
454 0 : nIndex = 0;
455 0 : for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
456 : {
457 0 : if(aVertIds[nIndex].eHori == eStringId)
458 : {
459 0 : eStringId = aVertIds[nIndex].eVert;
460 0 : break;
461 : }
462 : }
463 : }
464 0 : return eStringId;
465 : }
466 : // #i22341# - helper method in order to determine all possible
467 : // listbox relations in a relation map for a given relation
468 0 : static sal_uLong lcl_GetLBRelationsForRelations( const sal_uInt16 _nRel )
469 : {
470 0 : sal_uLong nLBRelations = 0L;
471 :
472 0 : for ( sal_uInt16 nRelMapPos = 0; nRelMapPos < SAL_N_ELEMENTS(aRelationMap); ++nRelMapPos )
473 : {
474 0 : if ( aRelationMap[nRelMapPos].nRelation == _nRel )
475 : {
476 0 : nLBRelations |= aRelationMap[nRelMapPos].nLBRelation;
477 : }
478 : }
479 :
480 0 : return nLBRelations;
481 : }
482 :
483 : // #i22341# - helper method on order to determine all possible
484 : // listbox relations in a relation map for a given string ID
485 0 : static sal_uLong lcl_GetLBRelationsForStrID( const FrmMap* _pMap,
486 : const SvxSwFramePosString::StringId _eStrId,
487 : const bool _bUseMirrorStr )
488 : {
489 0 : sal_uLong nLBRelations = 0L;
490 :
491 0 : std::size_t nRelMapSize = lcl_GetFrmMapCount( _pMap );
492 0 : for ( std::size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
493 : {
494 0 : if ( ( !_bUseMirrorStr && _pMap[nRelMapPos].eStrId == _eStrId ) ||
495 0 : ( _bUseMirrorStr && _pMap[nRelMapPos].eMirrorStrId == _eStrId ) )
496 : {
497 0 : nLBRelations |= _pMap[nRelMapPos].nLBRelations;
498 : }
499 : }
500 :
501 0 : return nLBRelations;
502 : }
503 :
504 0 : SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(Window* pParent, const SfxItemSet& rInAttrs)
505 : : SfxTabPage(pParent, "SwPosSizePage", "cui/ui/swpossizepage.ui", rInAttrs)
506 : , m_pVMap(0)
507 : , m_pHMap(0)
508 : , m_pSdrView(0)
509 : , m_nOldH(HoriOrientation::CENTER)
510 : , m_nOldHRel(RelOrientation::FRAME)
511 : , m_nOldV(VertOrientation::TOP)
512 : , m_nOldVRel(RelOrientation::PRINT_AREA)
513 : , m_fWidthHeightRatio(1.0)
514 : , m_bHtmlMode(false)
515 : , m_bAtHoriPosModified(false)
516 : , m_bAtVertPosModified(false)
517 : , m_bIsVerticalFrame(false)
518 : , m_bPositioningDisabled(false)
519 : , m_bIsMultiSelection(false)
520 0 : , m_bIsInRightToLeft(false)
521 : {
522 0 : get(m_pWidthMF, "width");
523 0 : get(m_pHeightMF, "height");
524 0 : get(m_pKeepRatioCB, "ratio");
525 0 : get(m_pToPageRB, "topage");
526 0 : get(m_pToParaRB, "topara");
527 0 : get(m_pToCharRB, "tochar");
528 0 : get(m_pAsCharRB, "aschar");
529 0 : get(m_pToFrameRB, "toframe");
530 0 : get(m_pPositionCB, "pos");
531 0 : get(m_pSizeCB, "size");
532 0 : get(m_pPosFrame, "posframe");
533 0 : get(m_pHoriFT, "horiposft");
534 0 : get(m_pHoriLB, "horipos");
535 0 : get(m_pHoriByFT, "horibyft");
536 0 : get(m_pHoriByMF, "byhori");
537 0 : get(m_pHoriToFT, "horitoft");
538 0 : get(m_pHoriToLB, "horianchor");
539 0 : get(m_pHoriMirrorCB, "mirror");
540 0 : get(m_pVertFT, "vertposft");
541 0 : get(m_pVertLB, "vertpos");
542 0 : get(m_pVertByFT, "vertbyft");
543 0 : get(m_pVertByMF, "byvert");
544 0 : get(m_pVertToFT, "verttoft");
545 0 : get(m_pVertToLB, "vertanchor");
546 0 : get(m_pFollowCB, "followtextflow");
547 0 : get(m_pExampleWN, "preview");
548 :
549 0 : setOptimalFrmWidth();
550 0 : setOptimalRelWidth();
551 :
552 0 : FieldUnit eDlgUnit = GetModuleFieldUnit( rInAttrs );
553 0 : SetFieldUnit( *m_pHoriByMF, eDlgUnit, true );
554 0 : SetFieldUnit( *m_pVertByMF, eDlgUnit, true );
555 0 : SetFieldUnit( *m_pWidthMF , eDlgUnit, true );
556 0 : SetFieldUnit( *m_pHeightMF, eDlgUnit, true );
557 :
558 0 : SetExchangeSupport();
559 :
560 0 : Link aLk = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl);
561 0 : m_pWidthMF->SetLoseFocusHdl( aLk );
562 0 : m_pHeightMF->SetLoseFocusHdl( aLk );
563 0 : m_pHoriByMF->SetLoseFocusHdl( aLk );
564 0 : m_pVertByMF->SetLoseFocusHdl( aLk );
565 0 : m_pFollowCB->SetClickHdl( aLk );
566 :
567 0 : aLk = LINK(this, SvxSwPosSizeTabPage, ModifyHdl);
568 0 : m_pWidthMF->SetModifyHdl( aLk );
569 0 : m_pHeightMF->SetModifyHdl( aLk );
570 0 : m_pHoriByMF->SetModifyHdl( aLk );
571 0 : m_pVertByMF->SetModifyHdl( aLk );
572 :
573 0 : aLk = LINK(this, SvxSwPosSizeTabPage, AnchorTypeHdl);
574 0 : m_pToPageRB->SetClickHdl( aLk );
575 0 : m_pToParaRB->SetClickHdl( aLk );
576 0 : m_pToCharRB->SetClickHdl( aLk );
577 0 : m_pAsCharRB->SetClickHdl( aLk );
578 0 : m_pToFrameRB->SetClickHdl( aLk );
579 :
580 0 : m_pHoriLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, PosHdl));
581 0 : m_pVertLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, PosHdl));
582 :
583 0 : m_pHoriToLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, RelHdl));
584 0 : m_pVertToLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, RelHdl));
585 :
586 0 : m_pHoriMirrorCB->SetClickHdl(LINK(this, SvxSwPosSizeTabPage, MirrorHdl));
587 0 : m_pPositionCB->SetClickHdl(LINK(this, SvxSwPosSizeTabPage, ProtectHdl));
588 0 : }
589 :
590 : namespace
591 : {
592 : struct FrmMaps
593 : {
594 : FrmMap *pMap;
595 : size_t nCount;
596 : };
597 : }
598 :
599 0 : void SvxSwPosSizeTabPage::setOptimalFrmWidth()
600 : {
601 : const FrmMaps aMaps[] = {
602 : { aHPageMap, SAL_N_ELEMENTS(aHPageMap) },
603 : { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) },
604 : { aVPageMap, SAL_N_ELEMENTS(aVPageMap) },
605 : { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) },
606 : { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) },
607 : { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) },
608 : { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) },
609 : { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFrameMap) },
610 : { aHParaMap, SAL_N_ELEMENTS(aHParaMap) },
611 : { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) },
612 : { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) },
613 : { aVParaMap, SAL_N_ELEMENTS(aVParaMap) },
614 : { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) },
615 : { aHCharMap, SAL_N_ELEMENTS(aHCharMap) },
616 : { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) },
617 : { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) },
618 : { aVCharMap, SAL_N_ELEMENTS(aVCharMap) },
619 : { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) },
620 : { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) },
621 : { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) },
622 : { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) }
623 0 : };
624 :
625 0 : std::vector<SvxSwFramePosString::StringId> aFrames;
626 0 : for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
627 : {
628 0 : for (size_t j = 0; j < aMaps[i].nCount; ++j)
629 : {
630 0 : aFrames.push_back(aMaps[i].pMap[j].eStrId);
631 0 : aFrames.push_back(aMaps[i].pMap[j].eMirrorStrId);
632 : }
633 : }
634 :
635 0 : std::sort(aFrames.begin(), aFrames.end());
636 0 : aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end());
637 :
638 0 : for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aFrames.begin(), aEnd = aFrames.end();
639 : aI != aEnd; ++aI)
640 : {
641 0 : m_pHoriLB->InsertEntry(m_aFramePosString.GetString(*aI));
642 : }
643 :
644 0 : Size aBiggest(m_pHoriLB->GetOptimalSize());
645 0 : m_pHoriLB->set_width_request(aBiggest.Width());
646 0 : m_pVertLB->set_width_request(aBiggest.Width());
647 0 : m_pHoriLB->Clear();
648 0 : }
649 :
650 : namespace
651 : {
652 : struct RelationMaps
653 : {
654 : RelationMap *pMap;
655 : size_t nCount;
656 : };
657 : }
658 :
659 0 : void SvxSwPosSizeTabPage::setOptimalRelWidth()
660 : {
661 : const RelationMaps aMaps[] = {
662 : { aRelationMap, SAL_N_ELEMENTS(aRelationMap) },
663 : { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) }
664 0 : };
665 :
666 0 : std::vector<SvxSwFramePosString::StringId> aRels;
667 0 : for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
668 : {
669 0 : for (size_t j = 0; j < aMaps[i].nCount; ++j)
670 : {
671 0 : aRels.push_back(aMaps[i].pMap[j].eStrId);
672 0 : aRels.push_back(aMaps[i].pMap[j].eMirrorStrId);
673 : }
674 : }
675 :
676 0 : std::sort(aRels.begin(), aRels.end());
677 0 : aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end());
678 :
679 0 : for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aRels.begin(), aEnd = aRels.end();
680 : aI != aEnd; ++aI)
681 : {
682 0 : m_pHoriLB->InsertEntry(m_aFramePosString.GetString(*aI));
683 : }
684 :
685 0 : Size aBiggest(m_pHoriLB->GetOptimalSize());
686 0 : m_pHoriLB->set_width_request(aBiggest.Width());
687 0 : m_pVertLB->set_width_request(aBiggest.Width());
688 0 : m_pHoriLB->Clear();
689 0 : }
690 :
691 0 : SvxSwPosSizeTabPage::~SvxSwPosSizeTabPage()
692 : {
693 0 : }
694 :
695 0 : SfxTabPage* SvxSwPosSizeTabPage::Create( Window* pParent, const SfxItemSet& rSet)
696 : {
697 0 : return new SvxSwPosSizeTabPage(pParent, rSet);
698 : }
699 :
700 0 : sal_uInt16* SvxSwPosSizeTabPage::GetRanges()
701 : {
702 : static sal_uInt16 pSwPosRanges[] =
703 : {
704 : SID_ATTR_TRANSFORM_POS_X,
705 : SID_ATTR_TRANSFORM_POS_Y,
706 : SID_ATTR_TRANSFORM_PROTECT_POS,
707 : SID_ATTR_TRANSFORM_PROTECT_POS,
708 : SID_ATTR_TRANSFORM_INTERN,
709 : SID_ATTR_TRANSFORM_INTERN,
710 : SID_ATTR_TRANSFORM_ANCHOR,
711 : SID_ATTR_TRANSFORM_VERT_ORIENT,
712 : SID_ATTR_TRANSFORM_WIDTH,
713 : SID_ATTR_TRANSFORM_SIZE_POINT,
714 : SID_ATTR_TRANSFORM_PROTECT_POS,
715 : SID_ATTR_TRANSFORM_INTERN,
716 : SID_ATTR_TRANSFORM_AUTOWIDTH,
717 : SID_ATTR_TRANSFORM_VERT_ORIENT,
718 : SID_HTML_MODE,
719 : SID_HTML_MODE,
720 : SID_SW_FOLLOW_TEXT_FLOW,
721 : SID_SW_FOLLOW_TEXT_FLOW,
722 : SID_ATTR_TRANSFORM_HORI_POSITION,
723 : SID_ATTR_TRANSFORM_VERT_POSITION,
724 : 0
725 : };
726 0 : return pSwPosRanges;
727 : }
728 :
729 0 : bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet& rSet)
730 : {
731 0 : bool bAnchorChanged = false;
732 0 : short nAnchor = GetAnchorType(&bAnchorChanged);
733 0 : bool bModified = false;
734 0 : if(bAnchorChanged)
735 : {
736 0 : rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
737 0 : bModified = true;
738 : }
739 0 : if ( m_pPositionCB->GetState() != m_pPositionCB->GetSavedValue() )
740 : {
741 0 : if( m_pPositionCB->GetState() == TRISTATE_INDET )
742 0 : rSet.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS );
743 : else
744 : rSet.Put(
745 0 : SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ),
746 0 : m_pPositionCB->GetState() == TRISTATE_TRUE ? sal_True : sal_False ) );
747 0 : bModified = true;
748 : }
749 :
750 0 : if ( m_pSizeCB->GetState() != m_pSizeCB->GetSavedValue() )
751 : {
752 0 : if ( m_pSizeCB->GetState() == TRISTATE_INDET )
753 0 : rSet.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE );
754 : else
755 : rSet.Put(
756 0 : SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ),
757 0 : m_pSizeCB->GetState() == TRISTATE_TRUE ? sal_True : sal_False ) );
758 0 : bModified = true;
759 : }
760 :
761 0 : const SfxItemSet& rOldSet = GetItemSet();
762 :
763 0 : if(!m_bPositioningDisabled)
764 : {
765 : //on multiple selections the positioning is set via SdrView
766 0 : if(m_bIsMultiSelection)
767 : {
768 0 : if( m_pHoriByMF->IsValueModified() || m_pVertByMF->IsValueModified() )
769 : {
770 : long nHoriByPos =
771 0 : static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
772 : long nVertByPos =
773 0 : static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
774 :
775 : // old rectangle with CoreUnit
776 0 : m_aRect = m_pSdrView->GetAllMarkedRect();
777 0 : m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect );
778 :
779 0 : nHoriByPos += m_aAnchorPos.X();
780 0 : nVertByPos += m_aAnchorPos.Y();
781 :
782 0 : rSet.Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_X ), nHoriByPos ) );
783 0 : rSet.Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_Y ), nVertByPos ) );
784 :
785 0 : bModified = true;
786 : }
787 : }
788 : else
789 : {
790 0 : if ( m_pHMap )
791 : {
792 : const SfxInt16Item& rHoriOrient =
793 0 : static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT));
794 : const SfxInt16Item& rHoriRelation =
795 0 : static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION));
796 : const SfxInt32Item& rHoriPosition =
797 0 : static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION)) ;
798 :
799 0 : sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriLB);
800 0 : short nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
801 0 : short nRel = GetRelation(m_pHMap, *m_pHoriToLB);
802 : const long nHoriByPos =
803 0 : static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
804 0 : if (
805 0 : nAlign != rHoriOrient.GetValue() ||
806 0 : nRel != rHoriRelation.GetValue() ||
807 0 : (m_pHoriByMF->IsEnabled() && nHoriByPos != rHoriPosition.GetValue())
808 : )
809 : {
810 0 : rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, nAlign));
811 0 : rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, nRel));
812 0 : if(m_pHoriByMF->IsEnabled())
813 0 : rSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, nHoriByPos));
814 0 : bModified = true;
815 : }
816 : }
817 0 : if(m_pHoriMirrorCB->IsEnabled() && TriState(m_pHoriMirrorCB->IsChecked()) != m_pHoriMirrorCB->GetSavedValue())
818 0 : bModified |= 0 != rSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, m_pHoriMirrorCB->IsChecked()));
819 :
820 0 : if ( m_pVMap )
821 : {
822 : const SfxInt16Item& rVertOrient =
823 0 : static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT));
824 : const SfxInt16Item& rVertRelation =
825 0 : static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION));
826 : const SfxInt32Item& rVertPosition =
827 0 : static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION));
828 :
829 0 : sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
830 0 : short nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
831 0 : short nRel = GetRelation(m_pVMap, *m_pVertToLB);
832 : // #i34055# - convert vertical position for
833 : // as-character anchored objects
834 : long nVertByPos =
835 0 : static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
836 0 : if ( GetAnchorType() == TextContentAnchorType_AS_CHARACTER )
837 : {
838 0 : nVertByPos *= -1;
839 : }
840 0 : if ( nAlign != rVertOrient.GetValue() ||
841 0 : nRel != rVertRelation.GetValue() ||
842 0 : ( m_pVertByMF->IsEnabled() &&
843 0 : nVertByPos != rVertPosition.GetValue() ) )
844 : {
845 0 : rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, nAlign));
846 0 : rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, nRel));
847 0 : if(m_pVertByMF->IsEnabled())
848 0 : rSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, nVertByPos));
849 0 : bModified = true;
850 : }
851 : }
852 :
853 : // #i18732#
854 0 : if(TriState(m_pFollowCB->IsChecked()) != m_pFollowCB->GetSavedValue())
855 : {
856 : //Writer internal type - based on SfxBoolItem
857 0 : const SfxPoolItem* pItem = GetItem( rOldSet, SID_SW_FOLLOW_TEXT_FLOW);
858 0 : if(pItem)
859 : {
860 0 : SfxBoolItem* pFollow = static_cast<SfxBoolItem*>(pItem->Clone());
861 0 : pFollow->SetValue(m_pFollowCB->IsChecked());
862 0 : bModified |= 0 != rSet.Put(*pFollow);
863 0 : delete pFollow;
864 : }
865 : }
866 : }
867 : }
868 0 : if ( m_pWidthMF->IsValueModified() || m_pHeightMF->IsValueModified() )
869 : {
870 0 : sal_uInt32 nWidth = static_cast<sal_uInt32>(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP)));
871 0 : sal_uInt32 nHeight = static_cast<sal_uInt32>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP)));
872 0 : rSet.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ),
873 0 : (sal_uInt32) nWidth ) );
874 0 : rSet.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ),
875 0 : (sal_uInt32) nHeight ) );
876 : //this item is required by SdrEditView::SetGeoAttrToMarked()
877 0 : rSet.Put( SfxAllEnumItem( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), RP_LT ) );
878 :
879 0 : bModified = true;
880 : }
881 :
882 0 : return bModified;
883 : }
884 :
885 0 : void SvxSwPosSizeTabPage::Reset( const SfxItemSet& rSet)
886 : {
887 0 : const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_TRANSFORM_ANCHOR );
888 0 : bool bInvalidateAnchor = false;
889 0 : short nAnchorType = TextContentAnchorType_AT_PARAGRAPH;
890 0 : if(pItem)
891 : {
892 0 : nAnchorType = static_cast<const SfxInt16Item*>(pItem)->GetValue();
893 0 : switch(nAnchorType)
894 : {
895 0 : case TextContentAnchorType_AT_PAGE: m_pToPageRB->Check(); break;
896 0 : case TextContentAnchorType_AT_PARAGRAPH: m_pToParaRB->Check(); break;
897 0 : case TextContentAnchorType_AT_CHARACTER: m_pToCharRB->Check(); break;
898 0 : case TextContentAnchorType_AS_CHARACTER: m_pAsCharRB->Check(); break;
899 0 : case TextContentAnchorType_AT_FRAME: m_pToFrameRB->Check(); break;
900 0 : default : bInvalidateAnchor = true;
901 : }
902 0 : m_pToPageRB->SaveValue();
903 0 : m_pToParaRB->SaveValue();
904 0 : m_pToCharRB->SaveValue();
905 0 : m_pAsCharRB->SaveValue();
906 0 : m_pToFrameRB->SaveValue();
907 : }
908 0 : if(bInvalidateAnchor)
909 : {
910 0 : m_pToPageRB->Enable( false );
911 0 : m_pToParaRB->Enable( false );
912 0 : m_pToCharRB->Enable( false );
913 0 : m_pAsCharRB->Enable( false );
914 0 : m_pToFrameRB->Enable( false );
915 : }
916 :
917 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_PROTECT_POS );
918 0 : if ( pItem )
919 : {
920 0 : sal_Bool bProtected = ( ( const SfxBoolItem* )pItem )->GetValue();
921 0 : m_pPositionCB->SetState( bProtected ? TRISTATE_TRUE : TRISTATE_FALSE );
922 0 : m_pPositionCB->EnableTriState( false );
923 0 : m_pSizeCB->Enable( !bProtected );
924 : }
925 : else
926 : {
927 0 : m_pPositionCB->SetState( TRISTATE_INDET );
928 : }
929 :
930 0 : m_pPositionCB->SaveValue();
931 :
932 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_PROTECT_SIZE );
933 :
934 0 : if ( pItem )
935 : {
936 0 : m_pSizeCB->SetState( ( (const SfxBoolItem*)pItem )->GetValue()
937 0 : ? TRISTATE_TRUE : TRISTATE_FALSE );
938 0 : m_pSizeCB->EnableTriState( false );
939 : }
940 : else
941 0 : m_pSizeCB->SetState( TRISTATE_INDET );
942 0 : m_pSizeCB->SaveValue();
943 :
944 0 : pItem = GetItem( rSet, SID_HTML_MODE );
945 0 : if(pItem)
946 : {
947 : m_bHtmlMode =
948 0 : (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
949 0 : != 0;
950 : }
951 :
952 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT );
953 0 : if(pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue())
954 : {
955 0 : OUString sHLabel = m_pHoriFT->GetText();
956 0 : m_pHoriFT->SetText(m_pVertFT->GetText());
957 0 : m_pVertFT->SetText(sHLabel);
958 0 : m_bIsVerticalFrame = true;
959 : }
960 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_IN_RTL_TEXT);
961 0 : if(pItem)
962 0 : m_bIsInRightToLeft = static_cast<const SfxBoolItem*>(pItem)->GetValue();
963 :
964 0 : pItem = GetItem( rSet, SID_SW_FOLLOW_TEXT_FLOW);
965 0 : if(pItem)
966 : {
967 : const bool bFollowTextFlow =
968 0 : static_cast<const SfxBoolItem*>(pItem)->GetValue();
969 0 : m_pFollowCB->Check( bFollowTextFlow );
970 : }
971 0 : m_pFollowCB->SaveValue();
972 :
973 0 : if(m_bHtmlMode)
974 : {
975 0 : m_pHoriMirrorCB->Show(false);
976 0 : m_pKeepRatioCB->Enable(false);
977 : // #i18732# - hide checkbox in HTML mode
978 0 : m_pFollowCB->Show(false);
979 : }
980 : else
981 : {
982 : // #i18732# correct enable/disable of check box 'Mirror on..'
983 0 : m_pHoriMirrorCB->Enable(!m_pAsCharRB->IsChecked() && !m_bIsMultiSelection);
984 :
985 : // #i18732# - enable/disable check box 'Follow text flow'.
986 0 : m_pFollowCB->Enable( m_pToParaRB->IsChecked() ||
987 0 : m_pToCharRB->IsChecked() );
988 : }
989 :
990 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_WIDTH );
991 0 : sal_Int32 nWidth = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, (sal_uInt32)1 );
992 :
993 0 : m_pWidthMF->SetValue(m_pWidthMF->Normalize(nWidth), FUNIT_TWIP);
994 :
995 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HEIGHT );
996 0 : sal_Int32 nHeight = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, (sal_uInt32)1 );
997 0 : m_pHeightMF->SetValue(m_pHeightMF->Normalize(nHeight), FUNIT_TWIP);
998 0 : m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
999 :
1000 0 : if(!m_bPositioningDisabled)
1001 : {
1002 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HORI_ORIENT);
1003 0 : if(pItem)
1004 : {
1005 0 : short nHoriOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue();
1006 0 : m_nOldH = nHoriOrientation;
1007 : }
1008 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_VERT_ORIENT);
1009 0 : if(pItem)
1010 : {
1011 0 : short nVertOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue();
1012 0 : m_nOldV = nVertOrientation;
1013 : }
1014 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HORI_RELATION);
1015 0 : if(pItem)
1016 : {
1017 0 : m_nOldHRel = static_cast< const SfxInt16Item*>(pItem)->GetValue();
1018 : }
1019 :
1020 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_VERT_RELATION);
1021 0 : if(pItem)
1022 : {
1023 0 : m_nOldVRel = static_cast< const SfxInt16Item*>(pItem)->GetValue();
1024 : }
1025 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HORI_MIRROR);
1026 0 : if(pItem)
1027 0 : m_pHoriMirrorCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
1028 0 : m_pHoriMirrorCB->SaveValue();
1029 :
1030 0 : sal_Int32 nHoriPos = 0;
1031 0 : sal_Int32 nVertPos = 0;
1032 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HORI_POSITION);
1033 0 : if(pItem)
1034 0 : nHoriPos = static_cast<const SfxInt32Item*>(pItem)->GetValue();
1035 0 : pItem = GetItem( rSet, SID_ATTR_TRANSFORM_VERT_POSITION);
1036 0 : if(pItem)
1037 0 : nVertPos = static_cast<const SfxInt32Item*>(pItem)->GetValue();
1038 :
1039 0 : InitPos(nAnchorType, m_nOldH, m_nOldHRel, m_nOldV, m_nOldVRel, nHoriPos, nVertPos);
1040 :
1041 0 : m_pVertByMF->SaveValue();
1042 0 : m_pHoriByMF->SaveValue();
1043 : // #i18732#
1044 0 : m_pFollowCB->SaveValue();
1045 :
1046 0 : RangeModifyHdl(m_pWidthMF); // initially set maximum values
1047 : }
1048 0 : }
1049 :
1050 0 : int SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
1051 : {
1052 0 : if( _pSet )
1053 0 : FillItemSet( *_pSet );
1054 0 : return( LEAVE_PAGE );
1055 : }
1056 :
1057 0 : void SvxSwPosSizeTabPage::EnableAnchorTypes(sal_uInt16 nAnchorEnable)
1058 : {
1059 0 : if((nAnchorEnable & SVX_OBJ_AT_FLY))
1060 0 : m_pToFrameRB->Show();
1061 0 : if(!(nAnchorEnable & SVX_OBJ_PAGE))
1062 0 : m_pToPageRB->Enable(false);
1063 0 : }
1064 :
1065 0 : short SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged)
1066 : {
1067 0 : short nRet = -1;
1068 0 : RadioButton* pCheckedButton = 0;
1069 0 : if(m_pToParaRB->IsEnabled())
1070 : {
1071 0 : if(m_pToPageRB->IsChecked())
1072 : {
1073 0 : nRet = TextContentAnchorType_AT_PAGE;
1074 0 : pCheckedButton = m_pToPageRB;
1075 : }
1076 0 : else if(m_pToParaRB->IsChecked())
1077 : {
1078 0 : nRet = TextContentAnchorType_AT_PARAGRAPH;
1079 0 : pCheckedButton = m_pToParaRB;
1080 : }
1081 0 : else if(m_pToCharRB->IsChecked())
1082 : {
1083 0 : nRet = TextContentAnchorType_AT_CHARACTER;
1084 0 : pCheckedButton = m_pToCharRB;
1085 : }
1086 0 : else if(m_pAsCharRB->IsChecked())
1087 : {
1088 0 : nRet = TextContentAnchorType_AS_CHARACTER;
1089 0 : pCheckedButton = m_pAsCharRB;
1090 : }
1091 0 : else if(m_pToFrameRB->IsChecked())
1092 : {
1093 0 : nRet = TextContentAnchorType_AT_FRAME;
1094 0 : pCheckedButton = m_pToFrameRB;
1095 : }
1096 : }
1097 0 : if(pbHasChanged)
1098 : {
1099 0 : if(pCheckedButton)
1100 0 : *pbHasChanged = pCheckedButton->IsChecked() != pCheckedButton->GetSavedValue();
1101 : else
1102 0 : *pbHasChanged = false;
1103 : }
1104 0 : return nRet;
1105 : }
1106 :
1107 0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl)
1108 : {
1109 0 : if(m_bPositioningDisabled)
1110 0 : return 0;
1111 0 : SvxSwFrameValidation aVal;
1112 :
1113 0 : aVal.nAnchorType = GetAnchorType();
1114 0 : aVal.bAutoHeight = false;
1115 0 : aVal.bAutoWidth = false;
1116 0 : aVal.bMirror = m_pHoriMirrorCB->IsChecked();
1117 : // #i18732#
1118 0 : aVal.bFollowTextFlow = m_pFollowCB->IsChecked();
1119 :
1120 0 : if ( m_pHMap )
1121 : {
1122 : // horizontal alignment
1123 0 : sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriToLB);
1124 0 : sal_uInt16 nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
1125 0 : sal_uInt16 nRel = GetRelation(m_pHMap, *m_pHoriToLB);
1126 :
1127 0 : aVal.nHoriOrient = (short)nAlign;
1128 0 : aVal.nHRelOrient = (short)nRel;
1129 : }
1130 : else
1131 0 : aVal.nHoriOrient = HoriOrientation::NONE;
1132 :
1133 0 : if ( m_pVMap )
1134 : {
1135 : // vertical alignment
1136 0 : sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
1137 0 : sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
1138 0 : sal_uInt16 nRel = GetRelation(m_pVMap, *m_pVertToLB);
1139 :
1140 0 : aVal.nVertOrient = (short)nAlign;
1141 0 : aVal.nVRelOrient = (short)nRel;
1142 : }
1143 : else
1144 0 : aVal.nVertOrient = VertOrientation::NONE;
1145 :
1146 : const long nAtHorzPosVal =
1147 0 : static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
1148 : const long nAtVertPosVal =
1149 0 : static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
1150 :
1151 0 : aVal.nHPos = nAtHorzPosVal;
1152 0 : aVal.nVPos = nAtVertPosVal;
1153 :
1154 0 : sal_Int32 nWidth = static_cast<sal_uInt32>(m_pWidthMF-> Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP)));
1155 0 : sal_Int32 nHeight = static_cast<sal_uInt32>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP)));
1156 0 : aVal.nWidth = nWidth;
1157 0 : aVal.nHeight = nHeight;
1158 :
1159 0 : if(m_aValidateLink.IsSet())
1160 0 : m_aValidateLink.Call(&aVal);
1161 :
1162 0 : nWidth = aVal.nWidth;
1163 0 : nHeight = aVal.nHeight;
1164 :
1165 : // minimum width also for style
1166 0 : m_pHeightMF->SetMin(m_pHeightMF->Normalize(aVal.nMinHeight), FUNIT_TWIP);
1167 0 : m_pWidthMF-> SetMin(m_pWidthMF->Normalize(aVal.nMinWidth), FUNIT_TWIP);
1168 :
1169 0 : sal_Int32 nMaxWidth(aVal.nMaxWidth);
1170 0 : sal_Int32 nMaxHeight(aVal.nMaxHeight);
1171 :
1172 0 : sal_Int64 nTmp = m_pHeightMF->Normalize(nMaxHeight);
1173 0 : m_pHeightMF->SetMax(nTmp, FUNIT_TWIP);
1174 :
1175 0 : nTmp = m_pWidthMF->Normalize(nMaxWidth);
1176 0 : m_pWidthMF->SetMax(nTmp, FUNIT_TWIP);
1177 :
1178 0 : m_pHoriByMF->SetMin(m_pHoriByMF->Normalize(aVal.nMinHPos), FUNIT_TWIP);
1179 0 : m_pHoriByMF->SetMax(m_pHoriByMF->Normalize(aVal.nMaxHPos), FUNIT_TWIP);
1180 0 : if ( aVal.nHPos != nAtHorzPosVal )
1181 0 : m_pHoriByMF->SetValue(m_pHoriByMF->Normalize(aVal.nHPos), FUNIT_TWIP);
1182 :
1183 0 : m_pVertByMF->SetMin(m_pVertByMF->Normalize(aVal.nMinVPos ), FUNIT_TWIP);
1184 0 : m_pVertByMF->SetMax(m_pVertByMF->Normalize(aVal.nMaxVPos), FUNIT_TWIP);
1185 0 : if ( aVal.nVPos != nAtVertPosVal )
1186 0 : m_pVertByMF->SetValue(m_pVertByMF->Normalize(aVal.nVPos), FUNIT_TWIP);
1187 :
1188 0 : return 0;
1189 : }
1190 :
1191 0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl)
1192 : {
1193 0 : m_pHoriMirrorCB->Enable(!m_pAsCharRB->IsChecked() && !m_bIsMultiSelection);
1194 :
1195 : // #i18732# - enable check box 'Follow text flow' for anchor
1196 : // type to-paragraph' and to-character
1197 0 : m_pFollowCB->Enable( m_pToParaRB->IsChecked() || m_pToCharRB->IsChecked() );
1198 :
1199 0 : short nId = GetAnchorType();
1200 :
1201 0 : InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX);
1202 0 : RangeModifyHdl(0);
1203 :
1204 0 : if(m_bHtmlMode)
1205 : {
1206 0 : PosHdl(m_pHoriLB);
1207 0 : PosHdl(m_pVertLB);
1208 : }
1209 0 : return 0;
1210 : }
1211 :
1212 0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl)
1213 : {
1214 0 : short nId = GetAnchorType();
1215 0 : InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX);
1216 :
1217 0 : return 0;
1218 : }
1219 :
1220 0 : IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, ListBox *, pLB )
1221 : {
1222 0 : sal_Bool bHori = pLB == m_pHoriToLB;
1223 :
1224 0 : UpdateExample();
1225 :
1226 0 : if (bHori)
1227 0 : m_bAtHoriPosModified = true;
1228 : else
1229 0 : m_bAtVertPosModified = true;
1230 :
1231 0 : if(m_bHtmlMode && TextContentAnchorType_AT_CHARACTER == GetAnchorType()) // again special treatment
1232 : {
1233 0 : if(bHori)
1234 : {
1235 0 : sal_uInt16 nRel = GetRelation(m_pHMap, *m_pHoriToLB);
1236 0 : if(RelOrientation::PRINT_AREA == nRel && 0 == m_pVertLB->GetSelectEntryPos())
1237 : {
1238 0 : m_pVertLB->SelectEntryPos(1);
1239 : }
1240 0 : else if(RelOrientation::CHAR == nRel && 1 == m_pVertLB->GetSelectEntryPos())
1241 : {
1242 0 : m_pVertLB->SelectEntryPos(0);
1243 : }
1244 : }
1245 : }
1246 0 : if (pLB) // only if the hanlder has been called by a change of the controller
1247 0 : RangeModifyHdl(0);
1248 :
1249 0 : return 0;
1250 :
1251 : }
1252 :
1253 0 : IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox *, pLB )
1254 : {
1255 0 : sal_Bool bHori = pLB == m_pHoriLB;
1256 0 : ListBox *pRelLB = bHori ? m_pHoriToLB : m_pVertToLB;
1257 0 : FixedText *pRelFT = bHori ? m_pHoriToFT : m_pVertToFT;
1258 0 : FrmMap *pMap = bHori ? m_pHMap : m_pVMap;
1259 :
1260 :
1261 0 : sal_uInt16 nMapPos = GetMapPos(pMap, *pLB);
1262 0 : sal_uInt16 nAlign = GetAlignment(pMap, nMapPos, *pLB, *pRelLB);
1263 :
1264 0 : if (bHori)
1265 : {
1266 0 : sal_Bool bEnable = HoriOrientation::NONE == nAlign;
1267 0 : m_pHoriByMF->Enable( bEnable );
1268 0 : m_pHoriByFT->Enable( bEnable );
1269 : }
1270 : else
1271 : {
1272 0 : sal_Bool bEnable = VertOrientation::NONE == nAlign;
1273 0 : m_pVertByMF->Enable( bEnable );
1274 0 : m_pVertByFT->Enable( bEnable );
1275 : }
1276 :
1277 0 : RangeModifyHdl( 0 );
1278 :
1279 0 : short nRel = 0;
1280 0 : if (pLB->GetSelectEntryCount())
1281 : {
1282 :
1283 0 : if (pRelLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
1284 0 : nRel = ((RelationMap *)pRelLB->GetEntryData(pRelLB->GetSelectEntryPos()))->nRelation;
1285 :
1286 0 : FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT);
1287 : }
1288 : else
1289 0 : pRelLB->Clear();
1290 :
1291 0 : UpdateExample();
1292 :
1293 0 : if (bHori)
1294 0 : m_bAtHoriPosModified = true;
1295 : else
1296 0 : m_bAtVertPosModified = true;
1297 :
1298 : // special treatment for HTML-Mode with horz-vert-dependencies
1299 0 : if(m_bHtmlMode && TextContentAnchorType_AT_CHARACTER == GetAnchorType())
1300 : {
1301 0 : sal_Bool bSet = sal_False;
1302 0 : if(bHori)
1303 : {
1304 : // on the right only below is allowed - from the left only at the top
1305 : // from the left at the character -> below
1306 0 : if((HoriOrientation::LEFT == nAlign || HoriOrientation::RIGHT == nAlign) &&
1307 0 : 0 == m_pVertLB->GetSelectEntryPos())
1308 : {
1309 0 : if(RelOrientation::FRAME == nRel)
1310 0 : m_pVertLB->SelectEntryPos(1);
1311 : else
1312 0 : m_pVertLB->SelectEntryPos(0);
1313 0 : bSet = sal_True;
1314 : }
1315 0 : else if(HoriOrientation::LEFT == nAlign && 1 == m_pVertLB->GetSelectEntryPos())
1316 : {
1317 0 : m_pVertLB->SelectEntryPos(0);
1318 0 : bSet = sal_True;
1319 : }
1320 0 : else if(HoriOrientation::NONE == nAlign && 1 == m_pVertLB->GetSelectEntryPos())
1321 : {
1322 0 : m_pVertLB->SelectEntryPos(0);
1323 0 : bSet = sal_True;
1324 : }
1325 0 : if(bSet)
1326 0 : PosHdl(m_pVertLB);
1327 : }
1328 : else
1329 : {
1330 0 : if(VertOrientation::TOP == nAlign)
1331 : {
1332 0 : if(1 == m_pHoriLB->GetSelectEntryPos())
1333 : {
1334 0 : m_pHoriLB->SelectEntryPos(0);
1335 0 : bSet = sal_True;
1336 : }
1337 0 : m_pHoriToLB->SelectEntryPos(1);
1338 : }
1339 0 : else if(VertOrientation::CHAR_BOTTOM == nAlign)
1340 : {
1341 0 : if(2 == m_pHoriLB->GetSelectEntryPos())
1342 : {
1343 0 : m_pHoriLB->SelectEntryPos(0);
1344 0 : bSet = sal_True;
1345 : }
1346 0 : m_pHoriToLB->SelectEntryPos(0) ;
1347 : }
1348 0 : if(bSet)
1349 0 : PosHdl(m_pHoriLB);
1350 : }
1351 :
1352 : }
1353 0 : return 0;
1354 : }
1355 :
1356 0 : IMPL_LINK( SvxSwPosSizeTabPage, ModifyHdl, Edit *, pEdit )
1357 : {
1358 0 : sal_Int64 nWidth = m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP));
1359 0 : sal_Int64 nHeight = m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP));
1360 0 : if ( m_pKeepRatioCB->IsChecked() )
1361 : {
1362 0 : if ( pEdit == m_pWidthMF )
1363 : {
1364 0 : nHeight = sal_Int64((double)nWidth / m_fWidthHeightRatio);
1365 0 : m_pHeightMF->SetValue(m_pHeightMF->Normalize(nHeight), FUNIT_TWIP);
1366 : }
1367 0 : else if(pEdit == m_pHeightMF)
1368 : {
1369 0 : nWidth = sal_Int64((double)nHeight * m_fWidthHeightRatio);
1370 0 : m_pWidthMF->SetValue(m_pWidthMF->Normalize(nWidth), FUNIT_TWIP);
1371 : }
1372 : }
1373 0 : m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
1374 0 : UpdateExample();
1375 0 : return 0;
1376 : }
1377 :
1378 0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl)
1379 : {
1380 0 : m_pSizeCB->Enable(m_pPositionCB->IsEnabled() && !m_pPositionCB->IsChecked());
1381 0 : return 0;
1382 : }
1383 :
1384 0 : short SvxSwPosSizeTabPage::GetRelation(FrmMap *, ListBox &rRelationLB)
1385 : {
1386 0 : short nRel = 0;
1387 0 : sal_Int32 nPos = rRelationLB.GetSelectEntryPos();
1388 :
1389 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
1390 : {
1391 0 : RelationMap *pEntry = (RelationMap *)rRelationLB.GetEntryData(nPos);
1392 0 : nRel = pEntry->nRelation;
1393 : }
1394 :
1395 0 : return nRel;
1396 : }
1397 :
1398 0 : short SvxSwPosSizeTabPage::GetAlignment(FrmMap *pMap, sal_uInt16 nMapPos, ListBox &/*rAlignLB*/, ListBox &rRelationLB)
1399 : {
1400 0 : short nAlign = 0;
1401 :
1402 : // #i22341# - special handling also for map <aVCharMap>,
1403 : // because it contains ambigous items for alignment
1404 0 : if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap ||
1405 : pMap == aVCharMap )
1406 : {
1407 0 : if (rRelationLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
1408 : {
1409 0 : sal_uLong nRel = ((RelationMap *)rRelationLB.GetEntryData(rRelationLB.GetSelectEntryPos()))->nLBRelation;
1410 0 : std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
1411 0 : SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
1412 :
1413 0 : for (std::size_t i = 0; i < nMapCount; i++)
1414 : {
1415 0 : if (pMap[i].eStrId == eStrId)
1416 : {
1417 0 : sal_uLong nLBRelations = pMap[i].nLBRelations;
1418 0 : if (nLBRelations & nRel)
1419 : {
1420 0 : nAlign = pMap[i].nAlign;
1421 0 : break;
1422 : }
1423 : }
1424 : }
1425 0 : }
1426 : }
1427 0 : else if (pMap)
1428 0 : nAlign = pMap[nMapPos].nAlign;
1429 :
1430 0 : return nAlign;
1431 : }
1432 :
1433 0 : sal_uInt16 SvxSwPosSizeTabPage::GetMapPos(FrmMap *pMap, ListBox &rAlignLB)
1434 : {
1435 0 : sal_uInt16 nMapPos = 0;
1436 0 : sal_Int32 nLBSelPos = rAlignLB.GetSelectEntryPos();
1437 :
1438 0 : if (nLBSelPos != LISTBOX_ENTRY_NOTFOUND)
1439 : {
1440 0 : if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
1441 : {
1442 0 : std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
1443 0 : OUString sSelEntry(rAlignLB.GetSelectEntry());
1444 :
1445 0 : for (std::size_t i = 0; i < nMapCount; i++)
1446 : {
1447 0 : SvxSwFramePosString::StringId eResId = pMap[i].eStrId;
1448 :
1449 0 : OUString sEntry = m_aFramePosString.GetString(eResId);
1450 :
1451 0 : if (sEntry == sSelEntry)
1452 : {
1453 0 : nMapPos = sal::static_int_cast< sal_uInt16 >(i);
1454 0 : break;
1455 : }
1456 0 : }
1457 : }
1458 : else
1459 0 : nMapPos = nLBSelPos;
1460 : }
1461 :
1462 0 : return nMapPos;
1463 : }
1464 :
1465 0 : void SvxSwPosSizeTabPage::InitPos(short nAnchor,
1466 : sal_uInt16 nH,
1467 : sal_uInt16 nHRel,
1468 : sal_uInt16 nV,
1469 : sal_uInt16 nVRel,
1470 : long nX,
1471 : long nY)
1472 : {
1473 0 : sal_Int32 nPos = m_pVertLB->GetSelectEntryPos();
1474 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pVMap )
1475 : {
1476 0 : m_nOldV = m_pVMap[nPos].nAlign;
1477 0 : nPos = m_pVertToLB->GetSelectEntryPos();
1478 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
1479 0 : m_nOldVRel = ((RelationMap *)m_pVertToLB->GetEntryData(nPos))->nRelation;
1480 : }
1481 :
1482 0 : nPos = m_pHoriLB->GetSelectEntryPos();
1483 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pHMap )
1484 : {
1485 0 : m_nOldH = m_pHMap[nPos].nAlign;
1486 :
1487 0 : nPos = m_pHoriToLB->GetSelectEntryPos();
1488 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
1489 0 : m_nOldHRel = ((RelationMap *)m_pHoriToLB->GetEntryData(nPos))->nRelation;
1490 : }
1491 :
1492 0 : sal_Bool bEnable = sal_True;
1493 0 : if( m_bIsMultiSelection )
1494 : {
1495 0 : m_pVMap = aVMultiSelectionMap;
1496 0 : m_pHMap = aHMultiSelectionMap;
1497 : }
1498 0 : else if( nAnchor == TextContentAnchorType_AT_PAGE )
1499 : {
1500 0 : m_pVMap = m_bHtmlMode ? aVPageHtmlMap : aVPageMap;
1501 0 : m_pHMap = m_bHtmlMode ? aHPageHtmlMap : aHPageMap;
1502 : }
1503 0 : else if ( nAnchor == TextContentAnchorType_AT_FRAME )
1504 : {
1505 : // #i18732# - own vertical alignment map for to frame
1506 : // anchored objects.
1507 0 : m_pVMap = m_bHtmlMode ? aVFlyHtmlMap : aVFrameMap;
1508 0 : m_pHMap = m_bHtmlMode ? aHFlyHtmlMap : aHFrameMap;
1509 : }
1510 0 : else if ( nAnchor == TextContentAnchorType_AT_PARAGRAPH )
1511 : {
1512 0 : if(m_bHtmlMode)
1513 : {
1514 0 : m_pVMap = aVParaHtmlMap;
1515 0 : m_pHMap = aHParaHtmlAbsMap;
1516 : }
1517 : else
1518 : {
1519 0 : m_pVMap = aVParaMap;
1520 0 : m_pHMap = aHParaMap;
1521 : }
1522 : }
1523 0 : else if ( nAnchor == TextContentAnchorType_AT_CHARACTER )
1524 : {
1525 0 : if(m_bHtmlMode)
1526 : {
1527 0 : m_pVMap = aVCharHtmlAbsMap;
1528 0 : m_pHMap = aHCharHtmlAbsMap;
1529 : }
1530 : else
1531 : {
1532 0 : m_pVMap = aVCharMap;
1533 0 : m_pHMap = aHCharMap;
1534 : }
1535 : }
1536 0 : else if ( nAnchor == TextContentAnchorType_AS_CHARACTER )
1537 : {
1538 0 : m_pVMap = m_bHtmlMode ? aVAsCharHtmlMap : aVAsCharMap;
1539 0 : m_pHMap = 0;
1540 0 : bEnable = sal_False;
1541 : }
1542 0 : m_pHoriLB->Enable( bEnable );
1543 0 : m_pHoriFT->Enable( bEnable );
1544 :
1545 : // select current Pos
1546 : // horizontal
1547 0 : if ( nH == USHRT_MAX )
1548 : {
1549 0 : nH = m_nOldH;
1550 0 : nHRel = m_nOldHRel;
1551 : }
1552 : // #i22341# - pass <nHRel> as 3rd parameter to method <FillPosLB>
1553 0 : sal_uInt16 nMapPos = FillPosLB(m_pHMap, nH, nHRel, *m_pHoriLB);
1554 0 : FillRelLB(m_pHMap, nMapPos, nH, nHRel, *m_pHoriToLB, *m_pHoriToFT);
1555 :
1556 : // vertical
1557 0 : if ( nV == USHRT_MAX )
1558 : {
1559 0 : nV = m_nOldV;
1560 0 : nVRel = m_nOldVRel;
1561 : }
1562 : // #i22341# - pass <nVRel> as 3rd parameter to method <FillPosLB>
1563 0 : nMapPos = FillPosLB(m_pVMap, nV, nVRel, *m_pVertLB);
1564 0 : FillRelLB(m_pVMap, nMapPos, nV, nVRel, *m_pVertToLB, *m_pVertToFT);
1565 :
1566 : // Edits init
1567 0 : bEnable = nH == HoriOrientation::NONE &&
1568 0 : nAnchor != TextContentAnchorType_AS_CHARACTER;//#61359# why not in formats&& !bFormat;
1569 0 : if (!bEnable)
1570 : {
1571 0 : m_pHoriByMF->SetValue( 0, FUNIT_TWIP );
1572 0 : if (nX != LONG_MAX && m_bHtmlMode)
1573 0 : m_pHoriByMF->SetModifyFlag();
1574 : }
1575 0 : else if(m_bIsMultiSelection)
1576 : {
1577 0 : m_pHoriByMF->SetValue( m_pHoriByMF->Normalize(m_aRect.Left()), FUNIT_TWIP );
1578 : }
1579 : else
1580 : {
1581 0 : if (nX != LONG_MAX)
1582 0 : m_pHoriByMF->SetValue( m_pHoriByMF->Normalize(nX), FUNIT_TWIP );
1583 : }
1584 0 : m_pHoriByFT->Enable( bEnable );
1585 0 : m_pHoriByMF->Enable( bEnable );
1586 :
1587 0 : bEnable = nV == VertOrientation::NONE;
1588 0 : if ( !bEnable )
1589 : {
1590 0 : m_pVertByMF->SetValue( 0, FUNIT_TWIP );
1591 0 : if(nY != LONG_MAX && m_bHtmlMode)
1592 0 : m_pVertByMF->SetModifyFlag();
1593 : }
1594 0 : else if(m_bIsMultiSelection)
1595 : {
1596 0 : m_pVertByMF->SetValue( m_pVertByMF->Normalize(m_aRect.Top()), FUNIT_TWIP );
1597 : }
1598 : else
1599 : {
1600 0 : if ( nAnchor == TextContentAnchorType_AS_CHARACTER )
1601 : {
1602 0 : if ( nY == LONG_MAX )
1603 0 : nY = 0;
1604 : else
1605 0 : nY *= -1;
1606 : }
1607 0 : if ( nY != LONG_MAX )
1608 0 : m_pVertByMF->SetValue( m_pVertByMF->Normalize(nY), FUNIT_TWIP );
1609 : }
1610 0 : m_pVertByFT->Enable( bEnable );
1611 0 : m_pVertByMF->Enable( bEnable );
1612 0 : UpdateExample();
1613 0 : }
1614 :
1615 0 : void SvxSwPosSizeTabPage::UpdateExample()
1616 : {
1617 0 : sal_Int32 nPos = m_pHoriLB->GetSelectEntryPos();
1618 0 : if ( m_pHMap && nPos != LISTBOX_ENTRY_NOTFOUND )
1619 : {
1620 0 : sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriLB);
1621 0 : short nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
1622 0 : short nRel = GetRelation(m_pHMap, *m_pHoriToLB);
1623 :
1624 0 : m_pExampleWN->SetHAlign(nAlign);
1625 0 : m_pExampleWN->SetHoriRel(nRel);
1626 : }
1627 :
1628 0 : nPos = m_pVertLB->GetSelectEntryPos();
1629 0 : if ( m_pVMap && nPos != LISTBOX_ENTRY_NOTFOUND )
1630 : {
1631 0 : sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
1632 0 : sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
1633 0 : sal_uInt16 nRel = GetRelation(m_pVMap, *m_pVertToLB);
1634 :
1635 0 : m_pExampleWN->SetVAlign(nAlign);
1636 0 : m_pExampleWN->SetVertRel(nRel);
1637 : }
1638 :
1639 : // Size
1640 0 : long nXPos = static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
1641 0 : long nYPos = static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
1642 0 : m_pExampleWN->SetRelPos(Point(nXPos, nYPos));
1643 :
1644 0 : m_pExampleWN->SetAnchor( GetAnchorType() );
1645 0 : m_pExampleWN->Invalidate();
1646 0 : }
1647 :
1648 0 : sal_uLong SvxSwPosSizeTabPage::FillRelLB(FrmMap *pMap, sal_uInt16 nMapPos, sal_uInt16 nAlign,
1649 : sal_uInt16 nRel, ListBox &rLB, FixedText &rFT)
1650 : {
1651 0 : OUString sSelEntry;
1652 0 : sal_uLong nLBRelations = 0;
1653 0 : std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
1654 :
1655 0 : rLB.Clear();
1656 :
1657 0 : if (nMapPos < nMapCount)
1658 : {
1659 0 : if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
1660 : {
1661 0 : OUString sOldEntry(rLB.GetSelectEntry());
1662 0 : sal_uInt16 nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
1663 0 : SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
1664 :
1665 0 : for (std::size_t _nMapPos = 0; _nMapPos < nMapCount; _nMapPos++)
1666 : {
1667 0 : if (pMap[_nMapPos].eStrId == eStrId)
1668 : {
1669 0 : nLBRelations = pMap[_nMapPos].nLBRelations;
1670 0 : for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
1671 : {
1672 0 : if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation)
1673 : {
1674 0 : SvxSwFramePosString::StringId sStrId1 = aAsCharRelationMap[nRelPos].eStrId;
1675 :
1676 0 : sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft);
1677 0 : OUString sEntry = m_aFramePosString.GetString(sStrId1);
1678 0 : sal_Int32 nPos = rLB.InsertEntry(sEntry);
1679 0 : rLB.SetEntryData(nPos, &aAsCharRelationMap[nRelPos]);
1680 0 : if (pMap[_nMapPos].nAlign == nAlign)
1681 0 : sSelEntry = sEntry;
1682 0 : break;
1683 : }
1684 : }
1685 : }
1686 : }
1687 0 : if (!sSelEntry.isEmpty())
1688 0 : rLB.SelectEntry(sSelEntry);
1689 : else
1690 : {
1691 0 : rLB.SelectEntry(sOldEntry);
1692 :
1693 0 : if (!rLB.GetSelectEntryCount())
1694 : {
1695 0 : for (sal_Int32 i = 0; i < rLB.GetEntryCount(); i++)
1696 : {
1697 0 : RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(i);
1698 0 : if (pEntry->nLBRelation == LB_REL_CHAR) // Default
1699 : {
1700 0 : rLB.SelectEntryPos(i);
1701 0 : break;
1702 : }
1703 : }
1704 : }
1705 0 : }
1706 : }
1707 : else
1708 : {
1709 0 : sal_uInt16 nRelCount = SAL_N_ELEMENTS(aRelationMap);
1710 :
1711 : // #i22341# - special handling for map <aVCharMap>,
1712 : // because its ambigous in its <eStrId>/<eMirrorStrId>.
1713 0 : if ( pMap == aVCharMap )
1714 : {
1715 : nLBRelations = ::lcl_GetLBRelationsForStrID( pMap,
1716 0 : ( m_pHoriMirrorCB->IsChecked()
1717 0 : ? pMap[nMapPos].eMirrorStrId
1718 0 : : pMap[nMapPos].eStrId ),
1719 0 : m_pHoriMirrorCB->IsChecked() );
1720 : }
1721 : else
1722 : {
1723 0 : nLBRelations = pMap[nMapPos].nLBRelations;
1724 : }
1725 :
1726 0 : for (sal_uLong nBit = 1; nBit < 0x80000000; nBit <<= 1)
1727 : {
1728 0 : if (nLBRelations & nBit)
1729 : {
1730 0 : for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
1731 : {
1732 0 : if (aRelationMap[nRelPos].nLBRelation == nBit)
1733 : {
1734 0 : SvxSwFramePosString::StringId sStrId1 = m_pHoriMirrorCB->IsChecked() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId;
1735 0 : sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft);
1736 0 : OUString sEntry = m_aFramePosString.GetString(sStrId1);
1737 0 : sal_Int32 nPos = rLB.InsertEntry(sEntry);
1738 0 : rLB.SetEntryData(nPos, &aRelationMap[nRelPos]);
1739 0 : if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == nRel)
1740 0 : sSelEntry = sEntry;
1741 : }
1742 : }
1743 : }
1744 : }
1745 0 : if (!sSelEntry.isEmpty())
1746 0 : rLB.SelectEntry(sSelEntry);
1747 : else
1748 : {
1749 : // Probably anchor change. So look for a similar relation.
1750 0 : switch (nRel)
1751 : {
1752 0 : case RelOrientation::FRAME: nRel = RelOrientation::PAGE_FRAME; break;
1753 0 : case RelOrientation::PRINT_AREA: nRel = RelOrientation::PAGE_PRINT_AREA; break;
1754 0 : case RelOrientation::PAGE_LEFT: nRel = RelOrientation::FRAME_LEFT; break;
1755 0 : case RelOrientation::PAGE_RIGHT: nRel = RelOrientation::FRAME_RIGHT; break;
1756 0 : case RelOrientation::FRAME_LEFT: nRel = RelOrientation::PAGE_LEFT; break;
1757 0 : case RelOrientation::FRAME_RIGHT: nRel = RelOrientation::PAGE_RIGHT; break;
1758 0 : case RelOrientation::PAGE_FRAME: nRel = RelOrientation::FRAME; break;
1759 0 : case RelOrientation::PAGE_PRINT_AREA: nRel = RelOrientation::PRINT_AREA; break;
1760 :
1761 : default:
1762 0 : if (rLB.GetEntryCount())
1763 : {
1764 0 : RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(rLB.GetEntryCount() - 1);
1765 0 : nRel = pEntry->nRelation;
1766 : }
1767 0 : break;
1768 : }
1769 :
1770 0 : for (sal_Int32 i = 0; i < rLB.GetEntryCount(); i++)
1771 : {
1772 0 : RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(i);
1773 0 : if (pEntry->nRelation == nRel)
1774 : {
1775 0 : rLB.SelectEntryPos(i);
1776 0 : break;
1777 : }
1778 : }
1779 :
1780 0 : if (!rLB.GetSelectEntryCount())
1781 0 : rLB.SelectEntryPos(0);
1782 : }
1783 : }
1784 : }
1785 :
1786 0 : rLB.Enable(rLB.GetEntryCount() != 0);
1787 0 : rFT.Enable(rLB.GetEntryCount() != 0);
1788 :
1789 0 : RelHdl(&rLB);
1790 :
1791 0 : return nLBRelations;
1792 : }
1793 :
1794 0 : sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap *_pMap,
1795 : sal_uInt16 _nAlign,
1796 : const sal_uInt16 _nRel,
1797 : ListBox &_rLB)
1798 : {
1799 0 : OUString sSelEntry, sOldEntry;
1800 0 : sOldEntry = _rLB.GetSelectEntry();
1801 :
1802 0 : _rLB.Clear();
1803 :
1804 : // #i22341# - determine all possible listbox relations for
1805 : // given relation for map <aVCharMap>
1806 : const sal_uLong nLBRelations = (_pMap != aVCharMap)
1807 : ? 0L
1808 0 : : ::lcl_GetLBRelationsForRelations( _nRel );
1809 :
1810 : // fill listbox
1811 0 : std::size_t nCount = ::lcl_GetFrmMapCount(_pMap);
1812 0 : for (std::size_t i = 0; _pMap && i < nCount; ++i)
1813 : {
1814 : // #61359# why not from the left/from inside or from the top?
1815 : // if (!bFormat || (pMap[i].eStrId != SwFPos::FROMLEFT && pMap[i].eStrId != SwFPos::FROMTOP))
1816 : {
1817 0 : SvxSwFramePosString::StringId eStrId = m_pHoriMirrorCB->IsChecked() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId;
1818 0 : eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, m_bIsInRightToLeft);
1819 0 : OUString sEntry(m_aFramePosString.GetString(eStrId));
1820 0 : if (_rLB.GetEntryPos(sEntry) == LISTBOX_ENTRY_NOTFOUND)
1821 : {
1822 : // don't insert duplicate entries at character wrapped borders
1823 0 : _rLB.InsertEntry(sEntry);
1824 : }
1825 : // #i22341# - add condition to handle map <aVCharMap>
1826 : // that is ambigous in the alignment.
1827 0 : if ( _pMap[i].nAlign == _nAlign &&
1828 0 : ( !(_pMap == aVCharMap) || _pMap[i].nLBRelations & nLBRelations ) )
1829 : {
1830 0 : sSelEntry = sEntry;
1831 0 : }
1832 : }
1833 : }
1834 :
1835 0 : _rLB.SelectEntry(sSelEntry);
1836 0 : if (!_rLB.GetSelectEntryCount())
1837 0 : _rLB.SelectEntry(sOldEntry);
1838 :
1839 0 : if (!_rLB.GetSelectEntryCount())
1840 0 : _rLB.SelectEntryPos(0);
1841 :
1842 0 : PosHdl(&_rLB);
1843 :
1844 0 : return GetMapPos(_pMap, _rLB);
1845 : }
1846 :
1847 0 : void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView )
1848 : {
1849 0 : m_pSdrView = pSdrView;
1850 0 : if(!m_pSdrView)
1851 : {
1852 : OSL_FAIL("No SdrView* set");
1853 0 : return;
1854 : }
1855 :
1856 : // setting of the rectangle and the working area
1857 0 : m_aRect = m_pSdrView->GetAllMarkedRect();
1858 0 : m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect );
1859 :
1860 : // get WorkArea
1861 0 : m_aWorkArea = m_pSdrView->GetWorkArea();
1862 :
1863 : // consider anchor position (for Writer)
1864 0 : const SdrMarkList& rMarkList = m_pSdrView->GetMarkedObjectList();
1865 0 : if( rMarkList.GetMarkCount() >= 1 )
1866 : {
1867 0 : const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1868 0 : m_aAnchorPos = pObj->GetAnchorPos();
1869 :
1870 0 : if( m_aAnchorPos != Point(0,0) ) // -> Writer
1871 : {
1872 0 : for( sal_uLong i = 1; i < rMarkList.GetMarkCount(); i++ )
1873 : {
1874 0 : pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
1875 0 : if( m_aAnchorPos != pObj->GetAnchorPos() )
1876 : {
1877 : // different anchor positions -> disable positioning
1878 0 : m_pPosFrame->Enable(false);
1879 0 : m_bPositioningDisabled = true;
1880 0 : return;
1881 : }
1882 : }
1883 : }
1884 0 : Point aPt = m_aAnchorPos * -1;
1885 0 : Point aPt2 = aPt;
1886 :
1887 0 : aPt += m_aWorkArea.TopLeft();
1888 0 : m_aWorkArea.SetPos( aPt );
1889 :
1890 0 : aPt2 += m_aRect.TopLeft();
1891 0 : m_aRect.SetPos( aPt2 );
1892 : }
1893 :
1894 : // this should happen via SID_ATTR_TRANSFORM_AUTOSIZE
1895 0 : if( rMarkList.GetMarkCount() != 1 )
1896 0 : m_bIsMultiSelection = true;
1897 : #if OSL_DEBUG_LEVEL > 1
1898 : else
1899 : {
1900 : const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1901 : SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
1902 : if( ( pObj->GetObjInventor() == SdrInventor ) &&
1903 : ( eKind==OBJ_TEXT || eKind==OBJ_TITLETEXT || eKind==OBJ_OUTLINETEXT) &&
1904 : pObj->HasText() )
1905 : {
1906 : OSL_FAIL("AutoWidth/AutoHeight should be enabled");
1907 : }
1908 : }
1909 : #endif
1910 0 : }
1911 :
1912 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|