1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
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>
34 #include <svx/strings.hrc>
35 #include <svx/dialmgr.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>
52 #include <svtools/optionsdrawinglayer.hxx>
53 #include <svl/slstitm.hxx>
54 #include <svx/xdef.hxx>
55 #include <svx/unobrushitemhelper.hxx>
56 #include <svx/SvxNumOptionsTabPageHelper.hxx>
57 #include <sal/log.hxx>
58 #include <svl/grabbagitem.hxx>
60 // static ----------------------------------------------------------------
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
65 const WhichRangesContainer
SvxPageDescPage::pRanges(
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 ------------------------------------------
72 const SvxPageUsage aArr
[] =
81 static sal_uInt16
PageUsageToPos_Impl( SvxPageUsage nUsage
)
83 for ( size_t i
= 0; i
< std::size(aArr
); ++i
)
84 if ( aArr
[i
] == nUsage
)
90 static SvxPageUsage
PosToPageUsage_Impl( sal_uInt16 nPos
)
92 if ( nPos
>= std::size(aArr
) )
93 return SvxPageUsage::NONE
;
98 static Size
GetMinBorderSpace_Impl( const SvxShadowItem
& rShadow
, const SvxBoxItem
& rBox
)
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
) );
109 static tools::Long
ConvertLong_Impl( const tools::Long nIn
, MapUnit eUnit
)
111 return OutputDevice::LogicToLogic( nIn
, eUnit
, MapUnit::MapTwip
);
114 static bool IsEqualSize_Impl( const SvxSizeItem
* pSize
, const Size
& rSize
)
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 );
128 #define MARGIN_LEFT ( MarginPosition(0x0001) )
129 #define MARGIN_RIGHT ( MarginPosition(0x0002) )
130 #define MARGIN_TOP ( MarginPosition(0x0004) )
131 #define MARGIN_BOTTOM ( MarginPosition(0x0008) )
133 // class SvxPageDescPage --------------------------------------------------
135 std::unique_ptr
<SfxTabPage
> SvxPageDescPage::Create( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rSet
)
137 return std::make_unique
<SvxPageDescPage
>(pPage
, pController
, *rSet
);
140 SvxPageDescPage::SvxPageDescPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rAttr
)
141 : SfxTabPage(pPage
, pController
, "cui/ui/pageformatpage.ui", "PageFormatPage", &rAttr
)
143 , eMode(SVX_PAGE_MODE_STANDARD
)
144 , ePaperStart(PAPER_A3
)
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_xPortraitBtn(m_xBuilder
->weld_radio_button("radiobuttonPortrait"))
153 , m_xLandscapeBtn(m_xBuilder
->weld_radio_button("radiobuttonLandscape"))
154 , m_xTextFlowLbl(m_xBuilder
->weld_label("labelTextFlow"))
155 , m_xTextFlowBox(new svx::FrameDirectionListBox(m_xBuilder
->weld_combo_box("comboTextFlowBox")))
156 , m_xPaperTrayBox(m_xBuilder
->weld_combo_box("comboPaperTray"))
157 , m_xLeftMarginLbl(m_xBuilder
->weld_label("labelLeftMargin"))
158 , m_xLeftMarginEdit(m_xBuilder
->weld_metric_spin_button("spinMargLeft", FieldUnit::CM
))
159 , m_xRightMarginLbl(m_xBuilder
->weld_label("labelRightMargin"))
160 , m_xRightMarginEdit(m_xBuilder
->weld_metric_spin_button("spinMargRight", FieldUnit::CM
))
161 , m_xTopMarginEdit(m_xBuilder
->weld_metric_spin_button("spinMargTop", FieldUnit::CM
))
162 , m_xBottomMarginEdit(m_xBuilder
->weld_metric_spin_button("spinMargBot", FieldUnit::CM
))
163 , m_xGutterMarginLbl(m_xBuilder
->weld_label("labelGutterMargin"))
164 , m_xGutterMarginEdit(m_xBuilder
->weld_metric_spin_button("spinMargGut", FieldUnit::CM
))
165 , m_xPageText(m_xBuilder
->weld_label("labelPageLayout"))
166 , m_xLayoutBox(m_xBuilder
->weld_combo_box("comboPageLayout"))
167 , m_xNumberFormatText(m_xBuilder
->weld_label("labelPageNumbers"))
168 , m_xNumberFormatBox(new SvxPageNumberListBox(m_xBuilder
->weld_combo_box("comboLayoutFormat")))
169 , m_xTblAlignFT(m_xBuilder
->weld_label("labelTblAlign"))
170 , m_xHorzBox(m_xBuilder
->weld_check_button("checkbuttonHorz"))
171 , m_xVertBox(m_xBuilder
->weld_check_button("checkbuttonVert"))
172 , m_xAdaptBox(m_xBuilder
->weld_check_button("checkAdaptBox"))
173 , m_xRegisterCB(m_xBuilder
->weld_check_button("checkRegisterTrue"))
174 , m_xRegisterFT(m_xBuilder
->weld_label("labelRegisterStyle"))
175 , m_xRegisterLB(m_xBuilder
->weld_combo_box("comboRegisterStyle"))
176 , m_xGutterPositionFT(m_xBuilder
->weld_label("labelGutterPosition"))
177 , m_xGutterPositionLB(m_xBuilder
->weld_combo_box("comboGutterPosition"))
178 , m_xRtlGutterCB(m_xBuilder
->weld_check_button("checkRtlGutter"))
179 , m_xBackgroundFullSizeCB(m_xBuilder
->weld_check_button("checkBackgroundFullSize"))
180 // Strings stored in UI
181 , m_xInsideLbl(m_xBuilder
->weld_label("labelInner"))
182 , m_xOutsideLbl(m_xBuilder
->weld_label("labelOuter"))
183 , m_xPrintRangeQueryText(m_xBuilder
->weld_label("labelMsg"))
184 , m_xBspWin(new weld::CustomWeld(*m_xBuilder
, "drawingareaPageDirection", m_aBspWin
))
186 m_xRegisterLB
->set_size_request(m_xRegisterLB
->get_approximate_digit_width() * 20, -1);
188 bBorderModified
= false;
189 m_aBspWin
.EnableRTL(false);
191 // this page needs ExchangeSupport
192 SetExchangeSupport();
194 bool bCJK
= SvtCJKOptions::IsAsianTypographyEnabled();
195 bool bCTL
= SvtCTLOptions::IsCTLFontEnabled();
198 const SfxUInt16Item
* pHtmlModeItem
= rAttr
.GetItemIfSet(SID_HTML_MODE
, false);
201 if (SfxObjectShell
* pShell
= SfxObjectShell::Current())
202 pHtmlModeItem
= pShell
->GetItem(SID_HTML_MODE
);
205 bWeb
= 0 != (pHtmlModeItem
->GetValue() & HTMLMODE_ON
);
207 // fill text flow listbox with valid entries
209 m_xTextFlowBox
->append(SvxFrameDirection::Horizontal_LR_TB
, SvxResId(RID_SVXSTR_PAGEDIR_LTR_HORI
));
212 m_xTextFlowBox
->append(SvxFrameDirection::Horizontal_RL_TB
, SvxResId(RID_SVXSTR_PAGEDIR_RTL_HORI
));
215 // #109989# do not show vertical directions in Writer/Web
218 m_xTextFlowBox
->append(SvxFrameDirection::Vertical_RL_TB
, SvxResId(RID_SVXSTR_PAGEDIR_RTL_VERT
));
219 m_xTextFlowBox
->append(SvxFrameDirection::Vertical_LR_TB
, SvxResId(RID_SVXSTR_PAGEDIR_LTR_VERT
));
222 // #109989# show the text direction box in Writer/Web too
223 if( (bCJK
|| bCTL
) &&
224 SfxItemState::UNKNOWN
< rAttr
.GetItemState(GetWhich( SID_ATTR_FRAMEDIRECTION
)))
226 m_xTextFlowLbl
->show();
227 m_xTextFlowBox
->show();
228 m_xTextFlowBox
->connect_changed(LINK(this, SvxPageDescPage
, FrameDirectionModify_Impl
));
230 m_aBspWin
.EnableFrameDirection(true);
234 FieldUnit eFUnit
= GetModuleFieldUnit( rAttr
);
235 SetFieldUnit( *m_xLeftMarginEdit
, eFUnit
);
236 SetFieldUnit( *m_xRightMarginEdit
, eFUnit
);
237 SetFieldUnit( *m_xTopMarginEdit
, eFUnit
);
238 SetFieldUnit( *m_xBottomMarginEdit
, eFUnit
);
239 SetFieldUnit(*m_xGutterMarginEdit
, eFUnit
);
240 SetFieldUnit( *m_xPaperWidthEdit
, eFUnit
);
241 SetFieldUnit( *m_xPaperHeightEdit
, eFUnit
);
243 if ( SfxViewShell::Current() && SfxViewShell::Current()->GetPrinter() )
245 mpDefPrinter
= SfxViewShell::Current()->GetPrinter();
249 mpDefPrinter
= VclPtr
<Printer
>::Create();
253 MapMode aOldMode
= mpDefPrinter
->GetMapMode();
254 mpDefPrinter
->SetMapMode(MapMode(MapUnit::MapTwip
));
256 // set first- and last-values for the margins
257 Size aPaperSize
= mpDefPrinter
->GetPaperSize();
258 Size aPrintSize
= mpDefPrinter
->GetOutputSize();
261 * To convert a point ( 0,0 ) into logic coordinates
262 * looks like nonsense; but it makes sense when the
263 * coordinate system's origin has been moved.
265 Point aPrintOffset
= mpDefPrinter
->GetPageOffset() - mpDefPrinter
->PixelToLogic( Point() );
266 mpDefPrinter
->SetMapMode( aOldMode
);
268 nFirstLeftMargin
= m_xLeftMarginEdit
->convert_value_from(m_xLeftMarginEdit
->normalize(aPrintOffset
.X()), FieldUnit::TWIP
);
269 nFirstRightMargin
= m_xRightMarginEdit
->convert_value_from(m_xRightMarginEdit
->normalize(aPaperSize
.Width() - aPrintSize
.Width() - aPrintOffset
.X()), FieldUnit::TWIP
);
270 nFirstTopMargin
= m_xTopMarginEdit
->convert_value_from(m_xTopMarginEdit
->normalize(aPrintOffset
.Y() ), FieldUnit::TWIP
);
271 nFirstBottomMargin
= m_xBottomMarginEdit
->convert_value_from(m_xBottomMarginEdit
->normalize(aPaperSize
.Height() - aPrintSize
.Height() - aPrintOffset
.Y()), FieldUnit::TWIP
);
272 nLastLeftMargin
= m_xLeftMarginEdit
->convert_value_from(m_xLeftMarginEdit
->normalize(aPrintOffset
.X() + aPrintSize
.Width()), FieldUnit::TWIP
);
273 nLastRightMargin
= m_xRightMarginEdit
->convert_value_from(m_xRightMarginEdit
->normalize(aPrintOffset
.X() + aPrintSize
.Width()), FieldUnit::TWIP
);
274 nLastTopMargin
= m_xTopMarginEdit
->convert_value_from(m_xTopMarginEdit
->normalize(aPrintOffset
.Y() + aPrintSize
.Height()), FieldUnit::TWIP
);
275 nLastBottomMargin
= m_xBottomMarginEdit
->convert_value_from(m_xBottomMarginEdit
->normalize(aPrintOffset
.Y() + aPrintSize
.Height()), FieldUnit::TWIP
);
277 // #i4219# take Maximum now from configuration (1/100th cm)
278 // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000
279 m_xPaperWidthEdit
->set_max(m_xPaperWidthEdit
->normalize(SvtOptionsDrawinglayer::GetMaximumPaperWidth()), FieldUnit::CM
);
280 m_xPaperHeightEdit
->set_max(m_xPaperHeightEdit
->normalize(SvtOptionsDrawinglayer::GetMaximumPaperHeight()), FieldUnit::CM
);
282 // #i4219# also for margins (1/100th cm). Was: 9999, keeping.
283 m_xLeftMarginEdit
->set_max(m_xLeftMarginEdit
->normalize(SvtOptionsDrawinglayer::GetMaximumPaperLeftMargin()), FieldUnit::MM
);
284 m_xRightMarginEdit
->set_max(m_xRightMarginEdit
->normalize(SvtOptionsDrawinglayer::GetMaximumPaperRightMargin()), FieldUnit::MM
);
285 m_xTopMarginEdit
->set_max(m_xTopMarginEdit
->normalize(SvtOptionsDrawinglayer::GetMaximumPaperTopMargin()), FieldUnit::MM
);
286 m_xBottomMarginEdit
->set_max(m_xBottomMarginEdit
->normalize(SvtOptionsDrawinglayer::GetMaximumPaperBottomMargin()), FieldUnit::MM
);
287 m_xGutterMarginEdit
->set_max(
288 m_xGutterMarginEdit
->normalize(SvtOptionsDrawinglayer::GetMaximumPaperLeftMargin()),
291 // Get the i18n framework numberings and add them to the listbox.
292 SvxNumOptionsTabPageHelper::GetI18nNumbering(m_xNumberFormatBox
->get_widget(), std::numeric_limits
<sal_uInt16
>::max());
295 SvxPageDescPage::~SvxPageDescPage()
299 mpDefPrinter
.disposeAndClear();
300 mbDelPrinter
= false;
304 void SvxPageDescPage::Init_Impl()
306 // adjust the handler
307 m_xLayoutBox
->connect_changed(LINK(this, SvxPageDescPage
, LayoutHdl_Impl
));
308 m_xGutterPositionLB
->connect_changed(LINK(this, SvxPageDescPage
, GutterPositionHdl_Impl
));
310 m_xPaperSizeBox
->connect_changed(LINK(this, SvxPageDescPage
, PaperSizeSelect_Impl
));
311 m_xPaperWidthEdit
->connect_value_changed( LINK(this, SvxPageDescPage
, PaperSizeModify_Impl
));
312 m_xPaperHeightEdit
->connect_value_changed(LINK(this, SvxPageDescPage
, PaperSizeModify_Impl
));
313 m_xLandscapeBtn
->connect_toggled(LINK(this, SvxPageDescPage
, SwapOrientation_Impl
));
314 m_xPortraitBtn
->connect_toggled(LINK(this, SvxPageDescPage
, SwapOrientation_Impl
));
316 Link
<weld::MetricSpinButton
&, void> aLink
= LINK(this, SvxPageDescPage
, BorderModify_Impl
);
317 m_xLeftMarginEdit
->connect_value_changed(aLink
);
318 m_xRightMarginEdit
->connect_value_changed(aLink
);
319 m_xTopMarginEdit
->connect_value_changed(aLink
);
320 m_xBottomMarginEdit
->connect_value_changed(aLink
);
321 m_xGutterMarginEdit
->connect_value_changed(aLink
);
323 m_xHorzBox
->connect_toggled(LINK(this, SvxPageDescPage
, CenterHdl_Impl
));
324 m_xVertBox
->connect_toggled(LINK(this, SvxPageDescPage
, CenterHdl_Impl
));
327 void SvxPageDescPage::Reset( const SfxItemSet
* rSet
)
329 SfxItemPool
* pPool
= rSet
->GetPool();
330 SAL_WARN_IF(!pPool
, "cui.tabpages", "Where is the pool?");
331 MapUnit eUnit
= pPool
->GetMetric( GetWhich( SID_ATTR_LRSPACE
) );
333 // adjust margins (right/left)
334 const SfxPoolItem
* pItem
= GetItem( *rSet
, SID_ATTR_LRSPACE
);
338 const SvxLRSpaceItem
& rLRSpace
= static_cast<const SvxLRSpaceItem
&>(*pItem
);
339 SetMetricValue( *m_xLeftMarginEdit
, rLRSpace
.GetLeft(), eUnit
);
340 SetMetricValue(*m_xGutterMarginEdit
, rLRSpace
.GetGutterMargin(), eUnit
);
342 static_cast<sal_uInt16
>(ConvertLong_Impl( rLRSpace
.GetLeft(), eUnit
)) );
343 SetMetricValue( *m_xRightMarginEdit
, rLRSpace
.GetRight(), eUnit
);
345 static_cast<sal_uInt16
>(ConvertLong_Impl( rLRSpace
.GetRight(), eUnit
)) );
348 // adjust margins (top/bottom)
349 pItem
= GetItem( *rSet
, SID_ATTR_ULSPACE
);
353 const SvxULSpaceItem
& rULSpace
= static_cast<const SvxULSpaceItem
&>(*pItem
);
354 SetMetricValue( *m_xTopMarginEdit
, rULSpace
.GetUpper(), eUnit
);
356 static_cast<sal_uInt16
>(ConvertLong_Impl( static_cast<tools::Long
>(rULSpace
.GetUpper()), eUnit
)) );
357 SetMetricValue( *m_xBottomMarginEdit
, rULSpace
.GetLower(), eUnit
);
359 static_cast<sal_uInt16
>(ConvertLong_Impl( static_cast<tools::Long
>(rULSpace
.GetLower()), eUnit
)) );
362 if (const SfxGrabBagItem
* pGragbagItem
= rSet
->GetItemIfSet(SID_ATTR_CHAR_GRABBAG
))
365 auto it
= pGragbagItem
->GetGrabBag().find("GutterAtTop");
366 if (it
!= pGragbagItem
->GetGrabBag().end())
368 it
->second
>>= bGutterAtTop
;
373 m_xGutterPositionLB
->set_active(1);
378 m_xGutterPositionLB
->set_active(0);
380 it
= pGragbagItem
->GetGrabBag().find("RtlGutter");
382 if (it
!= pGragbagItem
->GetGrabBag().end())
384 it
->second
>>= bRtlGutter
;
385 m_xRtlGutterCB
->set_active(bRtlGutter
);
386 m_xRtlGutterCB
->show();
388 it
= pGragbagItem
->GetGrabBag().find("BackgroundFullSize");
389 bool isBackgroundFullSize
{};
390 if (it
!= pGragbagItem
->GetGrabBag().end())
392 it
->second
>>= isBackgroundFullSize
;
393 m_xBackgroundFullSizeCB
->set_active(isBackgroundFullSize
);
394 m_xBackgroundFullSizeCB
->show();
399 SvxNumType eNumType
= SVX_NUM_ARABIC
;
400 bLandscape
= ( mpDefPrinter
->GetOrientation() == Orientation::Landscape
);
401 SvxPageUsage nUse
= SvxPageUsage::All
;
402 pItem
= GetItem( *rSet
, SID_ATTR_PAGE
);
406 const SvxPageItem
& rItem
= static_cast<const SvxPageItem
&>(*pItem
);
407 eNumType
= rItem
.GetNumType();
408 nUse
= rItem
.GetPageUsage();
409 bLandscape
= rItem
.IsLandscape();
413 m_xLayoutBox
->set_active(::PageUsageToPos_Impl(nUse
));
414 m_aBspWin
.SetUsage( nUse
);
415 LayoutHdl_Impl( *m_xLayoutBox
);
417 //adjust numeration type of the page style
418 m_xNumberFormatBox
->set_active_id(eNumType
);
420 m_xPaperTrayBox
->clear();
421 sal_uInt8 nPaperBin
= PAPERBIN_PRINTER_SETTINGS
;
422 pItem
= GetItem( *rSet
, SID_ATTR_PAGE_PAPERBIN
);
426 nPaperBin
= static_cast<const SvxPaperBinItem
*>(pItem
)->GetValue();
428 if ( nPaperBin
>= mpDefPrinter
->GetPaperBinCount() )
429 nPaperBin
= PAPERBIN_PRINTER_SETTINGS
;
434 if ( PAPERBIN_PRINTER_SETTINGS
== nPaperBin
)
435 aBinName
= EditResId(RID_SVXSTR_PAPERBIN_SETTINGS
);
437 aBinName
= mpDefPrinter
->GetPaperBinName( static_cast<sal_uInt16
>(nPaperBin
) );
439 m_xPaperTrayBox
->append(OUString::number(nPaperBin
), aBinName
);
440 m_xPaperTrayBox
->set_active_text(aBinName
);
441 // reset focus handler to default first so know none already connected
442 m_xPaperTrayBox
->connect_focus_in(Link
<weld::Widget
&, void>());
443 // update the list when widget gets focus
444 m_xPaperTrayBox
->connect_focus_in(LINK(this, SvxPageDescPage
, PaperBinHdl_Impl
));
446 Size aPaperSize
= SvxPaperInfo::GetPaperSize( mpDefPrinter
);
447 pItem
= GetItem( *rSet
, SID_ATTR_PAGE_SIZE
);
450 aPaperSize
= static_cast<const SvxSizeItem
*>(pItem
)->GetSize();
452 bool bOrientationSupport
=
453 mpDefPrinter
->HasSupport( PrinterSupport::SetOrientation
);
455 if ( !bOrientationSupport
&&
456 aPaperSize
.Width() > aPaperSize
.Height() )
459 // tdf#130548 disable callbacks on the other of a pair of the radiogroup
460 // when toggling its partner
461 m_xLandscapeBtn
->connect_toggled(Link
<weld::Toggleable
&, void>());
462 m_xPortraitBtn
->connect_toggled(Link
<weld::Toggleable
&, void>());
464 m_xLandscapeBtn
->set_active(bLandscape
);
465 m_xPortraitBtn
->set_active(!bLandscape
);
467 m_xLandscapeBtn
->connect_toggled(LINK(this, SvxPageDescPage
, SwapOrientation_Impl
));
468 m_xPortraitBtn
->connect_toggled(LINK(this, SvxPageDescPage
, SwapOrientation_Impl
));
470 m_aBspWin
.SetSize( Size( ConvertLong_Impl( aPaperSize
.Width(), eUnit
),
471 ConvertLong_Impl( aPaperSize
.Height(), eUnit
) ) );
473 aPaperSize
= OutputDevice::LogicToLogic(aPaperSize
, MapMode(eUnit
), MapMode(MapUnit::Map100thMM
));
477 // Actual Paper Format
478 Paper ePaper
= SvxPaperInfo::GetSvxPaper( aPaperSize
, MapUnit::Map100thMM
);
480 if ( PAPER_USER
!= ePaper
)
481 aPaperSize
= SvxPaperInfo::GetPaperSize( ePaper
, MapUnit::Map100thMM
);
486 // write values into the edits
487 SetMetricValue( *m_xPaperHeightEdit
, aPaperSize
.Height(), MapUnit::Map100thMM
);
488 SetMetricValue( *m_xPaperWidthEdit
, aPaperSize
.Width(), MapUnit::Map100thMM
);
489 m_xPaperSizeBox
->clear();
491 m_xPaperSizeBox
->FillPaperSizeEntries( ( ePaperStart
== PAPER_A3
) ? PaperSizeApp::Std
: PaperSizeApp::Draw
);
492 m_xPaperSizeBox
->set_active_id( ePaper
);
494 // application specific
498 case SVX_PAGE_MODE_CENTER
:
500 m_xTblAlignFT
->show();
503 DisableVerticalPageDir();
505 // horizontal alignment
506 pItem
= GetItem( *rSet
, SID_ATTR_PAGE_EXT1
);
507 m_xHorzBox
->set_active(pItem
&& static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
509 // vertical alignment
510 pItem
= GetItem( *rSet
, SID_ATTR_PAGE_EXT2
);
511 m_xVertBox
->set_active(pItem
&& static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
513 // set example window on the table
514 m_aBspWin
.SetTable( true );
515 m_aBspWin
.SetHorz(m_xHorzBox
->get_active());
516 m_aBspWin
.SetVert(m_xVertBox
->get_active());
518 m_xGutterMarginLbl
->hide();
519 m_xGutterMarginEdit
->hide();
520 m_xGutterPositionFT
->hide();
521 m_xGutterPositionLB
->hide();
526 case SVX_PAGE_MODE_PRESENTATION
:
528 DisableVerticalPageDir();
530 pItem
= GetItem( *rSet
, SID_ATTR_PAGE_EXT1
);
531 m_xAdaptBox
->set_active( pItem
&&
532 static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
534 //!!! hidden, because not implemented by StarDraw
535 m_xLayoutBox
->hide();
538 m_xGutterMarginLbl
->hide();
539 m_xGutterMarginEdit
->hide();
540 m_xGutterPositionFT
->hide();
541 m_xGutterPositionLB
->hide();
545 default: ;//prevent warning
549 // display background and border in the example
550 ResetBackground_Impl( *rSet
);
551 //! UpdateExample_Impl();
554 InitHeadFoot_Impl( *rSet
);
556 bBorderModified
= false;
557 SwapFirstValues_Impl( false );
558 UpdateExample_Impl();
560 m_xLeftMarginEdit
->save_value();
561 m_xRightMarginEdit
->save_value();
562 m_xTopMarginEdit
->save_value();
563 m_xBottomMarginEdit
->save_value();
564 m_xGutterMarginEdit
->save_value();
565 m_xLayoutBox
->save_value();
566 m_xNumberFormatBox
->save_value();
567 m_xPaperSizeBox
->save_value();
568 m_xPaperWidthEdit
->save_value();
569 m_xPaperHeightEdit
->save_value();
570 m_xPortraitBtn
->save_state();
571 m_xLandscapeBtn
->save_state();
572 m_xPaperTrayBox
->save_value();
573 m_xVertBox
->save_state();
574 m_xHorzBox
->save_state();
575 m_xAdaptBox
->save_state();
576 m_xGutterPositionLB
->save_value();
577 m_xRtlGutterCB
->save_state();
578 m_xBackgroundFullSizeCB
->save_state();
580 CheckMarginEdits( true );
583 if(SfxItemState::SET
== rSet
->GetItemState(SID_SWREGISTER_MODE
))
585 m_xRegisterCB
->set_active(rSet
->Get(SID_SWREGISTER_MODE
).GetValue());
586 m_xRegisterCB
->save_state();
587 RegisterModify(*m_xRegisterCB
);
589 if(SfxItemState::SET
== rSet
->GetItemState(SID_SWREGISTER_COLLECTION
))
591 m_xRegisterLB
->set_active_text(
592 rSet
->Get(SID_SWREGISTER_COLLECTION
).GetValue());
593 m_xRegisterLB
->save_value();
596 SfxItemState eState
= rSet
->GetItemState( GetWhich( SID_ATTR_FRAMEDIRECTION
),
598 if( SfxItemState::UNKNOWN
!= eState
)
600 SvxFrameDirection nVal
= SfxItemState::SET
== eState
601 ? static_cast<const SvxFrameDirectionItem
*>(pItem
)->GetValue()
602 : SvxFrameDirection::Horizontal_LR_TB
;
603 m_xTextFlowBox
->set_active_id(nVal
);
605 m_xTextFlowBox
->save_value();
606 m_aBspWin
.SetFrameDirection(nVal
);
610 void SvxPageDescPage::FillUserData()
612 if (SVX_PAGE_MODE_PRESENTATION
== eMode
)
613 SetUserData(m_xAdaptBox
->get_active() ? OUString("1") : OUString("0")) ;
617 bool SvxPageDescPage::FillItemSet( SfxItemSet
* rSet
)
619 bool bModified
= false;
620 const SfxItemSet
& rOldSet
= GetItemSet();
621 SfxItemPool
* pPool
= rOldSet
.GetPool();
622 DBG_ASSERT( pPool
, "Where is the pool?" );
623 sal_uInt16 nWhich
= GetWhich( SID_ATTR_LRSPACE
);
624 MapUnit eUnit
= pPool
->GetMetric( nWhich
);
625 const SfxPoolItem
* pOld
= nullptr;
627 // copy old left and right margins
628 SvxLRSpaceItem
aMargin( static_cast<const SvxLRSpaceItem
&>(rOldSet
.Get( nWhich
)) );
630 // copy old top and bottom margins
631 nWhich
= GetWhich( SID_ATTR_ULSPACE
);
632 SvxULSpaceItem
aTopMargin( static_cast<const SvxULSpaceItem
&>(rOldSet
.Get( nWhich
)) );
634 if (m_xLeftMarginEdit
->get_value_changed_from_saved())
636 aMargin
.SetLeft( static_cast<sal_uInt16
>(GetCoreValue( *m_xLeftMarginEdit
, eUnit
)) );
640 if (m_xRightMarginEdit
->get_value_changed_from_saved())
642 aMargin
.SetRight( static_cast<sal_uInt16
>(GetCoreValue( *m_xRightMarginEdit
, eUnit
)) );
646 if (m_xGutterMarginEdit
->get_value_changed_from_saved())
648 aMargin
.SetGutterMargin(static_cast<sal_uInt16
>(GetCoreValue(*m_xGutterMarginEdit
, eUnit
)));
652 // set left and right margins
655 pOld
= GetOldItem( *rSet
, SID_ATTR_LRSPACE
);
657 if ( !pOld
|| *static_cast<const SvxLRSpaceItem
*>(pOld
) != aMargin
)
658 rSet
->Put( aMargin
);
663 if (rOldSet
.HasItem(SID_ATTR_CHAR_GRABBAG
))
665 // Set gutter position.
666 SfxGrabBagItem
aGrabBagItem(rOldSet
.Get(SID_ATTR_CHAR_GRABBAG
));
667 if (m_xGutterPositionLB
->get_value_changed_from_saved())
669 bool bGutterAtTop
= m_xGutterPositionLB
->get_active() == 1;
670 aGrabBagItem
.GetGrabBag()["GutterAtTop"] <<= bGutterAtTop
;
673 if (m_xRtlGutterCB
->get_state_changed_from_saved())
675 bool const bRtlGutter(m_xRtlGutterCB
->get_active());
676 aGrabBagItem
.GetGrabBag()["RtlGutter"] <<= bRtlGutter
;
679 if (m_xBackgroundFullSizeCB
->get_state_changed_from_saved())
681 bool const isBackgroundFullSize(m_xBackgroundFullSizeCB
->get_active());
682 aGrabBagItem
.GetGrabBag()["BackgroundFullSize"] <<= isBackgroundFullSize
;
688 pOld
= rOldSet
.GetItem(SID_ATTR_CHAR_GRABBAG
);
690 if (!pOld
|| static_cast<const SfxGrabBagItem
&>(*pOld
) != aGrabBagItem
)
691 rSet
->Put(aGrabBagItem
);
699 if (m_xTopMarginEdit
->get_value_changed_from_saved())
701 aTopMargin
.SetUpper( static_cast<sal_uInt16
>(GetCoreValue( *m_xTopMarginEdit
, eUnit
)) );
705 if (m_xBottomMarginEdit
->get_value_changed_from_saved())
707 aTopMargin
.SetLower( static_cast<sal_uInt16
>(GetCoreValue( *m_xBottomMarginEdit
, eUnit
)) );
711 // set top and bottom margins
715 pOld
= GetOldItem( *rSet
, SID_ATTR_ULSPACE
);
717 if ( !pOld
|| *static_cast<const SvxULSpaceItem
*>(pOld
) != aTopMargin
)
720 rSet
->Put( aTopMargin
);
725 TypedWhichId
<SvxPaperBinItem
> nPaperWhich
= GetWhich( SID_ATTR_PAGE_PAPERBIN
);
726 sal_Int32 nPos
= m_xPaperTrayBox
->get_active();
727 sal_uInt16 nBin
= m_xPaperTrayBox
->get_id(nPos
).toInt32();
728 pOld
= GetOldItem( *rSet
, SID_ATTR_PAGE_PAPERBIN
);
730 if ( !pOld
|| static_cast<const SvxPaperBinItem
*>(pOld
)->GetValue() != nBin
)
732 rSet
->Put( SvxPaperBinItem( nPaperWhich
, static_cast<sal_uInt8
>(nBin
) ) );
736 Paper ePaper
= m_xPaperSizeBox
->get_active_id();
737 bool bChecked
= m_xLandscapeBtn
->get_active();
739 if ( PAPER_USER
== ePaper
)
741 if ( m_xPaperSizeBox
->get_value_changed_from_saved() ||
742 m_xPaperWidthEdit
->get_value_changed_from_saved() ||
743 m_xPaperHeightEdit
->get_value_changed_from_saved() ||
744 m_xLandscapeBtn
->get_state_changed_from_saved() )
746 Size
aSize( GetCoreValue( *m_xPaperWidthEdit
, eUnit
),
747 GetCoreValue( *m_xPaperHeightEdit
, eUnit
) );
748 pOld
= GetOldItem( *rSet
, SID_ATTR_PAGE_SIZE
);
750 if ( !pOld
|| static_cast<const SvxSizeItem
*>(pOld
)->GetSize() != aSize
)
752 rSet
->Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE
), aSize
) );
759 if (m_xPaperSizeBox
->get_value_changed_from_saved() || m_xLandscapeBtn
->get_state_changed_from_saved())
761 Size
aSize( SvxPaperInfo::GetPaperSize( ePaper
, eUnit
) );
766 pOld
= GetOldItem( *rSet
, SID_ATTR_PAGE_SIZE
);
768 if ( !pOld
|| static_cast<const SvxSizeItem
*>(pOld
)->GetSize() != aSize
)
770 rSet
->Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE
), aSize
) );
776 nWhich
= GetWhich( SID_ATTR_PAGE
);
777 SvxPageItem
aPage( static_cast<const SvxPageItem
&>(rOldSet
.Get( nWhich
)) );
778 bMod
= m_xLayoutBox
->get_value_changed_from_saved();
781 aPage
.SetPageUsage(::PosToPageUsage_Impl(m_xLayoutBox
->get_active()));
783 if (m_xLandscapeBtn
->get_state_changed_from_saved())
785 aPage
.SetLandscape(bChecked
);
789 //Get the NumType value
790 if (m_xNumberFormatBox
->get_value_changed_from_saved())
792 SvxNumType nEntryData
= m_xNumberFormatBox
->get_active_id();
793 aPage
.SetNumType( nEntryData
);
799 pOld
= GetOldItem( *rSet
, SID_ATTR_PAGE
);
801 if ( !pOld
|| *static_cast<const SvxPageItem
*>(pOld
) != aPage
)
807 else if ( SfxItemState::DEFAULT
== rOldSet
.GetItemState( nWhich
) )
808 rSet
->ClearItem( nWhich
);
810 rSet
->Put( rOldSet
.Get( nWhich
) );
812 // evaluate mode specific controls
816 case SVX_PAGE_MODE_CENTER
:
818 if (m_xHorzBox
->get_state_changed_from_saved())
820 SfxBoolItem
aHorz( GetWhich( SID_ATTR_PAGE_EXT1
),
821 m_xHorzBox
->get_active() );
826 if (m_xVertBox
->get_state_changed_from_saved())
828 SfxBoolItem
aVert( GetWhich( SID_ATTR_PAGE_EXT2
),
829 m_xVertBox
->get_active() );
836 case SVX_PAGE_MODE_PRESENTATION
:
838 // always put so that draw can evaluate this
839 rSet
->Put( SfxBoolItem( GetWhich( SID_ATTR_PAGE_EXT1
),
840 m_xAdaptBox
->get_active() ) );
844 default: ;//prevent warning
848 if (m_xRegisterCB
->get_visible() &&
849 (m_xRegisterCB
->get_active() || m_xRegisterCB
->get_state_changed_from_saved()))
851 const SfxBoolItem
& rRegItem
= rOldSet
.Get(SID_SWREGISTER_MODE
);
852 std::unique_ptr
<SfxBoolItem
> pRegItem(rRegItem
.Clone());
853 bool bCheck
= m_xRegisterCB
->get_active();
854 pRegItem
->SetValue(bCheck
);
855 rSet
->Put(std::move(pRegItem
));
860 rSet
->Put(SfxStringItem(SID_SWREGISTER_COLLECTION
,
861 m_xRegisterLB
->get_active_text()));
865 if (m_xTextFlowBox
->get_visible() && m_xTextFlowBox
->get_value_changed_from_saved())
867 SvxFrameDirection eDirection
= m_xTextFlowBox
->get_active_id();
868 rSet
->Put( SvxFrameDirectionItem( eDirection
, GetWhich( SID_ATTR_FRAMEDIRECTION
) ) );
875 IMPL_LINK_NOARG(SvxPageDescPage
, LayoutHdl_Impl
, weld::ComboBox
&, void)
877 // switch inside outside
878 const SvxPageUsage nUsage
= PosToPageUsage_Impl(m_xLayoutBox
->get_active());
880 if (nUsage
== SvxPageUsage::Mirror
)
882 m_xLeftMarginLbl
->hide();
883 m_xRightMarginLbl
->hide();
884 m_xInsideLbl
->show();
885 m_xOutsideLbl
->show();
889 m_xLeftMarginLbl
->show();
890 m_xRightMarginLbl
->show();
891 m_xInsideLbl
->hide();
892 m_xOutsideLbl
->hide();
894 UpdateExample_Impl( true );
897 IMPL_LINK_NOARG(SvxPageDescPage
, GutterPositionHdl_Impl
, weld::ComboBox
&, void)
899 UpdateExample_Impl(true);
902 IMPL_LINK_NOARG(SvxPageDescPage
, PaperBinHdl_Impl
, weld::Widget
&, void)
904 // tdf#124226 disconnect so not called again, unless Reset occurs
905 m_xPaperTrayBox
->connect_focus_in(Link
<weld::Widget
&, void>());
907 OUString aOldName
= m_xPaperTrayBox
->get_active_text();
908 m_xPaperTrayBox
->freeze();
909 m_xPaperTrayBox
->clear();
910 m_xPaperTrayBox
->append(OUString::number(PAPERBIN_PRINTER_SETTINGS
), EditResId(RID_SVXSTR_PAPERBIN_SETTINGS
));
911 OUString
aPaperBin(EditResId(RID_SVXSTR_PAPERBIN
));
912 const sal_uInt16 nBinCount
= mpDefPrinter
->GetPaperBinCount();
914 for (sal_uInt16 i
= 0; i
< nBinCount
; ++i
)
916 OUString aName
= mpDefPrinter
->GetPaperBinName(i
);
919 aName
= aPaperBin
+ " " + OUString::number( i
+1 );
921 m_xPaperTrayBox
->append(OUString::number(i
), aName
);
923 m_xPaperTrayBox
->thaw();
924 m_xPaperTrayBox
->set_active_text(aOldName
);
926 // tdf#123650 explicitly grab-focus after the modification otherwise gtk loses track
927 // of there the focus should be
928 m_xPaperTrayBox
->grab_focus();
931 IMPL_LINK_NOARG(SvxPageDescPage
, PaperSizeSelect_Impl
, weld::ComboBox
&, void)
933 Paper ePaper
= m_xPaperSizeBox
->get_active_id();
935 if ( ePaper
== PAPER_USER
)
938 Size
aSize( SvxPaperInfo::GetPaperSize( ePaper
, MapUnit::Map100thMM
) );
940 if (m_xLandscapeBtn
->get_active())
943 if ( aSize
.Height() < m_xPaperHeightEdit
->get_min( FieldUnit::MM_100TH
) )
944 m_xPaperHeightEdit
->set_min(
945 m_xPaperHeightEdit
->normalize( aSize
.Height() ), FieldUnit::MM_100TH
);
946 if ( aSize
.Width() < m_xPaperWidthEdit
->get_min( FieldUnit::MM_100TH
) )
947 m_xPaperWidthEdit
->set_min(
948 m_xPaperWidthEdit
->normalize( aSize
.Width() ), FieldUnit::MM_100TH
);
949 SetMetricValue( *m_xPaperHeightEdit
, aSize
.Height(), MapUnit::Map100thMM
);
950 SetMetricValue( *m_xPaperWidthEdit
, aSize
.Width(), MapUnit::Map100thMM
);
955 UpdateExample_Impl( true );
957 if ( eMode
!= SVX_PAGE_MODE_PRESENTATION
)
960 // Draw: if paper format the margin shall be 1 cm
961 tools::Long nTmp
= 0;
962 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
));
965 // no margin if screen
966 nTmp
= 1; // accordingly 1 cm
968 if ( bScreen
|| m_xRightMarginEdit
->get_value(FieldUnit::NONE
) == 0 )
969 SetMetricValue( *m_xRightMarginEdit
, nTmp
, MapUnit::MapCM
);
970 if ( bScreen
|| m_xLeftMarginEdit
->get_value(FieldUnit::NONE
) == 0 )
971 SetMetricValue( *m_xLeftMarginEdit
, nTmp
, MapUnit::MapCM
);
972 if ( bScreen
|| m_xBottomMarginEdit
->get_value(FieldUnit::NONE
) == 0 )
973 SetMetricValue( *m_xBottomMarginEdit
, nTmp
, MapUnit::MapCM
);
974 if ( bScreen
|| m_xTopMarginEdit
->get_value(FieldUnit::NONE
) == 0 )
975 SetMetricValue( *m_xTopMarginEdit
, nTmp
, MapUnit::MapCM
);
976 UpdateExample_Impl( true );
979 IMPL_LINK_NOARG(SvxPageDescPage
, PaperSizeModify_Impl
, weld::MetricSpinButton
&, void)
981 sal_uInt16 nWhich
= GetWhich( SID_ATTR_LRSPACE
);
982 MapUnit eUnit
= GetItemSet().GetPool()->GetMetric( nWhich
);
983 Size
aSize( GetCoreValue( *m_xPaperWidthEdit
, eUnit
),
984 GetCoreValue( *m_xPaperHeightEdit
, eUnit
) );
986 if ( aSize
.Width() > aSize
.Height() )
988 m_xLandscapeBtn
->set_active(true);
993 m_xPortraitBtn
->set_active(true);
997 Paper ePaper
= SvxPaperInfo::GetSvxPaper( aSize
, eUnit
);
998 m_xPaperSizeBox
->set_active_id( ePaper
);
999 UpdateExample_Impl( true );
1004 IMPL_LINK(SvxPageDescPage
, SwapOrientation_Impl
, weld::Toggleable
&, rBtn
, void)
1006 if (!rBtn
.get_active())
1009 bLandscape
= m_xLandscapeBtn
->get_active();
1011 const tools::Long lWidth
= GetCoreValue( *m_xPaperWidthEdit
, MapUnit::Map100thMM
);
1012 const tools::Long lHeight
= GetCoreValue( *m_xPaperHeightEdit
, MapUnit::Map100thMM
);
1014 // swap width and height
1015 SetMetricValue(*m_xPaperWidthEdit
, lHeight
, MapUnit::Map100thMM
);
1016 SetMetricValue(*m_xPaperHeightEdit
, lWidth
, MapUnit::Map100thMM
);
1018 // recalculate margins if necessary
1021 PaperSizeSelect_Impl(m_xPaperSizeBox
->get_widget());
1023 SwapFirstValues_Impl(bBorderModified
);
1024 UpdateExample_Impl(true);
1027 void SvxPageDescPage::SwapFirstValues_Impl( bool bSet
)
1029 MapMode aOldMode
= mpDefPrinter
->GetMapMode();
1030 Orientation eOri
= Orientation::Portrait
;
1033 eOri
= Orientation::Landscape
;
1034 Orientation eOldOri
= mpDefPrinter
->GetOrientation();
1035 mpDefPrinter
->SetOrientation( eOri
);
1036 mpDefPrinter
->SetMapMode(MapMode(MapUnit::MapTwip
));
1038 // set first- and last-values for margins
1039 Size aPaperSize
= mpDefPrinter
->GetPaperSize();
1040 Size aPrintSize
= mpDefPrinter
->GetOutputSize();
1042 * To convert a point ( 0,0 ) into logic coordinates
1043 * looks like nonsense; but it makes sense if the
1044 * coordinate system's origin has been moved.
1046 Point aPrintOffset
= mpDefPrinter
->GetPageOffset() - mpDefPrinter
->PixelToLogic( Point() );
1047 mpDefPrinter
->SetMapMode( aOldMode
);
1048 mpDefPrinter
->SetOrientation( eOldOri
);
1050 sal_Int64 nSetL
= m_xLeftMarginEdit
->denormalize(
1051 m_xLeftMarginEdit
->get_value( FieldUnit::TWIP
) );
1052 sal_Int64 nSetR
= m_xRightMarginEdit
->denormalize(
1053 m_xRightMarginEdit
->get_value( FieldUnit::TWIP
) );
1054 sal_Int64 nSetT
= m_xTopMarginEdit
->denormalize(
1055 m_xTopMarginEdit
->get_value( FieldUnit::TWIP
) );
1056 sal_Int64 nSetB
= m_xBottomMarginEdit
->denormalize(
1057 m_xBottomMarginEdit
->get_value( FieldUnit::TWIP
) );
1059 tools::Long nNewL
= aPrintOffset
.X();
1060 tools::Long nNewR
= aPaperSize
.Width() - aPrintSize
.Width() - aPrintOffset
.X();
1061 tools::Long nNewT
= aPrintOffset
.Y();
1062 tools::Long nNewB
= aPaperSize
.Height() - aPrintSize
.Height() - aPrintOffset
.Y();
1064 nFirstLeftMargin
= m_xLeftMarginEdit
->convert_value_from(m_xLeftMarginEdit
->normalize(nNewL
), FieldUnit::TWIP
);
1065 nFirstRightMargin
= m_xRightMarginEdit
->convert_value_from(m_xRightMarginEdit
->normalize(nNewR
), FieldUnit::TWIP
);
1066 nFirstTopMargin
= m_xTopMarginEdit
->convert_value_from(m_xTopMarginEdit
->normalize(nNewT
), FieldUnit::TWIP
);
1067 nFirstBottomMargin
= m_xBottomMarginEdit
->convert_value_from(m_xBottomMarginEdit
->normalize(nNewB
), FieldUnit::TWIP
);
1072 if ( nSetL
< nNewL
)
1073 m_xLeftMarginEdit
->set_value( m_xLeftMarginEdit
->normalize( nNewL
),
1075 if ( nSetR
< nNewR
)
1076 m_xRightMarginEdit
->set_value( m_xRightMarginEdit
->normalize( nNewR
),
1078 if ( nSetT
< nNewT
)
1079 m_xTopMarginEdit
->set_value( m_xTopMarginEdit
->normalize( nNewT
),
1081 if ( nSetB
< nNewB
)
1082 m_xBottomMarginEdit
->set_value( m_xBottomMarginEdit
->normalize( nNewB
),
1086 IMPL_LINK_NOARG(SvxPageDescPage
, BorderModify_Impl
, weld::MetricSpinButton
&, void)
1088 if ( !bBorderModified
)
1089 bBorderModified
= true;
1090 UpdateExample_Impl();
1095 void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground
)
1098 Size
aSize( GetCoreValue( *m_xPaperWidthEdit
, MapUnit::MapTwip
),
1099 GetCoreValue( *m_xPaperHeightEdit
, MapUnit::MapTwip
) );
1101 m_aBspWin
.SetSize( aSize
);
1104 bool bGutterAtTop
= m_xGutterPositionLB
->get_active() == 1;
1105 tools::Long nTop
= GetCoreValue(*m_xTopMarginEdit
, MapUnit::MapTwip
);
1108 nTop
+= GetCoreValue(*m_xGutterMarginEdit
, MapUnit::MapTwip
);
1110 m_aBspWin
.SetTop(nTop
);
1111 m_aBspWin
.SetBottom( GetCoreValue( *m_xBottomMarginEdit
, MapUnit::MapTwip
) );
1112 tools::Long nLeft
= GetCoreValue(*m_xLeftMarginEdit
, MapUnit::MapTwip
);
1115 nLeft
+= GetCoreValue(*m_xGutterMarginEdit
, MapUnit::MapTwip
);
1117 m_aBspWin
.SetLeft(nLeft
);
1118 m_aBspWin
.SetRight( GetCoreValue( *m_xRightMarginEdit
, MapUnit::MapTwip
) );
1121 m_aBspWin
.SetUsage(PosToPageUsage_Impl(m_xLayoutBox
->get_active()));
1122 if ( bResetbackground
)
1123 m_aBspWin
.ResetBackground();
1124 m_aBspWin
.Invalidate();
1128 void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet
& rSet
)
1130 sal_uInt16
nWhich(GetWhich(SID_ATTR_PAGE_HEADERSET
));
1132 if (SfxItemState::SET
== rSet
.GetItemState(nWhich
, false))
1134 const SvxSetItem
& rSetItem
= static_cast< const SvxSetItem
& >(rSet
.Get(nWhich
, false));
1135 const SfxItemSet
& rTmpSet
= rSetItem
.GetItemSet();
1136 const SfxBoolItem
& rOn
= rTmpSet
.Get(GetWhich(SID_ATTR_PAGE_ON
));
1140 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes
;
1142 if(mbEnableDrawingLayerFillStyles
)
1144 // create FillAttributes directly from DrawingLayer FillStyle entries
1145 aHeaderFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(rTmpSet
);
1149 nWhich
= GetWhich(SID_ATTR_BRUSH
);
1151 if(SfxItemState::SET
== rTmpSet
.GetItemState(nWhich
))
1153 // create FillAttributes from SvxBrushItem
1154 const SvxBrushItem
& rItem
= static_cast< const SvxBrushItem
& >(rTmpSet
.Get(nWhich
));
1155 SfxItemSetFixed
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
> aTempSet(*rTmpSet
.GetPool());
1157 setSvxBrushItemAsFillAttributesToTargetSet(rItem
, aTempSet
);
1158 aHeaderFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(aTempSet
);
1162 m_aBspWin
.setHeaderFillAttributes(aHeaderFillAttributes
);
1166 nWhich
= GetWhich(SID_ATTR_PAGE_FOOTERSET
);
1168 if (SfxItemState::SET
== rSet
.GetItemState(nWhich
, false))
1170 const SvxSetItem
& rSetItem
= static_cast< const SvxSetItem
& >(rSet
.Get(nWhich
,false));
1171 const SfxItemSet
& rTmpSet
= rSetItem
.GetItemSet();
1172 const SfxBoolItem
& rOn
= rTmpSet
.Get(GetWhich(SID_ATTR_PAGE_ON
));
1176 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes
;
1178 if(mbEnableDrawingLayerFillStyles
)
1180 // create FillAttributes directly from DrawingLayer FillStyle entries
1181 aFooterFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(rTmpSet
);
1185 nWhich
= GetWhich(SID_ATTR_BRUSH
);
1187 if(SfxItemState::SET
== rTmpSet
.GetItemState(nWhich
))
1189 // create FillAttributes from SvxBrushItem
1190 const SvxBrushItem
& rItem
= static_cast< const SvxBrushItem
& >(rTmpSet
.Get(nWhich
));
1191 SfxItemSetFixed
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
> aTempSet(*rTmpSet
.GetPool());
1193 setSvxBrushItemAsFillAttributesToTargetSet(rItem
, aTempSet
);
1194 aFooterFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(aTempSet
);
1198 m_aBspWin
.setFooterFillAttributes(aFooterFillAttributes
);
1202 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aPageFillAttributes
;
1204 if(mbEnableDrawingLayerFillStyles
)
1206 // create FillAttributes directly from DrawingLayer FillStyle entries
1207 aPageFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(rSet
);
1211 const SfxPoolItem
* pItem
= GetItem(rSet
, SID_ATTR_BRUSH
);
1215 // create FillAttributes from SvxBrushItem
1216 const SvxBrushItem
& rItem
= static_cast< const SvxBrushItem
& >(*pItem
);
1217 SfxItemSetFixed
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
> aTempSet(*rSet
.GetPool());
1219 setSvxBrushItemAsFillAttributesToTargetSet(rItem
, aTempSet
);
1220 aPageFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(aTempSet
);
1224 m_aBspWin
.setPageFillAttributes(aPageFillAttributes
);
1227 void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet
& rSet
)
1229 bLandscape
= m_xLandscapeBtn
->get_active();
1230 const SfxPoolItem
* pItem
= GetItem( rSet
, SID_ATTR_PAGE_SIZE
);
1233 m_aBspWin
.SetSize( static_cast<const SvxSizeItem
*>(pItem
)->GetSize() );
1235 const SvxSetItem
* pSetItem
= nullptr;
1237 // evaluate header attributes
1239 if ( SfxItemState::SET
==
1240 rSet
.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET
),
1241 false, reinterpret_cast<const SfxPoolItem
**>(&pSetItem
) ) )
1243 const SfxItemSet
& rHeaderSet
= pSetItem
->GetItemSet();
1244 const SfxBoolItem
& rHeaderOn
=
1245 rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
1247 if ( rHeaderOn
.GetValue() )
1249 const SvxSizeItem
& rSize
=
1250 rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_SIZE
) );
1251 const SvxULSpaceItem
& rUL
=
1252 rHeaderSet
.Get( GetWhich( SID_ATTR_ULSPACE
) );
1253 tools::Long nDist
= rUL
.GetLower();
1254 m_aBspWin
.SetHdHeight( rSize
.GetSize().Height() - nDist
);
1255 m_aBspWin
.SetHdDist( nDist
);
1256 const SvxLRSpaceItem
& rLR
=
1257 rHeaderSet
.Get( GetWhich( SID_ATTR_LRSPACE
) );
1258 m_aBspWin
.SetHdLeft( rLR
.GetLeft() );
1259 m_aBspWin
.SetHdRight( rLR
.GetRight() );
1260 m_aBspWin
.SetHeader( true );
1263 m_aBspWin
.SetHeader( false );
1265 // show background and border in the example
1266 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes
;
1268 if(mbEnableDrawingLayerFillStyles
)
1270 // create FillAttributes directly from DrawingLayer FillStyle entries
1271 aHeaderFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(rHeaderSet
);
1275 const sal_uInt16
nWhich(GetWhich(SID_ATTR_BRUSH
));
1277 if(rHeaderSet
.GetItemState(nWhich
) >= SfxItemState::DEFAULT
)
1279 // aBspWin.SetHdColor(rItem.GetColor());
1280 const SvxBrushItem
& rItem
= static_cast< const SvxBrushItem
& >(rHeaderSet
.Get(nWhich
));
1281 SfxItemSetFixed
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
> aTempSet(*rHeaderSet
.GetPool());
1283 setSvxBrushItemAsFillAttributesToTargetSet(rItem
, aTempSet
);
1284 aHeaderFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(aTempSet
);
1288 m_aBspWin
.setHeaderFillAttributes(aHeaderFillAttributes
);
1291 // evaluate footer attributes
1293 if ( SfxItemState::SET
!=
1294 rSet
.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET
),
1295 false, reinterpret_cast<const SfxPoolItem
**>(&pSetItem
) ) )
1298 const SfxItemSet
& rFooterSet
= pSetItem
->GetItemSet();
1299 const SfxBoolItem
& rFooterOn
=
1300 rFooterSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
1302 if ( rFooterOn
.GetValue() )
1304 const SvxSizeItem
& rSize
=
1305 rFooterSet
.Get( GetWhich( SID_ATTR_PAGE_SIZE
) );
1306 const SvxULSpaceItem
& rUL
=
1307 rFooterSet
.Get( GetWhich( SID_ATTR_ULSPACE
) );
1308 tools::Long nDist
= rUL
.GetUpper();
1309 m_aBspWin
.SetFtHeight( rSize
.GetSize().Height() - nDist
);
1310 m_aBspWin
.SetFtDist( nDist
);
1311 const SvxLRSpaceItem
& rLR
=
1312 rFooterSet
.Get( GetWhich( SID_ATTR_LRSPACE
) );
1313 m_aBspWin
.SetFtLeft( rLR
.GetLeft() );
1314 m_aBspWin
.SetFtRight( rLR
.GetRight() );
1315 m_aBspWin
.SetFooter( true );
1318 m_aBspWin
.SetFooter( false );
1320 // show background and border in the example
1321 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes
;
1323 if(mbEnableDrawingLayerFillStyles
)
1325 // create FillAttributes directly from DrawingLayer FillStyle entries
1326 aFooterFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(rFooterSet
);
1330 const sal_uInt16
nWhich(GetWhich(SID_ATTR_BRUSH
));
1332 if(rFooterSet
.GetItemState(nWhich
) >= SfxItemState::DEFAULT
)
1334 // aBspWin.SetFtColor(rItem.GetColor());
1335 const SvxBrushItem
& rItem
= static_cast<const SvxBrushItem
&>(rFooterSet
.Get(nWhich
));
1336 SfxItemSetFixed
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
> aTempSet(*rFooterSet
.GetPool());
1338 setSvxBrushItemAsFillAttributesToTargetSet(rItem
, aTempSet
);
1339 aFooterFillAttributes
= std::make_shared
<drawinglayer::attribute::SdrAllFillAttributesHelper
>(aTempSet
);
1343 m_aBspWin
.setFooterFillAttributes(aFooterFillAttributes
);
1346 void SvxPageDescPage::ActivatePage( const SfxItemSet
& rSet
)
1348 InitHeadFoot_Impl( rSet
);
1349 UpdateExample_Impl();
1350 ResetBackground_Impl( rSet
);
1354 DeactivateRC
SvxPageDescPage::DeactivatePage( SfxItemSet
* _pSet
)
1356 // Inquiry whether the page margins are beyond the printing area.
1357 // If not, ask user whether they shall be taken.
1358 // If not, stay on the TabPage.
1359 Paper ePaper
= m_xPaperSizeBox
->get_active_id();
1361 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() )
1363 std::unique_ptr
<weld::MessageDialog
> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
1364 VclMessageType::Question
, VclButtonsType::YesNo
,
1365 m_xPrintRangeQueryText
->get_label()));
1366 xQueryBox
->set_default_response(RET_NO
);
1367 if (xQueryBox
->run() == RET_NO
)
1369 weld::MetricSpinButton
* pField
= nullptr;
1370 if ( IsPrinterRangeOverflow( *m_xLeftMarginEdit
, nFirstLeftMargin
, nLastLeftMargin
, MARGIN_LEFT
) )
1371 pField
= m_xLeftMarginEdit
.get();
1372 if ( IsPrinterRangeOverflow( *m_xRightMarginEdit
, nFirstRightMargin
, nLastRightMargin
, MARGIN_RIGHT
)
1374 pField
= m_xRightMarginEdit
.get();
1375 if ( IsPrinterRangeOverflow( *m_xTopMarginEdit
, nFirstTopMargin
, nLastTopMargin
, MARGIN_TOP
)
1377 pField
= m_xTopMarginEdit
.get();
1378 if ( IsPrinterRangeOverflow( *m_xBottomMarginEdit
, nFirstBottomMargin
, nLastBottomMargin
, MARGIN_BOTTOM
)
1380 pField
= m_xBottomMarginEdit
.get();
1382 pField
->grab_focus();
1383 UpdateExample_Impl();
1384 return DeactivateRC::KeepPage
;
1387 CheckMarginEdits( false );
1392 FillItemSet( _pSet
);
1394 // put portray/landscape if applicable
1395 sal_uInt16 nWh
= GetWhich( SID_ATTR_PAGE_SIZE
);
1396 MapUnit eUnit
= GetItemSet().GetPool()->GetMetric( nWh
);
1397 Size
aSize( GetCoreValue( *m_xPaperWidthEdit
, eUnit
),
1398 GetCoreValue( *m_xPaperHeightEdit
, eUnit
) );
1400 // put, if current size is different to the value in _pSet
1401 const SvxSizeItem
* pSize
= GetItem( *_pSet
, SID_ATTR_PAGE_SIZE
);
1402 if ( aSize
.Width() && ( !pSize
|| !IsEqualSize_Impl( pSize
, aSize
) ) )
1403 _pSet
->Put( SvxSizeItem( nWh
, aSize
) );
1406 return DeactivateRC::LeavePage
;
1409 void SvxPageDescPage::RangeHdl_Impl()
1412 tools::Long nHHeight
= m_aBspWin
.GetHdHeight();
1413 tools::Long nHDist
= m_aBspWin
.GetHdDist();
1415 tools::Long nFHeight
= m_aBspWin
.GetFtHeight();
1416 tools::Long nFDist
= m_aBspWin
.GetFtDist();
1418 tools::Long nHFLeft
= std::max(m_aBspWin
.GetHdLeft(), m_aBspWin
.GetFtLeft());
1419 tools::Long nHFRight
= std::max(m_aBspWin
.GetHdRight(), m_aBspWin
.GetFtRight());
1421 // current values for page margins
1422 tools::Long nBT
= static_cast<tools::Long
>(m_xTopMarginEdit
->denormalize(m_xTopMarginEdit
->get_value(FieldUnit::TWIP
)));
1423 tools::Long nBB
= static_cast<tools::Long
>(m_xBottomMarginEdit
->denormalize(m_xBottomMarginEdit
->get_value(FieldUnit::TWIP
)));
1424 tools::Long nBL
= static_cast<tools::Long
>(m_xLeftMarginEdit
->denormalize(m_xLeftMarginEdit
->get_value(FieldUnit::TWIP
)));
1425 tools::Long nBR
= static_cast<tools::Long
>(m_xRightMarginEdit
->denormalize(m_xRightMarginEdit
->get_value(FieldUnit::TWIP
)));
1427 // calculate width of page border
1428 const SfxItemSet
* _pSet
= &GetItemSet();
1431 if ( _pSet
->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW
) ) >=
1432 SfxItemState::DEFAULT
&&
1433 _pSet
->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER
) ) >=
1434 SfxItemState::DEFAULT
)
1436 aBorder
= GetMinBorderSpace_Impl(
1437 _pSet
->Get(GetWhich(SID_ATTR_BORDER_SHADOW
)),
1438 _pSet
->Get(GetWhich(SID_ATTR_BORDER_OUTER
)));
1444 tools::Long nMin
= nHHeight
+ nHDist
+ nFDist
+ nFHeight
+ nBT
+ nBB
+
1445 MINBODY
+ aBorder
.Height();
1446 m_xPaperHeightEdit
->set_min(m_xPaperHeightEdit
->normalize(nMin
), FieldUnit::TWIP
);
1448 nMin
= MINBODY
+ nBL
+ nBR
+ aBorder
.Width();
1449 m_xPaperWidthEdit
->set_min(m_xPaperWidthEdit
->normalize(nMin
), FieldUnit::TWIP
);
1451 tools::Long nH
= static_cast<tools::Long
>(m_xPaperHeightEdit
->denormalize(m_xPaperHeightEdit
->get_value(FieldUnit::TWIP
)));
1452 tools::Long nW
= static_cast<tools::Long
>(m_xPaperWidthEdit
->denormalize(m_xPaperWidthEdit
->get_value(FieldUnit::TWIP
)));
1455 tools::Long nMax
= nH
- nBB
- aBorder
.Height() - MINBODY
-
1456 nFDist
- nFHeight
- nHDist
- nHHeight
;
1458 m_xTopMarginEdit
->set_max(m_xTopMarginEdit
->normalize(nMax
), FieldUnit::TWIP
);
1461 nMax
= nH
- nBT
- aBorder
.Height() - MINBODY
-
1462 nFDist
- nFHeight
- nHDist
- nHHeight
;
1464 m_xBottomMarginEdit
->set_max(m_xTopMarginEdit
->normalize(nMax
), FieldUnit::TWIP
);
1467 nMax
= nW
- nBR
- MINBODY
- aBorder
.Width() - nHFLeft
- nHFRight
;
1468 m_xLeftMarginEdit
->set_max(m_xLeftMarginEdit
->normalize(nMax
), FieldUnit::TWIP
);
1471 nMax
= nW
- nBL
- MINBODY
- aBorder
.Width() - nHFLeft
- nHFRight
;
1472 m_xRightMarginEdit
->set_max(m_xRightMarginEdit
->normalize(nMax
), FieldUnit::TWIP
);
1475 void SvxPageDescPage::CalcMargin_Impl()
1477 // current values for page margins
1478 tools::Long nBT
= GetCoreValue( *m_xTopMarginEdit
, MapUnit::MapTwip
);
1479 tools::Long nBB
= GetCoreValue( *m_xBottomMarginEdit
, MapUnit::MapTwip
);
1481 tools::Long nBL
= GetCoreValue( *m_xLeftMarginEdit
, MapUnit::MapTwip
);
1482 tools::Long nBR
= GetCoreValue( *m_xRightMarginEdit
, MapUnit::MapTwip
);
1484 tools::Long nH
= GetCoreValue( *m_xPaperHeightEdit
, MapUnit::MapTwip
);
1485 tools::Long nW
= GetCoreValue( *m_xPaperWidthEdit
, MapUnit::MapTwip
);
1487 tools::Long nWidth
= nBL
+ nBR
+ MINBODY
;
1488 tools::Long nHeight
= nBT
+ nBB
+ MINBODY
;
1490 if ( nWidth
<= nW
&& nHeight
<= nH
)
1495 tools::Long nTmp
= nBL
<= nBR
? nBR
: nBL
;
1496 nTmp
-= nWidth
- nW
;
1499 SetMetricValue( *m_xRightMarginEdit
, nTmp
, MapUnit::MapTwip
);
1501 SetMetricValue( *m_xLeftMarginEdit
, nTmp
, MapUnit::MapTwip
);
1506 tools::Long nTmp
= nBT
<= nBB
? nBB
: nBT
;
1507 nTmp
-= nHeight
- nH
;
1510 SetMetricValue( *m_xBottomMarginEdit
, nTmp
, MapUnit::MapTwip
);
1512 SetMetricValue( *m_xTopMarginEdit
, nTmp
, MapUnit::MapTwip
);
1516 IMPL_LINK_NOARG(SvxPageDescPage
, CenterHdl_Impl
, weld::Toggleable
&, void)
1518 m_aBspWin
.SetHorz(m_xHorzBox
->get_active());
1519 m_aBspWin
.SetVert(m_xVertBox
->get_active());
1520 UpdateExample_Impl();
1523 void SvxPageDescPage::SetCollectionList(const std::vector
<OUString
> &aList
)
1525 OSL_ENSURE(!aList
.empty(), "Empty string list");
1527 sStandardRegister
= aList
[0];
1528 m_xRegisterLB
->freeze();
1529 for (size_t i
= 1; i
< aList
.size(); ++i
)
1530 m_xRegisterLB
->append_text(aList
[i
]);
1531 m_xRegisterLB
->thaw();
1533 m_xRegisterCB
->show();
1534 m_xRegisterFT
->show();
1535 m_xRegisterLB
->show();
1536 m_xRegisterCB
->connect_toggled(LINK(this, SvxPageDescPage
, RegisterModify
));
1539 IMPL_LINK(SvxPageDescPage
, RegisterModify
, weld::Toggleable
&, rBox
, void)
1541 bool bEnable
= false;
1542 if (rBox
.get_active())
1545 if (m_xRegisterLB
->get_active() == -1)
1546 m_xRegisterLB
->set_active_text(sStandardRegister
);
1548 m_xRegisterFT
->set_sensitive(bEnable
);
1549 m_xRegisterLB
->set_sensitive(bEnable
);
1552 void SvxPageDescPage::DisableVerticalPageDir()
1554 m_xTextFlowBox
->remove_id(SvxFrameDirection::Vertical_RL_TB
);
1555 m_xTextFlowBox
->remove_id(SvxFrameDirection::Vertical_LR_TB
);
1556 if (m_xTextFlowBox
->get_count() < 2)
1558 m_xTextFlowLbl
->hide();
1559 m_xTextFlowBox
->hide();
1560 m_aBspWin
.EnableFrameDirection( false );
1564 IMPL_LINK_NOARG(SvxPageDescPage
, FrameDirectionModify_Impl
, weld::ComboBox
&, void)
1566 m_aBspWin
.SetFrameDirection(m_xTextFlowBox
->get_active_id());
1567 m_aBspWin
.Invalidate();
1570 bool SvxPageDescPage::IsPrinterRangeOverflow(
1571 weld::MetricSpinButton
& rField
, tools::Long nFirstMargin
, tools::Long nLastMargin
, MarginPosition nPos
)
1574 bool bCheck
= ( ( m_nPos
& nPos
) == 0 );
1575 tools::Long nValue
= rField
.get_value(FieldUnit::NONE
);
1577 ( nValue
< nFirstMargin
|| nValue
> nLastMargin
) &&
1578 rField
.get_value_changed_from_saved() )
1580 rField
.set_value(nValue
< nFirstMargin
? nFirstMargin
: nLastMargin
, FieldUnit::NONE
);
1587 /** Check if a value of a margin edit is outside the printer paper margins
1588 and save this information.
1590 void SvxPageDescPage::CheckMarginEdits( bool _bClear
)
1595 sal_Int64 nValue
= m_xLeftMarginEdit
->get_value(FieldUnit::NONE
);
1596 if ( nValue
< nFirstLeftMargin
|| nValue
> nLastLeftMargin
)
1597 m_nPos
|= MARGIN_LEFT
;
1598 nValue
= m_xRightMarginEdit
->get_value(FieldUnit::NONE
);
1599 if ( nValue
< nFirstRightMargin
|| nValue
> nLastRightMargin
)
1600 m_nPos
|= MARGIN_RIGHT
;
1601 nValue
= m_xTopMarginEdit
->get_value(FieldUnit::NONE
);
1602 if ( nValue
< nFirstTopMargin
|| nValue
> nLastTopMargin
)
1603 m_nPos
|= MARGIN_TOP
;
1604 nValue
= m_xBottomMarginEdit
->get_value(FieldUnit::NONE
);
1605 if ( nValue
< nFirstBottomMargin
|| nValue
> nLastBottomMargin
)
1606 m_nPos
|= MARGIN_BOTTOM
;
1609 bool SvxPageDescPage::IsMarginOutOfRange() const
1611 bool bRet
= ( ( ( !( m_nPos
& MARGIN_LEFT
) &&
1612 m_xLeftMarginEdit
->get_value_changed_from_saved() ) &&
1613 ( m_xLeftMarginEdit
->get_value(FieldUnit::NONE
) < nFirstLeftMargin
||
1614 m_xLeftMarginEdit
->get_value(FieldUnit::NONE
) > nLastLeftMargin
) ) ||
1615 ( ( !( m_nPos
& MARGIN_RIGHT
) &&
1616 m_xRightMarginEdit
->get_value_changed_from_saved() ) &&
1617 ( m_xRightMarginEdit
->get_value(FieldUnit::NONE
) < nFirstRightMargin
||
1618 m_xRightMarginEdit
->get_value(FieldUnit::NONE
) > nLastRightMargin
) ) ||
1619 ( ( !( m_nPos
& MARGIN_TOP
) &&
1620 m_xTopMarginEdit
->get_value_changed_from_saved() ) &&
1621 ( m_xTopMarginEdit
->get_value(FieldUnit::NONE
) < nFirstTopMargin
||
1622 m_xTopMarginEdit
->get_value(FieldUnit::NONE
) > nLastTopMargin
) ) ||
1623 ( ( !( m_nPos
& MARGIN_BOTTOM
) &&
1624 m_xBottomMarginEdit
->get_value_changed_from_saved() ) &&
1625 ( m_xBottomMarginEdit
->get_value(FieldUnit::NONE
) < nFirstBottomMargin
||
1626 m_xBottomMarginEdit
->get_value(FieldUnit::NONE
) > nLastBottomMargin
) ) );
1630 void SvxPageDescPage::PageCreated(const SfxAllItemSet
& aSet
)
1632 const SfxUInt16Item
* pModeItem
= aSet
.GetItem(SID_ENUM_PAGE_MODE
, false);
1633 const SfxUInt16Item
* pPaperStartItem
= aSet
.GetItem(SID_PAPER_START
, false);
1634 const SfxUInt16Item
* pPaperEndItem
= aSet
.GetItem(SID_PAPER_END
, false);
1635 const SfxStringListItem
* pCollectListItem
= aSet
.GetItem
<SfxStringListItem
>(SID_COLLECT_LIST
, false);
1636 const SfxBoolItem
* pSupportDrawingLayerFillStyleItem
= aSet
.GetItem
<SfxBoolItem
>(SID_DRAWINGLAYER_FILLSTYLES
, false);
1637 const SfxBoolItem
* pIsImpressDoc
= aSet
.GetItem
<SfxBoolItem
>(SID_IMPRESS_DOC
, false);
1641 eMode
= static_cast<SvxModeType
>(pModeItem
->GetValue());
1644 if(pPaperStartItem
&& pPaperEndItem
)
1646 SetPaperFormatRanges(static_cast<Paper
>(pPaperStartItem
->GetValue()));
1649 if(pCollectListItem
)
1651 SetCollectionList(pCollectListItem
->GetList());
1654 if(pSupportDrawingLayerFillStyleItem
)
1656 const bool bNew(pSupportDrawingLayerFillStyleItem
->GetValue());
1658 mbEnableDrawingLayerFillStyles
= bNew
;
1662 m_xNumberFormatText
->set_label(SvxResId(STR_SLIDE_NUMBERS
));
1665 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */