File: | home/maarten/src/libreoffice/core/sw/source/ui/frmdlg/wrap.cxx |
Warning: | line 437, column 32 Although the value stored to 'nBottom' is used in the enclosing expression, the value is never actually read from 'nBottom' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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> |
31 | #include <svx/swframevalidation.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> |
43 | #include <fmtwrapinfluenceonobjpos.hxx> |
44 | |
45 | using namespace ::com::sun::star; |
46 | |
47 | const sal_uInt16 SwWrapTabPage::m_aWrapPageRg[] = { |
48 | RES_LR_SPACE, RES_UL_SPACE, |
49 | RES_PROTECT, RES_SURROUND, |
50 | RES_PRINT, RES_PRINT, |
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 | |
65 | SwWrapTabPage::SwWrapTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet) |
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 | { |
91 | SetExchangeSupport(); |
92 | |
93 | Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwWrapTabPage, RangeModifyHdl)::tools::detail::makeLink( ::tools::detail::castTo<SwWrapTabPage *>(this), &SwWrapTabPage::LinkStubRangeModifyHdl); |
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)::tools::detail::makeLink( ::tools::detail::castTo<SwWrapTabPage *>(this), &SwWrapTabPage::LinkStubWrapTypeHdl); |
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)::tools::detail::makeLink( ::tools::detail::castTo<SwWrapTabPage *>(this), &SwWrapTabPage::LinkStubContourHdl)); |
108 | } |
109 | |
110 | SwWrapTabPage::~SwWrapTabPage() |
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 | |
119 | void SwWrapTabPage::Reset(const SfxItemSet *rSet) |
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( |
128 | FN_DRAW_WRAP_DLG((20000 + 200) + 3))).GetValue() ); |
129 | m_xWrapTransparentCB->save_state(); |
130 | } |
131 | else |
132 | { |
133 | bool bShowCB = m_bFormat; |
134 | if( !m_bFormat ) |
135 | { |
136 | SelectionType nSelType = m_pWrtSh->GetSelectionType(); |
137 | if( ( nSelType & SelectionType::Graphic ) || |
138 | ( nSelType & SelectionType::Ole && GraphicType::NONE != |
139 | m_pWrtSh->GetIMapGraphic().GetType() )) |
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())); |
150 | m_bHtmlMode = (m_nHtmlMode & HTMLMODE_ON) != 0; |
151 | |
152 | FieldUnit aMetric = ::GetDfltMetric(m_bHtmlMode); |
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 | |
251 | const SwFormatWrapInfluenceOnObjPos& rInfluence = rSet->Get(RES_WRAP_INFLUENCE_ON_OBJPOS); |
252 | m_xAllowOverlapCB->set_active(rInfluence.GetAllowOverlap()); |
253 | |
254 | ActivatePage( *rSet ); |
255 | } |
256 | |
257 | // stuff attributes into the set when OK |
258 | bool SwWrapTabPage::FillItemSet(SfxItemSet *rSet) |
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((20000 + 1300) + 1) )) || |
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 | |
317 | SvxULSpaceItem aUL( RES_UL_SPACE ); |
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 | |
334 | SvxLRSpaceItem aLR( RES_LR_SPACE ); |
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((20000 + 200) + 3), bChecked ? 0 : 1)); |
353 | } |
354 | |
355 | const SwFormatWrapInfluenceOnObjPos& rOldInfluence |
356 | = GetItemSet().Get(RES_WRAP_INFLUENCE_ON_OBJPOS); |
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 |
371 | void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) |
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 | { |
380 | SwWrtShell* pSh = m_bFormat ? ::GetActiveWrtShell() : m_pWrtSh; |
381 | SwFlyFrameAttrMgr aMgr( m_bNew, pSh, GetItemSet() ); |
382 | SvxSwFrameValidation aVal; |
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 |
Although the value stored to 'nBottom' is used in the enclosing expression, the value is never actually read from 'nBottom' | |
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 | |
545 | DeactivateRC SwWrapTabPage::DeactivatePage(SfxItemSet* _pSet) |
546 | { |
547 | if(_pSet) |
548 | FillItemSet(_pSet); |
549 | |
550 | return DeactivateRC::LeavePage; |
551 | } |
552 | |
553 | IMPL_LINK(SwWrapTabPage, RangeModifyHdl, weld::MetricSpinButton&, rEdit, void)void SwWrapTabPage::LinkStubRangeModifyHdl(void * instance, weld ::MetricSpinButton& data) { return static_cast<SwWrapTabPage *>(instance)->RangeModifyHdl(data); } void SwWrapTabPage ::RangeModifyHdl(weld::MetricSpinButton& rEdit) |
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)(static_cast <bool> (pOpposite) ? void (0) : __assert_fail ("pOpposite", "/home/maarten/src/libreoffice/core/sw/source/ui/frmdlg/wrap.cxx" , 566, __extension__ __PRETTY_FUNCTION__)); |
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 | |
577 | IMPL_LINK_NOARG(SwWrapTabPage, WrapTypeHdl, weld::ToggleButton&, void)void SwWrapTabPage::LinkStubWrapTypeHdl(void * instance, weld ::ToggleButton& data) { return static_cast<SwWrapTabPage *>(instance)->WrapTypeHdl(data); } void SwWrapTabPage:: WrapTypeHdl(__attribute__ ((unused)) weld::ToggleButton&) |
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 | |
591 | IMPL_LINK_NOARG(SwWrapTabPage, ContourHdl, weld::ToggleButton&, void)void SwWrapTabPage::LinkStubContourHdl(void * instance, weld:: ToggleButton& data) { return static_cast<SwWrapTabPage *>(instance)->ContourHdl(data); } void SwWrapTabPage:: ContourHdl(__attribute__ ((unused)) weld::ToggleButton&) |
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 | |
605 | void SwWrapTabPage::SetImages() |
606 | { |
607 | m_xWrapThroughRB->set_from_icon_name(RID_BMP_WRAP_THROUGH"sw/res/wr05.png"); |
608 | bool bWrapOutline = !m_xWrapOutlineCB->get_active(); |
609 | if (bWrapOutline) |
610 | { |
611 | m_xNoWrapRB->set_from_icon_name(RID_BMP_WRAP_NONE"sw/res/wr01.png"); |
612 | m_xWrapLeftRB->set_from_icon_name(RID_BMP_WRAP_LEFT"sw/res/wr02.png"); |
613 | m_xWrapRightRB->set_from_icon_name(RID_BMP_WRAP_RIGHT"sw/res/wr03.png"); |
614 | m_xWrapParallelRB->set_from_icon_name(RID_BMP_WRAP_PARALLEL"sw/res/wr04.png"); |
615 | m_xIdealWrapRB->set_from_icon_name(RID_BMP_WRAP_IDEAL"sw/res/wr06.png"); |
616 | } |
617 | else |
618 | { |
619 | m_xNoWrapRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_NONE"sw/res/wr07.png"); |
620 | m_xWrapLeftRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_LEFT"sw/res/wr08.png"); |
621 | m_xWrapRightRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_RIGHT"sw/res/wr09.png"); |
622 | m_xWrapParallelRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_PARALLEL"sw/res/wr010.png"); |
623 | m_xIdealWrapRB->set_from_icon_name(RID_BMP_WRAP_CONTOUR_IDEAL"sw/res/wr011.png"); |
624 | } |
625 | } |
626 | |
627 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |