1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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 #include <boost/scoped_ptr.hpp>
40 using namespace ::com::sun::star::text
;
41 #define SwFPos SvxSwFramePosString
45 SvxSwFramePosString::StringId eStrId
;
46 SvxSwFramePosString::StringId eMirrorStrId
;
48 sal_uLong nLBRelations
;
53 SvxSwFramePosString::StringId eStrId
;
54 SvxSwFramePosString::StringId eMirrorStrId
;
55 sal_uLong nLBRelation
;
58 struct StringIdPair_Impl
60 SvxSwFramePosString::StringId eHori
;
61 SvxSwFramePosString::StringId eVert
;
64 #define LB_FRAME 0x00000001L // paragraph text area
65 #define LB_PRTAREA 0x00000002L // paragraph text area + indents
66 #define LB_VERT_FRAME 0x00000004L // vertical paragraph text area
67 #define LB_VERT_PRTAREA 0x00000008L // vertical paragraph text area + indents
68 #define LB_REL_FRM_LEFT 0x00000010L // left paragraph margin
69 #define LB_REL_FRM_RIGHT 0x00000020L // right paragraph margin
71 #define LB_REL_PG_LEFT 0x00000040L // left page margin
72 #define LB_REL_PG_RIGHT 0x00000080L // right page margin
73 #define LB_REL_PG_FRAME 0x00000100L // complete page
74 #define LB_REL_PG_PRTAREA 0x00000200L // text area of page
76 #define LB_FLY_REL_PG_LEFT 0x00000400L // left frame margin
77 #define LB_FLY_REL_PG_RIGHT 0x00000800L // right frame margin
78 #define LB_FLY_REL_PG_FRAME 0x00001000L // complete frame
79 #define LB_FLY_REL_PG_PRTAREA 0x00002000L // frame interior
81 #define LB_REL_BASE 0x00010000L // as char, relative to baseline
82 #define LB_REL_CHAR 0x00020000L // as char, relative to character
83 #define LB_REL_ROW 0x00040000L // as char, relative to line
86 #define LB_FLY_VERT_FRAME 0x00100000L // vertical entire frame
87 #define LB_FLY_VERT_PRTAREA 0x00200000L // vertical frame text area
90 #define LB_VERT_LINE 0x00400000L // vertical text line
92 static RelationMap aRelationMap
[] =
94 {SwFPos::FRAME
, SwFPos::FRAME
, LB_FRAME
, RelOrientation::FRAME
},
95 {SwFPos::PRTAREA
, SwFPos::PRTAREA
, LB_PRTAREA
, RelOrientation::PRINT_AREA
},
96 {SwFPos::REL_PG_LEFT
, SwFPos::MIR_REL_PG_LEFT
, LB_REL_PG_LEFT
, RelOrientation::PAGE_LEFT
},
97 {SwFPos::REL_PG_RIGHT
, SwFPos::MIR_REL_PG_RIGHT
, LB_REL_PG_RIGHT
, RelOrientation::PAGE_RIGHT
},
98 {SwFPos::REL_FRM_LEFT
, SwFPos::MIR_REL_FRM_LEFT
, LB_REL_FRM_LEFT
, RelOrientation::FRAME_LEFT
},
99 {SwFPos::REL_FRM_RIGHT
, SwFPos::MIR_REL_FRM_RIGHT
, LB_REL_FRM_RIGHT
, RelOrientation::FRAME_RIGHT
},
100 {SwFPos::REL_PG_FRAME
, SwFPos::REL_PG_FRAME
, LB_REL_PG_FRAME
, RelOrientation::PAGE_FRAME
},
101 {SwFPos::REL_PG_PRTAREA
,SwFPos::REL_PG_PRTAREA
, LB_REL_PG_PRTAREA
, RelOrientation::PAGE_PRINT_AREA
},
102 {SwFPos::REL_CHAR
, SwFPos::REL_CHAR
, LB_REL_CHAR
, RelOrientation::CHAR
},
104 {SwFPos::FLY_REL_PG_LEFT
, SwFPos::FLY_MIR_REL_PG_LEFT
, LB_FLY_REL_PG_LEFT
, RelOrientation::PAGE_LEFT
},
105 {SwFPos::FLY_REL_PG_RIGHT
, SwFPos::FLY_MIR_REL_PG_RIGHT
, LB_FLY_REL_PG_RIGHT
, RelOrientation::PAGE_RIGHT
},
106 {SwFPos::FLY_REL_PG_FRAME
, SwFPos::FLY_REL_PG_FRAME
, LB_FLY_REL_PG_FRAME
, RelOrientation::PAGE_FRAME
},
107 {SwFPos::FLY_REL_PG_PRTAREA
, SwFPos::FLY_REL_PG_PRTAREA
, LB_FLY_REL_PG_PRTAREA
, RelOrientation::PAGE_PRINT_AREA
},
109 {SwFPos::REL_BORDER
, SwFPos::REL_BORDER
, LB_VERT_FRAME
, RelOrientation::FRAME
},
110 {SwFPos::REL_PRTAREA
, SwFPos::REL_PRTAREA
, LB_VERT_PRTAREA
, RelOrientation::PRINT_AREA
},
113 {SwFPos::FLY_REL_PG_FRAME
, SwFPos::FLY_REL_PG_FRAME
, LB_FLY_VERT_FRAME
, RelOrientation::FRAME
},
114 {SwFPos::FLY_REL_PG_PRTAREA
, SwFPos::FLY_REL_PG_PRTAREA
, LB_FLY_VERT_PRTAREA
, RelOrientation::PRINT_AREA
},
117 {SwFPos::REL_LINE
, SwFPos::REL_LINE
, LB_VERT_LINE
, RelOrientation::TEXT_LINE
}
120 static RelationMap aAsCharRelationMap
[] =
122 {SwFPos::REL_BASE
, SwFPos::REL_BASE
, LB_REL_BASE
, RelOrientation::FRAME
},
123 {SwFPos::REL_CHAR
, SwFPos::REL_CHAR
, LB_REL_CHAR
, RelOrientation::FRAME
},
124 {SwFPos::REL_ROW
, SwFPos::REL_ROW
, LB_REL_ROW
, RelOrientation::FRAME
}
127 /*--------------------------------------------------------------------
129 --------------------------------------------------------------------*/
131 #define HORI_PAGE_REL (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_PG_LEFT| \
134 static FrmMap aHPageMap
[] =
136 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, HoriOrientation::LEFT
, HORI_PAGE_REL
},
137 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, HoriOrientation::RIGHT
, HORI_PAGE_REL
},
138 {SwFPos::CENTER_HORI
,SwFPos::CENTER_HORI
, HoriOrientation::CENTER
, HORI_PAGE_REL
},
139 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, HoriOrientation::NONE
, HORI_PAGE_REL
}
142 static FrmMap aHPageHtmlMap
[] =
144 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, HoriOrientation::NONE
, LB_REL_PG_FRAME
}
147 #define VERT_PAGE_REL (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
149 static FrmMap aVPageMap
[] =
151 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, VERT_PAGE_REL
},
152 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::BOTTOM
, VERT_PAGE_REL
},
153 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::CENTER
, VERT_PAGE_REL
},
154 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, VertOrientation::NONE
, VERT_PAGE_REL
}
157 static FrmMap aVPageHtmlMap
[] =
159 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, VertOrientation::NONE
, LB_REL_PG_FRAME
}
162 /*--------------------------------------------------------------------
164 --------------------------------------------------------------------*/
166 #define HORI_FRAME_REL (LB_FLY_REL_PG_FRAME|LB_FLY_REL_PG_PRTAREA| \
167 LB_FLY_REL_PG_LEFT|LB_FLY_REL_PG_RIGHT)
169 static FrmMap aHFrameMap
[] =
171 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, HoriOrientation::LEFT
, HORI_FRAME_REL
},
172 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, HoriOrientation::RIGHT
, HORI_FRAME_REL
},
173 {SwFPos::CENTER_HORI
, SwFPos::CENTER_HORI
, HoriOrientation::CENTER
, HORI_FRAME_REL
},
174 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, HoriOrientation::NONE
, HORI_FRAME_REL
}
177 static FrmMap aHFlyHtmlMap
[] =
179 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, HoriOrientation::LEFT
, LB_FLY_REL_PG_FRAME
},
180 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, HoriOrientation::NONE
, LB_FLY_REL_PG_FRAME
}
183 // #i18732# - own vertical alignment map for to frame anchored objects
185 #define VERT_FRAME_REL (LB_VERT_FRAME|LB_FLY_VERT_PRTAREA)
187 static FrmMap aVFrameMap
[] =
189 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, VERT_FRAME_REL
},
190 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::BOTTOM
, VERT_FRAME_REL
},
191 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::CENTER
, VERT_FRAME_REL
},
192 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, VertOrientation::NONE
, VERT_FRAME_REL
}
195 static FrmMap aVFlyHtmlMap
[] =
197 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, LB_FLY_VERT_FRAME
},
198 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, VertOrientation::NONE
, LB_FLY_VERT_FRAME
}
201 static FrmMap aVMultiSelectionMap
[] =
203 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, VertOrientation::NONE
, 0}
205 static FrmMap aHMultiSelectionMap
[] =
207 {SwFPos::FROMLEFT
, SwFPos::FROMLEFT
, HoriOrientation::NONE
, 0}
210 /*--------------------------------------------------------------------
211 Anchored at paragraph
212 --------------------------------------------------------------------*/
214 #define HORI_PARA_REL (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
215 LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
218 static FrmMap aHParaMap
[] =
220 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, HoriOrientation::LEFT
, HORI_PARA_REL
},
221 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, HoriOrientation::RIGHT
, HORI_PARA_REL
},
222 {SwFPos::CENTER_HORI
, SwFPos::CENTER_HORI
, HoriOrientation::CENTER
, HORI_PARA_REL
},
223 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, HoriOrientation::NONE
, HORI_PARA_REL
}
226 #define HTML_HORI_PARA_REL (LB_FRAME|LB_PRTAREA)
228 static FrmMap aHParaHtmlMap
[] =
230 {SwFPos::LEFT
, SwFPos::LEFT
, HoriOrientation::LEFT
, HTML_HORI_PARA_REL
},
231 {SwFPos::RIGHT
, SwFPos::RIGHT
, HoriOrientation::RIGHT
, HTML_HORI_PARA_REL
}
234 static FrmMap aHParaHtmlAbsMap
[] =
236 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, HoriOrientation::LEFT
, HTML_HORI_PARA_REL
},
237 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, HoriOrientation::RIGHT
, HTML_HORI_PARA_REL
}
241 #define VERT_PARA_REL (LB_VERT_FRAME|LB_VERT_PRTAREA| \
242 LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
244 static FrmMap aVParaMap
[] =
246 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, VERT_PARA_REL
},
247 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::BOTTOM
, VERT_PARA_REL
},
248 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::CENTER
, VERT_PARA_REL
},
249 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, VertOrientation::NONE
, VERT_PARA_REL
}
252 static FrmMap aVParaHtmlMap
[] =
254 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, LB_VERT_PRTAREA
}
257 /*--------------------------------------------------------------------
258 Anchored at character
259 --------------------------------------------------------------------*/
261 #define HORI_CHAR_REL (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
262 LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
263 LB_REL_FRM_RIGHT|LB_REL_CHAR)
265 static FrmMap aHCharMap
[] =
267 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, HoriOrientation::LEFT
, HORI_CHAR_REL
},
268 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, HoriOrientation::RIGHT
, HORI_CHAR_REL
},
269 {SwFPos::CENTER_HORI
, SwFPos::CENTER_HORI
, HoriOrientation::CENTER
, HORI_CHAR_REL
},
270 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, HoriOrientation::NONE
, HORI_CHAR_REL
}
273 #define HTML_HORI_CHAR_REL (LB_FRAME|LB_PRTAREA|LB_REL_CHAR)
275 static FrmMap aHCharHtmlMap
[] =
277 {SwFPos::LEFT
, SwFPos::LEFT
, HoriOrientation::LEFT
, HTML_HORI_CHAR_REL
},
278 {SwFPos::RIGHT
, SwFPos::RIGHT
, HoriOrientation::RIGHT
, HTML_HORI_CHAR_REL
}
281 static FrmMap aHCharHtmlAbsMap
[] =
283 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, HoriOrientation::LEFT
, LB_PRTAREA
|LB_REL_CHAR
},
284 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, HoriOrientation::RIGHT
, LB_PRTAREA
},
285 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, HoriOrientation::NONE
, LB_REL_PG_FRAME
}
288 // #i18732# - allow vertical alignment at page areas
289 // #i22341# - handle <LB_REL_CHAR> on its own
290 #define VERT_CHAR_REL (LB_VERT_FRAME|LB_VERT_PRTAREA| \
291 LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
293 static FrmMap aVCharMap
[] =
296 // introduce mappings for new vertical alignment at top of line <LB_VERT_LINE>
297 // and correct mapping for vertical alignment at character for position <FROM_BOTTOM>
298 // Note: Because of these adjustments the map becomes ambigous in its values
299 // <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered
300 // in the methods <SwFrmPage::FillRelLB(..)>, <SwFrmPage::GetAlignment(..)>
301 // and <SwFrmPage::FillPosLB(..)>
302 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, VERT_CHAR_REL
|LB_REL_CHAR
},
303 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::BOTTOM
, VERT_CHAR_REL
|LB_REL_CHAR
},
304 {SwFPos::BELOW
, SwFPos::BELOW
, VertOrientation::CHAR_BOTTOM
, LB_REL_CHAR
},
305 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::CENTER
, VERT_CHAR_REL
|LB_REL_CHAR
},
306 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, VertOrientation::NONE
, VERT_CHAR_REL
},
307 {SwFPos::FROMBOTTOM
, SwFPos::FROMBOTTOM
, VertOrientation::NONE
, LB_REL_CHAR
|LB_VERT_LINE
},
308 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::LINE_TOP
, LB_VERT_LINE
},
309 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::LINE_BOTTOM
, LB_VERT_LINE
},
310 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::LINE_CENTER
, LB_VERT_LINE
}
314 static FrmMap aVCharHtmlMap
[] =
316 {SwFPos::BELOW
, SwFPos::BELOW
, VertOrientation::CHAR_BOTTOM
, LB_REL_CHAR
}
319 static FrmMap aVCharHtmlAbsMap
[] =
321 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, LB_REL_CHAR
},
322 {SwFPos::BELOW
, SwFPos::BELOW
, VertOrientation::CHAR_BOTTOM
, LB_REL_CHAR
}
324 /*--------------------------------------------------------------------
325 anchored as character
326 --------------------------------------------------------------------*/
328 static FrmMap aVAsCharMap
[] =
330 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, LB_REL_BASE
},
331 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::BOTTOM
, LB_REL_BASE
},
332 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::CENTER
, LB_REL_BASE
},
334 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::CHAR_TOP
, LB_REL_CHAR
},
335 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::CHAR_BOTTOM
, LB_REL_CHAR
},
336 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::CHAR_CENTER
, LB_REL_CHAR
},
338 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::LINE_TOP
, LB_REL_ROW
},
339 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::LINE_BOTTOM
, LB_REL_ROW
},
340 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::LINE_CENTER
, LB_REL_ROW
},
342 {SwFPos::FROMBOTTOM
, SwFPos::FROMBOTTOM
, VertOrientation::NONE
, LB_REL_BASE
}
345 static FrmMap aVAsCharHtmlMap
[] =
347 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::TOP
, LB_REL_BASE
},
348 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::CENTER
, LB_REL_BASE
},
350 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::CHAR_TOP
, LB_REL_CHAR
},
352 {SwFPos::TOP
, SwFPos::TOP
, VertOrientation::LINE_TOP
, LB_REL_ROW
},
353 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, VertOrientation::LINE_BOTTOM
, LB_REL_ROW
},
354 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, VertOrientation::LINE_CENTER
, LB_REL_ROW
}
357 static std::size_t lcl_GetFrmMapCount(const FrmMap
* pMap
)
361 if( pMap
== aVParaHtmlMap
)
362 return SAL_N_ELEMENTS(aVParaHtmlMap
);
363 if( pMap
== aVAsCharHtmlMap
)
364 return SAL_N_ELEMENTS( aVAsCharHtmlMap
);
365 if( pMap
== aHParaHtmlMap
)
366 return SAL_N_ELEMENTS( aHParaHtmlMap
);
367 if( pMap
== aHParaHtmlAbsMap
)
368 return SAL_N_ELEMENTS( aHParaHtmlAbsMap
);
369 if( pMap
== aVPageMap
)
370 return SAL_N_ELEMENTS( aVPageMap
);
371 if( pMap
== aVPageHtmlMap
)
372 return SAL_N_ELEMENTS( aVPageHtmlMap
);
373 if( pMap
== aVAsCharMap
)
374 return SAL_N_ELEMENTS( aVAsCharMap
);
375 if( pMap
== aVParaMap
)
376 return SAL_N_ELEMENTS( aVParaMap
);
377 if( pMap
== aHParaMap
)
378 return SAL_N_ELEMENTS( aHParaMap
);
379 if( pMap
== aHFrameMap
)
380 return SAL_N_ELEMENTS( aHFrameMap
);
381 if( pMap
== aVFrameMap
)
382 return SAL_N_ELEMENTS( aVFrameMap
);
383 if( pMap
== aHCharMap
)
384 return SAL_N_ELEMENTS( aHCharMap
);
385 if( pMap
== aHCharHtmlMap
)
386 return SAL_N_ELEMENTS( aHCharHtmlMap
);
387 if( pMap
== aHCharHtmlAbsMap
)
388 return SAL_N_ELEMENTS( aHCharHtmlAbsMap
);
389 if( pMap
== aVCharMap
)
390 return SAL_N_ELEMENTS( aVCharMap
);
391 if( pMap
== aVCharHtmlMap
)
392 return SAL_N_ELEMENTS( aVCharHtmlMap
);
393 if( pMap
== aVCharHtmlAbsMap
)
394 return SAL_N_ELEMENTS( aVCharHtmlAbsMap
);
395 if( pMap
== aHPageHtmlMap
)
396 return SAL_N_ELEMENTS( aHPageHtmlMap
);
397 if( pMap
== aHFlyHtmlMap
)
398 return SAL_N_ELEMENTS( aHFlyHtmlMap
);
399 if( pMap
== aVFlyHtmlMap
)
400 return SAL_N_ELEMENTS( aVFlyHtmlMap
);
401 if( pMap
== aVMultiSelectionMap
)
402 return SAL_N_ELEMENTS( aVMultiSelectionMap
);
403 if( pMap
== aHMultiSelectionMap
)
404 return SAL_N_ELEMENTS( aHMultiSelectionMap
);
405 return SAL_N_ELEMENTS(aHPageMap
);
410 static SvxSwFramePosString::StringId
lcl_ChangeResIdToVerticalOrRTL(
411 SvxSwFramePosString::StringId eStringId
, bool bVertical
, bool bRTL
)
413 //special handling of STR_FROMLEFT
414 if(SwFPos::FROMLEFT
== eStringId
)
416 eStringId
= bVertical
?
417 bRTL
? SwFPos::FROMBOTTOM
: SwFPos::FROMTOP
:
418 bRTL
? SwFPos::FROMRIGHT
: SwFPos::FROMLEFT
;
423 //exchange horizontal strings with vertical strings and vice versa
424 static const StringIdPair_Impl aHoriIds
[] =
426 {SwFPos::LEFT
, SwFPos::TOP
},
427 {SwFPos::RIGHT
, SwFPos::BOTTOM
},
428 {SwFPos::CENTER_HORI
, SwFPos::CENTER_VERT
},
429 {SwFPos::FROMTOP
, SwFPos::FROMRIGHT
},
430 {SwFPos::REL_PG_LEFT
, SwFPos::REL_PG_TOP
},
431 {SwFPos::REL_PG_RIGHT
, SwFPos::REL_PG_BOTTOM
} ,
432 {SwFPos::REL_FRM_LEFT
, SwFPos::REL_FRM_TOP
},
433 {SwFPos::REL_FRM_RIGHT
, SwFPos::REL_FRM_BOTTOM
}
435 static const StringIdPair_Impl aVertIds
[] =
437 {SwFPos::TOP
, SwFPos::RIGHT
},
438 {SwFPos::BOTTOM
, SwFPos::LEFT
},
439 {SwFPos::CENTER_VERT
, SwFPos::CENTER_HORI
},
440 {SwFPos::FROMTOP
, SwFPos::FROMRIGHT
},
441 {SwFPos::REL_PG_TOP
, SwFPos::REL_PG_LEFT
},
442 {SwFPos::REL_PG_BOTTOM
, SwFPos::REL_PG_RIGHT
} ,
443 {SwFPos::REL_FRM_TOP
, SwFPos::REL_FRM_LEFT
},
444 {SwFPos::REL_FRM_BOTTOM
, SwFPos::REL_FRM_RIGHT
}
447 for(nIndex
= 0; nIndex
< SAL_N_ELEMENTS(aHoriIds
); ++nIndex
)
449 if(aHoriIds
[nIndex
].eHori
== eStringId
)
451 eStringId
= aHoriIds
[nIndex
].eVert
;
456 for(nIndex
= 0; nIndex
< SAL_N_ELEMENTS(aVertIds
); ++nIndex
)
458 if(aVertIds
[nIndex
].eHori
== eStringId
)
460 eStringId
= aVertIds
[nIndex
].eVert
;
467 // #i22341# - helper method in order to determine all possible
468 // listbox relations in a relation map for a given relation
469 static sal_uLong
lcl_GetLBRelationsForRelations( const sal_uInt16 _nRel
)
471 sal_uLong nLBRelations
= 0L;
473 for ( sal_uInt16 nRelMapPos
= 0; nRelMapPos
< SAL_N_ELEMENTS(aRelationMap
); ++nRelMapPos
)
475 if ( aRelationMap
[nRelMapPos
].nRelation
== _nRel
)
477 nLBRelations
|= aRelationMap
[nRelMapPos
].nLBRelation
;
484 // #i22341# - helper method on order to determine all possible
485 // listbox relations in a relation map for a given string ID
486 static sal_uLong
lcl_GetLBRelationsForStrID( const FrmMap
* _pMap
,
487 const SvxSwFramePosString::StringId _eStrId
,
488 const bool _bUseMirrorStr
)
490 sal_uLong nLBRelations
= 0L;
492 std::size_t nRelMapSize
= lcl_GetFrmMapCount( _pMap
);
493 for ( std::size_t nRelMapPos
= 0; nRelMapPos
< nRelMapSize
; ++nRelMapPos
)
495 if ( ( !_bUseMirrorStr
&& _pMap
[nRelMapPos
].eStrId
== _eStrId
) ||
496 ( _bUseMirrorStr
&& _pMap
[nRelMapPos
].eMirrorStrId
== _eStrId
) )
498 nLBRelations
|= _pMap
[nRelMapPos
].nLBRelations
;
505 SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(vcl::Window
* pParent
, const SfxItemSet
& rInAttrs
)
506 : SfxTabPage(pParent
, "SwPosSizePage", "cui/ui/swpossizepage.ui", &rInAttrs
)
510 , m_nOldH(HoriOrientation::CENTER
)
511 , m_nOldHRel(RelOrientation::FRAME
)
512 , m_nOldV(VertOrientation::TOP
)
513 , m_nOldVRel(RelOrientation::PRINT_AREA
)
514 , m_fWidthHeightRatio(1.0)
516 , m_bAtHoriPosModified(false)
517 , m_bAtVertPosModified(false)
518 , m_bIsVerticalFrame(false)
519 , m_bPositioningDisabled(false)
520 , m_bIsMultiSelection(false)
521 , m_bIsInRightToLeft(false)
523 get(m_pWidthMF
, "width");
524 get(m_pHeightMF
, "height");
525 get(m_pKeepRatioCB
, "ratio");
526 get(m_pToPageRB
, "topage");
527 get(m_pToParaRB
, "topara");
528 get(m_pToCharRB
, "tochar");
529 get(m_pAsCharRB
, "aschar");
530 get(m_pToFrameRB
, "toframe");
531 get(m_pPositionCB
, "pos");
532 get(m_pSizeCB
, "size");
533 get(m_pPosFrame
, "posframe");
534 get(m_pHoriFT
, "horiposft");
535 get(m_pHoriLB
, "horipos");
536 get(m_pHoriByFT
, "horibyft");
537 get(m_pHoriByMF
, "byhori");
538 get(m_pHoriToFT
, "horitoft");
539 get(m_pHoriToLB
, "horianchor");
540 get(m_pHoriMirrorCB
, "mirror");
541 get(m_pVertFT
, "vertposft");
542 get(m_pVertLB
, "vertpos");
543 get(m_pVertByFT
, "vertbyft");
544 get(m_pVertByMF
, "byvert");
545 get(m_pVertToFT
, "verttoft");
546 get(m_pVertToLB
, "vertanchor");
547 get(m_pFollowCB
, "followtextflow");
548 get(m_pExampleWN
, "preview");
550 setOptimalFrmWidth();
551 setOptimalRelWidth();
553 FieldUnit eDlgUnit
= GetModuleFieldUnit( rInAttrs
);
554 SetFieldUnit( *m_pHoriByMF
, eDlgUnit
, true );
555 SetFieldUnit( *m_pVertByMF
, eDlgUnit
, true );
556 SetFieldUnit( *m_pWidthMF
, eDlgUnit
, true );
557 SetFieldUnit( *m_pHeightMF
, eDlgUnit
, true );
559 SetExchangeSupport();
561 Link
<> aLk
= LINK(this, SvxSwPosSizeTabPage
, RangeModifyHdl
);
562 m_pWidthMF
->SetLoseFocusHdl( aLk
);
563 m_pHeightMF
->SetLoseFocusHdl( aLk
);
564 m_pHoriByMF
->SetLoseFocusHdl( aLk
);
565 m_pVertByMF
->SetLoseFocusHdl( aLk
);
566 m_pFollowCB
->SetClickHdl( aLk
);
568 aLk
= LINK(this, SvxSwPosSizeTabPage
, ModifyHdl
);
569 m_pWidthMF
->SetModifyHdl( aLk
);
570 m_pHeightMF
->SetModifyHdl( aLk
);
571 m_pHoriByMF
->SetModifyHdl( aLk
);
572 m_pVertByMF
->SetModifyHdl( aLk
);
574 aLk
= LINK(this, SvxSwPosSizeTabPage
, AnchorTypeHdl
);
575 m_pToPageRB
->SetClickHdl( aLk
);
576 m_pToParaRB
->SetClickHdl( aLk
);
577 m_pToCharRB
->SetClickHdl( aLk
);
578 m_pAsCharRB
->SetClickHdl( aLk
);
579 m_pToFrameRB
->SetClickHdl( aLk
);
581 m_pHoriLB
->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage
, PosHdl
));
582 m_pVertLB
->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage
, PosHdl
));
584 m_pHoriToLB
->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage
, RelHdl
));
585 m_pVertToLB
->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage
, RelHdl
));
587 m_pHoriMirrorCB
->SetClickHdl(LINK(this, SvxSwPosSizeTabPage
, MirrorHdl
));
588 m_pPositionCB
->SetClickHdl(LINK(this, SvxSwPosSizeTabPage
, ProtectHdl
));
591 SvxSwPosSizeTabPage::~SvxSwPosSizeTabPage()
596 void SvxSwPosSizeTabPage::dispose()
600 m_pKeepRatioCB
.clear();
605 m_pToFrameRB
.clear();
606 m_pPositionCB
.clear();
615 m_pHoriMirrorCB
.clear();
623 m_pExampleWN
.clear();
624 SfxTabPage::dispose();
637 void SvxSwPosSizeTabPage::setOptimalFrmWidth()
639 const FrmMaps aMaps
[] = {
640 { aHPageMap
, SAL_N_ELEMENTS(aHPageMap
) },
641 { aHPageHtmlMap
, SAL_N_ELEMENTS(aHPageHtmlMap
) },
642 { aVPageMap
, SAL_N_ELEMENTS(aVPageMap
) },
643 { aVPageHtmlMap
, SAL_N_ELEMENTS(aVPageHtmlMap
) },
644 { aHFrameMap
, SAL_N_ELEMENTS(aHFrameMap
) },
645 { aHFlyHtmlMap
, SAL_N_ELEMENTS(aHFlyHtmlMap
) },
646 { aVFrameMap
, SAL_N_ELEMENTS(aVFrameMap
) },
647 { aVFlyHtmlMap
, SAL_N_ELEMENTS(aVFrameMap
) },
648 { aHParaMap
, SAL_N_ELEMENTS(aHParaMap
) },
649 { aHParaHtmlMap
, SAL_N_ELEMENTS(aHParaHtmlMap
) },
650 { aHParaHtmlAbsMap
, SAL_N_ELEMENTS(aHParaHtmlAbsMap
) },
651 { aVParaMap
, SAL_N_ELEMENTS(aVParaMap
) },
652 { aVParaHtmlMap
, SAL_N_ELEMENTS(aVParaHtmlMap
) },
653 { aHCharMap
, SAL_N_ELEMENTS(aHCharMap
) },
654 { aHCharHtmlMap
, SAL_N_ELEMENTS(aHCharHtmlMap
) },
655 { aHCharHtmlAbsMap
, SAL_N_ELEMENTS(aHCharHtmlAbsMap
) },
656 { aVCharMap
, SAL_N_ELEMENTS(aVCharMap
) },
657 { aVCharHtmlMap
, SAL_N_ELEMENTS(aVCharHtmlMap
) },
658 { aVCharHtmlAbsMap
, SAL_N_ELEMENTS(aVCharHtmlAbsMap
) },
659 { aVAsCharMap
, SAL_N_ELEMENTS(aVAsCharMap
) },
660 { aVAsCharHtmlMap
, SAL_N_ELEMENTS(aVAsCharHtmlMap
) }
663 std::vector
<SvxSwFramePosString::StringId
> aFrames
;
664 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aMaps
); ++i
)
666 for (size_t j
= 0; j
< aMaps
[i
].nCount
; ++j
)
668 aFrames
.push_back(aMaps
[i
].pMap
[j
].eStrId
);
669 aFrames
.push_back(aMaps
[i
].pMap
[j
].eMirrorStrId
);
673 std::sort(aFrames
.begin(), aFrames
.end());
674 aFrames
.erase(std::unique(aFrames
.begin(), aFrames
.end()), aFrames
.end());
676 for (std::vector
<SvxSwFramePosString::StringId
>::const_iterator aI
= aFrames
.begin(), aEnd
= aFrames
.end();
679 m_pHoriLB
->InsertEntry(m_aFramePosString
.GetString(*aI
));
682 Size
aBiggest(m_pHoriLB
->GetOptimalSize());
683 m_pHoriLB
->set_width_request(aBiggest
.Width());
684 m_pVertLB
->set_width_request(aBiggest
.Width());
697 void SvxSwPosSizeTabPage::setOptimalRelWidth()
699 const RelationMaps aMaps
[] = {
700 { aRelationMap
, SAL_N_ELEMENTS(aRelationMap
) },
701 { aAsCharRelationMap
, SAL_N_ELEMENTS(aAsCharRelationMap
) }
704 std::vector
<SvxSwFramePosString::StringId
> aRels
;
705 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aMaps
); ++i
)
707 for (size_t j
= 0; j
< aMaps
[i
].nCount
; ++j
)
709 aRels
.push_back(aMaps
[i
].pMap
[j
].eStrId
);
710 aRels
.push_back(aMaps
[i
].pMap
[j
].eMirrorStrId
);
714 std::sort(aRels
.begin(), aRels
.end());
715 aRels
.erase(std::unique(aRels
.begin(), aRels
.end()), aRels
.end());
717 for (std::vector
<SvxSwFramePosString::StringId
>::const_iterator aI
= aRels
.begin(), aEnd
= aRels
.end();
720 m_pHoriLB
->InsertEntry(m_aFramePosString
.GetString(*aI
));
723 Size
aBiggest(m_pHoriLB
->GetOptimalSize());
724 m_pHoriLB
->set_width_request(aBiggest
.Width());
725 m_pVertLB
->set_width_request(aBiggest
.Width());
729 VclPtr
<SfxTabPage
> SvxSwPosSizeTabPage::Create( vcl::Window
* pParent
, const SfxItemSet
* rSet
)
731 return VclPtr
<SvxSwPosSizeTabPage
>::Create(pParent
, *rSet
);
734 const sal_uInt16
* SvxSwPosSizeTabPage::GetRanges()
736 static const sal_uInt16 pSwPosRanges
[] =
738 SID_ATTR_TRANSFORM_POS_X
,
739 SID_ATTR_TRANSFORM_POS_Y
,
740 SID_ATTR_TRANSFORM_PROTECT_POS
,
741 SID_ATTR_TRANSFORM_PROTECT_POS
,
742 SID_ATTR_TRANSFORM_INTERN
,
743 SID_ATTR_TRANSFORM_INTERN
,
744 SID_ATTR_TRANSFORM_ANCHOR
,
745 SID_ATTR_TRANSFORM_VERT_ORIENT
,
746 SID_ATTR_TRANSFORM_WIDTH
,
747 SID_ATTR_TRANSFORM_SIZE_POINT
,
748 SID_ATTR_TRANSFORM_PROTECT_POS
,
749 SID_ATTR_TRANSFORM_INTERN
,
750 SID_ATTR_TRANSFORM_AUTOWIDTH
,
751 SID_ATTR_TRANSFORM_VERT_ORIENT
,
754 SID_SW_FOLLOW_TEXT_FLOW
,
755 SID_SW_FOLLOW_TEXT_FLOW
,
756 SID_ATTR_TRANSFORM_HORI_POSITION
,
757 SID_ATTR_TRANSFORM_VERT_POSITION
,
763 bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet
* rSet
)
765 bool bAnchorChanged
= false;
766 short nAnchor
= GetAnchorType(&bAnchorChanged
);
767 bool bModified
= false;
770 rSet
->Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR
, nAnchor
));
773 if ( m_pPositionCB
->IsValueChangedFromSaved() )
775 if( m_pPositionCB
->GetState() == TRISTATE_INDET
)
776 rSet
->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS
);
779 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS
),
780 m_pPositionCB
->GetState() == TRISTATE_TRUE
) );
784 if ( m_pSizeCB
->IsValueChangedFromSaved() )
786 if ( m_pSizeCB
->GetState() == TRISTATE_INDET
)
787 rSet
->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE
);
790 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE
),
791 m_pSizeCB
->GetState() == TRISTATE_TRUE
) );
795 const SfxItemSet
& rOldSet
= GetItemSet();
797 if(!m_bPositioningDisabled
)
799 //on multiple selections the positioning is set via SdrView
800 if(m_bIsMultiSelection
)
802 if( m_pHoriByMF
->IsValueModified() || m_pVertByMF
->IsValueModified() )
805 static_cast<long>(m_pHoriByMF
->Denormalize(m_pHoriByMF
->GetValue(FUNIT_TWIP
)));
807 static_cast<long>(m_pVertByMF
->Denormalize(m_pVertByMF
->GetValue(FUNIT_TWIP
)));
809 // old rectangle with CoreUnit
810 m_aRect
= m_pSdrView
->GetAllMarkedRect();
811 m_pSdrView
->GetSdrPageView()->LogicToPagePos( m_aRect
);
813 nHoriByPos
+= m_aAnchorPos
.X();
814 nVertByPos
+= m_aAnchorPos
.Y();
816 rSet
->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_X
), nHoriByPos
) );
817 rSet
->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_Y
), nVertByPos
) );
826 const SfxInt16Item
& rHoriOrient
=
827 static_cast<const SfxInt16Item
&>(rOldSet
.Get( SID_ATTR_TRANSFORM_HORI_ORIENT
));
828 const SfxInt16Item
& rHoriRelation
=
829 static_cast<const SfxInt16Item
&>(rOldSet
.Get( SID_ATTR_TRANSFORM_HORI_RELATION
));
830 const SfxInt32Item
& rHoriPosition
=
831 static_cast<const SfxInt32Item
&>(rOldSet
.Get( SID_ATTR_TRANSFORM_HORI_POSITION
)) ;
833 sal_uInt16 nMapPos
= GetMapPos(m_pHMap
, *m_pHoriLB
);
834 short nAlign
= GetAlignment(m_pHMap
, nMapPos
, *m_pHoriLB
, *m_pHoriToLB
);
835 short nRel
= GetRelation(m_pHMap
, *m_pHoriToLB
);
836 const long nHoriByPos
=
837 static_cast<long>(m_pHoriByMF
->Denormalize(m_pHoriByMF
->GetValue(FUNIT_TWIP
)));
839 nAlign
!= rHoriOrient
.GetValue() ||
840 nRel
!= rHoriRelation
.GetValue() ||
841 (m_pHoriByMF
->IsEnabled() && nHoriByPos
!= rHoriPosition
.GetValue())
844 rSet
->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT
, nAlign
));
845 rSet
->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION
, nRel
));
846 if(m_pHoriByMF
->IsEnabled())
847 rSet
->Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION
, nHoriByPos
));
851 if(m_pHoriMirrorCB
->IsEnabled() && m_pHoriMirrorCB
->IsValueChangedFromSaved())
852 bModified
|= 0 != rSet
->Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR
, m_pHoriMirrorCB
->IsChecked()));
856 const SfxInt16Item
& rVertOrient
=
857 static_cast<const SfxInt16Item
&>(rOldSet
.Get( SID_ATTR_TRANSFORM_VERT_ORIENT
));
858 const SfxInt16Item
& rVertRelation
=
859 static_cast<const SfxInt16Item
&>(rOldSet
.Get( SID_ATTR_TRANSFORM_VERT_RELATION
));
860 const SfxInt32Item
& rVertPosition
=
861 static_cast<const SfxInt32Item
&>(rOldSet
.Get( SID_ATTR_TRANSFORM_VERT_POSITION
));
863 sal_uInt16 nMapPos
= GetMapPos(m_pVMap
, *m_pVertLB
);
864 short nAlign
= GetAlignment(m_pVMap
, nMapPos
, *m_pVertLB
, *m_pVertToLB
);
865 short nRel
= GetRelation(m_pVMap
, *m_pVertToLB
);
866 // #i34055# - convert vertical position for
867 // as-character anchored objects
869 static_cast<long>(m_pVertByMF
->Denormalize(m_pVertByMF
->GetValue(FUNIT_TWIP
)));
870 if ( GetAnchorType() == TextContentAnchorType_AS_CHARACTER
)
874 if ( nAlign
!= rVertOrient
.GetValue() ||
875 nRel
!= rVertRelation
.GetValue() ||
876 ( m_pVertByMF
->IsEnabled() &&
877 nVertByPos
!= rVertPosition
.GetValue() ) )
879 rSet
->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT
, nAlign
));
880 rSet
->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION
, nRel
));
881 if(m_pVertByMF
->IsEnabled())
882 rSet
->Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION
, nVertByPos
));
888 if(m_pFollowCB
->IsValueChangedFromSaved())
890 //Writer internal type - based on SfxBoolItem
891 const SfxPoolItem
* pItem
= GetItem( rOldSet
, SID_SW_FOLLOW_TEXT_FLOW
);
894 boost::scoped_ptr
<SfxBoolItem
> pFollow(static_cast<SfxBoolItem
*>(pItem
->Clone()));
895 pFollow
->SetValue(m_pFollowCB
->IsChecked());
896 bModified
|= 0 != rSet
->Put(*pFollow
);
901 if ( m_pWidthMF
->IsValueModified() || m_pHeightMF
->IsValueModified() )
903 sal_uInt32 nWidth
= static_cast<sal_uInt32
>(m_pWidthMF
->Denormalize(m_pWidthMF
->GetValue(FUNIT_TWIP
)));
904 sal_uInt32 nHeight
= static_cast<sal_uInt32
>(m_pHeightMF
->Denormalize(m_pHeightMF
->GetValue(FUNIT_TWIP
)));
905 rSet
->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH
),
906 (sal_uInt32
) nWidth
) );
907 rSet
->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT
),
908 (sal_uInt32
) nHeight
) );
909 //this item is required by SdrEditView::SetGeoAttrToMarked()
910 rSet
->Put( SfxAllEnumItem( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT
), RP_LT
) );
918 void SvxSwPosSizeTabPage::Reset( const SfxItemSet
* rSet
)
920 const SfxPoolItem
* pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_ANCHOR
);
921 bool bInvalidateAnchor
= false;
922 short nAnchorType
= TextContentAnchorType_AT_PARAGRAPH
;
925 nAnchorType
= static_cast<const SfxInt16Item
*>(pItem
)->GetValue();
928 case TextContentAnchorType_AT_PAGE
: m_pToPageRB
->Check(); break;
929 case TextContentAnchorType_AT_PARAGRAPH
: m_pToParaRB
->Check(); break;
930 case TextContentAnchorType_AT_CHARACTER
: m_pToCharRB
->Check(); break;
931 case TextContentAnchorType_AS_CHARACTER
: m_pAsCharRB
->Check(); break;
932 case TextContentAnchorType_AT_FRAME
: m_pToFrameRB
->Check(); break;
933 default : bInvalidateAnchor
= true;
935 m_pToPageRB
->SaveValue();
936 m_pToParaRB
->SaveValue();
937 m_pToCharRB
->SaveValue();
938 m_pAsCharRB
->SaveValue();
939 m_pToFrameRB
->SaveValue();
941 if(bInvalidateAnchor
)
943 m_pToPageRB
->Enable( false );
944 m_pToParaRB
->Enable( false );
945 m_pToCharRB
->Enable( false );
946 m_pAsCharRB
->Enable( false );
947 m_pToFrameRB
->Enable( false );
950 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_PROTECT_POS
);
953 bool bProtected
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
954 m_pPositionCB
->SetState( bProtected
? TRISTATE_TRUE
: TRISTATE_FALSE
);
955 m_pPositionCB
->EnableTriState( false );
956 m_pSizeCB
->Enable( !bProtected
);
960 m_pPositionCB
->SetState( TRISTATE_INDET
);
963 m_pPositionCB
->SaveValue();
965 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_PROTECT_SIZE
);
969 m_pSizeCB
->SetState( static_cast<const SfxBoolItem
*>(pItem
)->GetValue()
970 ? TRISTATE_TRUE
: TRISTATE_FALSE
);
971 m_pSizeCB
->EnableTriState( false );
974 m_pSizeCB
->SetState( TRISTATE_INDET
);
975 m_pSizeCB
->SaveValue();
977 pItem
= GetItem( *rSet
, SID_HTML_MODE
);
981 (static_cast<const SfxUInt16Item
*>(pItem
)->GetValue() & HTMLMODE_ON
)
985 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT
);
986 if(pItem
&& static_cast<const SfxBoolItem
*>(pItem
)->GetValue())
988 OUString sHLabel
= m_pHoriFT
->GetText();
989 m_pHoriFT
->SetText(m_pVertFT
->GetText());
990 m_pVertFT
->SetText(sHLabel
);
991 m_bIsVerticalFrame
= true;
993 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_IN_RTL_TEXT
);
995 m_bIsInRightToLeft
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
997 pItem
= GetItem( *rSet
, SID_SW_FOLLOW_TEXT_FLOW
);
1000 const bool bFollowTextFlow
=
1001 static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1002 m_pFollowCB
->Check( bFollowTextFlow
);
1004 m_pFollowCB
->SaveValue();
1008 m_pHoriMirrorCB
->Show(false);
1009 m_pKeepRatioCB
->Enable(false);
1010 // #i18732# - hide checkbox in HTML mode
1011 m_pFollowCB
->Show(false);
1015 // #i18732# correct enable/disable of check box 'Mirror on..'
1016 m_pHoriMirrorCB
->Enable(!m_pAsCharRB
->IsChecked() && !m_bIsMultiSelection
);
1018 // #i18732# - enable/disable check box 'Follow text flow'.
1019 m_pFollowCB
->Enable( m_pToParaRB
->IsChecked() ||
1020 m_pToCharRB
->IsChecked() );
1023 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_WIDTH
);
1024 sal_Int32 nWidth
= std::max( pItem
? ( static_cast<const SfxUInt32Item
*>(pItem
)->GetValue()) : 0, (sal_uInt32
)1 );
1026 m_pWidthMF
->SetValue(m_pWidthMF
->Normalize(nWidth
), FUNIT_TWIP
);
1028 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_HEIGHT
);
1029 sal_Int32 nHeight
= std::max( pItem
? ( static_cast<const SfxUInt32Item
*>(pItem
)->GetValue()) : 0, (sal_uInt32
)1 );
1030 m_pHeightMF
->SetValue(m_pHeightMF
->Normalize(nHeight
), FUNIT_TWIP
);
1031 m_fWidthHeightRatio
= nHeight
? double(nWidth
) / double(nHeight
) : 1.0;
1033 if(!m_bPositioningDisabled
)
1035 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_HORI_ORIENT
);
1038 short nHoriOrientation
= static_cast< const SfxInt16Item
*>(pItem
)->GetValue();
1039 m_nOldH
= nHoriOrientation
;
1041 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_VERT_ORIENT
);
1044 short nVertOrientation
= static_cast< const SfxInt16Item
*>(pItem
)->GetValue();
1045 m_nOldV
= nVertOrientation
;
1047 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_HORI_RELATION
);
1050 m_nOldHRel
= static_cast< const SfxInt16Item
*>(pItem
)->GetValue();
1053 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_VERT_RELATION
);
1056 m_nOldVRel
= static_cast< const SfxInt16Item
*>(pItem
)->GetValue();
1058 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_HORI_MIRROR
);
1060 m_pHoriMirrorCB
->Check(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
1061 m_pHoriMirrorCB
->SaveValue();
1063 sal_Int32 nHoriPos
= 0;
1064 sal_Int32 nVertPos
= 0;
1065 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_HORI_POSITION
);
1067 nHoriPos
= static_cast<const SfxInt32Item
*>(pItem
)->GetValue();
1068 pItem
= GetItem( *rSet
, SID_ATTR_TRANSFORM_VERT_POSITION
);
1070 nVertPos
= static_cast<const SfxInt32Item
*>(pItem
)->GetValue();
1072 InitPos(nAnchorType
, m_nOldH
, m_nOldHRel
, m_nOldV
, m_nOldVRel
, nHoriPos
, nVertPos
);
1074 m_pVertByMF
->SaveValue();
1075 m_pHoriByMF
->SaveValue();
1077 m_pFollowCB
->SaveValue();
1079 RangeModifyHdl(m_pWidthMF
); // initially set maximum values
1083 SfxTabPage::sfxpg
SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet
* _pSet
)
1086 FillItemSet( _pSet
);
1090 void SvxSwPosSizeTabPage::EnableAnchorTypes(sal_uInt16 nAnchorEnable
)
1092 if((nAnchorEnable
& SVX_OBJ_AT_FLY
))
1093 m_pToFrameRB
->Show();
1094 if(!(nAnchorEnable
& SVX_OBJ_PAGE
))
1095 m_pToPageRB
->Enable(false);
1098 short SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged
)
1101 RadioButton
* pCheckedButton
= 0;
1102 if(m_pToParaRB
->IsEnabled())
1104 if(m_pToPageRB
->IsChecked())
1106 nRet
= TextContentAnchorType_AT_PAGE
;
1107 pCheckedButton
= m_pToPageRB
;
1109 else if(m_pToParaRB
->IsChecked())
1111 nRet
= TextContentAnchorType_AT_PARAGRAPH
;
1112 pCheckedButton
= m_pToParaRB
;
1114 else if(m_pToCharRB
->IsChecked())
1116 nRet
= TextContentAnchorType_AT_CHARACTER
;
1117 pCheckedButton
= m_pToCharRB
;
1119 else if(m_pAsCharRB
->IsChecked())
1121 nRet
= TextContentAnchorType_AS_CHARACTER
;
1122 pCheckedButton
= m_pAsCharRB
;
1124 else if(m_pToFrameRB
->IsChecked())
1126 nRet
= TextContentAnchorType_AT_FRAME
;
1127 pCheckedButton
= m_pToFrameRB
;
1133 *pbHasChanged
= pCheckedButton
->IsValueChangedFromSaved();
1135 *pbHasChanged
= false;
1140 IMPL_LINK_NOARG(SvxSwPosSizeTabPage
, RangeModifyHdl
)
1142 if(m_bPositioningDisabled
)
1144 SvxSwFrameValidation aVal
;
1146 aVal
.nAnchorType
= GetAnchorType();
1147 aVal
.bAutoHeight
= false;
1148 aVal
.bAutoWidth
= false;
1149 aVal
.bMirror
= m_pHoriMirrorCB
->IsChecked();
1151 aVal
.bFollowTextFlow
= m_pFollowCB
->IsChecked();
1155 // horizontal alignment
1156 sal_uInt16 nMapPos
= GetMapPos(m_pHMap
, *m_pHoriToLB
);
1157 sal_uInt16 nAlign
= GetAlignment(m_pHMap
, nMapPos
, *m_pHoriLB
, *m_pHoriToLB
);
1158 sal_uInt16 nRel
= GetRelation(m_pHMap
, *m_pHoriToLB
);
1160 aVal
.nHoriOrient
= (short)nAlign
;
1161 aVal
.nHRelOrient
= (short)nRel
;
1164 aVal
.nHoriOrient
= HoriOrientation::NONE
;
1168 // vertical alignment
1169 sal_uInt16 nMapPos
= GetMapPos(m_pVMap
, *m_pVertLB
);
1170 sal_uInt16 nAlign
= GetAlignment(m_pVMap
, nMapPos
, *m_pVertLB
, *m_pVertToLB
);
1171 sal_uInt16 nRel
= GetRelation(m_pVMap
, *m_pVertToLB
);
1173 aVal
.nVertOrient
= (short)nAlign
;
1174 aVal
.nVRelOrient
= (short)nRel
;
1177 aVal
.nVertOrient
= VertOrientation::NONE
;
1179 const long nAtHorzPosVal
=
1180 static_cast<long>(m_pHoriByMF
->Denormalize(m_pHoriByMF
->GetValue(FUNIT_TWIP
)));
1181 const long nAtVertPosVal
=
1182 static_cast<long>(m_pVertByMF
->Denormalize(m_pVertByMF
->GetValue(FUNIT_TWIP
)));
1184 aVal
.nHPos
= nAtHorzPosVal
;
1185 aVal
.nVPos
= nAtVertPosVal
;
1187 sal_Int32 nWidth
= static_cast<sal_uInt32
>(m_pWidthMF
-> Denormalize(m_pWidthMF
->GetValue(FUNIT_TWIP
)));
1188 sal_Int32 nHeight
= static_cast<sal_uInt32
>(m_pHeightMF
->Denormalize(m_pHeightMF
->GetValue(FUNIT_TWIP
)));
1189 aVal
.nWidth
= nWidth
;
1190 aVal
.nHeight
= nHeight
;
1192 if(m_aValidateLink
.IsSet())
1193 m_aValidateLink
.Call(&aVal
);
1195 nWidth
= aVal
.nWidth
;
1196 nHeight
= aVal
.nHeight
;
1198 // minimum width also for style
1199 m_pHeightMF
->SetMin(m_pHeightMF
->Normalize(aVal
.nMinHeight
), FUNIT_TWIP
);
1200 m_pWidthMF
-> SetMin(m_pWidthMF
->Normalize(aVal
.nMinWidth
), FUNIT_TWIP
);
1202 sal_Int32
nMaxWidth(aVal
.nMaxWidth
);
1203 sal_Int32
nMaxHeight(aVal
.nMaxHeight
);
1205 sal_Int64 nTmp
= m_pHeightMF
->Normalize(nMaxHeight
);
1206 m_pHeightMF
->SetMax(nTmp
, FUNIT_TWIP
);
1208 nTmp
= m_pWidthMF
->Normalize(nMaxWidth
);
1209 m_pWidthMF
->SetMax(nTmp
, FUNIT_TWIP
);
1211 m_pHoriByMF
->SetMin(m_pHoriByMF
->Normalize(aVal
.nMinHPos
), FUNIT_TWIP
);
1212 m_pHoriByMF
->SetMax(m_pHoriByMF
->Normalize(aVal
.nMaxHPos
), FUNIT_TWIP
);
1213 if ( aVal
.nHPos
!= nAtHorzPosVal
)
1214 m_pHoriByMF
->SetValue(m_pHoriByMF
->Normalize(aVal
.nHPos
), FUNIT_TWIP
);
1216 m_pVertByMF
->SetMin(m_pVertByMF
->Normalize(aVal
.nMinVPos
), FUNIT_TWIP
);
1217 m_pVertByMF
->SetMax(m_pVertByMF
->Normalize(aVal
.nMaxVPos
), FUNIT_TWIP
);
1218 if ( aVal
.nVPos
!= nAtVertPosVal
)
1219 m_pVertByMF
->SetValue(m_pVertByMF
->Normalize(aVal
.nVPos
), FUNIT_TWIP
);
1224 IMPL_LINK_NOARG(SvxSwPosSizeTabPage
, AnchorTypeHdl
)
1226 m_pHoriMirrorCB
->Enable(!m_pAsCharRB
->IsChecked() && !m_bIsMultiSelection
);
1228 // #i18732# - enable check box 'Follow text flow' for anchor
1229 // type to-paragraph' and to-character
1230 m_pFollowCB
->Enable( m_pToParaRB
->IsChecked() || m_pToCharRB
->IsChecked() );
1232 short nId
= GetAnchorType();
1234 InitPos( nId
, USHRT_MAX
, 0, USHRT_MAX
, 0, LONG_MAX
, LONG_MAX
);
1245 IMPL_LINK_NOARG(SvxSwPosSizeTabPage
, MirrorHdl
)
1247 short nId
= GetAnchorType();
1248 InitPos( nId
, USHRT_MAX
, 0, USHRT_MAX
, 0, LONG_MAX
, LONG_MAX
);
1253 IMPL_LINK( SvxSwPosSizeTabPage
, RelHdl
, ListBox
*, pLB
)
1255 bool bHori
= pLB
== m_pHoriToLB
;
1260 m_bAtHoriPosModified
= true;
1262 m_bAtVertPosModified
= true;
1264 if(m_bHtmlMode
&& TextContentAnchorType_AT_CHARACTER
== GetAnchorType()) // again special treatment
1268 sal_uInt16 nRel
= GetRelation(m_pHMap
, *m_pHoriToLB
);
1269 if(RelOrientation::PRINT_AREA
== nRel
&& 0 == m_pVertLB
->GetSelectEntryPos())
1271 m_pVertLB
->SelectEntryPos(1);
1273 else if(RelOrientation::CHAR
== nRel
&& 1 == m_pVertLB
->GetSelectEntryPos())
1275 m_pVertLB
->SelectEntryPos(0);
1279 if (pLB
) // only if the hanlder has been called by a change of the controller
1286 IMPL_LINK( SvxSwPosSizeTabPage
, PosHdl
, ListBox
*, pLB
)
1288 bool bHori
= pLB
== m_pHoriLB
;
1289 ListBox
*pRelLB
= bHori
? m_pHoriToLB
: m_pVertToLB
;
1290 FixedText
*pRelFT
= bHori
? m_pHoriToFT
: m_pVertToFT
;
1291 FrmMap
*pMap
= bHori
? m_pHMap
: m_pVMap
;
1294 sal_uInt16 nMapPos
= GetMapPos(pMap
, *pLB
);
1295 sal_uInt16 nAlign
= GetAlignment(pMap
, nMapPos
, *pLB
, *pRelLB
);
1299 bool bEnable
= HoriOrientation::NONE
== nAlign
;
1300 m_pHoriByMF
->Enable( bEnable
);
1301 m_pHoriByFT
->Enable( bEnable
);
1305 bool bEnable
= VertOrientation::NONE
== nAlign
;
1306 m_pVertByMF
->Enable( bEnable
);
1307 m_pVertByFT
->Enable( bEnable
);
1310 RangeModifyHdl( 0 );
1313 if (pLB
->GetSelectEntryCount())
1316 if (pRelLB
->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND
)
1317 nRel
= static_cast<RelationMap
*>(pRelLB
->GetSelectEntryData())->nRelation
;
1319 FillRelLB(pMap
, nMapPos
, nAlign
, nRel
, *pRelLB
, *pRelFT
);
1327 m_bAtHoriPosModified
= true;
1329 m_bAtVertPosModified
= true;
1331 // special treatment for HTML-Mode with horz-vert-dependencies
1332 if(m_bHtmlMode
&& TextContentAnchorType_AT_CHARACTER
== GetAnchorType())
1337 // on the right only below is allowed - from the left only at the top
1338 // from the left at the character -> below
1339 if((HoriOrientation::LEFT
== nAlign
|| HoriOrientation::RIGHT
== nAlign
) &&
1340 0 == m_pVertLB
->GetSelectEntryPos())
1342 if(RelOrientation::FRAME
== nRel
)
1343 m_pVertLB
->SelectEntryPos(1);
1345 m_pVertLB
->SelectEntryPos(0);
1348 else if(HoriOrientation::LEFT
== nAlign
&& 1 == m_pVertLB
->GetSelectEntryPos())
1350 m_pVertLB
->SelectEntryPos(0);
1353 else if(HoriOrientation::NONE
== nAlign
&& 1 == m_pVertLB
->GetSelectEntryPos())
1355 m_pVertLB
->SelectEntryPos(0);
1363 if(VertOrientation::TOP
== nAlign
)
1365 if(1 == m_pHoriLB
->GetSelectEntryPos())
1367 m_pHoriLB
->SelectEntryPos(0);
1370 m_pHoriToLB
->SelectEntryPos(1);
1372 else if(VertOrientation::CHAR_BOTTOM
== nAlign
)
1374 if(2 == m_pHoriLB
->GetSelectEntryPos())
1376 m_pHoriLB
->SelectEntryPos(0);
1379 m_pHoriToLB
->SelectEntryPos(0) ;
1389 IMPL_LINK( SvxSwPosSizeTabPage
, ModifyHdl
, Edit
*, pEdit
)
1391 sal_Int64 nWidth
= m_pWidthMF
->Denormalize(m_pWidthMF
->GetValue(FUNIT_TWIP
));
1392 sal_Int64 nHeight
= m_pHeightMF
->Denormalize(m_pHeightMF
->GetValue(FUNIT_TWIP
));
1393 if ( m_pKeepRatioCB
->IsChecked() )
1395 if ( pEdit
== m_pWidthMF
)
1397 nHeight
= sal_Int64((double)nWidth
/ m_fWidthHeightRatio
);
1398 m_pHeightMF
->SetValue(m_pHeightMF
->Normalize(nHeight
), FUNIT_TWIP
);
1400 else if(pEdit
== m_pHeightMF
)
1402 nWidth
= sal_Int64((double)nHeight
* m_fWidthHeightRatio
);
1403 m_pWidthMF
->SetValue(m_pWidthMF
->Normalize(nWidth
), FUNIT_TWIP
);
1406 m_fWidthHeightRatio
= nHeight
? double(nWidth
) / double(nHeight
) : 1.0;
1411 IMPL_LINK_NOARG(SvxSwPosSizeTabPage
, ProtectHdl
)
1413 m_pSizeCB
->Enable(m_pPositionCB
->IsEnabled() && !m_pPositionCB
->IsChecked());
1417 short SvxSwPosSizeTabPage::GetRelation(FrmMap
*, ListBox
&rRelationLB
)
1420 sal_Int32 nPos
= rRelationLB
.GetSelectEntryPos();
1422 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
1424 RelationMap
*pEntry
= static_cast<RelationMap
*>(rRelationLB
.GetEntryData(nPos
));
1425 nRel
= pEntry
->nRelation
;
1431 short SvxSwPosSizeTabPage::GetAlignment(FrmMap
*pMap
, sal_uInt16 nMapPos
, ListBox
&/*rAlignLB*/, ListBox
&rRelationLB
)
1435 // #i22341# - special handling also for map <aVCharMap>,
1436 // because it contains ambigous items for alignment
1437 if (pMap
== aVAsCharHtmlMap
|| pMap
== aVAsCharMap
||
1440 if (rRelationLB
.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND
)
1442 sal_uLong nRel
= static_cast<RelationMap
*>(rRelationLB
.GetSelectEntryData())->nLBRelation
;
1443 std::size_t nMapCount
= ::lcl_GetFrmMapCount(pMap
);
1444 SvxSwFramePosString::StringId eStrId
= pMap
[nMapPos
].eStrId
;
1446 for (std::size_t i
= 0; i
< nMapCount
; i
++)
1448 if (pMap
[i
].eStrId
== eStrId
)
1450 sal_uLong nLBRelations
= pMap
[i
].nLBRelations
;
1451 if (nLBRelations
& nRel
)
1453 nAlign
= pMap
[i
].nAlign
;
1461 nAlign
= pMap
[nMapPos
].nAlign
;
1466 sal_uInt16
SvxSwPosSizeTabPage::GetMapPos(FrmMap
*pMap
, ListBox
&rAlignLB
)
1468 sal_uInt16 nMapPos
= 0;
1469 sal_Int32 nLBSelPos
= rAlignLB
.GetSelectEntryPos();
1471 if (nLBSelPos
!= LISTBOX_ENTRY_NOTFOUND
)
1473 if (pMap
== aVAsCharHtmlMap
|| pMap
== aVAsCharMap
)
1475 std::size_t nMapCount
= ::lcl_GetFrmMapCount(pMap
);
1476 OUString
sSelEntry(rAlignLB
.GetSelectEntry());
1478 for (std::size_t i
= 0; i
< nMapCount
; i
++)
1480 SvxSwFramePosString::StringId eResId
= pMap
[i
].eStrId
;
1482 OUString sEntry
= m_aFramePosString
.GetString(eResId
);
1484 if (sEntry
== sSelEntry
)
1486 nMapPos
= sal::static_int_cast
< sal_uInt16
>(i
);
1492 nMapPos
= nLBSelPos
;
1498 void SvxSwPosSizeTabPage::InitPos(short nAnchor
,
1506 sal_Int32 nPos
= m_pVertLB
->GetSelectEntryPos();
1507 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
&& m_pVMap
)
1509 m_nOldV
= m_pVMap
[nPos
].nAlign
;
1510 nPos
= m_pVertToLB
->GetSelectEntryPos();
1511 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
1512 m_nOldVRel
= static_cast<RelationMap
*>(m_pVertToLB
->GetEntryData(nPos
))->nRelation
;
1515 nPos
= m_pHoriLB
->GetSelectEntryPos();
1516 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
&& m_pHMap
)
1518 m_nOldH
= m_pHMap
[nPos
].nAlign
;
1520 nPos
= m_pHoriToLB
->GetSelectEntryPos();
1521 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
1522 m_nOldHRel
= static_cast<RelationMap
*>(m_pHoriToLB
->GetEntryData(nPos
))->nRelation
;
1525 bool bEnable
= true;
1526 if( m_bIsMultiSelection
)
1528 m_pVMap
= aVMultiSelectionMap
;
1529 m_pHMap
= aHMultiSelectionMap
;
1531 else if( nAnchor
== TextContentAnchorType_AT_PAGE
)
1533 m_pVMap
= m_bHtmlMode
? aVPageHtmlMap
: aVPageMap
;
1534 m_pHMap
= m_bHtmlMode
? aHPageHtmlMap
: aHPageMap
;
1536 else if ( nAnchor
== TextContentAnchorType_AT_FRAME
)
1538 // #i18732# - own vertical alignment map for to frame
1539 // anchored objects.
1540 m_pVMap
= m_bHtmlMode
? aVFlyHtmlMap
: aVFrameMap
;
1541 m_pHMap
= m_bHtmlMode
? aHFlyHtmlMap
: aHFrameMap
;
1543 else if ( nAnchor
== TextContentAnchorType_AT_PARAGRAPH
)
1547 m_pVMap
= aVParaHtmlMap
;
1548 m_pHMap
= aHParaHtmlAbsMap
;
1552 m_pVMap
= aVParaMap
;
1553 m_pHMap
= aHParaMap
;
1556 else if ( nAnchor
== TextContentAnchorType_AT_CHARACTER
)
1560 m_pVMap
= aVCharHtmlAbsMap
;
1561 m_pHMap
= aHCharHtmlAbsMap
;
1565 m_pVMap
= aVCharMap
;
1566 m_pHMap
= aHCharMap
;
1569 else if ( nAnchor
== TextContentAnchorType_AS_CHARACTER
)
1571 m_pVMap
= m_bHtmlMode
? aVAsCharHtmlMap
: aVAsCharMap
;
1575 m_pHoriLB
->Enable( bEnable
);
1576 m_pHoriFT
->Enable( bEnable
);
1578 // select current Pos
1580 if ( nH
== USHRT_MAX
)
1585 // #i22341# - pass <nHRel> as 3rd parameter to method <FillPosLB>
1586 sal_uInt16 nMapPos
= FillPosLB(m_pHMap
, nH
, nHRel
, *m_pHoriLB
);
1587 FillRelLB(m_pHMap
, nMapPos
, nH
, nHRel
, *m_pHoriToLB
, *m_pHoriToFT
);
1590 if ( nV
== USHRT_MAX
)
1595 // #i22341# - pass <nVRel> as 3rd parameter to method <FillPosLB>
1596 nMapPos
= FillPosLB(m_pVMap
, nV
, nVRel
, *m_pVertLB
);
1597 FillRelLB(m_pVMap
, nMapPos
, nV
, nVRel
, *m_pVertToLB
, *m_pVertToFT
);
1600 bEnable
= nH
== HoriOrientation::NONE
&&
1601 nAnchor
!= TextContentAnchorType_AS_CHARACTER
;//#61359# why not in formats&& !bFormat;
1604 m_pHoriByMF
->SetValue( 0, FUNIT_TWIP
);
1605 if (nX
!= LONG_MAX
&& m_bHtmlMode
)
1606 m_pHoriByMF
->SetModifyFlag();
1608 else if(m_bIsMultiSelection
)
1610 m_pHoriByMF
->SetValue( m_pHoriByMF
->Normalize(m_aRect
.Left()), FUNIT_TWIP
);
1615 m_pHoriByMF
->SetValue( m_pHoriByMF
->Normalize(nX
), FUNIT_TWIP
);
1617 m_pHoriByFT
->Enable( bEnable
);
1618 m_pHoriByMF
->Enable( bEnable
);
1620 bEnable
= nV
== VertOrientation::NONE
;
1623 m_pVertByMF
->SetValue( 0, FUNIT_TWIP
);
1624 if(nY
!= LONG_MAX
&& m_bHtmlMode
)
1625 m_pVertByMF
->SetModifyFlag();
1627 else if(m_bIsMultiSelection
)
1629 m_pVertByMF
->SetValue( m_pVertByMF
->Normalize(m_aRect
.Top()), FUNIT_TWIP
);
1633 if ( nAnchor
== TextContentAnchorType_AS_CHARACTER
)
1635 if ( nY
== LONG_MAX
)
1640 if ( nY
!= LONG_MAX
)
1641 m_pVertByMF
->SetValue( m_pVertByMF
->Normalize(nY
), FUNIT_TWIP
);
1643 m_pVertByFT
->Enable( bEnable
);
1644 m_pVertByMF
->Enable( bEnable
);
1648 void SvxSwPosSizeTabPage::UpdateExample()
1650 sal_Int32 nPos
= m_pHoriLB
->GetSelectEntryPos();
1651 if ( m_pHMap
&& nPos
!= LISTBOX_ENTRY_NOTFOUND
)
1653 sal_uInt16 nMapPos
= GetMapPos(m_pHMap
, *m_pHoriLB
);
1654 short nAlign
= GetAlignment(m_pHMap
, nMapPos
, *m_pHoriLB
, *m_pHoriToLB
);
1655 short nRel
= GetRelation(m_pHMap
, *m_pHoriToLB
);
1657 m_pExampleWN
->SetHAlign(nAlign
);
1658 m_pExampleWN
->SetHoriRel(nRel
);
1661 nPos
= m_pVertLB
->GetSelectEntryPos();
1662 if ( m_pVMap
&& nPos
!= LISTBOX_ENTRY_NOTFOUND
)
1664 sal_uInt16 nMapPos
= GetMapPos(m_pVMap
, *m_pVertLB
);
1665 sal_uInt16 nAlign
= GetAlignment(m_pVMap
, nMapPos
, *m_pVertLB
, *m_pVertToLB
);
1666 sal_uInt16 nRel
= GetRelation(m_pVMap
, *m_pVertToLB
);
1668 m_pExampleWN
->SetVAlign(nAlign
);
1669 m_pExampleWN
->SetVertRel(nRel
);
1673 long nXPos
= static_cast<long>(m_pHoriByMF
->Denormalize(m_pHoriByMF
->GetValue(FUNIT_TWIP
)));
1674 long nYPos
= static_cast<long>(m_pVertByMF
->Denormalize(m_pVertByMF
->GetValue(FUNIT_TWIP
)));
1675 m_pExampleWN
->SetRelPos(Point(nXPos
, nYPos
));
1677 m_pExampleWN
->SetAnchor( GetAnchorType() );
1678 m_pExampleWN
->Invalidate();
1681 sal_uLong
SvxSwPosSizeTabPage::FillRelLB(FrmMap
*pMap
, sal_uInt16 nMapPos
, sal_uInt16 nAlign
,
1682 sal_uInt16 nRel
, ListBox
&rLB
, FixedText
&rFT
)
1685 sal_uLong nLBRelations
= 0;
1686 std::size_t nMapCount
= ::lcl_GetFrmMapCount(pMap
);
1690 if (nMapPos
< nMapCount
)
1692 if (pMap
== aVAsCharHtmlMap
|| pMap
== aVAsCharMap
)
1694 OUString
sOldEntry(rLB
.GetSelectEntry());
1695 sal_uInt16 nRelCount
= SAL_N_ELEMENTS(aAsCharRelationMap
);
1696 SvxSwFramePosString::StringId eStrId
= pMap
[nMapPos
].eStrId
;
1698 for (std::size_t _nMapPos
= 0; _nMapPos
< nMapCount
; _nMapPos
++)
1700 if (pMap
[_nMapPos
].eStrId
== eStrId
)
1702 nLBRelations
= pMap
[_nMapPos
].nLBRelations
;
1703 for (sal_uInt16 nRelPos
= 0; nRelPos
< nRelCount
; nRelPos
++)
1705 if (nLBRelations
& aAsCharRelationMap
[nRelPos
].nLBRelation
)
1707 SvxSwFramePosString::StringId sStrId1
= aAsCharRelationMap
[nRelPos
].eStrId
;
1709 sStrId1
= lcl_ChangeResIdToVerticalOrRTL(sStrId1
, m_bIsVerticalFrame
, m_bIsInRightToLeft
);
1710 OUString sEntry
= m_aFramePosString
.GetString(sStrId1
);
1711 sal_Int32 nPos
= rLB
.InsertEntry(sEntry
);
1712 rLB
.SetEntryData(nPos
, &aAsCharRelationMap
[nRelPos
]);
1713 if (pMap
[_nMapPos
].nAlign
== nAlign
)
1720 if (!sSelEntry
.isEmpty())
1721 rLB
.SelectEntry(sSelEntry
);
1724 rLB
.SelectEntry(sOldEntry
);
1726 if (!rLB
.GetSelectEntryCount())
1728 for (sal_Int32 i
= 0; i
< rLB
.GetEntryCount(); i
++)
1730 RelationMap
*pEntry
= static_cast<RelationMap
*>(rLB
.GetEntryData(i
));
1731 if (pEntry
->nLBRelation
== LB_REL_CHAR
) // Default
1733 rLB
.SelectEntryPos(i
);
1742 sal_uInt16 nRelCount
= SAL_N_ELEMENTS(aRelationMap
);
1744 // #i22341# - special handling for map <aVCharMap>,
1745 // because its ambigous in its <eStrId>/<eMirrorStrId>.
1746 if ( pMap
== aVCharMap
)
1748 nLBRelations
= ::lcl_GetLBRelationsForStrID( pMap
,
1749 ( m_pHoriMirrorCB
->IsChecked()
1750 ? pMap
[nMapPos
].eMirrorStrId
1751 : pMap
[nMapPos
].eStrId
),
1752 m_pHoriMirrorCB
->IsChecked() );
1756 nLBRelations
= pMap
[nMapPos
].nLBRelations
;
1759 for (sal_uLong nBit
= 1; nBit
< 0x80000000; nBit
<<= 1)
1761 if (nLBRelations
& nBit
)
1763 for (sal_uInt16 nRelPos
= 0; nRelPos
< nRelCount
; nRelPos
++)
1765 if (aRelationMap
[nRelPos
].nLBRelation
== nBit
)
1767 SvxSwFramePosString::StringId sStrId1
= m_pHoriMirrorCB
->IsChecked() ? aRelationMap
[nRelPos
].eMirrorStrId
: aRelationMap
[nRelPos
].eStrId
;
1768 sStrId1
= lcl_ChangeResIdToVerticalOrRTL(sStrId1
, m_bIsVerticalFrame
, m_bIsInRightToLeft
);
1769 OUString sEntry
= m_aFramePosString
.GetString(sStrId1
);
1770 sal_Int32 nPos
= rLB
.InsertEntry(sEntry
);
1771 rLB
.SetEntryData(nPos
, &aRelationMap
[nRelPos
]);
1772 if (sSelEntry
.isEmpty() && aRelationMap
[nRelPos
].nRelation
== nRel
)
1778 if (!sSelEntry
.isEmpty())
1779 rLB
.SelectEntry(sSelEntry
);
1782 // Probably anchor change. So look for a similar relation.
1785 case RelOrientation::FRAME
: nRel
= RelOrientation::PAGE_FRAME
; break;
1786 case RelOrientation::PRINT_AREA
: nRel
= RelOrientation::PAGE_PRINT_AREA
; break;
1787 case RelOrientation::PAGE_LEFT
: nRel
= RelOrientation::FRAME_LEFT
; break;
1788 case RelOrientation::PAGE_RIGHT
: nRel
= RelOrientation::FRAME_RIGHT
; break;
1789 case RelOrientation::FRAME_LEFT
: nRel
= RelOrientation::PAGE_LEFT
; break;
1790 case RelOrientation::FRAME_RIGHT
: nRel
= RelOrientation::PAGE_RIGHT
; break;
1791 case RelOrientation::PAGE_FRAME
: nRel
= RelOrientation::FRAME
; break;
1792 case RelOrientation::PAGE_PRINT_AREA
: nRel
= RelOrientation::PRINT_AREA
; break;
1795 if (rLB
.GetEntryCount())
1797 RelationMap
*pEntry
= static_cast<RelationMap
*>(rLB
.GetEntryData(rLB
.GetEntryCount() - 1));
1798 nRel
= pEntry
->nRelation
;
1803 for (sal_Int32 i
= 0; i
< rLB
.GetEntryCount(); i
++)
1805 RelationMap
*pEntry
= static_cast<RelationMap
*>(rLB
.GetEntryData(i
));
1806 if (pEntry
->nRelation
== nRel
)
1808 rLB
.SelectEntryPos(i
);
1813 if (!rLB
.GetSelectEntryCount())
1814 rLB
.SelectEntryPos(0);
1819 rLB
.Enable(rLB
.GetEntryCount() != 0);
1820 rFT
.Enable(rLB
.GetEntryCount() != 0);
1824 return nLBRelations
;
1827 sal_uInt16
SvxSwPosSizeTabPage::FillPosLB(FrmMap
*_pMap
,
1829 const sal_uInt16 _nRel
,
1832 OUString sSelEntry
, sOldEntry
;
1833 sOldEntry
= _rLB
.GetSelectEntry();
1837 // #i22341# - determine all possible listbox relations for
1838 // given relation for map <aVCharMap>
1839 const sal_uLong nLBRelations
= (_pMap
!= aVCharMap
)
1841 : ::lcl_GetLBRelationsForRelations( _nRel
);
1844 std::size_t nCount
= ::lcl_GetFrmMapCount(_pMap
);
1845 for (std::size_t i
= 0; _pMap
&& i
< nCount
; ++i
)
1847 // #61359# why not from the left/from inside or from the top?
1848 // if (!bFormat || (pMap[i].eStrId != SwFPos::FROMLEFT && pMap[i].eStrId != SwFPos::FROMTOP))
1850 SvxSwFramePosString::StringId eStrId
= m_pHoriMirrorCB
->IsChecked() ? _pMap
[i
].eMirrorStrId
: _pMap
[i
].eStrId
;
1851 eStrId
= lcl_ChangeResIdToVerticalOrRTL(eStrId
, m_bIsVerticalFrame
, m_bIsInRightToLeft
);
1852 OUString
sEntry(m_aFramePosString
.GetString(eStrId
));
1853 if (_rLB
.GetEntryPos(sEntry
) == LISTBOX_ENTRY_NOTFOUND
)
1855 // don't insert duplicate entries at character wrapped borders
1856 _rLB
.InsertEntry(sEntry
);
1858 // #i22341# - add condition to handle map <aVCharMap>
1859 // that is ambigous in the alignment.
1860 if ( _pMap
[i
].nAlign
== _nAlign
&&
1861 ( !(_pMap
== aVCharMap
) || _pMap
[i
].nLBRelations
& nLBRelations
) )
1868 _rLB
.SelectEntry(sSelEntry
);
1869 if (!_rLB
.GetSelectEntryCount())
1870 _rLB
.SelectEntry(sOldEntry
);
1872 if (!_rLB
.GetSelectEntryCount())
1873 _rLB
.SelectEntryPos(0);
1877 return GetMapPos(_pMap
, _rLB
);
1880 void SvxSwPosSizeTabPage::SetView( const SdrView
* pSdrView
)
1882 m_pSdrView
= pSdrView
;
1885 OSL_FAIL("No SdrView* set");
1889 // setting of the rectangle and the working area
1890 m_aRect
= m_pSdrView
->GetAllMarkedRect();
1891 m_pSdrView
->GetSdrPageView()->LogicToPagePos( m_aRect
);
1894 m_aWorkArea
= m_pSdrView
->GetWorkArea();
1896 // consider anchor position (for Writer)
1897 const SdrMarkList
& rMarkList
= m_pSdrView
->GetMarkedObjectList();
1898 if( rMarkList
.GetMarkCount() > 0 )
1900 const SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
1901 m_aAnchorPos
= pObj
->GetAnchorPos();
1903 if( m_aAnchorPos
!= Point(0,0) ) // -> Writer
1905 for( size_t i
= 1; i
< rMarkList
.GetMarkCount(); ++i
)
1907 pObj
= rMarkList
.GetMark( i
)->GetMarkedSdrObj();
1908 if( m_aAnchorPos
!= pObj
->GetAnchorPos() )
1910 // different anchor positions -> disable positioning
1911 m_pPosFrame
->Enable(false);
1912 m_bPositioningDisabled
= true;
1917 Point aPt
= m_aAnchorPos
* -1;
1920 aPt
+= m_aWorkArea
.TopLeft();
1921 m_aWorkArea
.SetPos( aPt
);
1923 aPt2
+= m_aRect
.TopLeft();
1924 m_aRect
.SetPos( aPt2
);
1927 // this should happen via SID_ATTR_TRANSFORM_AUTOSIZE
1928 if( rMarkList
.GetMarkCount() != 1 )
1929 m_bIsMultiSelection
= true;
1930 #if OSL_DEBUG_LEVEL > 1
1933 const SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
1934 SdrObjKind eKind
= (SdrObjKind
) pObj
->GetObjIdentifier();
1935 if( ( pObj
->GetObjInventor() == SdrInventor
) &&
1936 ( eKind
==OBJ_TEXT
|| eKind
==OBJ_TITLETEXT
|| eKind
==OBJ_OUTLINETEXT
) &&
1939 OSL_FAIL("AutoWidth/AutoHeight should be enabled");
1945 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */