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