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