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 <sal/config.h>
23 #include "PageMarginControl.hxx"
24 #include <strings.hrc>
26 #include <editeng/sizeitem.hxx>
27 #include <sfx2/app.hxx>
28 #include <sfx2/dispatch.hxx>
29 #include <sfx2/module.hxx>
30 #include <sfx2/viewfrm.hxx>
31 #include <svx/pageitem.hxx>
32 #include <svx/rulritem.hxx>
33 #include <svl/itempool.hxx>
34 #include <svl/intitem.hxx>
35 #include <svtools/unitconv.hxx>
36 #include <unotools/viewoptions.hxx>
38 #include <swtypes.hxx>
40 #include <PageMarginPopup.hxx>
42 #include <com/sun/star/document/XUndoManagerSupplier.hpp>
43 #include <com/sun/star/beans/NamedValue.hpp>
44 #include <com/sun/star/frame/XFrame.hpp>
46 #define SWPAGE_LEFT_GVALUE "Sw_Page_Left"
47 #define SWPAGE_RIGHT_GVALUE "Sw_Page_Right"
48 #define SWPAGE_TOP_GVALUE "Sw_Page_Top"
49 #define SWPAGE_DOWN_GVALUE "Sw_Page_Down"
50 #define SWPAGE_MIRROR_GVALUE "Sw_Page_Mirrored"
54 FieldUnit
lcl_GetFieldUnit()
56 FieldUnit eUnit
= FieldUnit::INCH
;
57 const SfxPoolItem
* pItem
= nullptr;
58 SfxItemState eState
= SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_METRIC
, pItem
);
59 if ( pItem
&& eState
>= SfxItemState::DEFAULT
)
61 eUnit
= static_cast<FieldUnit
>(static_cast<const SfxUInt16Item
*>( pItem
)->GetValue());
65 return SfxModule::GetCurrentFieldUnit();
73 SfxItemPool
&rPool
= SfxGetpApp()->GetPool();
74 sal_uInt16 nWhich
= rPool
.GetWhich( SID_ATTR_PAGE_SIZE
);
75 return rPool
.GetMetric( nWhich
);
78 css::uno::Reference
< css::document::XUndoManager
> getUndoManager( const css::uno::Reference
< css::frame::XFrame
>& rxFrame
)
80 const css::uno::Reference
< css::frame::XController
>& xController
= rxFrame
->getController();
81 if ( xController
.is() )
83 const css::uno::Reference
< css::frame::XModel
>& xModel
= xController
->getModel();
86 const css::uno::Reference
< css::document::XUndoManagerSupplier
> xSuppUndo( xModel
, css::uno::UNO_QUERY_THROW
);
87 return css::uno::Reference
< css::document::XUndoManager
>( xSuppUndo
->getUndoManager(), css::uno::UNO_SET_THROW
);
91 return css::uno::Reference
< css::document::XUndoManager
> ();
95 namespace sw::sidebar
{
97 PageMarginControl::PageMarginControl(PageMarginPopup
* pControl
, weld::Widget
* pParent
)
98 : WeldToolbarPopup(pControl
->getFrameInterface(), pParent
, "modules/swriter/ui/pagemargincontrol.ui", "PageMarginControl")
99 , m_xLeft(m_xBuilder
->weld_label("leftLabel"))
100 , m_xRight(m_xBuilder
->weld_label("rightLabel"))
101 , m_xInner(m_xBuilder
->weld_label("innerLabel"))
102 , m_xOuter(m_xBuilder
->weld_label("outerLabel"))
103 , m_xLeftMarginEdit(m_xBuilder
->weld_metric_spin_button("left", FieldUnit::CM
))
104 , m_xRightMarginEdit(m_xBuilder
->weld_metric_spin_button("right", FieldUnit::CM
))
105 , m_xTopMarginEdit(m_xBuilder
->weld_metric_spin_button("top", FieldUnit::CM
))
106 , m_xBottomMarginEdit(m_xBuilder
->weld_metric_spin_button("bottom", FieldUnit::CM
))
107 , m_xWidthHeightField(m_xBuilder
->weld_metric_spin_button("hidden", FieldUnit::CM
))
108 , m_xControl(pControl
)
109 , m_nPageLeftMargin(0)
110 , m_nPageRightMargin(0)
111 , m_nPageTopMargin(0)
112 , m_nPageBottomMargin(0)
114 , m_eUnit( lcl_GetUnit() )
115 , m_bUserCustomValuesAvailable( false )
116 , m_nUserCustomPageLeftMargin( 0 )
117 , m_nUserCustomPageRightMargin( 0 )
118 , m_nUserCustomPageTopMargin( 0 )
119 , m_nUserCustomPageBottomMargin( 0 )
120 , m_bUserCustomMirrored( false )
121 , m_bCustomValuesUsed( false )
123 m_xWidthHeightField
->set_unit(FieldUnit::CM
);
124 m_xWidthHeightField
->set_range(0, 9999, FieldUnit::NONE
);
125 m_xWidthHeightField
->set_digits(2);
126 m_xWidthHeightField
->set_increments(10, 100, FieldUnit::NONE
);
127 SetFieldUnit( *m_xWidthHeightField
, lcl_GetFieldUnit() );
129 bool bLandscape
= false;
130 const SvxSizeItem
* pSize
= nullptr;
131 const SvxLongLRSpaceItem
* pLRItem
= nullptr;
132 const SvxLongULSpaceItem
* pULItem
= nullptr;
133 if ( SfxViewFrame::Current() )
135 const SfxPoolItem
* pItem
;
136 SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE
, pItem
);
137 bLandscape
= static_cast<const SvxPageItem
*>( pItem
)->IsLandscape();
138 m_bMirrored
= static_cast<const SvxPageItem
*>( pItem
)->GetPageUsage() == SvxPageUsage::Mirror
;
139 SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE
, pItem
);
140 pSize
= static_cast<const SvxSizeItem
*>( pItem
);
141 SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE
, pItem
);
142 pLRItem
= static_cast<const SvxLongLRSpaceItem
*>( pItem
);
143 SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE
, pItem
);
144 pULItem
= static_cast<const SvxLongULSpaceItem
*>( pItem
);
149 m_nPageLeftMargin
= pLRItem
->GetLeft();
150 m_nPageRightMargin
= pLRItem
->GetRight();
155 m_nPageTopMargin
= pULItem
->GetUpper();
156 m_nPageBottomMargin
= pULItem
->GetLower();
161 m_xNarrow
= m_xBuilder
->weld_button("narrowL");
162 m_xNormal
= m_xBuilder
->weld_button("normalL");
163 m_xWide
= m_xBuilder
->weld_button("wideL");
164 m_xMirrored
= m_xBuilder
->weld_button("mirroredL");
165 m_xLast
= m_xBuilder
->weld_button("lastL");
169 m_xNarrow
= m_xBuilder
->weld_button("narrow");
170 m_xNormal
= m_xBuilder
->weld_button("normal");
171 m_xWide
= m_xBuilder
->weld_button("wide");
172 m_xMirrored
= m_xBuilder
->weld_button("mirrored");
173 m_xLast
= m_xBuilder
->weld_button("last");
182 m_xNarrow
->connect_clicked( LINK( this, PageMarginControl
, SelectMarginHdl
) );
183 m_xNormal
->connect_clicked( LINK( this, PageMarginControl
, SelectMarginHdl
) );
184 m_xWide
->connect_clicked( LINK( this, PageMarginControl
, SelectMarginHdl
) );
185 m_xMirrored
->connect_clicked( LINK( this, PageMarginControl
, SelectMarginHdl
) );
186 m_xLast
->connect_clicked( LINK( this, PageMarginControl
, SelectMarginHdl
) );
188 m_bUserCustomValuesAvailable
= GetUserCustomValues();
190 FillHelpText( m_bUserCustomValuesAvailable
);
192 Link
<weld::MetricSpinButton
&,void> aLinkLR
= LINK( this, PageMarginControl
, ModifyLRMarginHdl
);
193 m_xLeftMarginEdit
->connect_value_changed( aLinkLR
);
194 SetMetricValue( *m_xLeftMarginEdit
, m_nPageLeftMargin
, m_eUnit
);
195 SetFieldUnit( *m_xLeftMarginEdit
, lcl_GetFieldUnit() );
197 m_xRightMarginEdit
->connect_value_changed( aLinkLR
);
198 SetMetricValue( *m_xRightMarginEdit
, m_nPageRightMargin
, m_eUnit
);
199 SetFieldUnit( *m_xRightMarginEdit
, lcl_GetFieldUnit() );
201 Link
<weld::MetricSpinButton
&,void> aLinkUL
= LINK( this, PageMarginControl
, ModifyULMarginHdl
);
202 m_xTopMarginEdit
->connect_value_changed( aLinkUL
);
203 SetMetricValue( *m_xTopMarginEdit
, m_nPageTopMargin
, m_eUnit
);
204 SetFieldUnit( *m_xTopMarginEdit
, lcl_GetFieldUnit() );
206 m_xBottomMarginEdit
->connect_value_changed( aLinkUL
);
207 SetMetricValue( *m_xBottomMarginEdit
, m_nPageBottomMargin
, m_eUnit
);
208 SetFieldUnit( *m_xBottomMarginEdit
, lcl_GetFieldUnit() );
210 m_aPageSize
= pSize
->GetSize();
211 SetMetricFieldMaxValues( m_aPageSize
);
229 void PageMarginControl::GrabFocus()
231 m_xNarrow
->grab_focus();
234 PageMarginControl::~PageMarginControl()
236 StoreUserCustomValues();
239 void PageMarginControl::SetMetricFieldMaxValues( const Size
& rPageSize
)
241 const tools::Long nML
= m_xLeftMarginEdit
->denormalize( m_xLeftMarginEdit
->get_value( FieldUnit::TWIP
) );
242 const tools::Long nMR
= m_xRightMarginEdit
->denormalize( m_xRightMarginEdit
->get_value( FieldUnit::TWIP
) );
243 const tools::Long nMT
= m_xTopMarginEdit
->denormalize( m_xTopMarginEdit
->get_value( FieldUnit::TWIP
) );
244 const tools::Long nMB
= m_xBottomMarginEdit
->denormalize( m_xBottomMarginEdit
->get_value( FieldUnit::TWIP
) );
246 const tools::Long nPH
= OutputDevice::LogicToLogic( rPageSize
.Height(), m_eUnit
, MapUnit::MapTwip
);
247 const tools::Long nPW
= OutputDevice::LogicToLogic( rPageSize
.Width(), m_eUnit
, MapUnit::MapTwip
);
250 tools::Long nMax
= nPW
- nMR
- MINBODY
;
251 m_xLeftMarginEdit
->set_max( m_xLeftMarginEdit
->normalize( nMax
), FieldUnit::TWIP
);
254 nMax
= nPW
- nML
- MINBODY
;
255 m_xRightMarginEdit
->set_max( m_xRightMarginEdit
->normalize( nMax
), FieldUnit::TWIP
);
258 nMax
= nPH
- nMB
- MINBODY
;
259 m_xTopMarginEdit
->set_max( m_xTopMarginEdit
->normalize( nMax
), FieldUnit::TWIP
);
262 nMax
= nPH
- nMT
- MINBODY
;
263 m_xBottomMarginEdit
->set_max( m_xTopMarginEdit
->normalize( nMax
), FieldUnit::TWIP
);
266 void PageMarginControl::FillHelpText( const bool bUserCustomValuesAvailable
)
268 const OUString aLeft
= SwResId( STR_MARGIN_TOOLTIP_LEFT
);
269 const OUString aRight
= SwResId( STR_MARGIN_TOOLTIP_RIGHT
);
270 const OUString aTop
= SwResId( STR_MARGIN_TOOLTIP_TOP
);
271 const OUString aBottom
= SwResId( STR_MARGIN_TOOLTIP_BOT
);
273 SetMetricValue( *m_xWidthHeightField
, SWPAGE_NARROW_VALUE
, m_eUnit
);
274 const OUString aNarrowValText
= m_xWidthHeightField
->get_text();
275 OUString aHelpText
= aLeft
+
283 m_xNarrow
->set_tooltip_text( aHelpText
);
285 SetMetricValue( *m_xWidthHeightField
, SWPAGE_NORMAL_VALUE
, m_eUnit
);
286 const OUString aNormalValText
= m_xWidthHeightField
->get_text();
295 m_xNormal
->set_tooltip_text( aHelpText
);
297 SetMetricValue( *m_xWidthHeightField
, SWPAGE_WIDE_VALUE1
, m_eUnit
);
298 const OUString aWide1ValText
= m_xWidthHeightField
->get_text();
299 SetMetricValue( *m_xWidthHeightField
, SWPAGE_WIDE_VALUE2
, m_eUnit
);
300 const OUString aWide2ValText
= m_xWidthHeightField
->get_text();
309 m_xWide
->set_tooltip_text( aHelpText
);
311 const OUString aInner
= SwResId( STR_MARGIN_TOOLTIP_INNER
);
312 const OUString aOuter
= SwResId( STR_MARGIN_TOOLTIP_OUTER
);
314 SetMetricValue( *m_xWidthHeightField
, SWPAGE_WIDE_VALUE3
, m_eUnit
);
315 const OUString aWide3ValText
= m_xWidthHeightField
->get_text();
324 m_xMirrored
->set_tooltip_text( aHelpText
);
326 if ( bUserCustomValuesAvailable
)
328 aHelpText
= m_bUserCustomMirrored
? aInner
: aLeft
;
329 SetMetricValue( *m_xWidthHeightField
, m_nUserCustomPageLeftMargin
, m_eUnit
);
330 aHelpText
+= m_xWidthHeightField
->get_text();
331 aHelpText
+= m_bUserCustomMirrored
? aOuter
: aRight
;
332 SetMetricValue( *m_xWidthHeightField
, m_nUserCustomPageRightMargin
, m_eUnit
);
333 aHelpText
+= m_xWidthHeightField
->get_text();
335 SetMetricValue( *m_xWidthHeightField
, m_nUserCustomPageTopMargin
, m_eUnit
);
336 aHelpText
+= m_xWidthHeightField
->get_text();
337 aHelpText
+= aBottom
;
338 SetMetricValue( *m_xWidthHeightField
, m_nUserCustomPageBottomMargin
, m_eUnit
);
339 aHelpText
+= m_xWidthHeightField
->get_text();
345 m_xLast
->set_tooltip_text( aHelpText
);
348 IMPL_LINK( PageMarginControl
, SelectMarginHdl
, weld::Button
&, rControl
, void )
350 bool bMirrored
= false;
351 bool bApplyNewPageMargins
= true;
352 if( &rControl
== m_xNarrow
.get() )
354 m_nPageLeftMargin
= SWPAGE_NARROW_VALUE
;
355 m_nPageRightMargin
= SWPAGE_NARROW_VALUE
;
356 m_nPageTopMargin
= SWPAGE_NARROW_VALUE
;
357 m_nPageBottomMargin
= SWPAGE_NARROW_VALUE
;
360 if( &rControl
== m_xNormal
.get() )
362 m_nPageLeftMargin
= SWPAGE_NORMAL_VALUE
;
363 m_nPageRightMargin
= SWPAGE_NORMAL_VALUE
;
364 m_nPageTopMargin
= SWPAGE_NORMAL_VALUE
;
365 m_nPageBottomMargin
= SWPAGE_NORMAL_VALUE
;
368 if( &rControl
== m_xWide
.get() )
370 m_nPageLeftMargin
= SWPAGE_WIDE_VALUE2
;
371 m_nPageRightMargin
= SWPAGE_WIDE_VALUE2
;
372 m_nPageTopMargin
= SWPAGE_WIDE_VALUE1
;
373 m_nPageBottomMargin
= SWPAGE_WIDE_VALUE1
;
376 if( &rControl
== m_xMirrored
.get() )
378 m_nPageLeftMargin
= SWPAGE_WIDE_VALUE3
;
379 m_nPageRightMargin
= SWPAGE_WIDE_VALUE1
;
380 m_nPageTopMargin
= SWPAGE_WIDE_VALUE1
;
381 m_nPageBottomMargin
= SWPAGE_WIDE_VALUE1
;
384 if( &rControl
== m_xLast
.get() )
386 if ( m_bUserCustomValuesAvailable
)
388 m_nPageLeftMargin
= m_nUserCustomPageLeftMargin
;
389 m_nPageRightMargin
= m_nUserCustomPageRightMargin
;
390 m_nPageTopMargin
= m_nUserCustomPageTopMargin
;
391 m_nPageBottomMargin
= m_nUserCustomPageBottomMargin
;
392 bMirrored
= m_bUserCustomMirrored
;
396 bApplyNewPageMargins
= false;
400 if ( !bApplyNewPageMargins
)
403 const css::uno::Reference
< css::document::XUndoManager
> xUndoManager( getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) );
404 if ( xUndoManager
.is() )
405 xUndoManager
->enterUndoContext( "" );
407 ExecuteMarginLRChange( m_nPageLeftMargin
, m_nPageRightMargin
);
408 ExecuteMarginULChange( m_nPageTopMargin
, m_nPageBottomMargin
);
409 if ( m_bMirrored
!= bMirrored
)
411 m_bMirrored
= bMirrored
;
412 ExecutePageLayoutChange( m_bMirrored
);
415 if ( xUndoManager
.is() )
416 xUndoManager
->leaveUndoContext();
418 m_bCustomValuesUsed
= false;
419 m_xControl
->EndPopupMode();
422 void PageMarginControl::ExecuteMarginLRChange(
423 const tools::Long nPageLeftMargin
,
424 const tools::Long nPageRightMargin
)
426 if ( SfxViewFrame::Current() )
428 std::unique_ptr
<SvxLongLRSpaceItem
> pPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE
) );
429 pPageLRMarginItem
->SetLeft( nPageLeftMargin
);
430 pPageLRMarginItem
->SetRight( nPageRightMargin
);
431 SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE
,
432 SfxCallMode::RECORD
, { pPageLRMarginItem
.get() } );
433 pPageLRMarginItem
.reset();
437 void PageMarginControl::ExecuteMarginULChange(
438 const tools::Long nPageTopMargin
,
439 const tools::Long nPageBottomMargin
)
441 if ( SfxViewFrame::Current() )
443 std::unique_ptr
<SvxLongULSpaceItem
> pPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE
) );
444 pPageULMarginItem
->SetUpper( nPageTopMargin
);
445 pPageULMarginItem
->SetLower( nPageBottomMargin
);
446 SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE
,
447 SfxCallMode::RECORD
, { pPageULMarginItem
.get() } );
448 pPageULMarginItem
.reset();
452 void PageMarginControl::ExecutePageLayoutChange( const bool bMirrored
)
454 if ( SfxViewFrame::Current() )
456 std::unique_ptr
<SvxPageItem
> pPageItem( new SvxPageItem( SID_ATTR_PAGE
) );
457 pPageItem
->SetPageUsage( bMirrored
? SvxPageUsage::Mirror
: SvxPageUsage::All
);
458 SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE
,
459 SfxCallMode::RECORD
, { pPageItem
.get() } );
464 IMPL_LINK_NOARG( PageMarginControl
, ModifyLRMarginHdl
, weld::MetricSpinButton
&, void )
466 m_nPageLeftMargin
= GetCoreValue( *m_xLeftMarginEdit
, m_eUnit
);
467 m_nPageRightMargin
= GetCoreValue( *m_xRightMarginEdit
, m_eUnit
);
468 ExecuteMarginLRChange( m_nPageLeftMargin
, m_nPageRightMargin
);
469 SetMetricFieldMaxValues( m_aPageSize
);
470 m_bCustomValuesUsed
= true;
473 IMPL_LINK_NOARG( PageMarginControl
, ModifyULMarginHdl
, weld::MetricSpinButton
&, void )
475 m_nPageTopMargin
= GetCoreValue( *m_xTopMarginEdit
, m_eUnit
);
476 m_nPageBottomMargin
= GetCoreValue( *m_xBottomMarginEdit
, m_eUnit
);
477 ExecuteMarginULChange( m_nPageTopMargin
, m_nPageBottomMargin
);
478 SetMetricFieldMaxValues( m_aPageSize
);
479 m_bCustomValuesUsed
= true;
482 bool PageMarginControl::GetUserCustomValues()
484 bool bUserCustomValuesAvailable
= false;
486 SvtViewOptions
aWinOpt( EViewType::Window
, SWPAGE_LEFT_GVALUE
);
487 if ( aWinOpt
.Exists() )
489 css::uno::Sequence
< css::beans::NamedValue
> aSeq
= aWinOpt
.GetUserData();
491 if ( aSeq
.hasElements())
492 aSeq
[0].Value
>>= aTmp
;
493 OUString
aWinData( aTmp
);
494 m_nUserCustomPageLeftMargin
= aWinData
.toInt32();
495 bUserCustomValuesAvailable
= true;
498 SvtViewOptions
aWinOpt2( EViewType::Window
, SWPAGE_RIGHT_GVALUE
);
499 if ( aWinOpt2
.Exists() )
501 css::uno::Sequence
< css::beans::NamedValue
> aSeq
= aWinOpt2
.GetUserData();
503 if ( aSeq
.hasElements())
504 aSeq
[0].Value
>>= aTmp
;
505 OUString
aWinData( aTmp
);
506 m_nUserCustomPageRightMargin
= aWinData
.toInt32();
507 bUserCustomValuesAvailable
= true;
510 SvtViewOptions
aWinOpt3( EViewType::Window
, SWPAGE_TOP_GVALUE
);
511 if ( aWinOpt3
.Exists() )
513 css::uno::Sequence
< css::beans::NamedValue
> aSeq
= aWinOpt3
.GetUserData();
515 if ( aSeq
.hasElements() )
516 aSeq
[0].Value
>>= aTmp
;
517 OUString
aWinData( aTmp
);
518 m_nUserCustomPageTopMargin
= aWinData
.toInt32();
519 bUserCustomValuesAvailable
= true;
522 SvtViewOptions
aWinOpt4( EViewType::Window
, SWPAGE_DOWN_GVALUE
);
523 if ( aWinOpt4
.Exists() )
525 css::uno::Sequence
< css::beans::NamedValue
> aSeq
= aWinOpt4
.GetUserData();
527 if ( aSeq
.hasElements())
528 aSeq
[0].Value
>>= aTmp
;
529 OUString
aWinData( aTmp
);
530 m_nUserCustomPageBottomMargin
= aWinData
.toInt32();
531 bUserCustomValuesAvailable
= true;
534 SvtViewOptions
aWinOpt5( EViewType::Window
, SWPAGE_MIRROR_GVALUE
);
535 if ( aWinOpt5
.Exists() )
537 css::uno::Sequence
< css::beans::NamedValue
> aSeq
= aWinOpt5
.GetUserData();
539 if ( aSeq
.hasElements())
540 aSeq
[0].Value
>>= aTmp
;
541 OUString
aWinData( aTmp
);
542 m_bUserCustomMirrored
= aWinData
.toInt32() != 0;
543 bUserCustomValuesAvailable
= true;
546 return bUserCustomValuesAvailable
;
549 void PageMarginControl::StoreUserCustomValues()
551 if ( !m_bCustomValuesUsed
)
556 css::uno::Sequence
< css::beans::NamedValue
> aSeq( 1 );
557 SvtViewOptions
aWinOpt( EViewType::Window
, SWPAGE_LEFT_GVALUE
);
559 aSeq
[0].Name
= "mnPageLeftMargin";
560 aSeq
[0].Value
<<= OUString::number( m_nPageLeftMargin
);
561 aWinOpt
.SetUserData( aSeq
);
563 SvtViewOptions
aWinOpt2( EViewType::Window
, SWPAGE_RIGHT_GVALUE
);
564 aSeq
[0].Name
= "mnPageRightMargin";
565 aSeq
[0].Value
<<= OUString::number( m_nPageRightMargin
);
566 aWinOpt2
.SetUserData( aSeq
);
568 SvtViewOptions
aWinOpt3( EViewType::Window
, SWPAGE_TOP_GVALUE
);
569 aSeq
[0].Name
= "mnPageTopMargin";
570 aSeq
[0].Value
<<= OUString::number( m_nPageTopMargin
);
571 aWinOpt3
.SetUserData( aSeq
);
573 SvtViewOptions
aWinOpt4( EViewType::Window
, SWPAGE_DOWN_GVALUE
);
574 aSeq
[0].Name
= "mnPageBottomMargin";
575 aSeq
[0].Value
<<= OUString::number( m_nPageBottomMargin
);
576 aWinOpt4
.SetUserData( aSeq
);
578 SvtViewOptions
aWinOpt5( EViewType::Window
, SWPAGE_MIRROR_GVALUE
);
579 aSeq
[0].Name
= "mbMirrored";
580 aSeq
[0].Value
<<= OUString::number( (m_bMirrored
? 1 : 0) );
581 aWinOpt5
.SetUserData( aSeq
);
584 } // end of namespace sw::sidebar
586 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */