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