Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / sidebar / PageMarginControl.cxx
blob217c6f7d7fa730ff3b9a731a94e100157b213812
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <memory>
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>
39 #include <cmdid.h>
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 constexpr OUStringLiteral SWPAGE_LEFT_GVALUE = u"Sw_Page_Left";
47 constexpr OUStringLiteral SWPAGE_RIGHT_GVALUE = u"Sw_Page_Right";
48 constexpr OUStringLiteral SWPAGE_TOP_GVALUE = u"Sw_Page_Top";
49 constexpr OUStringLiteral SWPAGE_DOWN_GVALUE = u"Sw_Page_Down";
50 constexpr OUStringLiteral SWPAGE_MIRROR_GVALUE = u"Sw_Page_Mirrored";
52 namespace
54 FieldUnit lcl_GetFieldUnit()
56 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
58 const SfxUInt16Item* pItem = nullptr;
59 SfxItemState eState = pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem);
60 if (pItem && eState >= SfxItemState::DEFAULT)
61 return static_cast<FieldUnit>(pItem->GetValue());
63 return SfxModule::GetCurrentFieldUnit();
66 MapUnit lcl_GetUnit()
68 SfxItemPool &rPool = SfxGetpApp()->GetPool();
69 sal_uInt16 nWhich = rPool.GetWhich( SID_ATTR_PAGE_SIZE );
70 return rPool.GetMetric( nWhich );
73 css::uno::Reference< css::document::XUndoManager > getUndoManager( const css::uno::Reference< css::frame::XFrame >& rxFrame )
75 const css::uno::Reference< css::frame::XController >& xController = rxFrame->getController();
76 if ( xController.is() )
78 const css::uno::Reference< css::frame::XModel >& xModel = xController->getModel();
79 if ( xModel.is() )
81 const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, css::uno::UNO_QUERY_THROW );
82 return css::uno::Reference< css::document::XUndoManager >( xSuppUndo->getUndoManager(), css::uno::UNO_SET_THROW );
86 return css::uno::Reference< css::document::XUndoManager > ();
90 namespace sw::sidebar {
92 PageMarginControl::PageMarginControl(PageMarginPopup* pControl, weld::Widget* pParent)
93 : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "modules/swriter/ui/pagemargincontrol.ui", "PageMarginControl")
94 , m_xLeft(m_xBuilder->weld_label("leftLabel"))
95 , m_xRight(m_xBuilder->weld_label("rightLabel"))
96 , m_xInner(m_xBuilder->weld_label("innerLabel"))
97 , m_xOuter(m_xBuilder->weld_label("outerLabel"))
98 , m_xLeftMarginEdit(m_xBuilder->weld_metric_spin_button("left", FieldUnit::CM))
99 , m_xRightMarginEdit(m_xBuilder->weld_metric_spin_button("right", FieldUnit::CM))
100 , m_xTopMarginEdit(m_xBuilder->weld_metric_spin_button("top", FieldUnit::CM))
101 , m_xBottomMarginEdit(m_xBuilder->weld_metric_spin_button("bottom", FieldUnit::CM))
102 , m_xWidthHeightField(m_xBuilder->weld_metric_spin_button("hidden", FieldUnit::CM))
103 , m_xControl(pControl)
104 , m_nPageLeftMargin(0)
105 , m_nPageRightMargin(0)
106 , m_nPageTopMargin(0)
107 , m_nPageBottomMargin(0)
108 , m_bMirrored(false)
109 , m_eUnit( lcl_GetUnit() )
110 , m_bUserCustomValuesAvailable( false )
111 , m_nUserCustomPageLeftMargin( 0 )
112 , m_nUserCustomPageRightMargin( 0 )
113 , m_nUserCustomPageTopMargin( 0 )
114 , m_nUserCustomPageBottomMargin( 0 )
115 , m_bUserCustomMirrored( false )
116 , m_bCustomValuesUsed( false )
118 m_xWidthHeightField->set_unit(FieldUnit::CM);
119 m_xWidthHeightField->set_range(0, 9999, FieldUnit::NONE);
120 m_xWidthHeightField->set_digits(2);
121 m_xWidthHeightField->set_increments(10, 100, FieldUnit::NONE);
122 SetFieldUnit( *m_xWidthHeightField, lcl_GetFieldUnit() );
124 bool bLandscape = false;
125 const SvxSizeItem* pSize = nullptr;
126 const SvxLongLRSpaceItem* pLRItem = nullptr;
127 const SvxLongULSpaceItem* pULItem = nullptr;
128 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
130 const SvxPageItem* pPageItem;
131 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem );
132 bLandscape = pPageItem->IsLandscape();
133 m_bMirrored = pPageItem->GetPageUsage() == SvxPageUsage::Mirror;
134 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize );
135 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pLRItem );
136 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE, pULItem );
139 if ( pLRItem )
141 m_nPageLeftMargin = pLRItem->GetLeft();
142 m_nPageRightMargin = pLRItem->GetRight();
145 if ( pULItem )
147 m_nPageTopMargin = pULItem->GetUpper();
148 m_nPageBottomMargin = pULItem->GetLower();
151 if ( bLandscape )
153 m_xNarrow = m_xBuilder->weld_button("narrowL");
154 m_xNormal = m_xBuilder->weld_button("normalL");
155 m_xWide = m_xBuilder->weld_button("wideL");
156 m_xMirrored = m_xBuilder->weld_button("mirroredL");
157 m_xLast = m_xBuilder->weld_button("lastL");
159 else
161 m_xNarrow = m_xBuilder->weld_button("narrow");
162 m_xNormal = m_xBuilder->weld_button("normal");
163 m_xWide = m_xBuilder->weld_button("wide");
164 m_xMirrored = m_xBuilder->weld_button("mirrored");
165 m_xLast = m_xBuilder->weld_button("last");
168 m_xNarrow->show();
169 m_xNormal->show();
170 m_xWide->show();
171 m_xMirrored->show();
172 m_xLast->show();
174 m_xNarrow->connect_clicked( LINK( this, PageMarginControl, SelectMarginHdl ) );
175 m_xNormal->connect_clicked( LINK( this, PageMarginControl, SelectMarginHdl ) );
176 m_xWide->connect_clicked( LINK( this, PageMarginControl, SelectMarginHdl ) );
177 m_xMirrored->connect_clicked( LINK( this, PageMarginControl, SelectMarginHdl ) );
178 m_xLast->connect_clicked( LINK( this, PageMarginControl, SelectMarginHdl ) );
180 m_bUserCustomValuesAvailable = GetUserCustomValues();
182 FillHelpText( m_bUserCustomValuesAvailable );
184 Link<weld::MetricSpinButton&,void> aLinkLR = LINK( this, PageMarginControl, ModifyLRMarginHdl );
185 m_xLeftMarginEdit->connect_value_changed( aLinkLR );
186 SetMetricValue( *m_xLeftMarginEdit, m_nPageLeftMargin, m_eUnit );
187 SetFieldUnit( *m_xLeftMarginEdit, lcl_GetFieldUnit() );
189 m_xRightMarginEdit->connect_value_changed( aLinkLR );
190 SetMetricValue( *m_xRightMarginEdit, m_nPageRightMargin, m_eUnit );
191 SetFieldUnit( *m_xRightMarginEdit, lcl_GetFieldUnit() );
193 Link<weld::MetricSpinButton&,void> aLinkUL = LINK( this, PageMarginControl, ModifyULMarginHdl );
194 m_xTopMarginEdit->connect_value_changed( aLinkUL );
195 SetMetricValue( *m_xTopMarginEdit, m_nPageTopMargin, m_eUnit );
196 SetFieldUnit( *m_xTopMarginEdit, lcl_GetFieldUnit() );
198 m_xBottomMarginEdit->connect_value_changed( aLinkUL );
199 SetMetricValue( *m_xBottomMarginEdit, m_nPageBottomMargin, m_eUnit );
200 SetFieldUnit( *m_xBottomMarginEdit, lcl_GetFieldUnit() );
202 if (pSize)
204 m_aPageSize = pSize->GetSize();
205 SetMetricFieldMaxValues( m_aPageSize );
208 if ( m_bMirrored )
210 m_xLeft->hide();
211 m_xRight->hide();
212 m_xInner->show();
213 m_xOuter->show();
215 else
217 m_xLeft->show();
218 m_xRight->show();
219 m_xInner->hide();
220 m_xOuter->hide();
224 void PageMarginControl::GrabFocus()
226 m_xNarrow->grab_focus();
229 PageMarginControl::~PageMarginControl()
231 StoreUserCustomValues();
234 void PageMarginControl::SetMetricFieldMaxValues( const Size& rPageSize )
236 const tools::Long nML = m_xLeftMarginEdit->denormalize( m_xLeftMarginEdit->get_value( FieldUnit::TWIP ) );
237 const tools::Long nMR = m_xRightMarginEdit->denormalize( m_xRightMarginEdit->get_value( FieldUnit::TWIP ) );
238 const tools::Long nMT = m_xTopMarginEdit->denormalize( m_xTopMarginEdit->get_value( FieldUnit::TWIP ) );
239 const tools::Long nMB = m_xBottomMarginEdit->denormalize( m_xBottomMarginEdit->get_value( FieldUnit::TWIP ) );
241 const tools::Long nPH = OutputDevice::LogicToLogic( rPageSize.Height(), m_eUnit, MapUnit::MapTwip );
242 const tools::Long nPW = OutputDevice::LogicToLogic( rPageSize.Width(), m_eUnit, MapUnit::MapTwip );
244 // Left
245 tools::Long nMax = nPW - nMR - MINBODY;
246 m_xLeftMarginEdit->set_max( m_xLeftMarginEdit->normalize( nMax ), FieldUnit::TWIP );
248 // Right
249 nMax = nPW - nML - MINBODY;
250 m_xRightMarginEdit->set_max( m_xRightMarginEdit->normalize( nMax ), FieldUnit::TWIP );
252 //Top
253 nMax = nPH - nMB - MINBODY;
254 m_xTopMarginEdit->set_max( m_xTopMarginEdit->normalize( nMax ), FieldUnit::TWIP );
256 //Bottom
257 nMax = nPH - nMT - MINBODY;
258 m_xBottomMarginEdit->set_max( m_xTopMarginEdit->normalize( nMax ), FieldUnit::TWIP );
261 void PageMarginControl::FillHelpText( const bool bUserCustomValuesAvailable )
263 const OUString aLeft = SwResId( STR_MARGIN_TOOLTIP_LEFT );
264 const OUString aRight = SwResId( STR_MARGIN_TOOLTIP_RIGHT );
265 const OUString aTop = SwResId( STR_MARGIN_TOOLTIP_TOP );
266 const OUString aBottom = SwResId( STR_MARGIN_TOOLTIP_BOT );
268 SetMetricValue( *m_xWidthHeightField, SWPAGE_NARROW_VALUE, m_eUnit );
269 const OUString aNarrowValText = m_xWidthHeightField->get_text();
270 OUString aHelpText = aLeft +
271 aNarrowValText +
272 aRight +
273 aNarrowValText +
274 aTop +
275 aNarrowValText +
276 aBottom +
277 aNarrowValText;
278 m_xNarrow->set_tooltip_text( aHelpText );
280 SetMetricValue( *m_xWidthHeightField, SWPAGE_NORMAL_VALUE, m_eUnit );
281 const OUString aNormalValText = m_xWidthHeightField->get_text();
282 aHelpText = aLeft +
283 aNormalValText +
284 aRight +
285 aNormalValText +
286 aTop +
287 aNormalValText +
288 aBottom +
289 aNormalValText;
290 m_xNormal->set_tooltip_text( aHelpText );
292 SetMetricValue( *m_xWidthHeightField, SWPAGE_WIDE_VALUE1, m_eUnit );
293 const OUString aWide1ValText = m_xWidthHeightField->get_text();
294 SetMetricValue( *m_xWidthHeightField, SWPAGE_WIDE_VALUE2, m_eUnit );
295 const OUString aWide2ValText = m_xWidthHeightField->get_text();
296 aHelpText = aLeft +
297 aWide2ValText +
298 aRight +
299 aWide2ValText +
300 aTop +
301 aWide1ValText +
302 aBottom +
303 aWide1ValText;
304 m_xWide->set_tooltip_text( aHelpText );
306 const OUString aInner = SwResId( STR_MARGIN_TOOLTIP_INNER );
307 const OUString aOuter = SwResId( STR_MARGIN_TOOLTIP_OUTER );
309 SetMetricValue( *m_xWidthHeightField, SWPAGE_WIDE_VALUE3, m_eUnit );
310 const OUString aWide3ValText = m_xWidthHeightField->get_text();
311 aHelpText = aInner +
312 aWide3ValText +
313 aOuter +
314 aWide1ValText +
315 aTop +
316 aWide1ValText +
317 aBottom +
318 aWide1ValText;
319 m_xMirrored->set_tooltip_text( aHelpText );
321 if ( bUserCustomValuesAvailable )
323 aHelpText = m_bUserCustomMirrored ? aInner : aLeft;
324 SetMetricValue( *m_xWidthHeightField, m_nUserCustomPageLeftMargin, m_eUnit );
325 aHelpText += m_xWidthHeightField->get_text();
326 aHelpText += m_bUserCustomMirrored ? aOuter : aRight;
327 SetMetricValue( *m_xWidthHeightField, m_nUserCustomPageRightMargin, m_eUnit );
328 aHelpText += m_xWidthHeightField->get_text() + aTop;
329 SetMetricValue( *m_xWidthHeightField, m_nUserCustomPageTopMargin, m_eUnit );
330 aHelpText += m_xWidthHeightField->get_text() + aBottom;
331 SetMetricValue( *m_xWidthHeightField, m_nUserCustomPageBottomMargin, m_eUnit );
332 aHelpText += m_xWidthHeightField->get_text();
334 else
336 aHelpText.clear();
338 m_xLast->set_tooltip_text( aHelpText );
341 IMPL_LINK( PageMarginControl, SelectMarginHdl, weld::Button&, rControl, void )
343 bool bMirrored = false;
344 bool bApplyNewPageMargins = true;
345 if( &rControl == m_xNarrow.get() )
347 m_nPageLeftMargin = SWPAGE_NARROW_VALUE;
348 m_nPageRightMargin = SWPAGE_NARROW_VALUE;
349 m_nPageTopMargin = SWPAGE_NARROW_VALUE;
350 m_nPageBottomMargin = SWPAGE_NARROW_VALUE;
351 bMirrored = false;
353 if( &rControl == m_xNormal.get() )
355 m_nPageLeftMargin = SWPAGE_NORMAL_VALUE;
356 m_nPageRightMargin = SWPAGE_NORMAL_VALUE;
357 m_nPageTopMargin = SWPAGE_NORMAL_VALUE;
358 m_nPageBottomMargin = SWPAGE_NORMAL_VALUE;
359 bMirrored = false;
361 if( &rControl == m_xWide.get() )
363 m_nPageLeftMargin = SWPAGE_WIDE_VALUE2;
364 m_nPageRightMargin = SWPAGE_WIDE_VALUE2;
365 m_nPageTopMargin = SWPAGE_WIDE_VALUE1;
366 m_nPageBottomMargin = SWPAGE_WIDE_VALUE1;
367 bMirrored = false;
369 if( &rControl == m_xMirrored.get() )
371 m_nPageLeftMargin = SWPAGE_WIDE_VALUE3;
372 m_nPageRightMargin = SWPAGE_WIDE_VALUE1;
373 m_nPageTopMargin = SWPAGE_WIDE_VALUE1;
374 m_nPageBottomMargin = SWPAGE_WIDE_VALUE1;
375 bMirrored = true;
377 if( &rControl == m_xLast.get() )
379 if ( m_bUserCustomValuesAvailable )
381 m_nPageLeftMargin = m_nUserCustomPageLeftMargin;
382 m_nPageRightMargin = m_nUserCustomPageRightMargin;
383 m_nPageTopMargin = m_nUserCustomPageTopMargin;
384 m_nPageBottomMargin = m_nUserCustomPageBottomMargin;
385 bMirrored = m_bUserCustomMirrored;
387 else
389 bApplyNewPageMargins = false;
393 if ( !bApplyNewPageMargins )
394 return;
396 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
397 const css::uno::Reference<css::document::XUndoManager> xUndoManager(pViewFrm ? getUndoManager(pViewFrm->GetFrame().GetFrameInterface()) : nullptr);
398 if ( xUndoManager.is() )
399 xUndoManager->enterUndoContext( "" );
401 ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
402 ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
403 if ( m_bMirrored != bMirrored )
405 m_bMirrored = bMirrored;
406 ExecutePageLayoutChange( m_bMirrored );
409 if ( xUndoManager.is() )
410 xUndoManager->leaveUndoContext();
412 m_bCustomValuesUsed = false;
413 m_xControl->EndPopupMode();
416 void PageMarginControl::ExecuteMarginLRChange(
417 const tools::Long nPageLeftMargin,
418 const tools::Long nPageRightMargin )
420 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
422 SvxLongLRSpaceItem aPageLRMarginItem( 0, 0, SID_ATTR_PAGE_LRSPACE );
423 aPageLRMarginItem.SetLeft( nPageLeftMargin );
424 aPageLRMarginItem.SetRight( nPageRightMargin );
425 pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE,
426 SfxCallMode::RECORD, { &aPageLRMarginItem } );
430 void PageMarginControl::ExecuteMarginULChange(
431 const tools::Long nPageTopMargin,
432 const tools::Long nPageBottomMargin )
434 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
436 SvxLongULSpaceItem aPageULMarginItem( 0, 0, SID_ATTR_PAGE_ULSPACE );
437 aPageULMarginItem.SetUpper( nPageTopMargin );
438 aPageULMarginItem.SetLower( nPageBottomMargin );
439 pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE,
440 SfxCallMode::RECORD, { &aPageULMarginItem } );
444 void PageMarginControl::ExecutePageLayoutChange( const bool bMirrored )
446 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
448 SvxPageItem aPageItem( SID_ATTR_PAGE );
449 aPageItem.SetPageUsage( bMirrored ? SvxPageUsage::Mirror : SvxPageUsage::All );
450 pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE,
451 SfxCallMode::RECORD, { &aPageItem } );
455 IMPL_LINK_NOARG( PageMarginControl, ModifyLRMarginHdl, weld::MetricSpinButton&, void )
457 m_nPageLeftMargin = GetCoreValue( *m_xLeftMarginEdit, m_eUnit );
458 m_nPageRightMargin = GetCoreValue( *m_xRightMarginEdit, m_eUnit );
459 ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
460 SetMetricFieldMaxValues( m_aPageSize );
461 m_bCustomValuesUsed = true;
464 IMPL_LINK_NOARG( PageMarginControl, ModifyULMarginHdl, weld::MetricSpinButton&, void )
466 m_nPageTopMargin = GetCoreValue( *m_xTopMarginEdit, m_eUnit );
467 m_nPageBottomMargin = GetCoreValue( *m_xBottomMarginEdit, m_eUnit );
468 ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
469 SetMetricFieldMaxValues( m_aPageSize );
470 m_bCustomValuesUsed = true;
473 bool PageMarginControl::GetUserCustomValues()
475 bool bUserCustomValuesAvailable = false;
477 SvtViewOptions aWinOpt( EViewType::Window, SWPAGE_LEFT_GVALUE );
478 if ( aWinOpt.Exists() )
480 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt.GetUserData();
481 OUString aTmp;
482 if ( aSeq.hasElements())
483 aSeq[0].Value >>= aTmp;
484 OUString aWinData( aTmp );
485 m_nUserCustomPageLeftMargin = aWinData.toInt32();
486 bUserCustomValuesAvailable = true;
489 SvtViewOptions aWinOpt2( EViewType::Window, SWPAGE_RIGHT_GVALUE );
490 if ( aWinOpt2.Exists() )
492 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
493 OUString aTmp;
494 if ( aSeq.hasElements())
495 aSeq[0].Value >>= aTmp;
496 OUString aWinData( aTmp );
497 m_nUserCustomPageRightMargin = aWinData.toInt32();
498 bUserCustomValuesAvailable = true;
501 SvtViewOptions aWinOpt3( EViewType::Window, SWPAGE_TOP_GVALUE );
502 if ( aWinOpt3.Exists() )
504 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt3.GetUserData();
505 OUString aTmp;
506 if ( aSeq.hasElements() )
507 aSeq[0].Value >>= aTmp;
508 OUString aWinData( aTmp );
509 m_nUserCustomPageTopMargin = aWinData.toInt32();
510 bUserCustomValuesAvailable = true;
513 SvtViewOptions aWinOpt4( EViewType::Window, SWPAGE_DOWN_GVALUE );
514 if ( aWinOpt4.Exists() )
516 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt4.GetUserData();
517 OUString aTmp;
518 if ( aSeq.hasElements())
519 aSeq[0].Value >>= aTmp;
520 OUString aWinData( aTmp );
521 m_nUserCustomPageBottomMargin = aWinData.toInt32();
522 bUserCustomValuesAvailable = true;
525 SvtViewOptions aWinOpt5( EViewType::Window, SWPAGE_MIRROR_GVALUE );
526 if ( aWinOpt5.Exists() )
528 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt5.GetUserData();
529 OUString aTmp;
530 if ( aSeq.hasElements())
531 aSeq[0].Value >>= aTmp;
532 OUString aWinData( aTmp );
533 m_bUserCustomMirrored = aWinData.toInt32() != 0;
534 bUserCustomValuesAvailable = true;
537 return bUserCustomValuesAvailable;
540 void PageMarginControl::StoreUserCustomValues()
542 if ( !m_bCustomValuesUsed )
544 return;
547 css::uno::Sequence < css::beans::NamedValue > aSeq( 1 );
548 auto pSeq = aSeq.getArray();
549 SvtViewOptions aWinOpt( EViewType::Window, SWPAGE_LEFT_GVALUE );
551 pSeq[0].Name = "mnPageLeftMargin";
552 pSeq[0].Value <<= OUString::number( m_nPageLeftMargin );
553 aWinOpt.SetUserData( aSeq );
555 SvtViewOptions aWinOpt2( EViewType::Window, SWPAGE_RIGHT_GVALUE );
556 pSeq[0].Name = "mnPageRightMargin";
557 pSeq[0].Value <<= OUString::number( m_nPageRightMargin );
558 aWinOpt2.SetUserData( aSeq );
560 SvtViewOptions aWinOpt3( EViewType::Window, SWPAGE_TOP_GVALUE );
561 pSeq[0].Name = "mnPageTopMargin";
562 pSeq[0].Value <<= OUString::number( m_nPageTopMargin );
563 aWinOpt3.SetUserData( aSeq );
565 SvtViewOptions aWinOpt4( EViewType::Window, SWPAGE_DOWN_GVALUE );
566 pSeq[0].Name = "mnPageBottomMargin";
567 pSeq[0].Value <<= OUString::number( m_nPageBottomMargin );
568 aWinOpt4.SetUserData( aSeq );
570 SvtViewOptions aWinOpt5( EViewType::Window, SWPAGE_MIRROR_GVALUE );
571 pSeq[0].Name = "mbMirrored";
572 pSeq[0].Value <<= OUString::number( m_bMirrored ? 1 : 0 );
573 aWinOpt5.SetUserData( aSeq );
576 } // end of namespace sw::sidebar
578 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */