android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / frmdlg / wrap.cxx
blob684fe38b22bb65547e0ede42bab8d7bea67000e5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <hintids.hxx>
21 #include <vcl/graph.hxx>
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>
31 #include <svx/swframevalidation.hxx>
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>
43 #include <fmtwrapinfluenceonobjpos.hxx>
45 using namespace ::com::sun::star;
47 const WhichRangesContainer SwWrapTabPage::s_aWrapPageRg(svl::Items<
48 RES_LR_SPACE, RES_UL_SPACE,
49 RES_PRINT, RES_PRINT,
50 RES_PROTECT, RES_SURROUND
51 >);
53 SwWrapDlg::SwWrapDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtShell, bool bDrawMode)
54 : SfxSingleTabDialogController(pParent, &rSet, "modules/swriter/ui/wrapdialog.ui", "WrapDialog")
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));
64 SwWrapTabPage::SwWrapTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet)
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"))
96 SetExchangeSupport();
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);
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));
115 SwWrapTabPage::~SwWrapTabPage()
119 std::unique_ptr<SfxTabPage> SwWrapTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet)
121 return std::make_unique<SwWrapTabPage>(pPage, pController, *rSet);
124 void SwWrapTabPage::Reset(const SfxItemSet *rSet)
126 // contour for Draw, Graphic and OLE (Insert/Graphic/Properties still missing!)
127 if( m_bDrawMode )
129 m_xWrapOutlineCB->show();
130 m_xWrapOutsideCB->show();
132 m_xWrapTransparentCB->set_active( 0 == rSet->Get(FN_DRAW_WRAP_DLG).GetValue() );
133 m_xWrapTransparentCB->save_state();
135 else
137 bool bShowCB = m_bFormat;
138 if( !m_bFormat )
140 SelectionType nSelType = m_pWrtSh->GetSelectionType();
141 if( ( nSelType & SelectionType::Graphic ) ||
142 ( nSelType & SelectionType::Ole && GraphicType::NONE !=
143 m_pWrtSh->GetIMapGraphic().GetType() ))
144 bShowCB = true;
146 if( bShowCB )
148 m_xWrapOutlineCB->show();
149 m_xWrapOutsideCB->show();
153 m_nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
154 m_bHtmlMode = (m_nHtmlMode & HTMLMODE_ON) != 0;
156 FieldUnit aMetric = ::GetDfltMetric(m_bHtmlMode);
157 SetFieldUnit(*m_xLeftMarginED, aMetric);
158 SetFieldUnit(*m_xRightMarginED, aMetric);
159 SetFieldUnit(*m_xTopMarginED, aMetric);
160 SetFieldUnit(*m_xBottomMarginED, aMetric);
162 const SwFormatSurround& rSurround = rSet->Get(RES_SURROUND);
164 css::text::WrapTextMode nSur = rSurround.GetSurround();
165 const SwFormatAnchor &rAnch = rSet->Get(RES_ANCHOR);
166 m_nAnchorId = rAnch.GetAnchorId();
168 if (((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR))
169 && (nSur != css::text::WrapTextMode_NONE))
171 m_xWrapAnchorOnlyCB->set_active(rSurround.IsAnchorOnly());
173 else
175 m_xWrapAnchorOnlyCB->set_sensitive(false);
178 const bool bContour = rSurround.IsContour();
179 m_xWrapOutlineCB->set_active(bContour);
180 m_xWrapOutsideCB->set_active(rSurround.IsOutside());
181 m_xWrapThroughRB->set_sensitive(!m_xWrapOutlineCB->get_active());
182 m_bContourImage = !bContour;
184 weld::RadioButton* pBtn = nullptr;
186 switch (nSur)
188 case css::text::WrapTextMode_NONE:
190 pBtn = m_xNoWrapRB.get();
191 break;
194 case css::text::WrapTextMode_THROUGH:
196 // transparent ?
197 pBtn = m_xWrapThroughRB.get();
199 if (!m_bDrawMode)
201 const SvxOpaqueItem& rOpaque = rSet->Get(RES_OPAQUE);
202 m_xWrapTransparentCB->set_active(!rOpaque.GetValue());
204 break;
207 case css::text::WrapTextMode_PARALLEL:
209 pBtn = m_xWrapParallelRB.get();
210 break;
213 case css::text::WrapTextMode_DYNAMIC:
215 pBtn = m_xIdealWrapRB.get();
216 break;
219 default:
221 if (nSur == css::text::WrapTextMode_LEFT)
222 pBtn = m_xWrapLeftRB.get();
223 else if (nSur == css::text::WrapTextMode_RIGHT)
224 pBtn = m_xWrapRightRB.get();
227 if (pBtn)
229 pBtn->set_active(true);
230 WrapTypeHdl(*pBtn);
231 // For character objects that currently are in passage, the default
232 // "contour on" is prepared here, in case we switch to any other
233 // passage later.
234 if (m_bDrawMode && !m_xWrapOutlineCB->get_sensitive())
235 m_xWrapOutlineCB->set_active(true);
237 m_xWrapTransparentCB->set_sensitive(pBtn == m_xWrapThroughRB.get() && !m_bHtmlMode);
239 const SvxULSpaceItem& rUL = rSet->Get(RES_UL_SPACE);
240 const SvxLRSpaceItem& rLR = rSet->Get(RES_LR_SPACE);
242 // gap to text
243 m_xLeftMarginED->set_value(m_xLeftMarginED->normalize(rLR.GetLeft()), FieldUnit::TWIP);
244 m_xRightMarginED->set_value(m_xRightMarginED->normalize(rLR.GetRight()), FieldUnit::TWIP);
245 m_xTopMarginED->set_value(m_xTopMarginED->normalize(rUL.GetUpper()), FieldUnit::TWIP);
246 m_xBottomMarginED->set_value(m_xBottomMarginED->normalize(rUL.GetLower()), FieldUnit::TWIP);
248 m_xLeftMarginED->save_value();
249 m_xRightMarginED->save_value();
250 m_xTopMarginED->save_value();
251 m_xBottomMarginED->save_value();
253 ContourHdl(*m_xWrapOutlineCB);
255 const SwFormatWrapInfluenceOnObjPos& rInfluence = rSet->Get(RES_WRAP_INFLUENCE_ON_OBJPOS);
256 m_xAllowOverlapCB->set_active(rInfluence.GetAllowOverlap());
258 ActivatePage( *rSet );
261 // stuff attributes into the set when OK
262 bool SwWrapTabPage::FillItemSet(SfxItemSet *rSet)
264 bool bModified = false;
265 const SfxPoolItem* pOldItem;
266 const SwFormatSurround& rOldSur = GetItemSet().Get(RES_SURROUND);
267 SwFormatSurround aSur( rOldSur );
269 std::shared_ptr<SvxOpaqueItem> aOp(std::make_shared<SvxOpaqueItem>(RES_OPAQUE));
271 if (!m_bDrawMode)
273 aOp.reset(GetItemSet().Get(RES_OPAQUE).Clone());
274 aOp->SetValue(true);
277 if (m_xNoWrapRB->get_active())
278 aSur.SetSurround(css::text::WrapTextMode_NONE);
279 else if (m_xWrapLeftRB->get_active())
280 aSur.SetSurround(css::text::WrapTextMode_LEFT);
281 else if (m_xWrapRightRB->get_active())
282 aSur.SetSurround(css::text::WrapTextMode_RIGHT);
283 else if (m_xWrapParallelRB->get_active())
284 aSur.SetSurround(css::text::WrapTextMode_PARALLEL);
285 else if (m_xWrapThroughRB->get_active())
287 aSur.SetSurround(css::text::WrapTextMode_THROUGH);
288 if (m_xWrapTransparentCB->get_active() && !m_bDrawMode)
289 aOp->SetValue(false);
291 else if (m_xIdealWrapRB->get_active())
292 aSur.SetSurround(css::text::WrapTextMode_DYNAMIC);
294 aSur.SetAnchorOnly( m_xWrapAnchorOnlyCB->get_active() );
295 bool bContour = m_xWrapOutlineCB->get_active() && m_xWrapOutlineCB->get_sensitive();
296 aSur.SetContour( bContour );
298 if ( bContour )
299 aSur.SetOutside(m_xWrapOutsideCB->get_active());
301 if(nullptr == (pOldItem = GetOldItem( *rSet, RES_SURROUND )) ||
302 aSur != *pOldItem )
304 rSet->Put(aSur);
305 bModified = true;
308 if (!m_bDrawMode)
310 if(nullptr == (pOldItem = GetOldItem( *rSet, FN_OPAQUE )) ||
311 *aOp != *pOldItem )
313 rSet->Put(*aOp);
314 bModified = true;
318 bool bTopMod = m_xTopMarginED->get_value_changed_from_saved();
319 bool bBottomMod = m_xBottomMarginED->get_value_changed_from_saved();
321 SvxULSpaceItem aUL( RES_UL_SPACE );
322 aUL.SetUpper(o3tl::narrowing<sal_uInt16>(m_xTopMarginED->denormalize(m_xTopMarginED->get_value(FieldUnit::TWIP))));
323 aUL.SetLower(o3tl::narrowing<sal_uInt16>(m_xBottomMarginED->denormalize(m_xBottomMarginED->get_value(FieldUnit::TWIP))));
325 if ( bTopMod || bBottomMod )
327 if(nullptr == (pOldItem = GetOldItem(*rSet, RES_UL_SPACE)) ||
328 aUL != *pOldItem )
330 rSet->Put( aUL );
331 bModified = true;
335 bool bLeftMod = m_xLeftMarginED->get_value_changed_from_saved();
336 bool bRightMod = m_xRightMarginED->get_value_changed_from_saved();
338 SvxLRSpaceItem aLR( RES_LR_SPACE );
339 aLR.SetLeft(o3tl::narrowing<sal_uInt16>(m_xLeftMarginED->denormalize(m_xLeftMarginED->get_value(FieldUnit::TWIP))));
340 aLR.SetRight(o3tl::narrowing<sal_uInt16>(m_xRightMarginED->denormalize(m_xRightMarginED->get_value(FieldUnit::TWIP))));
342 if ( bLeftMod || bRightMod )
344 if( nullptr == (pOldItem = GetOldItem(*rSet, RES_LR_SPACE)) ||
345 aLR != *pOldItem )
347 rSet->Put(aLR);
348 bModified = true;
352 if ( m_bDrawMode )
354 bool bChecked = m_xWrapTransparentCB->get_active() && m_xWrapTransparentCB->get_sensitive();
355 if ((m_xWrapTransparentCB->get_saved_state() == TRISTATE_TRUE) != bChecked)
356 bModified |= nullptr != rSet->Put(SfxInt16Item(FN_DRAW_WRAP_DLG, bChecked ? 0 : 1));
359 const SwFormatWrapInfluenceOnObjPos& rOldInfluence
360 = GetItemSet().Get(RES_WRAP_INFLUENCE_ON_OBJPOS);
361 SwFormatWrapInfluenceOnObjPos aInfluence(rOldInfluence);
362 aInfluence.SetAllowOverlap(m_xAllowOverlapCB->get_active());
364 pOldItem = GetOldItem(*rSet, RES_WRAP_INFLUENCE_ON_OBJPOS);
365 if (!pOldItem || aInfluence != *pOldItem)
367 rSet->Put(aInfluence);
368 bModified = true;
371 return bModified;
374 // example update
375 void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet)
377 // anchor
378 const SwFormatAnchor &rAnch = rSet.Get(RES_ANCHOR);
379 m_nAnchorId = rAnch.GetAnchorId();
380 bool bEnable = (m_nAnchorId != RndStdIds::FLY_AS_CHAR);
382 SwWrtShell* pSh = m_bFormat ? ::GetActiveWrtShell() : m_pWrtSh;
383 if (pSh && !m_bDrawMode)
385 SwFlyFrameAttrMgr aMgr( m_bNew, pSh, GetItemSet() );
386 SvxSwFrameValidation aVal;
388 // size
389 const SwFormatFrameSize& rFrameSize = rSet.Get(RES_FRM_SIZE);
390 Size aSize = rFrameSize.GetSize();
392 // position
393 const SwFormatHoriOrient& rHori = rSet.Get(RES_HORI_ORIENT);
394 const SwFormatVertOrient& rVert = rSet.Get(RES_VERT_ORIENT);
396 aVal.nAnchorType = m_nAnchorId;
397 aVal.bAutoHeight = rFrameSize.GetHeightSizeType() == SwFrameSize::Minimum;
398 aVal.bMirror = rHori.IsPosToggle();
399 // #i18732#
400 aVal.bFollowTextFlow = rSet.Get(RES_FOLLOW_TEXT_FLOW).GetValue();
402 aVal.nHoriOrient = static_cast<short>(rHori.GetHoriOrient());
403 aVal.nVertOrient = static_cast<short>(rVert.GetVertOrient());
405 aVal.nHPos = rHori.GetPos();
406 aVal.nHRelOrient = rHori.GetRelationOrient();
407 aVal.nVPos = rVert.GetPos();
408 aVal.nVRelOrient = rVert.GetRelationOrient();
410 if (rFrameSize.GetWidthPercent() && rFrameSize.GetWidthPercent() != SwFormatFrameSize::SYNCED)
411 aSize.setWidth( aSize.Width() * rFrameSize.GetWidthPercent() / 100 );
413 if (rFrameSize.GetHeightPercent() && rFrameSize.GetHeightPercent() != SwFormatFrameSize::SYNCED)
414 aSize.setHeight( aSize.Height() * rFrameSize.GetHeightPercent() / 100 );
416 aVal.nWidth = aSize.Width();
417 aVal.nHeight = aSize.Height();
419 aMgr.ValidateMetrics(aVal, nullptr);
421 SwTwips nLeft;
422 SwTwips nRight;
423 SwTwips nTop;
424 SwTwips nBottom;
426 nLeft = aVal.nHPos - aVal.nMinHPos;
427 nRight = aVal.nMaxWidth - aVal.nWidth;
428 nTop = aVal.nVPos - aVal.nMinVPos;
429 nBottom = aVal.nMaxHeight - aVal.nHeight;
432 if (aVal.nAnchorType == RndStdIds::FLY_AS_CHAR)
434 nLeft = nRight;
436 if (aVal.nVPos < 0)
438 if (aVal.nVPos <= aVal.nMaxHeight)
439 nTop = aVal.nMaxVPos - aVal.nHeight;
440 else
441 nTop = 0; // no passage
443 else
444 nTop = aVal.nMaxVPos - aVal.nHeight - aVal.nVPos;
446 else
448 nLeft += nRight;
449 nTop += nBottom;
452 nBottom = nTop;
453 nRight = nLeft;
456 m_xLeftMarginED->set_max(m_xLeftMarginED->normalize(nLeft), FieldUnit::TWIP);
457 m_xRightMarginED->set_max(m_xRightMarginED->normalize(nRight), FieldUnit::TWIP);
459 m_xTopMarginED->set_max(m_xTopMarginED->normalize(nTop), FieldUnit::TWIP);
460 m_xBottomMarginED->set_max(m_xBottomMarginED->normalize(nBottom), FieldUnit::TWIP);
462 RangeModifyHdl(*m_xLeftMarginED);
463 RangeModifyHdl(*m_xTopMarginED);
466 const SwFormatSurround& rSurround = rSet.Get(RES_SURROUND);
467 css::text::WrapTextMode nSur = rSurround.GetSurround();
469 m_xWrapTransparentCB->set_sensitive(bEnable && !m_bHtmlMode && nSur == css::text::WrapTextMode_THROUGH);
470 if(m_bHtmlMode)
472 const SwFormatHoriOrient& rHori = rSet.Get(RES_HORI_ORIENT);
473 sal_Int16 eHOrient = rHori.GetHoriOrient();
474 sal_Int16 eHRelOrient = rHori.GetRelationOrient();
475 m_xWrapOutlineCB->hide();
476 const bool bAllHtmlModes =
477 ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR)) &&
478 (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT);
479 m_xWrapAnchorOnlyCB->set_sensitive(bAllHtmlModes && nSur != css::text::WrapTextMode_NONE);
480 m_xWrapOutsideCB->hide();
481 m_xIdealWrapRB->set_sensitive(false);
483 m_xWrapTransparentCB->set_sensitive(false);
484 m_xNoWrapRB->set_sensitive(RndStdIds::FLY_AT_PARA == m_nAnchorId);
485 m_xWrapParallelRB->set_sensitive(false);
486 m_xWrapLeftRB->set_sensitive
487 ( (RndStdIds::FLY_AT_PARA == m_nAnchorId)
488 || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
489 && (eHOrient == text::HoriOrientation::RIGHT)
490 && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
491 m_xWrapRightRB->set_sensitive
492 ( (RndStdIds::FLY_AT_PARA == m_nAnchorId)
493 || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
494 && (eHOrient == text::HoriOrientation::LEFT)
495 && (eHRelOrient == text::RelOrientation::PRINT_AREA)));
497 m_xWrapThroughRB->set_sensitive
498 ( ( (RndStdIds::FLY_AT_PAGE == m_nAnchorId)
499 || ( (RndStdIds::FLY_AT_CHAR == m_nAnchorId)
500 && (eHRelOrient != text::RelOrientation::PRINT_AREA))
501 || (RndStdIds::FLY_AT_PARA == m_nAnchorId))
502 && (eHOrient != text::HoriOrientation::RIGHT));
503 if (m_xNoWrapRB->get_active() && !m_xNoWrapRB->get_sensitive())
505 if(m_xWrapThroughRB->get_sensitive())
506 m_xWrapThroughRB->set_active(true);
507 else if(m_xWrapLeftRB->get_sensitive())
508 m_xWrapLeftRB->set_active(true);
509 else if(m_xWrapRightRB->get_sensitive())
510 m_xWrapRightRB->set_active(true);
513 if (m_xWrapLeftRB->get_active() && !m_xWrapLeftRB->get_sensitive())
515 if(m_xWrapRightRB->get_sensitive())
516 m_xWrapRightRB->set_active(true);
517 else if(m_xWrapThroughRB->get_sensitive())
518 m_xWrapThroughRB->set_active(true);
520 if (m_xWrapRightRB->get_active() && !m_xWrapRightRB->get_sensitive())
522 if(m_xWrapLeftRB->get_sensitive())
523 m_xWrapLeftRB->set_active(true);
524 else if(m_xWrapThroughRB->get_sensitive())
525 m_xWrapThroughRB->set_active(true);
527 if (m_xWrapThroughRB->get_active() && !m_xWrapThroughRB->get_sensitive())
528 if(m_xNoWrapRB->get_sensitive())
529 m_xNoWrapRB->set_active(true);
531 if (m_xWrapParallelRB->get_active() && !m_xWrapParallelRB->get_sensitive())
532 m_xWrapThroughRB->set_active(true);
534 else
536 m_xNoWrapRB->set_sensitive(bEnable);
537 m_xWrapLeftRB->set_sensitive(bEnable);
538 m_xWrapRightRB->set_sensitive(bEnable);
539 m_xIdealWrapRB->set_sensitive(bEnable);
540 m_xWrapThroughRB->set_sensitive(bEnable);
541 m_xWrapParallelRB->set_sensitive(bEnable);
542 m_xWrapAnchorOnlyCB->set_sensitive(
543 ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR))
544 && nSur != css::text::WrapTextMode_NONE );
546 ContourHdl(*m_xWrapOutlineCB);
549 DeactivateRC SwWrapTabPage::DeactivatePage(SfxItemSet* _pSet)
551 if(_pSet)
552 FillItemSet(_pSet);
554 return DeactivateRC::LeavePage;
557 IMPL_LINK(SwWrapTabPage, RangeModifyHdl, weld::MetricSpinButton&, rEdit, void)
559 auto nValue = rEdit.get_value(FieldUnit::NONE);
560 weld::MetricSpinButton* pOpposite = nullptr;
561 if (&rEdit == m_xLeftMarginED.get())
562 pOpposite = m_xRightMarginED.get();
563 else if (&rEdit == m_xRightMarginED.get())
564 pOpposite = m_xLeftMarginED.get();
565 else if (&rEdit == m_xTopMarginED.get())
566 pOpposite = m_xBottomMarginED.get();
567 else if (&rEdit == m_xBottomMarginED.get())
568 pOpposite = m_xTopMarginED.get();
570 assert(pOpposite);
572 if (pOpposite)
574 auto nOpposite = pOpposite->get_value(FieldUnit::NONE);
576 if (nValue + nOpposite > std::max(rEdit.get_max(FieldUnit::NONE), pOpposite->get_max(FieldUnit::NONE)))
577 pOpposite->set_value(pOpposite->get_max(FieldUnit::NONE) - nValue, FieldUnit::NONE);
581 IMPL_LINK_NOARG(SwWrapTabPage, WrapTypeHdl, weld::Toggleable&, void)
583 bool bWrapThrough = m_xWrapThroughRB->get_active();
584 m_xWrapTransparentCB->set_sensitive(bWrapThrough && !m_bHtmlMode);
585 bWrapThrough |= ( m_nAnchorId == RndStdIds::FLY_AS_CHAR );
586 m_xWrapOutlineCB->set_sensitive(!bWrapThrough && !m_xNoWrapRB->get_active());
587 m_xWrapOutsideCB->set_sensitive(!bWrapThrough && m_xWrapOutlineCB->get_active());
588 m_xWrapAnchorOnlyCB->set_sensitive(
589 ((m_nAnchorId == RndStdIds::FLY_AT_PARA) || (m_nAnchorId == RndStdIds::FLY_AT_CHAR)) &&
590 (!m_xNoWrapRB->get_active()) );
592 ContourHdl(*m_xWrapOutlineCB);
595 IMPL_LINK_NOARG(SwWrapTabPage, ContourHdl, weld::Toggleable&, void)
597 bool bEnable = !(m_xWrapOutlineCB->get_active() && m_xWrapOutlineCB->get_sensitive());
599 m_xWrapOutsideCB->set_sensitive(!bEnable);
601 bEnable = !m_xWrapOutlineCB->get_active();
602 if (bEnable == m_bContourImage) // so that it doesn't always flicker
604 m_bContourImage = !bEnable;
605 SetImages();
609 void SwWrapTabPage::SetImages()
611 m_xWrapThroughImg->set_from_icon_name(RID_BMP_WRAP_THROUGH);
612 bool bWrapOutline = !m_xWrapOutlineCB->get_active();
613 if (bWrapOutline)
615 m_xNoWrapImg->set_from_icon_name(RID_BMP_WRAP_NONE);
616 m_xWrapLeftImg->set_from_icon_name(RID_BMP_WRAP_LEFT);
617 m_xWrapRightImg->set_from_icon_name(RID_BMP_WRAP_RIGHT);
618 m_xWrapParallelImg->set_from_icon_name(RID_BMP_WRAP_PARALLEL);
619 m_xIdealWrapImg->set_from_icon_name(RID_BMP_WRAP_IDEAL);
621 else
623 m_xNoWrapImg->set_from_icon_name(RID_BMP_WRAP_CONTOUR_NONE);
624 m_xWrapLeftImg->set_from_icon_name(RID_BMP_WRAP_CONTOUR_LEFT);
625 m_xWrapRightImg->set_from_icon_name(RID_BMP_WRAP_CONTOUR_RIGHT);
626 m_xWrapParallelImg->set_from_icon_name(RID_BMP_WRAP_CONTOUR_PARALLEL);
627 m_xIdealWrapImg->set_from_icon_name(RID_BMP_WRAP_CONTOUR_IDEAL);
631 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */