LibreOffice Module cui (master)  1
page.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 <memory>
21 #include <o3tl/unit_conversion.hxx>
22 #include <sfx2/objsh.hxx>
23 #include <sfx2/printer.hxx>
24 #include <sfx2/viewsh.hxx>
25 #include <svl/cjkoptions.hxx>
26 #include <svl/ctloptions.hxx>
27 #include <svtools/unitconv.hxx>
28 #include <vcl/svapp.hxx>
29 #include <vcl/weld.hxx>
30 #include <sfx2/htmlmode.hxx>
31 #include <sal/macros.h>
32 #include <osl/diagnose.h>
33 
34 #include <svx/strings.hrc>
35 #include <svx/dialmgr.hxx>
36 #include <page.hxx>
37 #include <svx/pageitem.hxx>
38 #include <editeng/brushitem.hxx>
39 #include <editeng/boxitem.hxx>
40 #include <editeng/shaditem.hxx>
41 #include <editeng/pbinitem.hxx>
42 #include <editeng/lrspitem.hxx>
43 #include <editeng/ulspitem.hxx>
44 #include <editeng/sizeitem.hxx>
45 #include <editeng/frmdiritem.hxx>
46 #include <svx/dlgutil.hxx>
47 #include <editeng/paperinf.hxx>
48 #include <svl/stritem.hxx>
49 #include <editeng/eerdll.hxx>
50 #include <editeng/editrids.hrc>
51 #include <svx/svxids.hrc>
53 #include <svl/slstitm.hxx>
54 #include <svx/xdef.hxx>
57 #include <sal/log.hxx>
58 #include <svl/grabbagitem.hxx>
59 
60 // static ----------------------------------------------------------------
61 
62 // #i19922# - tdf#126051 see svx/source/dialog/hdft.cxx and sw/source/uibase/sidebar/PageMarginControl.hxx
63 constexpr tools::Long MINBODY = o3tl::toTwips(1, o3tl::Length::mm); // 1mm in twips rounded
64 
66  svl::Items<
67  SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_SHADOW,
68  SID_ATTR_LRSPACE, SID_ATTR_PAGE_SHARED,
69  SID_SWREGISTER_COLLECTION, SID_SWREGISTER_MODE>);
70 // ------- Mapping page layout ------------------------------------------
71 
72 const SvxPageUsage aArr[] =
73 {
74  SvxPageUsage::All,
75  SvxPageUsage::Mirror,
76  SvxPageUsage::Right,
77  SvxPageUsage::Left
78 };
79 
80 
81 static sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage )
82 {
83  for ( size_t i = 0; i < std::size(aArr); ++i )
84  if ( aArr[i] == nUsage )
85  return i;
86  return 3;
87 }
88 
89 
90 static SvxPageUsage PosToPageUsage_Impl( sal_uInt16 nPos )
91 {
92  if ( nPos >= std::size(aArr) )
93  return SvxPageUsage::NONE;
94  return aArr[nPos];
95 }
96 
97 
98 static Size GetMinBorderSpace_Impl( const SvxShadowItem& rShadow, const SvxBoxItem& rBox )
99 {
100  Size aSz;
101  aSz.setHeight( rShadow.CalcShadowSpace( SvxShadowItemSide::BOTTOM ) + rBox.CalcLineSpace( SvxBoxItemLine::BOTTOM ) );
102  aSz.AdjustHeight(rShadow.CalcShadowSpace( SvxShadowItemSide::TOP ) + rBox.CalcLineSpace( SvxBoxItemLine::TOP ) );
103  aSz.setWidth( rShadow.CalcShadowSpace( SvxShadowItemSide::LEFT ) + rBox.CalcLineSpace( SvxBoxItemLine::LEFT ) );
104  aSz.AdjustWidth(rShadow.CalcShadowSpace( SvxShadowItemSide::RIGHT ) + rBox.CalcLineSpace( SvxBoxItemLine::RIGHT ) );
105  return aSz;
106 }
107 
108 
110 {
111  return OutputDevice::LogicToLogic( nIn, eUnit, MapUnit::MapTwip );
112 }
113 
114 static bool IsEqualSize_Impl( const SvxSizeItem* pSize, const Size& rSize )
115 {
116  if ( pSize )
117  {
118  Size aSize = pSize->GetSize();
119  tools::Long nDiffW = std::abs( rSize.Width () - aSize.Width () );
120  tools::Long nDiffH = std::abs( rSize.Height() - aSize.Height() );
121  return ( nDiffW < 10 && nDiffH < 10 );
122  }
123  else
124  return false;
125 }
126 
127 
128 #define MARGIN_LEFT ( MarginPosition(0x0001) )
129 #define MARGIN_RIGHT ( MarginPosition(0x0002) )
130 #define MARGIN_TOP ( MarginPosition(0x0004) )
131 #define MARGIN_BOTTOM ( MarginPosition(0x0008) )
132 
133 // class SvxPageDescPage --------------------------------------------------
134 
135 std::unique_ptr<SfxTabPage> SvxPageDescPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
136 {
137  return std::make_unique<SvxPageDescPage>(pPage, pController, *rSet);
138 }
139 
141  : SfxTabPage(pPage, pController, "cui/ui/pageformatpage.ui", "PageFormatPage", &rAttr)
142  , bLandscape(false)
144  , ePaperStart(PAPER_A3)
145  , m_nPos(0)
146  , mpDefPrinter(nullptr)
147  , mbDelPrinter(false)
148  , mbEnableDrawingLayerFillStyles(false)
149  , m_xPaperSizeBox(new SvxPaperSizeListBox(m_xBuilder->weld_combo_box("comboPageFormat")))
150  , m_xPaperWidthEdit(m_xBuilder->weld_metric_spin_button("spinWidth", FieldUnit::CM))
151  , m_xPaperHeightEdit(m_xBuilder->weld_metric_spin_button("spinHeight", FieldUnit::CM))
152  , m_xOrientationFT(m_xBuilder->weld_label("labelOrientation"))
153  , m_xPortraitBtn(m_xBuilder->weld_radio_button("radiobuttonPortrait"))
154  , m_xLandscapeBtn(m_xBuilder->weld_radio_button("radiobuttonLandscape"))
155  , m_xTextFlowLbl(m_xBuilder->weld_label("labelTextFlow"))
156  , m_xTextFlowBox(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("comboTextFlowBox")))
157  , m_xPaperTrayBox(m_xBuilder->weld_combo_box("comboPaperTray"))
158  , m_xLeftMarginLbl(m_xBuilder->weld_label("labelLeftMargin"))
159  , m_xLeftMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargLeft", FieldUnit::CM))
160  , m_xRightMarginLbl(m_xBuilder->weld_label("labelRightMargin"))
161  , m_xRightMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargRight", FieldUnit::CM))
162  , m_xTopMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargTop", FieldUnit::CM))
163  , m_xBottomMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargBot", FieldUnit::CM))
164  , m_xGutterMarginLbl(m_xBuilder->weld_label("labelGutterMargin"))
165  , m_xGutterMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargGut", FieldUnit::CM))
166  , m_xPageText(m_xBuilder->weld_label("labelPageLayout"))
167  , m_xLayoutBox(m_xBuilder->weld_combo_box("comboPageLayout"))
168  , m_xNumberFormatText(m_xBuilder->weld_label("labelPageNumbers"))
169  , m_xNumberFormatBox(new SvxPageNumberListBox(m_xBuilder->weld_combo_box("comboLayoutFormat")))
170  , m_xTblAlignFT(m_xBuilder->weld_label("labelTblAlign"))
171  , m_xHorzBox(m_xBuilder->weld_check_button("checkbuttonHorz"))
172  , m_xVertBox(m_xBuilder->weld_check_button("checkbuttonVert"))
173  , m_xAdaptBox(m_xBuilder->weld_check_button("checkAdaptBox"))
174  , m_xRegisterCB(m_xBuilder->weld_check_button("checkRegisterTrue"))
175  , m_xRegisterFT(m_xBuilder->weld_label("labelRegisterStyle"))
176  , m_xRegisterLB(m_xBuilder->weld_combo_box("comboRegisterStyle"))
177  , m_xGutterPositionFT(m_xBuilder->weld_label("labelGutterPosition"))
178  , m_xGutterPositionLB(m_xBuilder->weld_combo_box("comboGutterPosition"))
179  , m_xRtlGutterCB(m_xBuilder->weld_check_button("checkRtlGutter"))
180  , m_xBackgroundFullSizeCB(m_xBuilder->weld_check_button("checkBackgroundFullSize"))
181  // Strings stored in UI
182  , m_xInsideLbl(m_xBuilder->weld_label("labelInner"))
183  , m_xOutsideLbl(m_xBuilder->weld_label("labelOuter"))
184  , m_xPrintRangeQueryText(m_xBuilder->weld_label("labelMsg"))
185  , m_xBspWin(new weld::CustomWeld(*m_xBuilder, "drawingareaPageDirection", m_aBspWin))
186 {
187  m_xRegisterLB->set_size_request(m_xRegisterLB->get_approximate_digit_width() * 20, -1);
188 
189  bBorderModified = false;
190  m_aBspWin.EnableRTL(false);
191 
192  // this page needs ExchangeSupport
194 
195  SvtCTLOptions aCTLLanguageOptions;
197  bool bCTL = aCTLLanguageOptions.IsCTLFontEnabled();
198  bool bWeb = false;
199 
200  const SfxUInt16Item* pHtmlModeItem = rAttr.GetItemIfSet(SID_HTML_MODE, false);
201  if (!pHtmlModeItem)
202  {
204  if (pShell)
205  pHtmlModeItem = pShell->GetItem(SID_HTML_MODE);
206  }
207  if (pHtmlModeItem)
208  bWeb = 0 != (pHtmlModeItem->GetValue() & HTMLMODE_ON);
209 
210  // fill text flow listbox with valid entries
211 
212  m_xTextFlowBox->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_PAGEDIR_LTR_HORI));
213 
214  if (bCTL)
215  m_xTextFlowBox->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_PAGEDIR_RTL_HORI));
216 
217 
218  // #109989# do not show vertical directions in Writer/Web
219  if( !bWeb && bCJK )
220  {
221  m_xTextFlowBox->append(SvxFrameDirection::Vertical_RL_TB, SvxResId(RID_SVXSTR_PAGEDIR_RTL_VERT));
222  m_xTextFlowBox->append(SvxFrameDirection::Vertical_LR_TB, SvxResId(RID_SVXSTR_PAGEDIR_LTR_VERT));
223  }
224 
225  // #109989# show the text direction box in Writer/Web too
226  if( (bCJK || bCTL) &&
227  SfxItemState::UNKNOWN < rAttr.GetItemState(GetWhich( SID_ATTR_FRAMEDIRECTION )))
228  {
229  m_xTextFlowLbl->show();
230  m_xTextFlowBox->show();
231  m_xTextFlowBox->connect_changed(LINK(this, SvxPageDescPage, FrameDirectionModify_Impl));
232 
234  }
235  Init_Impl();
236 
237  FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
238  SetFieldUnit( *m_xLeftMarginEdit, eFUnit );
239  SetFieldUnit( *m_xRightMarginEdit, eFUnit );
240  SetFieldUnit( *m_xTopMarginEdit, eFUnit );
241  SetFieldUnit( *m_xBottomMarginEdit, eFUnit );
243  SetFieldUnit( *m_xPaperWidthEdit, eFUnit );
244  SetFieldUnit( *m_xPaperHeightEdit, eFUnit );
245 
246  if ( SfxViewShell::Current() && SfxViewShell::Current()->GetPrinter() )
247  {
249  }
250  else
251  {
253  mbDelPrinter = true;
254  }
255 
256  MapMode aOldMode = mpDefPrinter->GetMapMode();
257  mpDefPrinter->SetMapMode(MapMode(MapUnit::MapTwip));
258 
259  // set first- and last-values for the margins
260  Size aPaperSize = mpDefPrinter->GetPaperSize();
261  Size aPrintSize = mpDefPrinter->GetOutputSize();
262 
263  /*
264  * To convert a point ( 0,0 ) into logic coordinates
265  * looks like nonsense; but it makes sense when the
266  * coordinate system's origin has been moved.
267  */
269  mpDefPrinter->SetMapMode( aOldMode );
270 
271  nFirstLeftMargin = m_xLeftMarginEdit->convert_value_from(m_xLeftMarginEdit->normalize(aPrintOffset.X()), FieldUnit::TWIP);
272  nFirstRightMargin = m_xRightMarginEdit->convert_value_from(m_xRightMarginEdit->normalize(aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X()), FieldUnit::TWIP);
273  nFirstTopMargin = m_xTopMarginEdit->convert_value_from(m_xTopMarginEdit->normalize(aPrintOffset.Y() ), FieldUnit::TWIP);
274  nFirstBottomMargin = m_xBottomMarginEdit->convert_value_from(m_xBottomMarginEdit->normalize(aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y()), FieldUnit::TWIP );
275  nLastLeftMargin = m_xLeftMarginEdit->convert_value_from(m_xLeftMarginEdit->normalize(aPrintOffset.X() + aPrintSize.Width()), FieldUnit::TWIP);
276  nLastRightMargin = m_xRightMarginEdit->convert_value_from(m_xRightMarginEdit->normalize(aPrintOffset.X() + aPrintSize.Width()), FieldUnit::TWIP);
277  nLastTopMargin = m_xTopMarginEdit->convert_value_from(m_xTopMarginEdit->normalize(aPrintOffset.Y() + aPrintSize.Height()), FieldUnit::TWIP);
278  nLastBottomMargin = m_xBottomMarginEdit->convert_value_from(m_xBottomMarginEdit->normalize(aPrintOffset.Y() + aPrintSize.Height()), FieldUnit::TWIP);
279 
280  // #i4219# take Maximum now from configuration (1/100th cm)
281  // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000
284 
285  // #i4219# also for margins (1/100th cm). Was: 9999, keeping.
290  m_xGutterMarginEdit->set_max(
292  FieldUnit::MM);
293 
294  // Get the i18n framework numberings and add them to the listbox.
295  SvxNumOptionsTabPageHelper::GetI18nNumbering(m_xNumberFormatBox->get_widget(), std::numeric_limits<sal_uInt16>::max());
296 }
297 
299 {
300  if(mbDelPrinter)
301  {
303  mbDelPrinter = false;
304  }
305 }
306 
308 {
309  // adjust the handler
310  m_xLayoutBox->connect_changed(LINK(this, SvxPageDescPage, LayoutHdl_Impl));
311  m_xGutterPositionLB->connect_changed(LINK(this, SvxPageDescPage, GutterPositionHdl_Impl));
312 
313  m_xPaperSizeBox->connect_changed(LINK(this, SvxPageDescPage, PaperSizeSelect_Impl));
314  m_xPaperWidthEdit->connect_value_changed( LINK(this, SvxPageDescPage, PaperSizeModify_Impl));
315  m_xPaperHeightEdit->connect_value_changed(LINK(this, SvxPageDescPage, PaperSizeModify_Impl));
316  m_xLandscapeBtn->connect_toggled(LINK(this, SvxPageDescPage, SwapOrientation_Impl));
317  m_xPortraitBtn->connect_toggled(LINK(this, SvxPageDescPage, SwapOrientation_Impl));
318 
319  Link<weld::MetricSpinButton&, void> aLink = LINK(this, SvxPageDescPage, BorderModify_Impl);
320  m_xLeftMarginEdit->connect_value_changed(aLink);
321  m_xRightMarginEdit->connect_value_changed(aLink);
322  m_xTopMarginEdit->connect_value_changed(aLink);
323  m_xBottomMarginEdit->connect_value_changed(aLink);
324  m_xGutterMarginEdit->connect_value_changed(aLink);
325 
326  m_xHorzBox->connect_toggled(LINK(this, SvxPageDescPage, CenterHdl_Impl));
327  m_xVertBox->connect_toggled(LINK(this, SvxPageDescPage, CenterHdl_Impl));
328 }
329 
331 {
332  SfxItemPool* pPool = rSet->GetPool();
333  SAL_WARN_IF(!pPool, "cui.tabpages", "Where is the pool?");
334  MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) );
335 
336  // adjust margins (right/left)
337  const SfxPoolItem* pItem = GetItem( *rSet, SID_ATTR_LRSPACE );
338 
339  if ( pItem )
340  {
341  const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(*pItem);
342  SetMetricValue( *m_xLeftMarginEdit, rLRSpace.GetLeft(), eUnit );
345  static_cast<sal_uInt16>(ConvertLong_Impl( rLRSpace.GetLeft(), eUnit )) );
346  SetMetricValue( *m_xRightMarginEdit, rLRSpace.GetRight(), eUnit );
348  static_cast<sal_uInt16>(ConvertLong_Impl( rLRSpace.GetRight(), eUnit )) );
349  }
350 
351  // adjust margins (top/bottom)
352  pItem = GetItem( *rSet, SID_ATTR_ULSPACE );
353 
354  if ( pItem )
355  {
356  const SvxULSpaceItem& rULSpace = static_cast<const SvxULSpaceItem&>(*pItem);
357  SetMetricValue( *m_xTopMarginEdit, rULSpace.GetUpper(), eUnit );
359  static_cast<sal_uInt16>(ConvertLong_Impl( static_cast<tools::Long>(rULSpace.GetUpper()), eUnit )) );
360  SetMetricValue( *m_xBottomMarginEdit, rULSpace.GetLower(), eUnit );
362  static_cast<sal_uInt16>(ConvertLong_Impl( static_cast<tools::Long>(rULSpace.GetLower()), eUnit )) );
363  }
364 
365  if (const SfxGrabBagItem* pGragbagItem = rSet->GetItemIfSet(SID_ATTR_CHAR_GRABBAG))
366  {
367  bool bGutterAtTop{};
368  auto it = pGragbagItem->GetGrabBag().find("GutterAtTop");
369  if (it != pGragbagItem->GetGrabBag().end())
370  {
371  it->second >>= bGutterAtTop;
372  }
373 
374  if (bGutterAtTop)
375  {
376  m_xGutterPositionLB->set_active(1);
377  }
378  else
379  {
380  // Left.
381  m_xGutterPositionLB->set_active(0);
382  }
383  it = pGragbagItem->GetGrabBag().find("RtlGutter");
384  bool bRtlGutter{};
385  if (it != pGragbagItem->GetGrabBag().end())
386  {
387  it->second >>= bRtlGutter;
388  m_xRtlGutterCB->set_active(bRtlGutter);
389  m_xRtlGutterCB->show();
390  }
391  it = pGragbagItem->GetGrabBag().find("BackgroundFullSize");
392  bool isBackgroundFullSize{};
393  if (it != pGragbagItem->GetGrabBag().end())
394  {
395  it->second >>= isBackgroundFullSize;
396  m_xBackgroundFullSizeCB->set_active(isBackgroundFullSize);
397  m_xBackgroundFullSizeCB->show();
398  }
399  }
400 
401  // general page data
402  SvxNumType eNumType = SVX_NUM_ARABIC;
403  bLandscape = ( mpDefPrinter->GetOrientation() == Orientation::Landscape );
404  SvxPageUsage nUse = SvxPageUsage::All;
405  pItem = GetItem( *rSet, SID_ATTR_PAGE );
406 
407  if ( pItem )
408  {
409  const SvxPageItem& rItem = static_cast<const SvxPageItem&>(*pItem);
410  eNumType = rItem.GetNumType();
411  nUse = rItem.GetPageUsage();
412  bLandscape = rItem.IsLandscape();
413  }
414 
415  // alignment
416  m_xLayoutBox->set_active(::PageUsageToPos_Impl(nUse));
417  m_aBspWin.SetUsage( nUse );
418  LayoutHdl_Impl( *m_xLayoutBox );
419 
420  //adjust numeration type of the page style
421  m_xNumberFormatBox->set_active_id(eNumType);
422 
423  m_xPaperTrayBox->clear();
425  pItem = GetItem( *rSet, SID_ATTR_PAGE_PAPERBIN );
426 
427  if ( pItem )
428  {
429  nPaperBin = static_cast<const SvxPaperBinItem*>(pItem)->GetValue();
430 
431  if ( nPaperBin >= mpDefPrinter->GetPaperBinCount() )
432  nPaperBin = PAPERBIN_PRINTER_SETTINGS;
433  }
434 
435  OUString aBinName;
436 
437  if ( PAPERBIN_PRINTER_SETTINGS == nPaperBin )
438  aBinName = EditResId(RID_SVXSTR_PAPERBIN_SETTINGS);
439  else
440  aBinName = mpDefPrinter->GetPaperBinName( static_cast<sal_uInt16>(nPaperBin) );
441 
442  m_xPaperTrayBox->append(OUString::number(nPaperBin), aBinName);
443  m_xPaperTrayBox->set_active_text(aBinName);
444  // reset focus handler to default first so know none already connected
445  m_xPaperTrayBox->connect_focus_in(Link<weld::Widget&, void>());
446  // update the list when widget gets focus
447  m_xPaperTrayBox->connect_focus_in(LINK(this, SvxPageDescPage, PaperBinHdl_Impl));
448 
450  pItem = GetItem( *rSet, SID_ATTR_PAGE_SIZE );
451 
452  if ( pItem )
453  aPaperSize = static_cast<const SvxSizeItem*>(pItem)->GetSize();
454 
455  bool bOrientationSupport =
456  mpDefPrinter->HasSupport( PrinterSupport::SetOrientation );
457 
458  if ( !bOrientationSupport &&
459  aPaperSize.Width() > aPaperSize.Height() )
460  bLandscape = true;
461 
462  // tdf#130548 disable callbacks on the other of a pair of the radiogroup
463  // when toggling its partner
465  m_xPortraitBtn->connect_toggled(Link<weld::Toggleable&, void>());
466 
467  m_xLandscapeBtn->set_active(bLandscape);
468  m_xPortraitBtn->set_active(!bLandscape);
469 
470  m_xLandscapeBtn->connect_toggled(LINK(this, SvxPageDescPage, SwapOrientation_Impl));
471  m_xPortraitBtn->connect_toggled(LINK(this, SvxPageDescPage, SwapOrientation_Impl));
472 
473  m_aBspWin.SetSize( Size( ConvertLong_Impl( aPaperSize.Width(), eUnit ),
474  ConvertLong_Impl( aPaperSize.Height(), eUnit ) ) );
475 
476  aPaperSize = OutputDevice::LogicToLogic(aPaperSize, MapMode(eUnit), MapMode(MapUnit::Map100thMM));
477  if ( bLandscape )
478  Swap( aPaperSize );
479 
480  // Actual Paper Format
481  Paper ePaper = SvxPaperInfo::GetSvxPaper( aPaperSize, MapUnit::Map100thMM );
482 
483  if ( PAPER_USER != ePaper )
484  aPaperSize = SvxPaperInfo::GetPaperSize( ePaper, MapUnit::Map100thMM );
485 
486  if ( bLandscape )
487  Swap( aPaperSize );
488 
489  // write values into the edits
490  SetMetricValue( *m_xPaperHeightEdit, aPaperSize.Height(), MapUnit::Map100thMM );
491  SetMetricValue( *m_xPaperWidthEdit, aPaperSize.Width(), MapUnit::Map100thMM );
492  m_xPaperSizeBox->clear();
493 
494  m_xPaperSizeBox->FillPaperSizeEntries( ( ePaperStart == PAPER_A3 ) ? PaperSizeApp::Std : PaperSizeApp::Draw );
495  m_xPaperSizeBox->set_active_id( ePaper );
496 
497  // application specific
498 
499  switch ( eMode )
500  {
502  {
503  m_xTblAlignFT->show();
504  m_xHorzBox->show();
505  m_xVertBox->show();
507 
508  // horizontal alignment
509  pItem = GetItem( *rSet, SID_ATTR_PAGE_EXT1 );
510  m_xHorzBox->set_active(pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue());
511 
512  // vertical alignment
513  pItem = GetItem( *rSet, SID_ATTR_PAGE_EXT2 );
514  m_xVertBox->set_active(pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue());
515 
516  // set example window on the table
517  m_aBspWin.SetTable( true );
518  m_aBspWin.SetHorz(m_xHorzBox->get_active());
519  m_aBspWin.SetVert(m_xVertBox->get_active());
520 
521  m_xGutterMarginLbl->hide();
522  m_xGutterMarginEdit->hide();
523  m_xGutterPositionFT->hide();
524  m_xGutterPositionLB->hide();
525 
526  break;
527  }
528 
530  {
532  m_xAdaptBox->show();
533  pItem = GetItem( *rSet, SID_ATTR_PAGE_EXT1 );
534  m_xAdaptBox->set_active( pItem &&
535  static_cast<const SfxBoolItem*>(pItem)->GetValue() );
536 
538  m_xLayoutBox->hide();
539  m_xPageText->hide();
540 
541  m_xGutterMarginLbl->hide();
542  m_xGutterMarginEdit->hide();
543  m_xGutterPositionFT->hide();
544  m_xGutterPositionLB->hide();
545 
546  break;
547  }
548  default: ;//prevent warning
549  }
550 
551 
552  // display background and border in the example
553  ResetBackground_Impl( *rSet );
555  RangeHdl_Impl();
556 
557  InitHeadFoot_Impl( *rSet );
558 
559  bBorderModified = false;
560  SwapFirstValues_Impl( false );
562 
563  m_xLeftMarginEdit->save_value();
564  m_xRightMarginEdit->save_value();
565  m_xTopMarginEdit->save_value();
566  m_xBottomMarginEdit->save_value();
567  m_xGutterMarginEdit->save_value();
568  m_xLayoutBox->save_value();
569  m_xNumberFormatBox->save_value();
570  m_xPaperSizeBox->save_value();
571  m_xPaperWidthEdit->save_value();
572  m_xPaperHeightEdit->save_value();
573  m_xPortraitBtn->save_state();
574  m_xLandscapeBtn->save_state();
575  m_xPaperTrayBox->save_value();
576  m_xVertBox->save_state();
577  m_xHorzBox->save_state();
578  m_xAdaptBox->save_state();
579  m_xGutterPositionLB->save_value();
580  m_xRtlGutterCB->save_state();
581  m_xBackgroundFullSizeCB->save_state();
582 
583  CheckMarginEdits( true );
584 
585 
586  if(SfxItemState::SET == rSet->GetItemState(SID_SWREGISTER_MODE))
587  {
588  m_xRegisterCB->set_active(rSet->Get(SID_SWREGISTER_MODE).GetValue());
589  m_xRegisterCB->save_state();
590  RegisterModify(*m_xRegisterCB);
591  }
592  if(SfxItemState::SET == rSet->GetItemState(SID_SWREGISTER_COLLECTION))
593  {
594  m_xRegisterLB->set_active_text(
595  rSet->Get(SID_SWREGISTER_COLLECTION).GetValue());
596  m_xRegisterLB->save_value();
597  }
598 
599  SfxItemState eState = rSet->GetItemState( GetWhich( SID_ATTR_FRAMEDIRECTION ),
600  true, &pItem );
601  if( SfxItemState::UNKNOWN != eState )
602  {
603  SvxFrameDirection nVal = SfxItemState::SET == eState
604  ? static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue()
605  : SvxFrameDirection::Horizontal_LR_TB;
606  m_xTextFlowBox->set_active_id(nVal);
607 
608  m_xTextFlowBox->save_value();
610  }
611 }
612 
614 {
616  SetUserData(m_xAdaptBox->get_active() ? OUString("1") : OUString("0")) ;
617 
618 }
619 
621 {
622  bool bModified = false;
623  const SfxItemSet& rOldSet = GetItemSet();
624  SfxItemPool* pPool = rOldSet.GetPool();
625  DBG_ASSERT( pPool, "Where is the pool?" );
626  sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE );
627  MapUnit eUnit = pPool->GetMetric( nWhich );
628  const SfxPoolItem* pOld = nullptr;
629 
630  // copy old left and right margins
631  SvxLRSpaceItem aMargin( static_cast<const SvxLRSpaceItem&>(rOldSet.Get( nWhich )) );
632 
633  // copy old top and bottom margins
634  nWhich = GetWhich( SID_ATTR_ULSPACE );
635  SvxULSpaceItem aTopMargin( static_cast<const SvxULSpaceItem&>(rOldSet.Get( nWhich )) );
636 
637  if (m_xLeftMarginEdit->get_value_changed_from_saved())
638  {
639  aMargin.SetLeft( static_cast<sal_uInt16>(GetCoreValue( *m_xLeftMarginEdit, eUnit )) );
640  bModified = true;
641  }
642 
643  if (m_xRightMarginEdit->get_value_changed_from_saved())
644  {
645  aMargin.SetRight( static_cast<sal_uInt16>(GetCoreValue( *m_xRightMarginEdit, eUnit )) );
646  bModified = true;
647  }
648 
649  if (m_xGutterMarginEdit->get_value_changed_from_saved())
650  {
651  aMargin.SetGutterMargin(static_cast<sal_uInt16>(GetCoreValue(*m_xGutterMarginEdit, eUnit)));
652  bModified = true;
653  }
654 
655  // set left and right margins
656  if (bModified)
657  {
658  pOld = GetOldItem( *rSet, SID_ATTR_LRSPACE );
659 
660  if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin )
661  rSet->Put( aMargin );
662  else
663  bModified = false;
664  }
665 
666  if (rOldSet.HasItem(SID_ATTR_CHAR_GRABBAG))
667  {
668  // Set gutter position.
669  SfxGrabBagItem aGrabBagItem(rOldSet.Get(SID_ATTR_CHAR_GRABBAG));
670  if (m_xGutterPositionLB->get_value_changed_from_saved())
671  {
672  bool bGutterAtTop = m_xGutterPositionLB->get_active() == 1;
673  aGrabBagItem.GetGrabBag()["GutterAtTop"] <<= bGutterAtTop;
674  bModified = true;
675  }
676  if (m_xRtlGutterCB->get_state_changed_from_saved())
677  {
678  bool const bRtlGutter(m_xRtlGutterCB->get_active());
679  aGrabBagItem.GetGrabBag()["RtlGutter"] <<= bRtlGutter;
680  bModified = true;
681  }
682  if (m_xBackgroundFullSizeCB->get_state_changed_from_saved())
683  {
684  bool const isBackgroundFullSize(m_xBackgroundFullSizeCB->get_active());
685  aGrabBagItem.GetGrabBag()["BackgroundFullSize"] <<= isBackgroundFullSize;
686  bModified = true;
687  }
688 
689  if (bModified)
690  {
691  pOld = rOldSet.GetItem(SID_ATTR_CHAR_GRABBAG);
692 
693  if (!pOld || static_cast<const SfxGrabBagItem&>(*pOld) != aGrabBagItem)
694  rSet->Put(aGrabBagItem);
695  else
696  bModified = false;
697  }
698  }
699 
700  bool bMod = false;
701 
702  if (m_xTopMarginEdit->get_value_changed_from_saved())
703  {
704  aTopMargin.SetUpper( static_cast<sal_uInt16>(GetCoreValue( *m_xTopMarginEdit, eUnit )) );
705  bMod = true;
706  }
707 
708  if (m_xBottomMarginEdit->get_value_changed_from_saved())
709  {
710  aTopMargin.SetLower( static_cast<sal_uInt16>(GetCoreValue( *m_xBottomMarginEdit, eUnit )) );
711  bMod = true;
712  }
713 
714  // set top and bottom margins
715 
716  if ( bMod )
717  {
718  pOld = GetOldItem( *rSet, SID_ATTR_ULSPACE );
719 
720  if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aTopMargin )
721  {
722  bModified = true;
723  rSet->Put( aTopMargin );
724  }
725  }
726 
727  // paper tray
728  nWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN );
729  sal_Int32 nPos = m_xPaperTrayBox->get_active();
730  sal_uInt16 nBin = m_xPaperTrayBox->get_id(nPos).toInt32();
731  pOld = GetOldItem( *rSet, SID_ATTR_PAGE_PAPERBIN );
732 
733  if ( !pOld || static_cast<const SvxPaperBinItem*>(pOld)->GetValue() != nBin )
734  {
735  rSet->Put( SvxPaperBinItem( nWhich, static_cast<sal_uInt8>(nBin) ) );
736  bModified = true;
737  }
738 
739  Paper ePaper = m_xPaperSizeBox->get_active_id();
740  bool bChecked = m_xLandscapeBtn->get_active();
741 
742  if ( PAPER_USER == ePaper )
743  {
744  if ( m_xPaperSizeBox->get_value_changed_from_saved() ||
745  m_xPaperWidthEdit->get_value_changed_from_saved() ||
746  m_xPaperHeightEdit->get_value_changed_from_saved() ||
747  m_xLandscapeBtn->get_state_changed_from_saved() )
748  {
749  Size aSize( GetCoreValue( *m_xPaperWidthEdit, eUnit ),
750  GetCoreValue( *m_xPaperHeightEdit, eUnit ) );
751  pOld = GetOldItem( *rSet, SID_ATTR_PAGE_SIZE );
752 
753  if ( !pOld || static_cast<const SvxSizeItem*>(pOld)->GetSize() != aSize )
754  {
755  rSet->Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
756  bModified = true;
757  }
758  }
759  }
760  else
761  {
762  if (m_xPaperSizeBox->get_value_changed_from_saved() || m_xLandscapeBtn->get_state_changed_from_saved())
763  {
764  Size aSize( SvxPaperInfo::GetPaperSize( ePaper, eUnit ) );
765 
766  if ( bChecked )
767  Swap( aSize );
768 
769  pOld = GetOldItem( *rSet, SID_ATTR_PAGE_SIZE );
770 
771  if ( !pOld || static_cast<const SvxSizeItem*>(pOld)->GetSize() != aSize )
772  {
773  rSet->Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
774  bModified = true;
775  }
776  }
777  }
778 
779  nWhich = GetWhich( SID_ATTR_PAGE );
780  SvxPageItem aPage( static_cast<const SvxPageItem&>(rOldSet.Get( nWhich )) );
781  bMod = m_xLayoutBox->get_value_changed_from_saved();
782 
783  if ( bMod )
784  aPage.SetPageUsage(::PosToPageUsage_Impl(m_xLayoutBox->get_active()));
785 
786  if (m_xLandscapeBtn->get_state_changed_from_saved())
787  {
788  aPage.SetLandscape(bChecked);
789  bMod = true;
790  }
791 
792  //Get the NumType value
793  if (m_xNumberFormatBox->get_value_changed_from_saved())
794  {
795  SvxNumType nEntryData = m_xNumberFormatBox->get_active_id();
796  aPage.SetNumType( nEntryData );
797  bMod = true;
798  }
799 
800  if ( bMod )
801  {
802  pOld = GetOldItem( *rSet, SID_ATTR_PAGE );
803 
804  if ( !pOld || *static_cast<const SvxPageItem*>(pOld) != aPage )
805  {
806  rSet->Put( aPage );
807  bModified = true;
808  }
809  }
810  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich ) )
811  rSet->ClearItem( nWhich );
812  else
813  rSet->Put( rOldSet.Get( nWhich ) );
814 
815  // evaluate mode specific controls
816 
817  switch ( eMode )
818  {
820  {
821  if (m_xHorzBox->get_state_changed_from_saved())
822  {
823  SfxBoolItem aHorz( GetWhich( SID_ATTR_PAGE_EXT1 ),
824  m_xHorzBox->get_active() );
825  rSet->Put( aHorz );
826  bModified = true;
827  }
828 
829  if (m_xVertBox->get_state_changed_from_saved())
830  {
831  SfxBoolItem aVert( GetWhich( SID_ATTR_PAGE_EXT2 ),
832  m_xVertBox->get_active() );
833  rSet->Put( aVert );
834  bModified = true;
835  }
836  break;
837  }
838 
840  {
841  // always put so that draw can evaluate this
842  rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_PAGE_EXT1 ),
843  m_xAdaptBox->get_active() ) );
844  bModified = true;
845  break;
846  }
847  default: ;//prevent warning
848 
849  }
850 
851  if (m_xRegisterCB->get_visible() &&
852  (m_xRegisterCB->get_active() || m_xRegisterCB->get_state_changed_from_saved()))
853  {
854  const SfxBoolItem& rRegItem = rOldSet.Get(SID_SWREGISTER_MODE);
855  std::unique_ptr<SfxBoolItem> pRegItem(rRegItem.Clone());
856  bool bCheck = m_xRegisterCB->get_active();
857  pRegItem->SetValue(bCheck);
858  rSet->Put(std::move(pRegItem));
859  bModified = true;
860  if(bCheck)
861  {
862  bModified = true;
863  rSet->Put(SfxStringItem(SID_SWREGISTER_COLLECTION,
864  m_xRegisterLB->get_active_text()));
865  }
866  }
867 
868  if (m_xTextFlowBox->get_visible() && m_xTextFlowBox->get_value_changed_from_saved())
869  {
870  SvxFrameDirection eDirection = m_xTextFlowBox->get_active_id();
871  rSet->Put( SvxFrameDirectionItem( eDirection, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
872  bModified = true;
873  }
874 
875  return bModified;
876 }
877 
879 {
880  // switch inside outside
881  const SvxPageUsage nUsage = PosToPageUsage_Impl(m_xLayoutBox->get_active());
882 
883  if (nUsage == SvxPageUsage::Mirror)
884  {
885  m_xLeftMarginLbl->hide();
886  m_xRightMarginLbl->hide();
887  m_xInsideLbl->show();
888  m_xOutsideLbl->show();
889  }
890  else
891  {
892  m_xLeftMarginLbl->show();
893  m_xRightMarginLbl->show();
894  m_xInsideLbl->hide();
895  m_xOutsideLbl->hide();
896  }
897  UpdateExample_Impl( true );
898 }
899 
900 IMPL_LINK_NOARG(SvxPageDescPage, GutterPositionHdl_Impl, weld::ComboBox&, void)
901 {
902  UpdateExample_Impl(true);
903 }
904 
905 IMPL_LINK_NOARG(SvxPageDescPage, PaperBinHdl_Impl, weld::Widget&, void)
906 {
907  // tdf#124226 disconnect so not called again, unless Reset occurs
908  m_xPaperTrayBox->connect_focus_in(Link<weld::Widget&, void>());
909 
910  OUString aOldName = m_xPaperTrayBox->get_active_text();
911  m_xPaperTrayBox->freeze();
912  m_xPaperTrayBox->clear();
913  m_xPaperTrayBox->append(OUString::number(PAPERBIN_PRINTER_SETTINGS), EditResId(RID_SVXSTR_PAPERBIN_SETTINGS));
914  OUString aPaperBin(EditResId(RID_SVXSTR_PAPERBIN));
915  const sal_uInt16 nBinCount = mpDefPrinter->GetPaperBinCount();
916 
917  for (sal_uInt16 i = 0; i < nBinCount; ++i)
918  {
919  OUString aName = mpDefPrinter->GetPaperBinName(i);
920  if (aName.isEmpty())
921  {
922  aName = aPaperBin + " " + OUString::number( i+1 );
923  }
924  m_xPaperTrayBox->append(OUString::number(i), aName);
925  }
926  m_xPaperTrayBox->set_active_text(aOldName);
927  m_xPaperTrayBox->thaw();
928 
929  // tdf#123650 explicitly grab-focus after the modification otherwise gtk loses track
930  // of there the focus should be
931  m_xPaperTrayBox->grab_focus();
932 }
933 
934 IMPL_LINK_NOARG(SvxPageDescPage, PaperSizeSelect_Impl, weld::ComboBox&, void)
935 {
936  Paper ePaper = m_xPaperSizeBox->get_active_id();
937 
938  if ( ePaper == PAPER_USER )
939  return;
940 
941  Size aSize( SvxPaperInfo::GetPaperSize( ePaper, MapUnit::Map100thMM ) );
942 
943  if (m_xLandscapeBtn->get_active())
944  Swap( aSize );
945 
946  if ( aSize.Height() < m_xPaperHeightEdit->get_min( FieldUnit::MM_100TH ) )
947  m_xPaperHeightEdit->set_min(
948  m_xPaperHeightEdit->normalize( aSize.Height() ), FieldUnit::MM_100TH );
949  if ( aSize.Width() < m_xPaperWidthEdit->get_min( FieldUnit::MM_100TH ) )
950  m_xPaperWidthEdit->set_min(
951  m_xPaperWidthEdit->normalize( aSize.Width() ), FieldUnit::MM_100TH );
952  SetMetricValue( *m_xPaperHeightEdit, aSize.Height(), MapUnit::Map100thMM );
953  SetMetricValue( *m_xPaperWidthEdit, aSize.Width(), MapUnit::Map100thMM );
954 
955  CalcMargin_Impl();
956 
957  RangeHdl_Impl();
958  UpdateExample_Impl( true );
959 
961  return;
962 
963  // Draw: if paper format the margin shall be 1 cm
964  tools::Long nTmp = 0;
965  bool bScreen = (( PAPER_SCREEN_4_3 == ePaper )||( PAPER_SCREEN_16_9 == ePaper)||( PAPER_SCREEN_16_10 == ePaper)||( PAPER_WIDESCREEN == ePaper)||( PAPER_ONSCREENSHOW_4_3 == ePaper)||( PAPER_ONSCREENSHOW_16_9 == ePaper)||( PAPER_ONSCREENSHOW_16_10 == ePaper));
966 
967  if ( !bScreen )
968  // no margin if screen
969  nTmp = 1; // accordingly 1 cm
970 
971  if ( bScreen || m_xRightMarginEdit->get_value(FieldUnit::NONE) == 0 )
972  SetMetricValue( *m_xRightMarginEdit, nTmp, MapUnit::MapCM );
973  if ( bScreen || m_xLeftMarginEdit->get_value(FieldUnit::NONE) == 0 )
974  SetMetricValue( *m_xLeftMarginEdit, nTmp, MapUnit::MapCM );
975  if ( bScreen || m_xBottomMarginEdit->get_value(FieldUnit::NONE) == 0 )
976  SetMetricValue( *m_xBottomMarginEdit, nTmp, MapUnit::MapCM );
977  if ( bScreen || m_xTopMarginEdit->get_value(FieldUnit::NONE) == 0 )
978  SetMetricValue( *m_xTopMarginEdit, nTmp, MapUnit::MapCM );
979  UpdateExample_Impl( true );
980 }
981 
983 {
984  sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE );
985  MapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWhich );
986  Size aSize( GetCoreValue( *m_xPaperWidthEdit, eUnit ),
987  GetCoreValue( *m_xPaperHeightEdit, eUnit ) );
988 
989  if ( aSize.Width() > aSize.Height() )
990  {
991  m_xLandscapeBtn->set_active(true);
992  bLandscape = true;
993  }
994  else
995  {
996  m_xPortraitBtn->set_active(true);
997  bLandscape = false;
998  }
999 
1000  Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, eUnit );
1001  m_xPaperSizeBox->set_active_id( ePaper );
1002  UpdateExample_Impl( true );
1003 
1004  RangeHdl_Impl();
1005 }
1006 
1007 IMPL_LINK(SvxPageDescPage, SwapOrientation_Impl, weld::Toggleable&, rBtn, void)
1008 {
1009  if (!rBtn.get_active())
1010  return;
1011 
1012  bLandscape = m_xLandscapeBtn->get_active();
1013 
1014  const tools::Long lWidth = GetCoreValue( *m_xPaperWidthEdit, MapUnit::Map100thMM );
1015  const tools::Long lHeight = GetCoreValue( *m_xPaperHeightEdit, MapUnit::Map100thMM );
1016 
1017  // swap width and height
1018  SetMetricValue(*m_xPaperWidthEdit, lHeight, MapUnit::Map100thMM);
1019  SetMetricValue(*m_xPaperHeightEdit, lWidth, MapUnit::Map100thMM);
1020 
1021  // recalculate margins if necessary
1022  CalcMargin_Impl();
1023 
1024  PaperSizeSelect_Impl(m_xPaperSizeBox->get_widget());
1025  RangeHdl_Impl();
1026  SwapFirstValues_Impl(bBorderModified);
1027  UpdateExample_Impl(true);
1028 }
1029 
1031 {
1032  MapMode aOldMode = mpDefPrinter->GetMapMode();
1033  Orientation eOri = Orientation::Portrait;
1034 
1035  if ( bLandscape )
1036  eOri = Orientation::Landscape;
1038  mpDefPrinter->SetOrientation( eOri );
1039  mpDefPrinter->SetMapMode(MapMode(MapUnit::MapTwip));
1040 
1041  // set first- and last-values for margins
1042  Size aPaperSize = mpDefPrinter->GetPaperSize();
1043  Size aPrintSize = mpDefPrinter->GetOutputSize();
1044  /*
1045  * To convert a point ( 0,0 ) into logic coordinates
1046  * looks like nonsense; but it makes sense if the
1047  * coordinate system's origin has been moved.
1048  */
1049  Point aPrintOffset = mpDefPrinter->GetPageOffset() - mpDefPrinter->PixelToLogic( Point() );
1050  mpDefPrinter->SetMapMode( aOldMode );
1051  mpDefPrinter->SetOrientation( eOldOri );
1052 
1053  sal_Int64 nSetL = m_xLeftMarginEdit->denormalize(
1054  m_xLeftMarginEdit->get_value( FieldUnit::TWIP ) );
1055  sal_Int64 nSetR = m_xRightMarginEdit->denormalize(
1056  m_xRightMarginEdit->get_value( FieldUnit::TWIP ) );
1057  sal_Int64 nSetT = m_xTopMarginEdit->denormalize(
1058  m_xTopMarginEdit->get_value( FieldUnit::TWIP ) );
1059  sal_Int64 nSetB = m_xBottomMarginEdit->denormalize(
1060  m_xBottomMarginEdit->get_value( FieldUnit::TWIP ) );
1061 
1062  tools::Long nNewL = aPrintOffset.X();
1063  tools::Long nNewR = aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X();
1064  tools::Long nNewT = aPrintOffset.Y();
1065  tools::Long nNewB = aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y();
1066 
1067  nFirstLeftMargin = m_xLeftMarginEdit->convert_value_from(m_xLeftMarginEdit->normalize(nNewL), FieldUnit::TWIP);
1068  nFirstRightMargin = m_xRightMarginEdit->convert_value_from(m_xRightMarginEdit->normalize(nNewR), FieldUnit::TWIP);
1069  nFirstTopMargin = m_xTopMarginEdit->convert_value_from(m_xTopMarginEdit->normalize(nNewT), FieldUnit::TWIP);
1070  nFirstBottomMargin = m_xBottomMarginEdit->convert_value_from(m_xBottomMarginEdit->normalize(nNewB), FieldUnit::TWIP);
1071 
1072  if ( !bSet )
1073  return;
1074 
1075  if ( nSetL < nNewL )
1076  m_xLeftMarginEdit->set_value( m_xLeftMarginEdit->normalize( nNewL ),
1077  FieldUnit::TWIP );
1078  if ( nSetR < nNewR )
1079  m_xRightMarginEdit->set_value( m_xRightMarginEdit->normalize( nNewR ),
1080  FieldUnit::TWIP );
1081  if ( nSetT < nNewT )
1082  m_xTopMarginEdit->set_value( m_xTopMarginEdit->normalize( nNewT ),
1083  FieldUnit::TWIP );
1084  if ( nSetB < nNewB )
1085  m_xBottomMarginEdit->set_value( m_xBottomMarginEdit->normalize( nNewB ),
1086  FieldUnit::TWIP );
1087 }
1088 
1090 {
1091  if ( !bBorderModified )
1092  bBorderModified = true;
1093  UpdateExample_Impl();
1094 
1095  RangeHdl_Impl();
1096 }
1097 
1098 void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground )
1099 {
1100  // Size
1101  Size aSize( GetCoreValue( *m_xPaperWidthEdit, MapUnit::MapTwip ),
1102  GetCoreValue( *m_xPaperHeightEdit, MapUnit::MapTwip ) );
1103 
1104  m_aBspWin.SetSize( aSize );
1105 
1106  // Margins
1107  bool bGutterAtTop = m_xGutterPositionLB->get_active() == 1;
1108  tools::Long nTop = GetCoreValue(*m_xTopMarginEdit, MapUnit::MapTwip);
1109  if (bGutterAtTop)
1110  {
1111  nTop += GetCoreValue(*m_xGutterMarginEdit, MapUnit::MapTwip);
1112  }
1113  m_aBspWin.SetTop(nTop);
1114  m_aBspWin.SetBottom( GetCoreValue( *m_xBottomMarginEdit, MapUnit::MapTwip ) );
1115  tools::Long nLeft = GetCoreValue(*m_xLeftMarginEdit, MapUnit::MapTwip);
1116  if (!bGutterAtTop)
1117  {
1118  nLeft += GetCoreValue(*m_xGutterMarginEdit, MapUnit::MapTwip);
1119  }
1120  m_aBspWin.SetLeft(nLeft);
1121  m_aBspWin.SetRight( GetCoreValue( *m_xRightMarginEdit, MapUnit::MapTwip ) );
1122 
1123  // Layout
1125  if ( bResetbackground )
1127  m_aBspWin.Invalidate();
1128 }
1129 
1130 
1132 {
1133  sal_uInt16 nWhich(GetWhich(SID_ATTR_PAGE_HEADERSET));
1134 
1135  if (SfxItemState::SET == rSet.GetItemState(nWhich, false))
1136  {
1137  const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, false));
1138  const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1139  const SfxBoolItem& rOn = rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON));
1140 
1141  if(rOn.GetValue())
1142  {
1144 
1146  {
1147  // create FillAttributes directly from DrawingLayer FillStyle entries
1148  aHeaderFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(rTmpSet);
1149  }
1150  else
1151  {
1152  nWhich = GetWhich(SID_ATTR_BRUSH);
1153 
1154  if(SfxItemState::SET == rTmpSet.GetItemState(nWhich))
1155  {
1156  // create FillAttributes from SvxBrushItem
1157  const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich));
1159 
1161  aHeaderFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(aTempSet);
1162  }
1163  }
1164 
1165  m_aBspWin.setHeaderFillAttributes(aHeaderFillAttributes);
1166  }
1167  }
1168 
1169  nWhich = GetWhich(SID_ATTR_PAGE_FOOTERSET);
1170 
1171  if (SfxItemState::SET == rSet.GetItemState(nWhich, false))
1172  {
1173  const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich,false));
1174  const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1175  const SfxBoolItem& rOn = rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON));
1176 
1177  if(rOn.GetValue())
1178  {
1180 
1182  {
1183  // create FillAttributes directly from DrawingLayer FillStyle entries
1184  aFooterFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(rTmpSet);
1185  }
1186  else
1187  {
1188  nWhich = GetWhich(SID_ATTR_BRUSH);
1189 
1190  if(SfxItemState::SET == rTmpSet.GetItemState(nWhich))
1191  {
1192  // create FillAttributes from SvxBrushItem
1193  const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich));
1195 
1197  aFooterFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(aTempSet);
1198  }
1199  }
1200 
1201  m_aBspWin.setFooterFillAttributes(aFooterFillAttributes);
1202  }
1203  }
1204 
1206 
1208  {
1209  // create FillAttributes directly from DrawingLayer FillStyle entries
1210  aPageFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(rSet);
1211  }
1212  else
1213  {
1214  const SfxPoolItem* pItem = GetItem(rSet, SID_ATTR_BRUSH);
1215 
1216  if(pItem)
1217  {
1218  // create FillAttributes from SvxBrushItem
1219  const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(*pItem);
1221 
1223  aPageFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(aTempSet);
1224  }
1225  }
1226 
1227  m_aBspWin.setPageFillAttributes(aPageFillAttributes);
1228 }
1229 
1231 {
1232  bLandscape = m_xLandscapeBtn->get_active();
1233  const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
1234 
1235  if ( pItem )
1236  m_aBspWin.SetSize( static_cast<const SvxSizeItem*>(pItem)->GetSize() );
1237 
1238  const SvxSetItem* pSetItem = nullptr;
1239 
1240  // evaluate header attributes
1241 
1242  if ( SfxItemState::SET ==
1243  rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ),
1244  false, reinterpret_cast<const SfxPoolItem**>(&pSetItem) ) )
1245  {
1246  const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
1247  const SfxBoolItem& rHeaderOn =
1248  rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1249 
1250  if ( rHeaderOn.GetValue() )
1251  {
1252  const SvxSizeItem& rSize =
1253  rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1254  const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(
1255  rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) ));
1256  tools::Long nDist = rUL.GetLower();
1257  m_aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist );
1258  m_aBspWin.SetHdDist( nDist );
1259  const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(
1260  rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
1261  m_aBspWin.SetHdLeft( rLR.GetLeft() );
1262  m_aBspWin.SetHdRight( rLR.GetRight() );
1263  m_aBspWin.SetHeader( true );
1264  }
1265  else
1266  m_aBspWin.SetHeader( false );
1267 
1268  // show background and border in the example
1270 
1272  {
1273  // create FillAttributes directly from DrawingLayer FillStyle entries
1274  aHeaderFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(rHeaderSet);
1275  }
1276  else
1277  {
1278  const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH));
1279 
1280  if(rHeaderSet.GetItemState(nWhich) >= SfxItemState::DEFAULT)
1281  {
1282  // aBspWin.SetHdColor(rItem.GetColor());
1283  const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rHeaderSet.Get(nWhich));
1285 
1287  aHeaderFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(aTempSet);
1288  }
1289  }
1290 
1291  m_aBspWin.setHeaderFillAttributes(aHeaderFillAttributes);
1292  }
1293 
1294  // evaluate footer attributes
1295 
1296  if ( SfxItemState::SET !=
1297  rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ),
1298  false, reinterpret_cast<const SfxPoolItem**>(&pSetItem) ) )
1299  return;
1300 
1301  const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
1302  const SfxBoolItem& rFooterOn =
1303  rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1304 
1305  if ( rFooterOn.GetValue() )
1306  {
1307  const SvxSizeItem& rSize =
1308  rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1309  const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(
1310  rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) ));
1311  tools::Long nDist = rUL.GetUpper();
1312  m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist );
1313  m_aBspWin.SetFtDist( nDist );
1314  const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(
1315  rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
1316  m_aBspWin.SetFtLeft( rLR.GetLeft() );
1317  m_aBspWin.SetFtRight( rLR.GetRight() );
1318  m_aBspWin.SetFooter( true );
1319  }
1320  else
1321  m_aBspWin.SetFooter( false );
1322 
1323  // show background and border in the example
1325 
1327  {
1328  // create FillAttributes directly from DrawingLayer FillStyle entries
1329  aFooterFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(rFooterSet);
1330  }
1331  else
1332  {
1333  const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH));
1334 
1335  if(rFooterSet.GetItemState(nWhich) >= SfxItemState::DEFAULT)
1336  {
1337  // aBspWin.SetFtColor(rItem.GetColor());
1338  const SvxBrushItem& rItem = static_cast<const SvxBrushItem&>(rFooterSet.Get(nWhich));
1340 
1342  aFooterFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(aTempSet);
1343  }
1344  }
1345 
1346  m_aBspWin.setFooterFillAttributes(aFooterFillAttributes);
1347 }
1348 
1350 {
1351  InitHeadFoot_Impl( rSet );
1353  ResetBackground_Impl( rSet );
1354  RangeHdl_Impl();
1355 }
1356 
1358 {
1359  // Inquiry whether the page margins are beyond the printing area.
1360  // If not, ask user whether they shall be taken.
1361  // If not, stay on the TabPage.
1362  Paper ePaper = m_xPaperSizeBox->get_active_id();
1363 
1364  if ( ePaper != PAPER_SCREEN_4_3 && ePaper != PAPER_SCREEN_16_9 && ePaper != PAPER_SCREEN_16_10 && ePaper != PAPER_WIDESCREEN && ePaper != PAPER_ONSCREENSHOW_4_3 && ePaper != PAPER_ONSCREENSHOW_16_9 && ePaper != PAPER_ONSCREENSHOW_16_10 && IsMarginOutOfRange() )
1365  {
1366  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
1367  VclMessageType::Question, VclButtonsType::YesNo,
1368  m_xPrintRangeQueryText->get_label()));
1369  xQueryBox->set_default_response(RET_NO);
1370  if (xQueryBox->run() == RET_NO)
1371  {
1372  weld::MetricSpinButton* pField = nullptr;
1374  pField = m_xLeftMarginEdit.get();
1376  && !pField )
1377  pField = m_xRightMarginEdit.get();
1379  && !pField )
1380  pField = m_xTopMarginEdit.get();
1382  && !pField )
1383  pField = m_xBottomMarginEdit.get();
1384  if ( pField )
1385  pField->grab_focus();
1387  return DeactivateRC::KeepPage;
1388  }
1389  else
1390  CheckMarginEdits( false );
1391  }
1392 
1393  if ( _pSet )
1394  {
1395  FillItemSet( _pSet );
1396 
1397  // put portray/landscape if applicable
1398  sal_uInt16 nWh = GetWhich( SID_ATTR_PAGE_SIZE );
1399  MapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWh );
1400  Size aSize( GetCoreValue( *m_xPaperWidthEdit, eUnit ),
1401  GetCoreValue( *m_xPaperHeightEdit, eUnit ) );
1402 
1403  // put, if current size is different to the value in _pSet
1404  const SvxSizeItem* pSize = GetItem( *_pSet, SID_ATTR_PAGE_SIZE );
1405  if ( aSize.Width() && ( !pSize || !IsEqualSize_Impl( pSize, aSize ) ) )
1406  _pSet->Put( SvxSizeItem( nWh, aSize ) );
1407  }
1408 
1409  return DeactivateRC::LeavePage;
1410 }
1411 
1413 {
1414  // example window
1415  tools::Long nHHeight = m_aBspWin.GetHdHeight();
1416  tools::Long nHDist = m_aBspWin.GetHdDist();
1417 
1418  tools::Long nFHeight = m_aBspWin.GetFtHeight();
1419  tools::Long nFDist = m_aBspWin.GetFtDist();
1420 
1421  tools::Long nHFLeft = std::max(m_aBspWin.GetHdLeft(), m_aBspWin.GetFtLeft());
1422  tools::Long nHFRight = std::max(m_aBspWin.GetHdRight(), m_aBspWin.GetFtRight());
1423 
1424  // current values for page margins
1425  tools::Long nBT = static_cast<tools::Long>(m_xTopMarginEdit->denormalize(m_xTopMarginEdit->get_value(FieldUnit::TWIP)));
1426  tools::Long nBB = static_cast<tools::Long>(m_xBottomMarginEdit->denormalize(m_xBottomMarginEdit->get_value(FieldUnit::TWIP)));
1427  tools::Long nBL = static_cast<tools::Long>(m_xLeftMarginEdit->denormalize(m_xLeftMarginEdit->get_value(FieldUnit::TWIP)));
1428  tools::Long nBR = static_cast<tools::Long>(m_xRightMarginEdit->denormalize(m_xRightMarginEdit->get_value(FieldUnit::TWIP)));
1429 
1430  // calculate width of page border
1431  const SfxItemSet* _pSet = &GetItemSet();
1432  Size aBorder;
1433 
1434  if ( _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW) ) >=
1435  SfxItemState::DEFAULT &&
1436  _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER) ) >=
1437  SfxItemState::DEFAULT )
1438  {
1439  aBorder = GetMinBorderSpace_Impl(
1440  static_cast<const SvxShadowItem&>(_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW))),
1441  static_cast<const SvxBoxItem&>(_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER))));
1442  }
1443 
1444  // limits paper
1445  // maximum is 54 cm
1446 
1447  tools::Long nMin = nHHeight + nHDist + nFDist + nFHeight + nBT + nBB +
1448  MINBODY + aBorder.Height();
1449  m_xPaperHeightEdit->set_min(m_xPaperHeightEdit->normalize(nMin), FieldUnit::TWIP);
1450 
1451  nMin = MINBODY + nBL + nBR + aBorder.Width();
1452  m_xPaperWidthEdit->set_min(m_xPaperWidthEdit->normalize(nMin), FieldUnit::TWIP);
1453 
1454  tools::Long nH = static_cast<tools::Long>(m_xPaperHeightEdit->denormalize(m_xPaperHeightEdit->get_value(FieldUnit::TWIP)));
1455  tools::Long nW = static_cast<tools::Long>(m_xPaperWidthEdit->denormalize(m_xPaperWidthEdit->get_value(FieldUnit::TWIP)));
1456 
1457  // Top
1458  tools::Long nMax = nH - nBB - aBorder.Height() - MINBODY -
1459  nFDist - nFHeight - nHDist - nHHeight;
1460 
1461  m_xTopMarginEdit->set_max(m_xTopMarginEdit->normalize(nMax), FieldUnit::TWIP);
1462 
1463  // Bottom
1464  nMax = nH - nBT - aBorder.Height() - MINBODY -
1465  nFDist - nFHeight - nHDist - nHHeight;
1466 
1467  m_xBottomMarginEdit->set_max(m_xTopMarginEdit->normalize(nMax), FieldUnit::TWIP);
1468 
1469  // Left
1470  nMax = nW - nBR - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1471  m_xLeftMarginEdit->set_max(m_xLeftMarginEdit->normalize(nMax), FieldUnit::TWIP);
1472 
1473  // Right
1474  nMax = nW - nBL - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1475  m_xRightMarginEdit->set_max(m_xRightMarginEdit->normalize(nMax), FieldUnit::TWIP);
1476 }
1477 
1479 {
1480  // current values for page margins
1481  tools::Long nBT = GetCoreValue( *m_xTopMarginEdit, MapUnit::MapTwip );
1482  tools::Long nBB = GetCoreValue( *m_xBottomMarginEdit, MapUnit::MapTwip );
1483 
1484  tools::Long nBL = GetCoreValue( *m_xLeftMarginEdit, MapUnit::MapTwip );
1485  tools::Long nBR = GetCoreValue( *m_xRightMarginEdit, MapUnit::MapTwip );
1486 
1487  tools::Long nH = GetCoreValue( *m_xPaperHeightEdit, MapUnit::MapTwip );
1488  tools::Long nW = GetCoreValue( *m_xPaperWidthEdit, MapUnit::MapTwip );
1489 
1490  tools::Long nWidth = nBL + nBR + MINBODY;
1491  tools::Long nHeight = nBT + nBB + MINBODY;
1492 
1493  if ( nWidth <= nW && nHeight <= nH )
1494  return;
1495 
1496  if ( nWidth > nW )
1497  {
1498  tools::Long nTmp = nBL <= nBR ? nBR : nBL;
1499  nTmp -= nWidth - nW;
1500 
1501  if ( nBL <= nBR )
1502  SetMetricValue( *m_xRightMarginEdit, nTmp, MapUnit::MapTwip );
1503  else
1504  SetMetricValue( *m_xLeftMarginEdit, nTmp, MapUnit::MapTwip );
1505  }
1506 
1507  if ( nHeight > nH )
1508  {
1509  tools::Long nTmp = nBT <= nBB ? nBB : nBT;
1510  nTmp -= nHeight - nH;
1511 
1512  if ( nBT <= nBB )
1513  SetMetricValue( *m_xBottomMarginEdit, nTmp, MapUnit::MapTwip );
1514  else
1515  SetMetricValue( *m_xTopMarginEdit, nTmp, MapUnit::MapTwip );
1516  }
1517 }
1518 
1520 {
1521  m_aBspWin.SetHorz(m_xHorzBox->get_active());
1522  m_aBspWin.SetVert(m_xVertBox->get_active());
1523  UpdateExample_Impl();
1524 }
1525 
1526 void SvxPageDescPage::SetCollectionList(const std::vector<OUString> &aList)
1527 {
1528  OSL_ENSURE(!aList.empty(), "Empty string list");
1529 
1530  sStandardRegister = aList[0];
1531  m_xRegisterLB->freeze();
1532  for (size_t i = 1; i < aList.size(); ++i)
1533  m_xRegisterLB->append_text(aList[i]);
1534  m_xRegisterLB->thaw();
1535 
1536  m_xRegisterCB->show();
1537  m_xRegisterFT->show();
1538  m_xRegisterLB->show();
1539  m_xRegisterCB->connect_toggled(LINK(this, SvxPageDescPage, RegisterModify));
1540 }
1541 
1542 IMPL_LINK(SvxPageDescPage, RegisterModify, weld::Toggleable&, rBox, void)
1543 {
1544  bool bEnable = false;
1545  if (rBox.get_active())
1546  {
1547  bEnable = true;
1548  if (m_xRegisterLB->get_active() == -1)
1549  m_xRegisterLB->set_active_text(sStandardRegister);
1550  }
1551  m_xRegisterFT->set_sensitive(bEnable);
1552  m_xRegisterLB->set_sensitive(bEnable);
1553 }
1554 
1556 {
1557  m_xTextFlowBox->remove_id(SvxFrameDirection::Vertical_RL_TB);
1558  m_xTextFlowBox->remove_id(SvxFrameDirection::Vertical_LR_TB);
1559  if (m_xTextFlowBox->get_count() < 2)
1560  {
1561  m_xTextFlowLbl->hide();
1562  m_xTextFlowBox->hide();
1564  }
1565 }
1566 
1567 IMPL_LINK_NOARG(SvxPageDescPage, FrameDirectionModify_Impl, weld::ComboBox&, void)
1568 {
1569  m_aBspWin.SetFrameDirection(m_xTextFlowBox->get_active_id());
1570  m_aBspWin.Invalidate();
1571 }
1572 
1574  weld::MetricSpinButton& rField, tools::Long nFirstMargin, tools::Long nLastMargin, MarginPosition nPos )
1575 {
1576  bool bRet = false;
1577  bool bCheck = ( ( m_nPos & nPos ) == 0 );
1578  tools::Long nValue = rField.get_value(FieldUnit::NONE);
1579  if ( bCheck &&
1580  ( nValue < nFirstMargin || nValue > nLastMargin ) &&
1581  rField.get_value_changed_from_saved() )
1582  {
1583  rField.set_value(nValue < nFirstMargin ? nFirstMargin : nLastMargin, FieldUnit::NONE);
1584  bRet = true;
1585  }
1586 
1587  return bRet;
1588 }
1589 
1594 {
1595  if ( _bClear )
1596  m_nPos = 0;
1597 
1598  sal_Int64 nValue = m_xLeftMarginEdit->get_value(FieldUnit::NONE);
1599  if ( nValue < nFirstLeftMargin || nValue > nLastLeftMargin )
1600  m_nPos |= MARGIN_LEFT;
1601  nValue = m_xRightMarginEdit->get_value(FieldUnit::NONE);
1602  if ( nValue < nFirstRightMargin || nValue > nLastRightMargin )
1603  m_nPos |= MARGIN_RIGHT;
1604  nValue = m_xTopMarginEdit->get_value(FieldUnit::NONE);
1605  if ( nValue < nFirstTopMargin || nValue > nLastTopMargin )
1606  m_nPos |= MARGIN_TOP;
1607  nValue = m_xBottomMarginEdit->get_value(FieldUnit::NONE);
1608  if ( nValue < nFirstBottomMargin || nValue > nLastBottomMargin )
1609  m_nPos |= MARGIN_BOTTOM;
1610 }
1611 
1613 {
1614  bool bRet = ( ( ( !( m_nPos & MARGIN_LEFT ) &&
1615  m_xLeftMarginEdit->get_value_changed_from_saved() ) &&
1616  ( m_xLeftMarginEdit->get_value(FieldUnit::NONE) < nFirstLeftMargin ||
1617  m_xLeftMarginEdit->get_value(FieldUnit::NONE) > nLastLeftMargin ) ) ||
1618  ( ( !( m_nPos & MARGIN_RIGHT ) &&
1619  m_xRightMarginEdit->get_value_changed_from_saved() ) &&
1620  ( m_xRightMarginEdit->get_value(FieldUnit::NONE) < nFirstRightMargin ||
1621  m_xRightMarginEdit->get_value(FieldUnit::NONE) > nLastRightMargin ) ) ||
1622  ( ( !( m_nPos & MARGIN_TOP ) &&
1623  m_xTopMarginEdit->get_value_changed_from_saved() ) &&
1624  ( m_xTopMarginEdit->get_value(FieldUnit::NONE) < nFirstTopMargin ||
1625  m_xTopMarginEdit->get_value(FieldUnit::NONE) > nLastTopMargin ) ) ||
1626  ( ( !( m_nPos & MARGIN_BOTTOM ) &&
1627  m_xBottomMarginEdit->get_value_changed_from_saved() ) &&
1628  ( m_xBottomMarginEdit->get_value(FieldUnit::NONE) < nFirstBottomMargin ||
1629  m_xBottomMarginEdit->get_value(FieldUnit::NONE) > nLastBottomMargin ) ) );
1630  return bRet;
1631 }
1632 
1634 {
1635  const SfxUInt16Item* pModeItem = aSet.GetItem(SID_ENUM_PAGE_MODE, false);
1636  const SfxUInt16Item* pPaperStartItem = aSet.GetItem(SID_PAPER_START, false);
1637  const SfxUInt16Item* pPaperEndItem = aSet.GetItem(SID_PAPER_END, false);
1638  const SfxStringListItem* pCollectListItem = aSet.GetItem<SfxStringListItem>(SID_COLLECT_LIST, false);
1639  const SfxBoolItem* pSupportDrawingLayerFillStyleItem = aSet.GetItem<SfxBoolItem>(SID_DRAWINGLAYER_FILLSTYLES, false);
1640  const SfxBoolItem* pIsImpressDoc = aSet.GetItem<SfxBoolItem>(SID_IMPRESS_DOC, false);
1641 
1642  if (pModeItem)
1643  {
1644  eMode = static_cast<SvxModeType>(pModeItem->GetValue());
1645  }
1646 
1647  if(pPaperStartItem && pPaperEndItem)
1648  {
1649  SetPaperFormatRanges(static_cast<Paper>(pPaperStartItem->GetValue()));
1650  }
1651 
1652  if(pCollectListItem)
1653  {
1654  SetCollectionList(pCollectListItem->GetList());
1655  }
1656 
1657  if(pSupportDrawingLayerFillStyleItem)
1658  {
1659  const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue());
1660 
1662  }
1663 
1664  if (pIsImpressDoc)
1665  m_xNumberFormatText->set_label(SvxResId(STR_SLIDE_NUMBERS));
1666 }
1667 
1668 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsLandscape() const
bool GetValue() const
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
#define MARGIN_LEFT
Definition: page.cxx:128
SVX_PAGE_MODE_PRESENTATION
FieldUnit
void SetMetricValue(weld::MetricSpinButton &rField, sal_Int64 nCoreValue, MapUnit eUnit)
sal_uInt16 GetPaperBinCount() const
std::unique_ptr< weld::CheckButton > m_xBackgroundFullSizeCB
Definition: page.hxx:129
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
std::unique_ptr< weld::MetricSpinButton > m_xPaperWidthEdit
Definition: page.hxx:94
#define MARGIN_BOTTOM
Definition: page.cxx:131
std::unique_ptr< weld::Label > m_xGutterMarginLbl
Definition: page.hxx:109
Size & Swap(Size &rSize)
size_t m_nPos
virtual SfxBoolItem * Clone(SfxItemPool *=nullptr) const override
void setHeaderFillAttributes(const drawinglayer::attribute::SdrAllFillAttributesHelperPtr &rFillAttributes)
void SetPageUsage(SvxPageUsage eU)
sal_uInt16 GetLower() const
void SetUserData(const OUString &rString)
constexpr auto toTwips(N number, Length from)
void SetFooter(bool bNew)
void setWidth(tools::Long nWidth)
void set_value(sal_Int64 nValue, FieldUnit eValueUnit)
static constexpr auto Items
std::unique_ptr< weld::RadioButton > m_xPortraitBtn
Definition: page.hxx:97
std::unique_ptr< weld::MetricSpinButton > m_xPaperHeightEdit
Definition: page.hxx:95
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
tools::Long GetFtLeft() const
PAPER_ONSCREENSHOW_4_3
void RangeHdl_Impl()
Definition: page.cxx:1412
void setPageFillAttributes(const drawinglayer::attribute::SdrAllFillAttributesHelperPtr &rFillAttributes)
#define MARGIN_TOP
Definition: page.cxx:130
long Long
tools::Long GetRight() const
bool mbDelPrinter
Definition: page.hxx:87
void SetFtHeight(tools::Long nNew)
tools::Long nFirstRightMargin
Definition: page.hxx:71
void SetHdHeight(tools::Long nNew)
void SetLandscape(bool bL)
static const WhichRangesContainer pRanges
Definition: page.hxx:67
sal_uInt16 MarginPosition
Definition: page.hxx:63
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: page.cxx:1357
std::unique_ptr< weld::MetricSpinButton > m_xRightMarginEdit
Definition: page.hxx:106
sal_uInt16 GetValue() const
SvxModeType eMode
Definition: page.hxx:81
const MapMode & GetMapMode() const
IMPL_LINK_NOARG(SvxPageDescPage, LayoutHdl_Impl, weld::ComboBox &, void)
Definition: page.cxx:878
SvxFrameDirection
static SfxObjectShell * Current()
void SetTop(tools::Long nNew)
tools::Long GetHdDist() const
tools::Long GetFtHeight() const
MarginPosition m_nPos
Definition: page.hxx:84
bool IsCTLFontEnabled() const
OUString sStandardRegister
Definition: page.hxx:69
PAPER_ONSCREENSHOW_16_9
Orientation GetOrientation() const
void SetMapMode()
std::unique_ptr< weld::Label > m_xRegisterFT
Definition: page.hxx:124
VclPtr< Printer > mpDefPrinter
Definition: page.hxx:85
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
std::unique_ptr< weld::Label > m_xNumberFormatText
Definition: page.hxx:114
tools::Long nLastBottomMargin
Definition: page.hxx:77
FieldUnit GetModuleFieldUnit(const SfxItemSet &rSet)
SvxNumType
std::unique_ptr< SvxPageNumberListBox > m_xNumberFormatBox
Definition: page.hxx:115
Point GetPageOffset() const
RET_NO
bool IsMarginOutOfRange() const
Definition: page.cxx:1612
constexpr tools::Long Width() const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
#define PAPERBIN_PRINTER_SETTINGS
void SetTable(bool bNew)
std::unique_ptr< SvxPaperSizeListBox > m_xPaperSizeBox
Definition: page.hxx:93
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: page.cxx:1349
void ResetBackground_Impl(const SfxItemSet &rSet)
Definition: page.cxx:1131
SvxNumType GetNumType() const
tools::Long GetGutterMargin() const
void SetFtRight(tools::Long nNew)
tools::Long GetFtDist() const
tools::Long nLastTopMargin
Definition: page.hxx:76
void Init_Impl()
Definition: page.cxx:307
static sal_uInt16 PageUsageToPos_Impl(SvxPageUsage nUsage)
Definition: page.cxx:81
void SetExchangeSupport()
void SetFtLeft(tools::Long nNew)
void SetGutterMargin(const tools::Long nGutterMargin)
OUString SvxResId(TranslateId aId)
void setFooterFillAttributes(const drawinglayer::attribute::SdrAllFillAttributesHelperPtr &rFillAttributes)
SvxPageWindow m_aBspWin
Definition: page.hxx:90
SVX_NUM_ARABIC
static SfxViewShell * Current()
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
void SetNumType(SvxNumType eNum)
Mode eMode
void ResetBackground()
void SetFrameDirection(SvxFrameDirection nDirection)
bool bLandscape
Definition: page.hxx:79
tools::Long GetHdHeight() const
static bool IsEqualSize_Impl(const SvxSizeItem *pSize, const Size &rSize)
Definition: page.cxx:114
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
void SetCollectionList(const std::vector< OUString > &aList)
Definition: page.cxx:1526
const SfxItemSet & GetItemSet() const
OUString GetPaperBinName(sal_uInt16 nPaperBin) const
std::unique_ptr< weld::Label > m_xGutterPositionFT
Definition: page.hxx:126
virtual tools::Long GetValue() const override
bool HasSupport(PrinterSupport eFeature) const
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
virtual ~SvxPageDescPage() override
Definition: page.cxx:298
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: page.cxx:135
Orientation
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
sal_uInt32 GetMaximumPaperTopMargin()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: page.cxx:1633
int i
tools::Long nFirstTopMargin
Definition: page.hxx:72
sal_uInt16 CalcShadowSpace(SvxShadowItemSide nShadow) const
void SetHeader(bool bNew)
tools::Long nLastLeftMargin
Definition: page.hxx:74
Size GetOutputSize() const
HTMLMODE_ON
tools::Long GetLeft() const
tools::Long nLastRightMargin
Definition: page.hxx:75
void SetFtDist(tools::Long nNew)
void SetBottom(tools::Long nNew)
sal_uInt32 GetMaximumPaperBottomMargin()
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
std::unique_ptr< weld::Label > m_xTextFlowLbl
Definition: page.hxx:99
void SetHdDist(tools::Long nNew)
void SetSize(const Size &rSize)
bool IsAsianTypographyEnabled()
void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem &rBrush, SfxItemSet &rToSet)
Paper ePaperStart
Definition: page.hxx:82
void UpdateExample_Impl(bool bResetbackground=false)
Definition: page.cxx:1098
static SvxPageUsage PosToPageUsage_Impl(sal_uInt16 nPos)
Definition: page.cxx:90
void SwapFirstValues_Impl(bool bSet)
Definition: page.cxx:1030
Paper
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
void SetHdRight(tools::Long nNew)
std::unique_ptr< weld::RadioButton > m_xLandscapeBtn
Definition: page.hxx:98
sal_uInt32 GetMaximumPaperLeftMargin()
PAPER_WIDESCREEN
std::unique_ptr< weld::ComboBox > m_xRegisterLB
Definition: page.hxx:125
bool get_value_changed_from_saved() const
SfxItemPool * GetPool() const
std::vector< OUString > & GetList()
SVX_PAGE_MODE_STANDARD
std::unique_ptr< weld::Label > m_xTblAlignFT
Definition: page.hxx:117
sal_Int64 get_value(FieldUnit eDestUnit) const
std::unique_ptr< weld::Label > m_xPageText
Definition: page.hxx:112
SvxPageUsage
sal_uInt32 GetMaximumPaperHeight()
std::unique_ptr< weld::CheckButton > m_xRtlGutterCB
Definition: page.hxx:128
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SvxModeType
PAPER_SCREEN_16_10
bool bBorderModified
Definition: page.hxx:80
PAPER_SCREEN_4_3
std::unique_ptr< weld::CheckButton > m_xHorzBox
Definition: page.hxx:118
SvxPageUsage GetPageUsage() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool IsPrinterRangeOverflow(weld::MetricSpinButton &rField, tools::Long nFirstMargin, tools::Long nLastMargin, MarginPosition nPos)
Definition: page.cxx:1573
SvxPageDescPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: page.cxx:140
PAPER_USER
weld::Window * GetFrameWeld() const
virtual bool FillItemSet(SfxItemSet *rOutSet) override
Definition: page.cxx:620
tools::Long GetHdRight() const
SfxItemState
std::unique_ptr< weld::MetricSpinButton > m_xGutterMarginEdit
Definition: page.hxx:110
virtual void FillUserData() override
Definition: page.cxx:613
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< weld::MetricSpinButton > m_xLeftMarginEdit
Definition: page.hxx:104
constexpr tools::Long Height() const
unsigned char sal_uInt8
sal_Int64 GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
#define GetWhich(nSlot)
void CheckMarginEdits(bool _bClear)
Check if a value of a margin edit is outside the printer paper margins and save this information...
Definition: page.cxx:1593
std::unique_ptr< weld::MetricSpinButton > m_xTopMarginEdit
Definition: page.hxx:107
bool SetOrientation(Orientation eOrient)
static Size GetMinBorderSpace_Impl(const SvxShadowItem &rShadow, const SvxBoxItem &rBox)
Definition: page.cxx:98
OUString aName
void SetPaperFormatRanges(Paper eStart)
Definition: page.hxx:183
std::unique_ptr< weld::MetricSpinButton > m_xBottomMarginEdit
Definition: page.hxx:108
std::unique_ptr< svx::FrameDirectionListBox > m_xTextFlowBox
Definition: page.hxx:100
tools::Long AdjustWidth(tools::Long n)
static VclPtr< reference_type > Create(Arg &&...arg)
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
tools::Long GetFtRight() const
bool mbEnableDrawingLayerFillStyles
Definition: page.hxx:88
PAPER_SCREEN_16_9
sal_uInt32 GetMaximumPaperRightMargin()
void CalcMargin_Impl()
Definition: page.cxx:1478
PAPER_A3
virtual SfxPrinter * GetPrinter(bool bCreate=false)
tools::Long AdjustHeight(tools::Long n)
const SvxPageUsage aArr[]
Definition: page.cxx:72
IMPL_LINK(SvxPageDescPage, SwapOrientation_Impl, weld::Toggleable &, rBtn, void)
Definition: page.cxx:1007
void SetLeft(tools::Long nNew)
sal_uInt16 CalcLineSpace(SvxBoxItemLine nLine, bool bEvenIfNoLine=false) const
void SetRight(tools::Long nNew)
DeactivateRC
void setHeight(tools::Long nHeight)
MapUnit
tools::Long nFirstLeftMargin
Definition: page.hxx:70
std::unique_ptr< weld::ComboBox > m_xGutterPositionLB
Definition: page.hxx:127
std::unique_ptr< weld::ComboBox > m_xLayoutBox
Definition: page.hxx:113
std::unique_ptr< weld::Label > m_xPrintRangeQueryText
Definition: page.hxx:132
void SetUsage(SvxPageUsage eU)
PAPER_ONSCREENSHOW_16_10
void SetHorz(bool bNew)
#define MARGIN_RIGHT
Definition: page.cxx:129
std::unique_ptr< weld::ComboBox > m_xPaperTrayBox
Definition: page.hxx:101
virtual void Reset(const SfxItemSet *rSet) override
Definition: page.cxx:330
static tools::Long ConvertLong_Impl(const tools::Long nIn, MapUnit eUnit)
Definition: page.cxx:109
constexpr tools::Long MINBODY
Definition: page.cxx:63
static void GetI18nNumbering(weld::ComboBox &rFmtLB, sal_uInt16 nDoNotRemove)
void InitHeadFoot_Impl(const SfxItemSet &rSet)
Definition: page.cxx:1230
void DisableVerticalPageDir()
Disables vertical page direction entries in the text flow listbox.
Definition: page.cxx:1555
std::unique_ptr< weld::CheckButton > m_xVertBox
Definition: page.hxx:119
SVX_PAGE_MODE_CENTER
sal_uInt32 GetMaximumPaperWidth()
void EnableFrameDirection(bool bEnable)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
tools::Long nFirstBottomMargin
Definition: page.hxx:73
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
std::unique_ptr< weld::CheckButton > m_xRegisterCB
Definition: page.hxx:123
void SetHdLeft(tools::Long nNew)
std::unique_ptr< weld::CheckButton > m_xAdaptBox
Definition: page.hxx:121
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
tools::Long GetHdLeft() const
void SetVert(bool bNew)
const Size & GetSize() const
sal_uInt16 nPos
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
sal_Int16 nValue
sal_uInt16 GetUpper() const
bool m_bDetectedRangeSegmentation false
static Paper GetSvxPaper(const Size &rSize, MapUnit eUnit)
OUString EditResId(TranslateId aId)
Size GetPaperSize() const