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