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