Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sw / source / uibase / sidebar / PageMarginControl.cxx
blobec6a18a66948fbc881e56c132a9a6c148d920d88
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 <cstdlib>
25 #include "PageMarginControl.hxx"
26 #include "PropertyPanel.hrc"
28 #include <editeng/sizeitem.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <svx/svxids.hrc>
31 #include <svx/pageitem.hxx>
32 #include <svl/itempool.hxx>
33 #include <svl/intitem.hxx>
35 #include <swtypes.hxx>
36 #include <cmdid.h>
38 #include <com/sun/star/document/XUndoManagerSupplier.hpp>
40 #include <vcl/settings.hxx>
42 #define SWPAGE_LEFT_GVALUE "Sw_Page_Left"
43 #define SWPAGE_RIGHT_GVALUE "Sw_Page_Right"
44 #define SWPAGE_TOP_GVALUE "Sw_Page_Top"
45 #define SWPAGE_DOWN_GVALUE "Sw_Page_Down"
46 #define SWPAGE_MIRROR_GVALUE "Sw_Page_Mirrored"
48 namespace
50 FieldUnit lcl_GetFieldUnit()
52 FieldUnit eUnit = FUNIT_INCH;
53 const SfxPoolItem* pItem = nullptr;
54 SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_METRIC, pItem );
55 if ( pItem && eState >= SfxItemState::DEFAULT )
57 eUnit = (FieldUnit)static_cast<const SfxUInt16Item*>( pItem )->GetValue();
59 else
61 return SfxModule::GetCurrentFieldUnit();
64 return eUnit;
67 MapUnit lcl_GetUnit()
69 SfxItemPool &rPool = SfxGetpApp()->GetPool();
70 sal_uInt16 nWhich = rPool.GetWhich( SID_ATTR_PAGE_SIZE );
71 return rPool.GetMetric( nWhich );
74 const css::uno::Reference< css::document::XUndoManager > getUndoManager( const css::uno::Reference< css::frame::XFrame >& rxFrame )
76 const css::uno::Reference< css::frame::XController >& xController = rxFrame->getController();
77 if ( xController.is() )
79 const css::uno::Reference< css::frame::XModel >& xModel = xController->getModel();
80 if ( xModel.is() )
82 const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, css::uno::UNO_QUERY_THROW );
83 if ( xSuppUndo.is() )
85 const css::uno::Reference< css::document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), css::uno::UNO_QUERY_THROW );
86 return xUndoManager;
91 return css::uno::Reference< css::document::XUndoManager > ();
95 namespace sw { namespace sidebar {
97 PageMarginControl::PageMarginControl( sal_uInt16 nId )
98 : SfxPopupWindow( nId, "PageMarginControl", "modules/swriter/ui/pagemargincontrol.ui" )
99 , m_nPageLeftMargin(0)
100 , m_nPageRightMargin(0)
101 , m_nPageTopMargin(0)
102 , m_nPageBottomMargin(0)
103 , m_bMirrored(false)
104 , m_eUnit( lcl_GetUnit() )
105 , m_bUserCustomValuesAvailable( false )
106 , m_nUserCustomPageLeftMargin( 0 )
107 , m_nUserCustomPageRightMargin( 0 )
108 , m_nUserCustomPageTopMargin( 0 )
109 , m_nUserCustomPageBottomMargin( 0 )
110 , m_bUserCustomMirrored( false )
111 , m_bCustomValuesUsed( false )
113 bool bLandscape = false;
114 const SfxPoolItem* pItem;
115 const SvxSizeItem* pSize = nullptr;
116 const SvxLongLRSpaceItem* pLRItem = nullptr;
117 const SvxLongULSpaceItem* pULItem = nullptr;
118 if ( SfxViewFrame::Current() )
120 SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem );
121 bLandscape = static_cast<const SvxPageItem*>( pItem )->IsLandscape();
122 m_bMirrored = static_cast<const SvxPageItem*>( pItem )->GetPageUsage() == SvxPageUsage::Mirror;
123 SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pItem );
124 pSize = static_cast<const SvxSizeItem*>( pItem );
125 SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pItem );
126 pLRItem = static_cast<const SvxLongLRSpaceItem*>( pItem );
127 SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE, pItem );
128 pULItem = static_cast<const SvxLongULSpaceItem*>( pItem );
131 if ( pLRItem )
133 m_nPageLeftMargin = pLRItem->GetLeft();
134 m_nPageRightMargin = pLRItem->GetRight();
137 if ( pULItem )
139 m_nPageTopMargin = pULItem->GetUpper();
140 m_nPageBottomMargin = pULItem->GetLower();
143 if ( bLandscape )
145 get( m_pNarrow, "narrowL" );
146 get( m_pNormal, "normalL" );
147 get( m_pWide, "wideL" );
148 get( m_pMirrored, "mirroredL" );
149 get( m_pLast, "lastL" );
151 else
153 get( m_pNarrow, "narrow" );
154 get( m_pNormal, "normal" );
155 get( m_pWide, "wide" );
156 get( m_pMirrored, "mirrored" );
157 get( m_pLast, "last" );
160 m_pNarrow->Show();
161 m_pNormal->Show();
162 m_pWide->Show();
163 m_pMirrored->Show();
164 m_pLast->Show();
166 m_pNarrow->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
167 m_pNormal->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
168 m_pWide->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
169 m_pMirrored->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
170 m_pLast->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
172 get( m_pContainer, "container" );
173 m_pWidthHeightField = VclPtr<MetricField>::Create( m_pContainer.get(), (WinBits)0 );
174 m_pWidthHeightField->Hide();
175 m_pWidthHeightField->SetUnit( FUNIT_CM );
176 m_pWidthHeightField->SetMax( 9999 );
177 m_pWidthHeightField->SetDecimalDigits( 2 );
178 m_pWidthHeightField->SetSpinSize( 10 );
179 m_pWidthHeightField->SetLast( 9999 );
180 SetFieldUnit( *m_pWidthHeightField.get(), lcl_GetFieldUnit() );
182 m_bUserCustomValuesAvailable = GetUserCustomValues();
184 FillHelpText( m_bUserCustomValuesAvailable );
186 get( m_pLeftMarginEdit, "left" );
187 get( m_pRightMarginEdit, "right" );
188 get( m_pTopMarginEdit, "top" );
189 get( m_pBottomMarginEdit, "bottom" );
191 Link<Edit&,void> aLinkLR = LINK( this, PageMarginControl, ModifyLRMarginHdl );
192 m_pLeftMarginEdit->SetModifyHdl( aLinkLR );
193 SetMetricValue( *m_pLeftMarginEdit.get(), m_nPageLeftMargin, m_eUnit );
195 m_pRightMarginEdit->SetModifyHdl( aLinkLR );
196 SetMetricValue( *m_pRightMarginEdit.get(), m_nPageRightMargin, m_eUnit );
198 Link<Edit&,void> aLinkUL = LINK( this, PageMarginControl, ModifyULMarginHdl );
199 m_pTopMarginEdit->SetModifyHdl( aLinkUL );
200 SetMetricValue( *m_pTopMarginEdit.get(), m_nPageTopMargin, m_eUnit );
202 m_pBottomMarginEdit->SetModifyHdl( aLinkUL );
203 SetMetricValue( *m_pBottomMarginEdit.get(), m_nPageBottomMargin, m_eUnit );
205 m_aPageSize = pSize->GetSize();
206 SetMetricFieldMaxValues( m_aPageSize );
208 get( m_pLeft, "leftLabel" );
209 get( m_pRight, "rightLabel" );
210 get( m_pInner, "innerLabel" );
211 get( m_pOuter, "outerLabel" );
213 if ( m_bMirrored )
215 m_pLeft->Hide();
216 m_pRight->Hide();
217 m_pInner->Show();
218 m_pOuter->Show();
220 else
222 m_pLeft->Show();
223 m_pRight->Show();
224 m_pInner->Hide();
225 m_pOuter->Hide();
229 PageMarginControl::~PageMarginControl()
231 disposeOnce();
234 void PageMarginControl::dispose()
236 StoreUserCustomValues();
238 m_pLeft.disposeAndClear();
239 m_pRight.disposeAndClear();
240 m_pInner.disposeAndClear();
241 m_pOuter.disposeAndClear();
242 m_pLeftMarginEdit.disposeAndClear();
243 m_pRightMarginEdit.disposeAndClear();
244 m_pTopMarginEdit.disposeAndClear();
245 m_pBottomMarginEdit.disposeAndClear();
246 m_pNarrow.disposeAndClear();
247 m_pNormal.disposeAndClear();
248 m_pWide.disposeAndClear();
249 m_pMirrored.disposeAndClear();
250 m_pLast.disposeAndClear();
252 m_pWidthHeightField.disposeAndClear();
253 m_pContainer.disposeAndClear();
255 SfxPopupWindow::dispose();
258 void PageMarginControl::SetMetricFieldMaxValues( const Size& rPageSize )
260 const long nML = m_pLeftMarginEdit->Denormalize( m_pLeftMarginEdit->GetValue( FUNIT_TWIP ) );
261 const long nMR = m_pRightMarginEdit->Denormalize( m_pRightMarginEdit->GetValue( FUNIT_TWIP ) );
262 const long nMT = m_pTopMarginEdit->Denormalize( m_pTopMarginEdit->GetValue( FUNIT_TWIP ) );
263 const long nMB = m_pBottomMarginEdit->Denormalize( m_pBottomMarginEdit->GetValue( FUNIT_TWIP ) );
265 const long nPH = LogicToLogic( rPageSize.Height(), (MapUnit)m_eUnit, MapUnit::MapTwip );
266 const long nPW = LogicToLogic( rPageSize.Width(), (MapUnit)m_eUnit, MapUnit::MapTwip );
268 // Left
269 long nMax = nPW - nMR - MINBODY;
270 m_pLeftMarginEdit->SetMax( m_pLeftMarginEdit->Normalize( nMax ), FUNIT_TWIP );
272 // Right
273 nMax = nPW - nML - MINBODY;
274 m_pRightMarginEdit->SetMax( m_pRightMarginEdit->Normalize( nMax ), FUNIT_TWIP );
276 //Top
277 nMax = nPH - nMB - MINBODY;
278 m_pTopMarginEdit->SetMax( m_pTopMarginEdit->Normalize( nMax ), FUNIT_TWIP );
280 //Bottom
281 nMax = nPH - nMT - MINBODY;
282 m_pBottomMarginEdit->SetMax( m_pTopMarginEdit->Normalize( nMax ), FUNIT_TWIP );
285 void PageMarginControl::FillHelpText( const bool bUserCustomValuesAvailable )
287 const OUString aLeft = SwResId( STR_MARGIN_TOOLTIP_LEFT );
288 const OUString aRight = SwResId( STR_MARGIN_TOOLTIP_RIGHT );
289 const OUString aTop = SwResId( STR_MARGIN_TOOLTIP_TOP );
290 const OUString aBottom = SwResId( STR_MARGIN_TOOLTIP_BOT );
292 SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_NARROW_VALUE, m_eUnit );
293 const OUString aNarrowValText = m_pWidthHeightField->GetText();
294 OUString aHelpText = aLeft;
295 aHelpText += aNarrowValText;
296 aHelpText += aRight;
297 aHelpText += aNarrowValText;
298 aHelpText += aTop;
299 aHelpText += aNarrowValText;
300 aHelpText += aBottom;
301 aHelpText += aNarrowValText;
302 m_pNarrow->SetQuickHelpText( aHelpText );
304 SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_NORMAL_VALUE, m_eUnit );
305 const OUString aNormalValText = m_pWidthHeightField->GetText();
306 aHelpText = aLeft;
307 aHelpText += aNormalValText;
308 aHelpText += aRight;
309 aHelpText += aNormalValText;
310 aHelpText += aTop;
311 aHelpText += aNormalValText;
312 aHelpText += aBottom;
313 aHelpText += aNormalValText;
314 m_pNormal->SetQuickHelpText( aHelpText );
316 SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_WIDE_VALUE1, m_eUnit );
317 const OUString aWide1ValText = m_pWidthHeightField->GetText();
318 SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_WIDE_VALUE2, m_eUnit );
319 const OUString aWide2ValText = m_pWidthHeightField->GetText();
320 aHelpText = aLeft;
321 aHelpText += aWide2ValText;
322 aHelpText += aRight;
323 aHelpText += aWide2ValText;
324 aHelpText += aTop;
325 aHelpText += aWide1ValText;
326 aHelpText += aBottom;
327 aHelpText += aWide1ValText;
328 m_pWide->SetQuickHelpText( aHelpText );
330 const OUString aInner = SwResId( STR_MARGIN_TOOLTIP_INNER );
331 const OUString aOuter = SwResId( STR_MARGIN_TOOLTIP_OUTER );
333 SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_WIDE_VALUE3, m_eUnit );
334 const OUString aWide3ValText = m_pWidthHeightField->GetText();
335 aHelpText = aInner;
336 aHelpText += aWide3ValText;
337 aHelpText += aOuter;
338 aHelpText += aWide1ValText;
339 aHelpText += aTop;
340 aHelpText += aWide1ValText;
341 aHelpText += aBottom;
342 aHelpText += aWide1ValText;
343 m_pMirrored->SetQuickHelpText( aHelpText );
345 if ( bUserCustomValuesAvailable )
347 aHelpText = m_bUserCustomMirrored ? aInner : aLeft;
348 SetMetricValue( *m_pWidthHeightField.get(), m_nUserCustomPageLeftMargin, m_eUnit );
349 aHelpText += m_pWidthHeightField->GetText();
350 aHelpText += m_bUserCustomMirrored ? aOuter : aRight;
351 SetMetricValue( *m_pWidthHeightField.get(), m_nUserCustomPageRightMargin, m_eUnit );
352 aHelpText += m_pWidthHeightField->GetText();
353 aHelpText += aTop;
354 SetMetricValue( *m_pWidthHeightField.get(), m_nUserCustomPageTopMargin, m_eUnit );
355 aHelpText += m_pWidthHeightField->GetText();
356 aHelpText += aBottom;
357 SetMetricValue( *m_pWidthHeightField.get(), m_nUserCustomPageBottomMargin, m_eUnit );
358 aHelpText += m_pWidthHeightField->GetText();
360 else
362 aHelpText.clear();
364 m_pLast->SetQuickHelpText( aHelpText );
367 IMPL_LINK( PageMarginControl, SelectMarginHdl, Button*, pControl, void )
369 bool bMirrored = false;
370 bool bApplyNewPageMargins = true;
371 if( pControl == m_pNarrow.get() )
373 m_nPageLeftMargin = SWPAGE_NARROW_VALUE;
374 m_nPageRightMargin = SWPAGE_NARROW_VALUE;
375 m_nPageTopMargin = SWPAGE_NARROW_VALUE;
376 m_nPageBottomMargin = SWPAGE_NARROW_VALUE;
377 bMirrored = false;
379 if( pControl == m_pNormal.get() )
381 m_nPageLeftMargin = SWPAGE_NORMAL_VALUE;
382 m_nPageRightMargin = SWPAGE_NORMAL_VALUE;
383 m_nPageTopMargin = SWPAGE_NORMAL_VALUE;
384 m_nPageBottomMargin = SWPAGE_NORMAL_VALUE;
385 bMirrored = false;
387 if( pControl == m_pWide.get() )
389 m_nPageLeftMargin = SWPAGE_WIDE_VALUE2;
390 m_nPageRightMargin = SWPAGE_WIDE_VALUE2;
391 m_nPageTopMargin = SWPAGE_WIDE_VALUE1;
392 m_nPageBottomMargin = SWPAGE_WIDE_VALUE1;
393 bMirrored = false;
395 if( pControl == m_pMirrored.get() )
397 m_nPageLeftMargin = SWPAGE_WIDE_VALUE3;
398 m_nPageRightMargin = SWPAGE_WIDE_VALUE1;
399 m_nPageTopMargin = SWPAGE_WIDE_VALUE1;
400 m_nPageBottomMargin = SWPAGE_WIDE_VALUE1;
401 bMirrored = true;
403 if( pControl == m_pLast.get() )
405 if ( m_bUserCustomValuesAvailable )
407 m_nPageLeftMargin = m_nUserCustomPageLeftMargin;
408 m_nPageRightMargin = m_nUserCustomPageRightMargin;
409 m_nPageTopMargin = m_nUserCustomPageTopMargin;
410 m_nPageBottomMargin = m_nUserCustomPageBottomMargin;
411 bMirrored = m_bUserCustomMirrored;
413 else
415 bApplyNewPageMargins = false;
419 if ( bApplyNewPageMargins )
421 const css::uno::Reference< css::document::XUndoManager > xUndoManager( getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) );
422 if ( xUndoManager.is() )
423 xUndoManager->enterUndoContext( "" );
425 ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
426 ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
427 if ( m_bMirrored != bMirrored )
429 m_bMirrored = bMirrored;
430 ExecutePageLayoutChange( m_bMirrored );
433 if ( xUndoManager.is() )
434 xUndoManager->leaveUndoContext();
436 m_bCustomValuesUsed = false;
437 EndPopupMode();
441 void PageMarginControl::ExecuteMarginLRChange(
442 const long nPageLeftMargin,
443 const long nPageRightMargin )
445 if ( SfxViewFrame::Current() )
447 std::unique_ptr<SvxLongLRSpaceItem> pPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) );
448 pPageLRMarginItem->SetLeft( nPageLeftMargin );
449 pPageLRMarginItem->SetRight( nPageRightMargin );
450 SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE,
451 SfxCallMode::RECORD, { pPageLRMarginItem.get() } );
452 pPageLRMarginItem.reset();
456 void PageMarginControl::ExecuteMarginULChange(
457 const long nPageTopMargin,
458 const long nPageBottomMargin )
460 if ( SfxViewFrame::Current() )
462 std::unique_ptr<SvxLongULSpaceItem> pPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) );
463 pPageULMarginItem->SetUpper( nPageTopMargin );
464 pPageULMarginItem->SetLower( nPageBottomMargin );
465 SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE,
466 SfxCallMode::RECORD, { pPageULMarginItem.get() } );
467 pPageULMarginItem.reset();
471 void PageMarginControl::ExecutePageLayoutChange( const bool bMirrored )
473 if ( SfxViewFrame::Current() )
475 std::unique_ptr<SvxPageItem> pPageItem( new SvxPageItem( SID_ATTR_PAGE ) );
476 pPageItem->SetPageUsage( bMirrored ? SvxPageUsage::Mirror : SvxPageUsage::All );
477 SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE,
478 SfxCallMode::RECORD, { pPageItem.get() } );
479 pPageItem.reset();
483 IMPL_LINK_NOARG( PageMarginControl, ModifyLRMarginHdl, Edit&, void )
485 m_nPageLeftMargin = GetCoreValue( *m_pLeftMarginEdit.get(), m_eUnit );
486 m_nPageRightMargin = GetCoreValue( *m_pRightMarginEdit.get(), m_eUnit );
487 ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
488 SetMetricFieldMaxValues( m_aPageSize );
489 m_bCustomValuesUsed = true;
492 IMPL_LINK_NOARG( PageMarginControl, ModifyULMarginHdl, Edit&, void )
494 m_nPageTopMargin = GetCoreValue( *m_pTopMarginEdit.get(), m_eUnit );
495 m_nPageBottomMargin = GetCoreValue( *m_pBottomMarginEdit.get(), m_eUnit );
496 ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
497 SetMetricFieldMaxValues( m_aPageSize );
498 m_bCustomValuesUsed = true;
501 bool PageMarginControl::GetUserCustomValues()
503 bool bUserCustomValuesAvailable = false;
505 SvtViewOptions aWinOpt( EViewType::Window, SWPAGE_LEFT_GVALUE );
506 if ( aWinOpt.Exists() )
508 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt.GetUserData();
509 OUString aTmp;
510 if ( aSeq.getLength())
511 aSeq[0].Value >>= aTmp;
512 OUString aWinData( aTmp );
513 m_nUserCustomPageLeftMargin = aWinData.toInt32();
514 bUserCustomValuesAvailable = true;
517 SvtViewOptions aWinOpt2( EViewType::Window, SWPAGE_RIGHT_GVALUE );
518 if ( aWinOpt2.Exists() )
520 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
521 OUString aTmp;
522 if ( aSeq.getLength())
523 aSeq[0].Value >>= aTmp;
524 OUString aWinData( aTmp );
525 m_nUserCustomPageRightMargin = aWinData.toInt32();
526 bUserCustomValuesAvailable = true;
529 SvtViewOptions aWinOpt3( EViewType::Window, SWPAGE_TOP_GVALUE );
530 if ( aWinOpt3.Exists() )
532 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt3.GetUserData();
533 OUString aTmp;
534 if ( aSeq.getLength() )
535 aSeq[0].Value >>= aTmp;
536 OUString aWinData( aTmp );
537 m_nUserCustomPageTopMargin = aWinData.toInt32();
538 bUserCustomValuesAvailable = true;
541 SvtViewOptions aWinOpt4( EViewType::Window, SWPAGE_DOWN_GVALUE );
542 if ( aWinOpt4.Exists() )
544 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt4.GetUserData();
545 OUString aTmp;
546 if ( aSeq.getLength())
547 aSeq[0].Value >>= aTmp;
548 OUString aWinData( aTmp );
549 m_nUserCustomPageBottomMargin = aWinData.toInt32();
550 bUserCustomValuesAvailable = true;
553 SvtViewOptions aWinOpt5( EViewType::Window, SWPAGE_MIRROR_GVALUE );
554 if ( aWinOpt5.Exists() )
556 css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt5.GetUserData();
557 OUString aTmp;
558 if ( aSeq.getLength())
559 aSeq[0].Value >>= aTmp;
560 OUString aWinData( aTmp );
561 m_bUserCustomMirrored = aWinData.toInt32() != 0;
562 bUserCustomValuesAvailable = true;
565 return bUserCustomValuesAvailable;
568 void PageMarginControl::StoreUserCustomValues()
570 if ( !m_bCustomValuesUsed )
572 return;
575 css::uno::Sequence < css::beans::NamedValue > aSeq( 1 );
576 SvtViewOptions aWinOpt( EViewType::Window, SWPAGE_LEFT_GVALUE );
578 aSeq[0].Name = "mnPageLeftMargin";
579 aSeq[0].Value <<= OUString::number( m_nPageLeftMargin );
580 aWinOpt.SetUserData( aSeq );
582 SvtViewOptions aWinOpt2( EViewType::Window, SWPAGE_RIGHT_GVALUE );
583 aSeq[0].Name = "mnPageRightMargin";
584 aSeq[0].Value <<= OUString::number( m_nPageRightMargin );
585 aWinOpt2.SetUserData( aSeq );
587 SvtViewOptions aWinOpt3( EViewType::Window, SWPAGE_TOP_GVALUE );
588 aSeq[0].Name = "mnPageTopMargin";
589 aSeq[0].Value <<= OUString::number( m_nPageTopMargin );
590 aWinOpt3.SetUserData( aSeq );
592 SvtViewOptions aWinOpt4( EViewType::Window, SWPAGE_DOWN_GVALUE );
593 aSeq[0].Name = "mnPageBottomMargin";
594 aSeq[0].Value <<= OUString::number( m_nPageBottomMargin );
595 aWinOpt4.SetUserData( aSeq );
597 SvtViewOptions aWinOpt5( EViewType::Window, SWPAGE_MIRROR_GVALUE );
598 aSeq[0].Name = "mbMirrored";
599 aSeq[0].Value <<= OUString::number( (m_bMirrored ? 1 : 0) );
600 aWinOpt5.SetUserData( aSeq );
603 } } // end of namespace sw::sidebar
605 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */