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