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 
23 #include <sfx2/htmlmode.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <svl/intitem.hxx>
26 #include <editeng/opaqitem.hxx>
27 #include <editeng/ulspitem.hxx>
28 #include <editeng/lrspitem.hxx>
29 #include <fmtfollowtextflow.hxx>
30 #include <svtools/unitconv.hxx>
32 
33 #include <cmdid.h>
34 #include <docsh.hxx>
35 #include <uitool.hxx>
36 #include <wrtsh.hxx>
37 #include <swmodule.hxx>
38 #include <viewopt.hxx>
39 #include <fmtsrnd.hxx>
40 #include <frmmgr.hxx>
41 #include <wrap.hxx>
42 #include <bitmaps.hlst>
44 
45 using namespace ::com::sun::star;
46 
47 const sal_uInt16 SwWrapTabPage::m_aWrapPageRg[] = {
51  0
52 };
53 
54 SwWrapDlg::SwWrapDlg(weld::Window* pParent, SfxItemSet& rSet, SwWrtShell* pWrtShell, bool bDrawMode)
55  : SfxSingleTabDialogController(pParent, &rSet, "modules/swriter/ui/wrapdialog.ui", "WrapDialog")
56 {
57  // create TabPage
58  auto xNewPage = SwWrapTabPage::Create(get_content_area(), this, &rSet);
59  SwWrapTabPage* pWrapPage = static_cast<SwWrapTabPage*>(xNewPage.get());
60  pWrapPage->SetFormatUsed(false, bDrawMode);
61  pWrapPage->SetShell(pWrtShell);
62  SetTabPage(std::move(xNewPage));
63 }
64 
66  : SfxTabPage(pPage, pController, "modules/swriter/ui/wrappage.ui", "WrapPage", &rSet)
67  , m_nAnchorId(RndStdIds::FLY_AT_PARA)
68  , m_nHtmlMode(0)
69  , m_pWrtSh(nullptr)
70  , m_bFormat(false)
71  , m_bNew(true)
72  , m_bHtmlMode(false)
73  , m_bDrawMode(false)
74  , m_bContourImage(false)
75  , m_xNoWrapRB(m_xBuilder->weld_radio_button("none"))
76  , m_xWrapLeftRB(m_xBuilder->weld_radio_button("before"))
77  , m_xWrapRightRB(m_xBuilder->weld_radio_button("after"))
78  , m_xWrapParallelRB(m_xBuilder->weld_radio_button("parallel"))
79  , m_xWrapThroughRB(m_xBuilder->weld_radio_button("through"))
80  , m_xIdealWrapRB(m_xBuilder->weld_radio_button("optimal"))
81  , m_xLeftMarginED(m_xBuilder->weld_metric_spin_button("left", FieldUnit::CM))
82  , m_xRightMarginED(m_xBuilder->weld_metric_spin_button("right", FieldUnit::CM))
83  , m_xTopMarginED(m_xBuilder->weld_metric_spin_button("top", FieldUnit::CM))
84  , m_xBottomMarginED(m_xBuilder->weld_metric_spin_button("bottom", FieldUnit::CM))
85  , m_xWrapAnchorOnlyCB(m_xBuilder->weld_check_button("anchoronly"))
86  , m_xWrapTransparentCB(m_xBuilder->weld_check_button("transparent"))
87  , m_xWrapOutlineCB(m_xBuilder->weld_check_button("outline"))
88  , m_xWrapOutsideCB(m_xBuilder->weld_check_button("outside"))
89  , m_xAllowOverlapCB(m_xBuilder->weld_check_button("allowoverlap"))
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 
114 std::unique_ptr<SfxTabPage> SwWrapTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet)
115 {
116  return std::make_unique<SwWrapTabPage>(pPage, pController, *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 
252  m_xAllowOverlapCB->set_active(rInfluence.GetAllowOverlap());
253 
254  ActivatePage( *rSet );
255 }
256 
257 // stuff attributes into the set when OK
259 {
260  bool bModified = false;
261  const SfxPoolItem* pOldItem;
262  const SwFormatSurround& rOldSur = GetItemSet().Get(RES_SURROUND);
263  SwFormatSurround aSur( rOldSur );
264 
265  std::shared_ptr<SvxOpaqueItem> aOp(std::make_shared<SvxOpaqueItem>(RES_OPAQUE));
266 
267  if (!m_bDrawMode)
268  {
269  aOp.reset(GetItemSet().Get(RES_OPAQUE).Clone());
270  aOp->SetValue(true);
271  }
272 
273  if (m_xNoWrapRB->get_active())
274  aSur.SetSurround(css::text::WrapTextMode_NONE);
275  else if (m_xWrapLeftRB->get_active())
276  aSur.SetSurround(css::text::WrapTextMode_LEFT);
277  else if (m_xWrapRightRB->get_active())
278  aSur.SetSurround(css::text::WrapTextMode_RIGHT);
279  else if (m_xWrapParallelRB->get_active())
280  aSur.SetSurround(css::text::WrapTextMode_PARALLEL);
281  else if (m_xWrapThroughRB->get_active())
282  {
283  aSur.SetSurround(css::text::WrapTextMode_THROUGH);
284  if (m_xWrapTransparentCB->get_active() && !m_bDrawMode)
285  aOp->SetValue(false);
286  }
287  else if (m_xIdealWrapRB->get_active())
288  aSur.SetSurround(css::text::WrapTextMode_DYNAMIC);
289 
290  aSur.SetAnchorOnly( m_xWrapAnchorOnlyCB->get_active() );
291  bool bContour = m_xWrapOutlineCB->get_active() && m_xWrapOutlineCB->get_sensitive();
292  aSur.SetContour( bContour );
293 
294  if ( bContour )
295  aSur.SetOutside(m_xWrapOutsideCB->get_active());
296 
297  if(nullptr == (pOldItem = GetOldItem( *rSet, RES_SURROUND )) ||
298  aSur != *pOldItem )
299  {
300  rSet->Put(aSur);
301  bModified = true;
302  }
303 
304  if (!m_bDrawMode)
305  {
306  if(nullptr == (pOldItem = GetOldItem( *rSet, FN_OPAQUE )) ||
307  *aOp != *pOldItem )
308  {
309  rSet->Put(*aOp);
310  bModified = true;
311  }
312  }
313 
314  bool bTopMod = m_xTopMarginED->get_value_changed_from_saved();
315  bool bBottomMod = m_xBottomMarginED->get_value_changed_from_saved();
316 
318  aUL.SetUpper(static_cast<sal_uInt16>(m_xTopMarginED->denormalize(m_xTopMarginED->get_value(FieldUnit::TWIP))));
319  aUL.SetLower(static_cast<sal_uInt16>(m_xBottomMarginED->denormalize(m_xBottomMarginED->get_value(FieldUnit::TWIP))));
320 
321  if ( bTopMod || bBottomMod )
322  {
323  if(nullptr == (pOldItem = GetOldItem(*rSet, RES_UL_SPACE)) ||
324  aUL != *pOldItem )
325  {
326  rSet->Put( aUL );
327  bModified = true;
328  }
329  }
330 
331  bool bLeftMod = m_xLeftMarginED->get_value_changed_from_saved();
332  bool bRightMod = m_xRightMarginED->get_value_changed_from_saved();
333 
335  aLR.SetLeft(static_cast<sal_uInt16>(m_xLeftMarginED->denormalize(m_xLeftMarginED->get_value(FieldUnit::TWIP))));
336  aLR.SetRight(static_cast<sal_uInt16>(m_xRightMarginED->denormalize(m_xRightMarginED->get_value(FieldUnit::TWIP))));
337 
338  if ( bLeftMod || bRightMod )
339  {
340  if( nullptr == (pOldItem = GetOldItem(*rSet, RES_LR_SPACE)) ||
341  aLR != *pOldItem )
342  {
343  rSet->Put(aLR);
344  bModified = true;
345  }
346  }
347 
348  if ( m_bDrawMode )
349  {
350  bool bChecked = m_xWrapTransparentCB->get_active() && m_xWrapTransparentCB->get_sensitive();
351  if ((m_xWrapTransparentCB->get_saved_state() == TRISTATE_TRUE) != bChecked)
352  bModified |= nullptr != rSet->Put(SfxInt16Item(FN_DRAW_WRAP_DLG, bChecked ? 0 : 1));
353  }
354 
355  const SwFormatWrapInfluenceOnObjPos& rOldInfluence
357  SwFormatWrapInfluenceOnObjPos aInfluence(rOldInfluence);
358  aInfluence.SetAllowOverlap(m_xAllowOverlapCB->get_active());
359 
360  pOldItem = GetOldItem(*rSet, RES_WRAP_INFLUENCE_ON_OBJPOS);
361  if (!pOldItem || aInfluence != *pOldItem)
362  {
363  rSet->Put(aInfluence);
364  bModified = true;
365  }
366 
367  return bModified;
368 }
369 
370 // example update
372 {
373  // anchor
374  const SwFormatAnchor &rAnch = rSet.Get(RES_ANCHOR);
375  m_nAnchorId = rAnch.GetAnchorId();
376  bool bEnable = (m_nAnchorId != RndStdIds::FLY_AS_CHAR);
377 
378  if (!m_bDrawMode)
379  {
381  SwFlyFrameAttrMgr aMgr( m_bNew, pSh, GetItemSet() );
383 
384  // size
385  const SwFormatFrameSize& rFrameSize = rSet.Get(RES_FRM_SIZE);
386  Size aSize = rFrameSize.GetSize();
387 
388  // position
389  const SwFormatHoriOrient& rHori = rSet.Get(RES_HORI_ORIENT);
390  const SwFormatVertOrient& rVert = rSet.Get(RES_VERT_ORIENT);
391 
392  aVal.nAnchorType = m_nAnchorId;
393  aVal.bAutoHeight = rFrameSize.GetHeightSizeType() == SwFrameSize::Minimum;
394  aVal.bMirror = rHori.IsPosToggle();
395  // #i18732#
396  aVal.bFollowTextFlow = rSet.Get(RES_FOLLOW_TEXT_FLOW).GetValue();
397 
398  aVal.nHoriOrient = static_cast<short>(rHori.GetHoriOrient());
399  aVal.nVertOrient = static_cast<short>(rVert.GetVertOrient());
400 
401  aVal.nHPos = rHori.GetPos();
402  aVal.nHRelOrient = rHori.GetRelationOrient();
403  aVal.nVPos = rVert.GetPos();
404  aVal.nVRelOrient = rVert.GetRelationOrient();
405 
406  if (rFrameSize.GetWidthPercent() && rFrameSize.GetWidthPercent() != SwFormatFrameSize::SYNCED)
407  aSize.setWidth( aSize.Width() * rFrameSize.GetWidthPercent() / 100 );
408 
409  if (rFrameSize.GetHeightPercent() && rFrameSize.GetHeightPercent() != SwFormatFrameSize::SYNCED)
410  aSize.setHeight( aSize.Height() * rFrameSize.GetHeightPercent() / 100 );
411 
412  aVal.nWidth = aSize.Width();
413  aVal.nHeight = aSize.Height();
414 
415  aMgr.ValidateMetrics(aVal, nullptr);
416 
417  SwTwips nLeft;
418  SwTwips nRight;
419  SwTwips nTop;
420  SwTwips nBottom;
421 
422  nLeft = aVal.nHPos - aVal.nMinHPos;
423  nRight = aVal.nMaxWidth - aVal.nWidth;
424  nTop = aVal.nVPos - aVal.nMinVPos;
425  nBottom = aVal.nMaxHeight - aVal.nHeight;
426 
427  {
428  if (aVal.nAnchorType == RndStdIds::FLY_AS_CHAR)
429  {
430  nLeft = nRight;
431 
432  if (aVal.nVPos < 0)
433  {
434  if (aVal.nVPos <= aVal.nMaxHeight)
435  nTop = aVal.nMaxVPos - aVal.nHeight;
436  else
437  nTop = nBottom = 0; // no passage
438  }
439  else
440  nTop = aVal.nMaxVPos - aVal.nHeight - aVal.nVPos;
441  }
442  else
443  {
444  nLeft += nRight;
445  nTop += nBottom;
446  }
447 
448  nBottom = nTop;
449  nRight = nLeft;
450  }
451 
452  m_xLeftMarginED->set_max(m_xLeftMarginED->normalize(nLeft), FieldUnit::TWIP);
453  m_xRightMarginED->set_max(m_xRightMarginED->normalize(nRight), FieldUnit::TWIP);
454 
455  m_xTopMarginED->set_max(m_xTopMarginED->normalize(nTop), FieldUnit::TWIP);
456  m_xBottomMarginED->set_max(m_xBottomMarginED->normalize(nBottom), FieldUnit::TWIP);
457 
458  RangeModifyHdl(*m_xLeftMarginED);
459  RangeModifyHdl(*m_xTopMarginED);
460  }
461 
462  const SwFormatSurround& rSurround = rSet.Get(RES_SURROUND);
463  css::text::WrapTextMode nSur = rSurround.GetSurround();
464 
465  m_xWrapTransparentCB->set_sensitive(bEnable && !m_bHtmlMode && nSur == css::text::WrapTextMode_THROUGH);
466  if(m_bHtmlMode)
467  {
468  const SwFormatHoriOrient& rHori = rSet.Get(RES_HORI_ORIENT);
469  sal_Int16 eHOrient = rHori.GetHoriOrient();
470  sal_Int16 eHRelOrient = rHori.GetRelationOrient();
471  m_xWrapOutlineCB->hide();
472  const bool bAllHtmlModes =
473  ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR)) &&
474  (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT);
475  m_xWrapAnchorOnlyCB->set_sensitive(bAllHtmlModes && nSur != css::text::WrapTextMode_NONE);
476  m_xWrapOutsideCB->hide();
477  m_xIdealWrapRB->set_sensitive(false);
478 
479  m_xWrapTransparentCB->set_sensitive(false);
480  m_xNoWrapRB->set_sensitive(RndStdIds::FLY_AT_PARA == m_nAnchorId);
481  m_xWrapParallelRB->set_sensitive(false);
482  m_xWrapLeftRB->set_sensitive
483  ( (RndStdIds::FLY_AT_PARA == m_nAnchorId)
484  || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
485  && (eHOrient == text::HoriOrientation::RIGHT)
486  && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
487  m_xWrapRightRB->set_sensitive
488  ( (RndStdIds::FLY_AT_PARA == m_nAnchorId)
489  || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
490  && (eHOrient == text::HoriOrientation::LEFT)
491  && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
492 
493  m_xWrapThroughRB->set_sensitive
494  ( ( (RndStdIds::FLY_AT_PAGE == m_nAnchorId)
495  || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
496  && (eHRelOrient != text::RelOrientation::PRINT_AREA))
497  || (RndStdIds::FLY_AT_PARA == m_nAnchorId))
498  && (eHOrient != text::HoriOrientation::RIGHT));
499  if (m_xNoWrapRB->get_active() && !m_xNoWrapRB->get_sensitive())
500  {
501  if(m_xWrapThroughRB->get_sensitive())
502  m_xWrapThroughRB->set_active(true);
503  else if(m_xWrapLeftRB->get_sensitive())
504  m_xWrapLeftRB->set_active(true);
505  else if(m_xWrapRightRB->get_sensitive())
506  m_xWrapRightRB->set_active(true);
507 
508  }
509  if (m_xWrapLeftRB->get_active() && !m_xWrapLeftRB->get_sensitive())
510  {
511  if(m_xWrapRightRB->get_sensitive())
512  m_xWrapRightRB->set_active(true);
513  else if(m_xWrapThroughRB->get_sensitive())
514  m_xWrapThroughRB->set_active(true);
515  }
516  if (m_xWrapRightRB->get_active() && !m_xWrapRightRB->get_sensitive())
517  {
518  if(m_xWrapLeftRB->get_sensitive())
519  m_xWrapLeftRB->set_active(true);
520  else if(m_xWrapThroughRB->get_sensitive())
521  m_xWrapThroughRB->set_active(true);
522  }
523  if (m_xWrapThroughRB->get_active() && !m_xWrapThroughRB->get_sensitive())
524  if(m_xNoWrapRB->get_sensitive())
525  m_xNoWrapRB->set_active(true);
526 
527  if (m_xWrapParallelRB->get_active() && !m_xWrapParallelRB->get_sensitive())
528  m_xWrapThroughRB->set_active(true);
529  }
530  else
531  {
532  m_xNoWrapRB->set_sensitive(bEnable);
533  m_xWrapLeftRB->set_sensitive(bEnable);
534  m_xWrapRightRB->set_sensitive(bEnable);
535  m_xIdealWrapRB->set_sensitive(bEnable);
536  m_xWrapThroughRB->set_sensitive(bEnable);
537  m_xWrapParallelRB->set_sensitive(bEnable);
538  m_xWrapAnchorOnlyCB->set_sensitive(
539  ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR))
540  && nSur != css::text::WrapTextMode_NONE );
541  }
542  ContourHdl(*m_xWrapOutlineCB);
543 }
544 
546 {
547  if(_pSet)
548  FillItemSet(_pSet);
549 
550  return DeactivateRC::LeavePage;
551 }
552 
553 IMPL_LINK(SwWrapTabPage, RangeModifyHdl, weld::MetricSpinButton&, rEdit, void)
554 {
555  auto nValue = rEdit.get_value(FieldUnit::NONE);
556  weld::MetricSpinButton* pOpposite = nullptr;
557  if (&rEdit == m_xLeftMarginED.get())
558  pOpposite = m_xRightMarginED.get();
559  else if (&rEdit == m_xRightMarginED.get())
560  pOpposite = m_xLeftMarginED.get();
561  else if (&rEdit == m_xTopMarginED.get())
562  pOpposite = m_xBottomMarginED.get();
563  else if (&rEdit == m_xBottomMarginED.get())
564  pOpposite = m_xTopMarginED.get();
565 
566  assert(pOpposite);
567 
568  if (pOpposite)
569  {
570  auto nOpposite = pOpposite->get_value(FieldUnit::NONE);
571 
572  if (nValue + nOpposite > std::max(rEdit.get_max(FieldUnit::NONE), pOpposite->get_max(FieldUnit::NONE)))
573  pOpposite->set_value(pOpposite->get_max(FieldUnit::NONE) - nValue, FieldUnit::NONE);
574  }
575 }
576 
578 {
579  bool bWrapThrough = m_xWrapThroughRB->get_active();
580  m_xWrapTransparentCB->set_sensitive(bWrapThrough && !m_bHtmlMode);
581  bWrapThrough |= ( m_nAnchorId == RndStdIds::FLY_AS_CHAR );
582  m_xWrapOutlineCB->set_sensitive(!bWrapThrough && !m_xNoWrapRB->get_active());
583  m_xWrapOutsideCB->set_sensitive(!bWrapThrough && m_xWrapOutlineCB->get_active());
584  m_xWrapAnchorOnlyCB->set_sensitive(
585  ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR)) &&
586  (!m_xNoWrapRB->get_active()) );
587 
588  ContourHdl(*m_xWrapOutlineCB);
589 }
590 
592 {
593  bool bEnable = !(m_xWrapOutlineCB->get_active() && m_xWrapOutlineCB->get_sensitive());
594 
595  m_xWrapOutsideCB->set_sensitive(!bEnable);
596 
597  bEnable = !m_xWrapOutlineCB->get_active();
598  if (bEnable == m_bContourImage) // so that it doesn't always flicker
599  {
600  m_bContourImage = !bEnable;
601  SetImages();
602  }
603 }
604 
606 {
607  m_xWrapThroughRB->set_from_icon_name(RID_BMP_WRAP_THROUGH);
608  bool bWrapOutline = !m_xWrapOutlineCB->get_active();
609  if (bWrapOutline)
610  {
611  m_xNoWrapRB->set_from_icon_name(RID_BMP_WRAP_NONE);
612  m_xWrapLeftRB->set_from_icon_name(RID_BMP_WRAP_LEFT);
613  m_xWrapRightRB->set_from_icon_name(RID_BMP_WRAP_RIGHT);
614  m_xWrapParallelRB->set_from_icon_name(RID_BMP_WRAP_PARALLEL);
615  m_xIdealWrapRB->set_from_icon_name(RID_BMP_WRAP_IDEAL);
616  }
617  else
618  {
619  m_xNoWrapRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_NONE);
620  m_xWrapLeftRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_LEFT);
621  m_xWrapRightRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_RIGHT);
622  m_xWrapParallelRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_PARALLEL);
623  m_xIdealWrapRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_IDEAL);
624  }
625 }
626 
627 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SvxProtectItem > RES_PROTECT(100)
bool IsContour() const
Definition: fmtsrnd.hxx:53
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
FieldUnit
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
sal_uInt16 GetLower() const
void setWidth(tools::Long nWidth)
std::string GetValue
void SetFormatUsed(bool bFormat, bool bDrawMode)
Definition: wrap.hxx:91
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
std::unique_ptr< weld::MetricSpinButton > m_xBottomMarginED
Definition: wrap.hxx:62
SwTwips GetPos() const
Definition: fmtornt.hxx:92
tools::Long GetRight() const
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:108
std::unique_ptr< weld::RadioButton > m_xWrapParallelRB
Definition: wrap.hxx:54
RndStdIds m_nAnchorId
Definition: wrap.hxx:39
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: wrap.cxx:114
weld::Container * get_content_area()
long SwTwips
Definition: swtypes.hxx:49
void SetSurround(css::text::WrapTextMode eNew)
Definition: fmtsrnd.hxx:55
constexpr TypedWhichId< SvxOpaqueItem > RES_OPAQUE(99)
static SfxObjectShell * Current()
IMPL_LINK(SwWrapTabPage, RangeModifyHdl, weld::MetricSpinButton &, rEdit, void)
Definition: wrap.cxx:553
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
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
Value in Var-direction gives minimum (can be exceeded but not be less).
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
void SetAllowOverlap(bool bAllowOverlap)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
int get_max(FieldUnit eValueUnit) const
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void SetExchangeSupport()
bool IsAnchorOnly() const
Definition: fmtsrnd.hxx:52
constexpr TypedWhichId< SwFormatWrapInfluenceOnObjPos > RES_WRAP_INFLUENCE_ON_OBJPOS(125)
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)
void SetShell(SwWrtShell *pSh)
Definition: wrap.hxx:92
const SfxItemSet & GetItemSet() const
std::unique_ptr< weld::RadioButton > m_xWrapRightRB
Definition: wrap.hxx:53
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: wrap.cxx:545
std::unique_ptr< weld::RadioButton > m_xWrapLeftRB
Definition: wrap.hxx:52
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
std::unique_ptr< weld::CheckButton > m_xWrapOutlineCB
Definition: wrap.hxx:67
SwWrapTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: wrap.cxx:65
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:686
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
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:337
tools::Long GetLeft() const
sal_uInt8 GetHeightPercent() const
Definition: fmtfsize.hxx:88
tools::Long Width() const
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 SetTabPage(std::unique_ptr< SfxTabPage > xTabPage)
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:577
Graphic GetIMapGraphic() const
Remove default parameter, because method always called this default value.
Definition: editsh.cxx:604
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
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: wrap.cxx:258
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
weld::Entry & rEdit
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SwTwips GetPos() const
Definition: fmtornt.hxx:59
bool m_bDrawMode
Definition: wrap.hxx:47
std::unique_ptr< weld::CheckButton > m_xWrapAnchorOnlyCB
Definition: wrap.hxx:65
tools::Long Height() const
SwWrapDlg(weld::Window *pParent, SfxItemSet &rSet, SwWrtShell *pSh, bool bDrawMode)
Definition: wrap.cxx:54
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
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:79
DeactivateRC
void setHeight(tools::Long nHeight)
int get_value(FieldUnit eDestUnit) const
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
RndStdIds
bool IsOutside() const
Definition: fmtsrnd.hxx:54
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: wrap.cxx:371
std::unique_ptr< weld::CheckButton > m_xAllowOverlapCB
Definition: wrap.hxx:69
constexpr TypedWhichId< SwFormatFollowTextFlow > RES_FOLLOW_TEXT_FLOW(123)
bool m_bContourImage
Definition: wrap.hxx:48
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1402
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
#define FN_OPAQUE
Definition: cmdid.h:847
void SetImages()
Definition: wrap.cxx:605
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
void ValidateMetrics(SvxSwFrameValidation &rVal, const SwPosition *pToCharContentPos, bool bOnlyPercentRefValue=false)
Definition: frmmgr.cxx:251
#define FN_DRAW_WRAP_DLG
Definition: cmdid.h:151
const Size & GetSize() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
sal_Int16 nValue
sal_uInt16 GetUpper() const
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80