LibreOffice Module sw (master)  1
wrap.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 <hintids.hxx>
21 #include <vcl/graph.hxx>
22 #include <vcl/settings.hxx>
23 
24 #include <sfx2/htmlmode.hxx>
25 #include <sfx2/objsh.hxx>
26 #include <svl/intitem.hxx>
27 #include <editeng/opaqitem.hxx>
28 #include <editeng/ulspitem.hxx>
29 #include <editeng/lrspitem.hxx>
30 #include <fmtfollowtextflow.hxx>
31 #include <svtools/unitconv.hxx>
33 
34 #include <cmdid.h>
35 #include <docsh.hxx>
36 #include <uitool.hxx>
37 #include <wrtsh.hxx>
38 #include <swmodule.hxx>
39 #include <viewopt.hxx>
40 #include <fmtsrnd.hxx>
41 #include <frmatr.hxx>
42 #include <frmmgr.hxx>
43 #include <globals.hrc>
44 #include <wrap.hxx>
45 #include <bitmaps.hlst>
46 
47 using namespace ::com::sun::star;
48 
49 const sal_uInt16 SwWrapTabPage::m_aWrapPageRg[] = {
53  0
54 };
55 
56 SwWrapDlg::SwWrapDlg(weld::Window* pParent, SfxItemSet& rSet, SwWrtShell* pWrtShell, bool bDrawMode)
57  : SfxSingleTabDialogController(pParent, &rSet, "modules/swriter/ui/wrapdialog.ui", "WrapDialog")
58 {
59  // create TabPage
60  TabPageParent pPageParent(get_content_area(), this);
61  VclPtr<SwWrapTabPage> xNewPage = static_cast<SwWrapTabPage*>(SwWrapTabPage::Create(pPageParent, &rSet).get());
62  xNewPage->SetFormatUsed(false, bDrawMode);
63  xNewPage->SetShell(pWrtShell);
64  SetTabPage(xNewPage);
65 }
66 
68  : SfxTabPage(pParent, "modules/swriter/ui/wrappage.ui", "WrapPage", &rSet)
69  , m_nAnchorId(RndStdIds::FLY_AT_PARA)
70  , m_nHtmlMode(0)
71  , m_pWrtSh(nullptr)
72  , m_bFormat(false)
73  , m_bNew(true)
74  , m_bHtmlMode(false)
75  , m_bDrawMode(false)
76  , m_bContourImage(false)
77  , m_xNoWrapRB(m_xBuilder->weld_radio_button("none"))
78  , m_xWrapLeftRB(m_xBuilder->weld_radio_button("before"))
79  , m_xWrapRightRB(m_xBuilder->weld_radio_button("after"))
80  , m_xWrapParallelRB(m_xBuilder->weld_radio_button("parallel"))
81  , m_xWrapThroughRB(m_xBuilder->weld_radio_button("through"))
82  , m_xIdealWrapRB(m_xBuilder->weld_radio_button("optimal"))
83  , m_xLeftMarginED(m_xBuilder->weld_metric_spin_button("left", FieldUnit::CM))
84  , m_xRightMarginED(m_xBuilder->weld_metric_spin_button("right", FieldUnit::CM))
85  , m_xTopMarginED(m_xBuilder->weld_metric_spin_button("top", FieldUnit::CM))
86  , m_xBottomMarginED(m_xBuilder->weld_metric_spin_button("bottom", FieldUnit::CM))
87  , m_xWrapAnchorOnlyCB(m_xBuilder->weld_check_button("anchoronly"))
88  , m_xWrapTransparentCB(m_xBuilder->weld_check_button("transparent"))
89  , m_xWrapOutlineCB(m_xBuilder->weld_check_button("outline"))
90  , m_xWrapOutsideCB(m_xBuilder->weld_check_button("outside"))
91 {
93 
94  Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwWrapTabPage, RangeModifyHdl);
95  m_xLeftMarginED->connect_value_changed(aLk);
96  m_xRightMarginED->connect_value_changed(aLk);
97  m_xTopMarginED->connect_value_changed(aLk);
98  m_xBottomMarginED->connect_value_changed(aLk);
99 
100  Link<weld::ToggleButton&,void> aLk2 = LINK(this, SwWrapTabPage, WrapTypeHdl);
101  m_xNoWrapRB->connect_toggled(aLk2);
102  m_xWrapLeftRB->connect_toggled(aLk2);
103  m_xWrapRightRB->connect_toggled(aLk2);
104  m_xWrapParallelRB->connect_toggled(aLk2);
105  m_xWrapThroughRB->connect_toggled(aLk2);
106  m_xIdealWrapRB->connect_toggled(aLk2);
107  SetImages();
108  m_xWrapOutlineCB->connect_toggled(LINK(this, SwWrapTabPage, ContourHdl));
109 }
110 
112 {
113 }
114 
116 {
117  return VclPtr<SwWrapTabPage>::Create(pParent, *rSet);
118 }
119 
121 {
122  // contour for Draw, Graphic and OLE (Insert/Graphic/Properties still missing!)
123  if( m_bDrawMode )
124  {
125  m_xWrapOutlineCB->show();
126  m_xWrapOutsideCB->show();
127 
128  m_xWrapTransparentCB->set_active( 0 == static_cast<const SfxInt16Item&>(rSet->Get(
130  m_xWrapTransparentCB->save_state();
131  }
132  else
133  {
134  bool bShowCB = m_bFormat;
135  if( !m_bFormat )
136  {
138  if( ( nSelType & SelectionType::Graphic ) ||
139  ( nSelType & SelectionType::Ole && GraphicType::NONE !=
141  bShowCB = true;
142  }
143  if( bShowCB )
144  {
145  m_xWrapOutlineCB->show();
146  m_xWrapOutsideCB->show();
147  }
148  }
149 
150  m_nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
152 
154  SetFieldUnit(*m_xLeftMarginED, aMetric);
155  SetFieldUnit(*m_xRightMarginED, aMetric);
156  SetFieldUnit(*m_xTopMarginED, aMetric);
157  SetFieldUnit(*m_xBottomMarginED, aMetric);
158 
159  const SwFormatSurround& rSurround = rSet->Get(RES_SURROUND);
160 
161  css::text::WrapTextMode nSur = rSurround.GetSurround();
162  const SwFormatAnchor &rAnch = rSet->Get(RES_ANCHOR);
163  m_nAnchorId = rAnch.GetAnchorId();
164 
165  if (((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR))
166  && (nSur != css::text::WrapTextMode_NONE))
167  {
168  m_xWrapAnchorOnlyCB->set_active(rSurround.IsAnchorOnly());
169  }
170  else
171  {
172  m_xWrapAnchorOnlyCB->set_sensitive(false);
173  }
174 
175  const bool bContour = rSurround.IsContour();
176  m_xWrapOutlineCB->set_active(bContour);
177  m_xWrapOutsideCB->set_active(rSurround.IsOutside());
178  m_xWrapThroughRB->set_sensitive(!m_xWrapOutlineCB->get_active());
179  m_bContourImage = !bContour;
180 
181  weld::RadioButton* pBtn = nullptr;
182 
183  switch (nSur)
184  {
185  case css::text::WrapTextMode_NONE:
186  {
187  pBtn = m_xNoWrapRB.get();
188  break;
189  }
190 
191  case css::text::WrapTextMode_THROUGH:
192  {
193  // transparent ?
194  pBtn = m_xWrapThroughRB.get();
195 
196  if (!m_bDrawMode)
197  {
198  const SvxOpaqueItem& rOpaque = rSet->Get(RES_OPAQUE);
199  m_xWrapTransparentCB->set_active(!rOpaque.GetValue());
200  }
201  break;
202  }
203 
204  case css::text::WrapTextMode_PARALLEL:
205  {
206  pBtn = m_xWrapParallelRB.get();
207  break;
208  }
209 
210  case css::text::WrapTextMode_DYNAMIC:
211  {
212  pBtn = m_xIdealWrapRB.get();
213  break;
214  }
215 
216  default:
217  {
218  if (nSur == css::text::WrapTextMode_LEFT)
219  pBtn = m_xWrapLeftRB.get();
220  else if (nSur == css::text::WrapTextMode_RIGHT)
221  pBtn = m_xWrapRightRB.get();
222  }
223  }
224  if (pBtn)
225  {
226  pBtn->set_active(true);
227  WrapTypeHdl(*pBtn);
228  // For character objects that currently are in passage, the default
229  // "contour on" is prepared here, in case we switch to any other
230  // passage later.
231  if (m_bDrawMode && !m_xWrapOutlineCB->get_sensitive())
232  m_xWrapOutlineCB->set_active(true);
233  }
234  m_xWrapTransparentCB->set_sensitive(pBtn == m_xWrapThroughRB.get() && !m_bHtmlMode);
235 
236  const SvxULSpaceItem& rUL = rSet->Get(RES_UL_SPACE);
237  const SvxLRSpaceItem& rLR = rSet->Get(RES_LR_SPACE);
238 
239  // gap to text
240  m_xLeftMarginED->set_value(m_xLeftMarginED->normalize(rLR.GetLeft()), FieldUnit::TWIP);
241  m_xRightMarginED->set_value(m_xRightMarginED->normalize(rLR.GetRight()), FieldUnit::TWIP);
242  m_xTopMarginED->set_value(m_xTopMarginED->normalize(rUL.GetUpper()), FieldUnit::TWIP);
243  m_xBottomMarginED->set_value(m_xBottomMarginED->normalize(rUL.GetLower()), FieldUnit::TWIP);
244 
245  m_xLeftMarginED->save_value();
246  m_xRightMarginED->save_value();
247  m_xTopMarginED->save_value();
248  m_xBottomMarginED->save_value();
249 
250  ContourHdl(*m_xWrapOutlineCB);
251  ActivatePage( *rSet );
252 }
253 
254 // stuff attributes into the set when OK
256 {
257  bool bModified = false;
258  const SfxPoolItem* pOldItem;
259  const SwFormatSurround& rOldSur = GetItemSet().Get(RES_SURROUND);
260  SwFormatSurround aSur( rOldSur );
261 
262  std::shared_ptr<SvxOpaqueItem> aOp(std::make_shared<SvxOpaqueItem>(RES_OPAQUE));
263 
264  if (!m_bDrawMode)
265  {
266  aOp.reset(static_cast<SvxOpaqueItem*>(GetItemSet().Get(RES_OPAQUE).Clone()));
267  aOp->SetValue(true);
268  }
269 
270  if (m_xNoWrapRB->get_active())
271  aSur.SetSurround(css::text::WrapTextMode_NONE);
272  else if (m_xWrapLeftRB->get_active())
273  aSur.SetSurround(css::text::WrapTextMode_LEFT);
274  else if (m_xWrapRightRB->get_active())
275  aSur.SetSurround(css::text::WrapTextMode_RIGHT);
276  else if (m_xWrapParallelRB->get_active())
277  aSur.SetSurround(css::text::WrapTextMode_PARALLEL);
278  else if (m_xWrapThroughRB->get_active())
279  {
280  aSur.SetSurround(css::text::WrapTextMode_THROUGH);
281  if (m_xWrapTransparentCB->get_active() && !m_bDrawMode)
282  aOp->SetValue(false);
283  }
284  else if (m_xIdealWrapRB->get_active())
285  aSur.SetSurround(css::text::WrapTextMode_DYNAMIC);
286 
287  aSur.SetAnchorOnly( m_xWrapAnchorOnlyCB->get_active() );
288  bool bContour = m_xWrapOutlineCB->get_active() && m_xWrapOutlineCB->get_sensitive();
289  aSur.SetContour( bContour );
290 
291  if ( bContour )
292  aSur.SetOutside(m_xWrapOutsideCB->get_active());
293 
294  if(nullptr == (pOldItem = GetOldItem( *rSet, RES_SURROUND )) ||
295  aSur != *pOldItem )
296  {
297  rSet->Put(aSur);
298  bModified = true;
299  }
300 
301  if (!m_bDrawMode)
302  {
303  if(nullptr == (pOldItem = GetOldItem( *rSet, FN_OPAQUE )) ||
304  *aOp != *pOldItem )
305  {
306  rSet->Put(*aOp);
307  bModified = true;
308  }
309  }
310 
311  bool bTopMod = m_xTopMarginED->get_value_changed_from_saved();
312  bool bBottomMod = m_xBottomMarginED->get_value_changed_from_saved();
313 
315  aUL.SetUpper(static_cast<sal_uInt16>(m_xTopMarginED->denormalize(m_xTopMarginED->get_value(FieldUnit::TWIP))));
316  aUL.SetLower(static_cast<sal_uInt16>(m_xBottomMarginED->denormalize(m_xBottomMarginED->get_value(FieldUnit::TWIP))));
317 
318  if ( bTopMod || bBottomMod )
319  {
320  if(nullptr == (pOldItem = GetOldItem(*rSet, RES_UL_SPACE)) ||
321  aUL != *pOldItem )
322  {
323  rSet->Put( aUL );
324  bModified = true;
325  }
326  }
327 
328  bool bLeftMod = m_xLeftMarginED->get_value_changed_from_saved();
329  bool bRightMod = m_xRightMarginED->get_value_changed_from_saved();
330 
332  aLR.SetLeft(static_cast<sal_uInt16>(m_xLeftMarginED->denormalize(m_xLeftMarginED->get_value(FieldUnit::TWIP))));
333  aLR.SetRight(static_cast<sal_uInt16>(m_xRightMarginED->denormalize(m_xRightMarginED->get_value(FieldUnit::TWIP))));
334 
335  if ( bLeftMod || bRightMod )
336  {
337  if( nullptr == (pOldItem = GetOldItem(*rSet, RES_LR_SPACE)) ||
338  aLR != *pOldItem )
339  {
340  rSet->Put(aLR);
341  bModified = true;
342  }
343  }
344 
345  if ( m_bDrawMode )
346  {
347  bool bChecked = m_xWrapTransparentCB->get_active() && m_xWrapTransparentCB->get_sensitive();
348  if ((m_xWrapTransparentCB->get_saved_state() == TRISTATE_TRUE) != bChecked)
349  bModified |= nullptr != rSet->Put(SfxInt16Item(FN_DRAW_WRAP_DLG, bChecked ? 0 : 1));
350  }
351 
352  return bModified;
353 }
354 
355 // example update
357 {
358  // anchor
359  const SwFormatAnchor &rAnch = rSet.Get(RES_ANCHOR);
360  m_nAnchorId = rAnch.GetAnchorId();
361  bool bEnable = (m_nAnchorId != RndStdIds::FLY_AS_CHAR);
362 
363  if (!m_bDrawMode)
364  {
366  SwFlyFrameAttrMgr aMgr( m_bNew, pSh, GetItemSet() );
368 
369  // size
370  const SwFormatFrameSize& rFrameSize = rSet.Get(RES_FRM_SIZE);
371  Size aSize = rFrameSize.GetSize();
372 
373  // position
374  const SwFormatHoriOrient& rHori = rSet.Get(RES_HORI_ORIENT);
375  const SwFormatVertOrient& rVert = rSet.Get(RES_VERT_ORIENT);
376 
377  aVal.nAnchorType = m_nAnchorId;
378  aVal.bAutoHeight = rFrameSize.GetHeightSizeType() == ATT_MIN_SIZE;
379  aVal.bMirror = rHori.IsPosToggle();
380  // #i18732#
381  aVal.bFollowTextFlow = rSet.Get(RES_FOLLOW_TEXT_FLOW).GetValue();
382 
383  aVal.nHoriOrient = static_cast<short>(rHori.GetHoriOrient());
384  aVal.nVertOrient = static_cast<short>(rVert.GetVertOrient());
385 
386  aVal.nHPos = rHori.GetPos();
387  aVal.nHRelOrient = rHori.GetRelationOrient();
388  aVal.nVPos = rVert.GetPos();
389  aVal.nVRelOrient = rVert.GetRelationOrient();
390 
391  if (rFrameSize.GetWidthPercent() && rFrameSize.GetWidthPercent() != SwFormatFrameSize::SYNCED)
392  aSize.setWidth( aSize.Width() * rFrameSize.GetWidthPercent() / 100 );
393 
394  if (rFrameSize.GetHeightPercent() && rFrameSize.GetHeightPercent() != SwFormatFrameSize::SYNCED)
395  aSize.setHeight( aSize.Height() * rFrameSize.GetHeightPercent() / 100 );
396 
397  aVal.nWidth = aSize.Width();
398  aVal.nHeight = aSize.Height();
399 
400  aMgr.ValidateMetrics(aVal, nullptr);
401 
402  SwTwips nLeft;
403  SwTwips nRight;
404  SwTwips nTop;
405  SwTwips nBottom;
406 
407  nLeft = aVal.nHPos - aVal.nMinHPos;
408  nRight = aVal.nMaxWidth - aVal.nWidth;
409  nTop = aVal.nVPos - aVal.nMinVPos;
410  nBottom = aVal.nMaxHeight - aVal.nHeight;
411 
412  {
413  if (aVal.nAnchorType == RndStdIds::FLY_AS_CHAR)
414  {
415  nLeft = nRight;
416 
417  if (aVal.nVPos < 0)
418  {
419  if (aVal.nVPos <= aVal.nMaxHeight)
420  nTop = aVal.nMaxVPos - aVal.nHeight;
421  else
422  nTop = nBottom = 0; // no passage
423  }
424  else
425  nTop = aVal.nMaxVPos - aVal.nHeight - aVal.nVPos;
426  }
427  else
428  {
429  nLeft += nRight;
430  nTop += nBottom;
431  }
432 
433  nBottom = nTop;
434  nRight = nLeft;
435  }
436 
437  m_xLeftMarginED->set_max(m_xLeftMarginED->normalize(nLeft), FieldUnit::TWIP);
438  m_xRightMarginED->set_max(m_xRightMarginED->normalize(nRight), FieldUnit::TWIP);
439 
440  m_xTopMarginED->set_max(m_xTopMarginED->normalize(nTop), FieldUnit::TWIP);
441  m_xBottomMarginED->set_max(m_xBottomMarginED->normalize(nBottom), FieldUnit::TWIP);
442 
443  RangeModifyHdl(*m_xLeftMarginED);
444  RangeModifyHdl(*m_xTopMarginED);
445  }
446 
447  const SwFormatSurround& rSurround = rSet.Get(RES_SURROUND);
448  css::text::WrapTextMode nSur = rSurround.GetSurround();
449 
450  m_xWrapTransparentCB->set_sensitive(bEnable && !m_bHtmlMode && nSur == css::text::WrapTextMode_THROUGH);
451  if(m_bHtmlMode)
452  {
453  const SwFormatHoriOrient& rHori = rSet.Get(RES_HORI_ORIENT);
454  sal_Int16 eHOrient = rHori.GetHoriOrient();
455  sal_Int16 eHRelOrient = rHori.GetRelationOrient();
456  m_xWrapOutlineCB->hide();
457  const bool bAllHtmlModes =
458  ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR)) &&
459  (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT);
460  m_xWrapAnchorOnlyCB->set_sensitive(bAllHtmlModes && nSur != css::text::WrapTextMode_NONE);
461  m_xWrapOutsideCB->hide();
462  m_xIdealWrapRB->set_sensitive(false);
463 
464  m_xWrapTransparentCB->set_sensitive(false);
465  m_xNoWrapRB->set_sensitive(RndStdIds::FLY_AT_PARA == m_nAnchorId);
466  m_xWrapParallelRB->set_sensitive(false);
467  m_xWrapLeftRB->set_sensitive
468  ( (RndStdIds::FLY_AT_PARA == m_nAnchorId)
469  || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
470  && (eHOrient == text::HoriOrientation::RIGHT)
471  && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
472  m_xWrapRightRB->set_sensitive
473  ( (RndStdIds::FLY_AT_PARA == m_nAnchorId)
474  || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
475  && (eHOrient == text::HoriOrientation::LEFT)
476  && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
477 
478  m_xWrapThroughRB->set_sensitive
479  ( ( (RndStdIds::FLY_AT_PAGE == m_nAnchorId)
480  || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
481  && (eHRelOrient != text::RelOrientation::PRINT_AREA))
482  || (RndStdIds::FLY_AT_PARA == m_nAnchorId))
483  && (eHOrient != text::HoriOrientation::RIGHT));
484  if (m_xNoWrapRB->get_active() && !m_xNoWrapRB->get_sensitive())
485  {
486  if(m_xWrapThroughRB->get_sensitive())
487  m_xWrapThroughRB->set_active(true);
488  else if(m_xWrapLeftRB->get_sensitive())
489  m_xWrapLeftRB->set_active(true);
490  else if(m_xWrapRightRB->get_sensitive())
491  m_xWrapRightRB->set_active(true);
492 
493  }
494  if (m_xWrapLeftRB->get_active() && !m_xWrapLeftRB->get_sensitive())
495  {
496  if(m_xWrapRightRB->get_sensitive())
497  m_xWrapRightRB->set_active(true);
498  else if(m_xWrapThroughRB->get_sensitive())
499  m_xWrapThroughRB->set_active(true);
500  }
501  if (m_xWrapRightRB->get_active() && !m_xWrapRightRB->get_sensitive())
502  {
503  if(m_xWrapLeftRB->get_sensitive())
504  m_xWrapLeftRB->set_active(true);
505  else if(m_xWrapThroughRB->get_sensitive())
506  m_xWrapThroughRB->set_active(true);
507  }
508  if (m_xWrapThroughRB->get_active() && !m_xWrapThroughRB->get_sensitive())
509  if(m_xNoWrapRB->get_sensitive())
510  m_xNoWrapRB->set_active(true);
511 
512  if (m_xWrapParallelRB->get_active() && !m_xWrapParallelRB->get_sensitive())
513  m_xWrapThroughRB->set_active(true);
514  }
515  else
516  {
517  m_xNoWrapRB->set_sensitive(bEnable);
518  m_xWrapLeftRB->set_sensitive(bEnable);
519  m_xWrapRightRB->set_sensitive(bEnable);
520  m_xIdealWrapRB->set_sensitive(bEnable);
521  m_xWrapThroughRB->set_sensitive(bEnable);
522  m_xWrapParallelRB->set_sensitive(bEnable);
523  m_xWrapAnchorOnlyCB->set_sensitive(
524  ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR))
525  && nSur != css::text::WrapTextMode_NONE );
526  }
527  ContourHdl(*m_xWrapOutlineCB);
528 }
529 
531 {
532  if(_pSet)
533  FillItemSet(_pSet);
534 
535  return DeactivateRC::LeavePage;
536 }
537 
538 IMPL_LINK(SwWrapTabPage, RangeModifyHdl, weld::MetricSpinButton&, rEdit, void)
539 {
540  auto nValue = rEdit.get_value(FieldUnit::NONE);
541  weld::MetricSpinButton* pOpposite = nullptr;
542  if (&rEdit == m_xLeftMarginED.get())
543  pOpposite = m_xRightMarginED.get();
544  else if (&rEdit == m_xRightMarginED.get())
545  pOpposite = m_xLeftMarginED.get();
546  else if (&rEdit == m_xTopMarginED.get())
547  pOpposite = m_xBottomMarginED.get();
548  else if (&rEdit == m_xBottomMarginED.get())
549  pOpposite = m_xTopMarginED.get();
550 
551  assert(pOpposite);
552 
553  if (pOpposite)
554  {
555  auto nOpposite = pOpposite->get_value(FieldUnit::NONE);
556 
557  if (nValue + nOpposite > std::max(rEdit.get_max(FieldUnit::NONE), pOpposite->get_max(FieldUnit::NONE)))
558  pOpposite->set_value(pOpposite->get_max(FieldUnit::NONE) - nValue, FieldUnit::NONE);
559  }
560 }
561 
563 {
564  bool bWrapThrough = m_xWrapThroughRB->get_active();
565  m_xWrapTransparentCB->set_sensitive(bWrapThrough && !m_bHtmlMode);
566  bWrapThrough |= ( m_nAnchorId == RndStdIds::FLY_AS_CHAR );
567  m_xWrapOutlineCB->set_sensitive(!bWrapThrough && !m_xNoWrapRB->get_active());
568  m_xWrapOutsideCB->set_sensitive(!bWrapThrough && m_xWrapOutlineCB->get_active());
569  m_xWrapAnchorOnlyCB->set_sensitive(
570  ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR)) &&
571  (!m_xNoWrapRB->get_active()) );
572 
573  ContourHdl(*m_xWrapOutlineCB);
574 }
575 
577 {
578  bool bEnable = !(m_xWrapOutlineCB->get_active() && m_xWrapOutlineCB->get_sensitive());
579 
580  m_xWrapOutsideCB->set_sensitive(!bEnable);
581 
582  bEnable = !m_xWrapOutlineCB->get_active();
583  if (bEnable == m_bContourImage) // so that it doesn't always flicker
584  {
585  m_bContourImage = !bEnable;
586  SetImages();
587  }
588 }
589 
591 {
592  m_xWrapThroughRB->set_from_icon_name(RID_BMP_WRAP_THROUGH);
593  bool bWrapOutline = !m_xWrapOutlineCB->get_active();
594  if (bWrapOutline)
595  {
596  m_xNoWrapRB->set_from_icon_name(RID_BMP_WRAP_NONE);
597  m_xWrapLeftRB->set_from_icon_name(RID_BMP_WRAP_LEFT);
598  m_xWrapRightRB->set_from_icon_name(RID_BMP_WRAP_RIGHT);
599  m_xWrapParallelRB->set_from_icon_name(RID_BMP_WRAP_PARALLEL);
600  m_xIdealWrapRB->set_from_icon_name(RID_BMP_WRAP_IDEAL);
601  }
602  else
603  {
604  m_xNoWrapRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_NONE);
605  m_xWrapLeftRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_LEFT);
606  m_xWrapRightRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_RIGHT);
607  m_xWrapParallelRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_PARALLEL);
608  m_xIdealWrapRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_IDEAL);
609  }
610 }
611 
612 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetLeft() const
long Width() const
bool IsContour() const
Definition: fmtsrnd.hxx:53
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
FieldUnit
#define RES_FRM_SIZE
Definition: hintids.hxx:194
sal_uInt16 GetLower() const
#define RES_HORI_ORIENT
Definition: hintids.hxx:208
std::string GetValue
long Height() const
void SetFormatUsed(bool bFormat, bool bDrawMode)
Definition: wrap.hxx:95
std::unique_ptr< weld::MetricSpinButton > m_xBottomMarginED
Definition: wrap.hxx:62
SwTwips GetPos() const
Definition: fmtornt.hxx:92
#define RES_SURROUND
Definition: hintids.hxx:206
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:115
std::unique_ptr< weld::RadioButton > m_xWrapParallelRB
Definition: wrap.hxx:54
RndStdIds m_nAnchorId
Definition: wrap.hxx:39
weld::Container * get_content_area()
long SwTwips
Definition: swtypes.hxx:49
void SetSurround(css::text::WrapTextMode eNew)
Definition: fmtsrnd.hxx:55
static SfxObjectShell * Current()
IMPL_LINK(SwWrapTabPage, RangeModifyHdl, weld::MetricSpinButton &, rEdit, void)
Definition: wrap.cxx:538
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
#define RES_PROTECT
Definition: hintids.hxx:205
void SetOutside(bool bNew)
Definition: fmtsrnd.hxx:58
TRISTATE_TRUE
virtual ~SwWrapTabPage() override
Definition: wrap.cxx:111
void SetContour(bool bNew)
Definition: fmtsrnd.hxx:57
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
int get_max(FieldUnit eValueUnit) const
void SetLeft(const long nL, const sal_uInt16 nProp=100)
Value in Var-direction gives minimum (can be exceeded but not be less).
Definition: fmtfsize.hxx:39
void SetTabPage(SfxTabPage *pTabPage)
void SetExchangeSupport()
bool IsAnchorOnly() const
Definition: fmtsrnd.hxx:52
#define RES_UL_SPACE
Definition: hintids.hxx:197
#define RES_PRINT
Definition: hintids.hxx:203
virtual void Reset(const SfxItemSet *rSet) override
Definition: wrap.cxx:120
virtual void set_active(bool active)=0
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
#define RES_FOLLOW_TEXT_FLOW
Definition: hintids.hxx:228
void SetShell(SwWrtShell *pSh)
Definition: wrap.hxx:96
const SfxItemSet & GetItemSet() const
std::unique_ptr< weld::RadioButton > m_xWrapRightRB
Definition: wrap.hxx:53
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: wrap.cxx:530
std::unique_ptr< weld::RadioButton > m_xWrapLeftRB
Definition: wrap.hxx:52
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
void SetRight(const long nR, const sal_uInt16 nProp=100)
std::unique_ptr< weld::CheckButton > m_xWrapOutlineCB
Definition: wrap.hxx:67
#define RES_ANCHOR
Definition: hintids.hxx:209
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:710
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
std::unique_ptr< weld::RadioButton > m_xWrapThroughRB
Definition: wrap.hxx:55
GraphicType GetType() const
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
#define RES_VERT_ORIENT
Definition: hintids.hxx:207
std::unique_ptr< weld::MetricSpinButton > m_xRightMarginED
Definition: wrap.hxx:60
FlyAnchors.
Definition: fmtanchr.hxx:34
HTMLMODE_ON
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:340
sal_uInt8 GetHeightPercent() const
Definition: fmtfsize.hxx:88
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
bool m_bHtmlMode
Definition: wrap.hxx:46
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
void set_value(int nValue, FieldUnit eValueUnit)
SwWrtShell * m_pWrtSh
Definition: wrap.hxx:42
IMPL_LINK_NOARG(SwWrapTabPage, WrapTypeHdl, weld::ToggleButton &, void)
Definition: wrap.cxx:562
Graphic GetIMapGraphic() const
Remove default parameter, because method always called this default value.
Definition: editsh.cxx:610
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
std::unique_ptr< weld::MetricSpinButton > m_xLeftMarginED
Definition: wrap.hxx:59
std::unique_ptr< weld::MetricSpinButton > m_xTopMarginED
Definition: wrap.hxx:61
void SetAnchorOnly(bool bNew)
Definition: fmtsrnd.hxx:56
#define RES_LR_SPACE
Definition: hintids.hxx:196
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: wrap.cxx:255
SelectionType
Definition: wrtsh.hxx:58
std::unique_ptr< weld::CheckButton > m_xWrapTransparentCB
Definition: wrap.hxx:66
bool m_bFormat
Definition: wrap.hxx:44
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 m_nHtmlMode
Definition: wrap.hxx:40
bool IsPosToggle() const
Definition: fmtornt.hxx:95
SwWrapTabPage(TabPageParent pParent, const SfxItemSet &rSet)
Definition: wrap.cxx:67
weld::Entry & rEdit
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SwTwips GetPos() const
Definition: fmtornt.hxx:59
#define RES_OPAQUE
Definition: hintids.hxx:204
bool m_bDrawMode
Definition: wrap.hxx:47
static VclPtr< reference_type > Create(Arg &&...arg)
std::unique_ptr< weld::CheckButton > m_xWrapAnchorOnlyCB
Definition: wrap.hxx:65
SwWrapDlg(weld::Window *pParent, SfxItemSet &rSet, SwWrtShell *pSh, bool bDrawMode)
Definition: wrap.cxx:56
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
long GetRight() const
bool m_bNew
Definition: wrap.hxx:45
std::unique_ptr< weld::RadioButton > m_xIdealWrapRB
Definition: wrap.hxx:56
static const sal_uInt16 m_aWrapPageRg[]
Definition: wrap.hxx:83
DeactivateRC
static VclPtr< SfxTabPage > Create(TabPageParent pParent, const SfxItemSet *rSet)
Definition: wrap.cxx:115
reference_type * get() const
int get_value(FieldUnit eDestUnit) const
SVX_DLLPUBLIC MSO_SPT Get(const OUString &)
RndStdIds
bool IsOutside() const
Definition: fmtsrnd.hxx:54
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: wrap.cxx:356
bool m_bContourImage
Definition: wrap.hxx:48
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1404
std::unique_ptr< weld::CheckButton > m_xWrapOutsideCB
Definition: wrap.hxx:68
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
std::unique_ptr< weld::RadioButton > m_xNoWrapRB
Definition: wrap.hxx:51
void setWidth(long nWidth)
#define FN_OPAQUE
Definition: cmdid.h:824
void SetImages()
Definition: wrap.cxx:590
void ValidateMetrics(SvxSwFrameValidation &rVal, const SwPosition *pToCharContentPos, bool bOnlyPercentRefValue=false)
Definition: frmmgr.cxx:248
#define FN_DRAW_WRAP_DLG
Definition: cmdid.h:150
const Size & GetSize() const
sal_uInt16 GetUpper() const
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80
void setHeight(long nHeight)