LCOV - code coverage report
Current view: top level - sw/source/core/uibase/sidebar - PageMarginControl.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 304 0.0 %
Date: 2014-04-14 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/config.h>
      21             : 
      22             : #include <cstdlib>
      23             : 
      24             : #include "PageMarginControl.hxx"
      25             : #include "PagePropertyPanel.hxx"
      26             : #include "PagePropertyPanel.hrc"
      27             : 
      28             : #include <swtypes.hxx>
      29             : 
      30             : #include <svx/sidebar/ValueSetWithTextControl.hxx>
      31             : #include <vcl/settings.hxx>
      32             : 
      33             : #define SWPAGE_LEFT_GVALUE      "Sw_Page_Left"
      34             : #define SWPAGE_RIGHT_GVALUE     "Sw_Page_Right"
      35             : #define SWPAGE_TOP_GVALUE       "Sw_Page_Top"
      36             : #define SWPAGE_DOWN_GVALUE      "Sw_Page_Down"
      37             : #define SWPAGE_MIRROR_GVALUE    "Sw_Page_Mirrored"
      38             : 
      39             : namespace sw { namespace sidebar {
      40             : 
      41           0 : PageMarginControl::PageMarginControl(
      42             :     Window* pParent,
      43             :     PagePropertyPanel& rPanel,
      44             :     const SvxLongLRSpaceItem& aPageLRMargin,
      45             :     const SvxLongULSpaceItem& aPageULMargin,
      46             :     const bool bMirrored,
      47             :     const Size aPageSize,
      48             :     const sal_Bool bLandscape,
      49             :     const FieldUnit eFUnit,
      50             :     const SfxMapUnit eUnit )
      51             :     : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_MARGIN) )
      52           0 :     , mpMarginValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_MARGIN) ) )
      53             :     , maCustom(this, SW_RES(FT_CUSTOM))
      54             :     , maLeft(this, SW_RES(FT_LEFT))
      55             :     , maInner(this, SW_RES(FT_INNER))
      56             :     , maLeftMarginEdit(this, SW_RES(MF_SWLEFT_MARGIN))
      57             :     , maRight(this, SW_RES(FT_RIGHT))
      58             :     , maOuter(this, SW_RES(FT_OUTER))
      59             :     , maRightMarginEdit(this, SW_RES(MF_SWRIGHT_MARGIN))
      60             :     , maTop(this, SW_RES(FT_TOP))
      61             :     , maTopMarginEdit(this, SW_RES(MF_SWTOP_MARGIN))
      62             :     , maBottom(this, SW_RES(FT_BOTTOM))
      63             :     , maBottomMarginEdit(this, SW_RES(MF_SWBOTTOM_MARGIN))
      64             :     , maWidthHeightField( this, SW_RES(FLD_WIDTH_HEIGHT) )
      65           0 :     , mnPageLeftMargin( aPageLRMargin.GetLeft() )
      66           0 :     , mnPageRightMargin( aPageLRMargin.GetRight() )
      67           0 :     , mnPageTopMargin( aPageULMargin.GetUpper() )
      68           0 :     , mnPageBottomMargin( aPageULMargin.GetLower() )
      69             :     , mbMirrored( bMirrored )
      70             :     , meUnit( eUnit )
      71             :     , mbUserCustomValuesAvailable(false)
      72             :     , mnUserCustomPageLeftMargin(0)
      73             :     , mnUserCustomPageRightMargin(0)
      74             :     , mnUserCustomPageTopMargin(0)
      75             :     , mnUserCustomPageBottomMargin(0)
      76             :     , mbUserCustomMirrored(false)
      77             :     , mbCustomValuesUsed( false )
      78           0 :     , mrPagePropPanel(rPanel)
      79             : {
      80           0 :     maWidthHeightField.Hide();
      81           0 :     SetFieldUnit( maWidthHeightField, eFUnit );
      82             : 
      83           0 :     mbUserCustomValuesAvailable = GetUserCustomValues();
      84             : 
      85           0 :     mpMarginValueSet->SetStyle( mpMarginValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
      86           0 :     mpMarginValueSet->SetColor( GetSettings().GetStyleSettings().GetMenuColor() );
      87             : 
      88           0 :     FillValueSet( bLandscape, mbUserCustomValuesAvailable );
      89             : 
      90           0 :     mpMarginValueSet->SetNoSelection();
      91           0 :     mpMarginValueSet->SetSelectHdl( LINK(this, PageMarginControl,ImplMarginHdl ) );
      92           0 :     mpMarginValueSet->Show();
      93             : 
      94           0 :     SelectValueSetItem();
      95             : 
      96           0 :     SetFieldUnit( maLeftMarginEdit, eFUnit );
      97           0 :     Link aLinkLR = LINK( this, PageMarginControl, ModifyLRMarginHdl );
      98           0 :     maLeftMarginEdit.SetModifyHdl( aLinkLR );
      99           0 :     SetMetricValue( maLeftMarginEdit, mnPageLeftMargin, meUnit );
     100             : 
     101           0 :     SetFieldUnit( maRightMarginEdit, eFUnit );
     102           0 :     maRightMarginEdit.SetModifyHdl( aLinkLR );
     103           0 :     SetMetricValue( maRightMarginEdit, mnPageRightMargin, meUnit );
     104             : 
     105           0 :     Link aLinkUL = LINK( this, PageMarginControl, ModifyULMarginHdl );
     106           0 :     SetFieldUnit( maTopMarginEdit, eFUnit );
     107           0 :     maTopMarginEdit.SetModifyHdl( aLinkUL );
     108           0 :     SetMetricValue( maTopMarginEdit, mnPageTopMargin, meUnit );
     109             : 
     110           0 :     SetFieldUnit( maBottomMarginEdit, eFUnit );
     111           0 :     maBottomMarginEdit.SetModifyHdl( aLinkUL );
     112           0 :     SetMetricValue( maBottomMarginEdit, mnPageBottomMargin, meUnit );
     113             : 
     114           0 :     SetMetricFieldMaxValues( aPageSize );
     115             : 
     116           0 :     if ( mbMirrored )
     117             :     {
     118           0 :         maLeft.Hide();
     119           0 :         maRight.Hide();
     120           0 :         maInner.Show();
     121           0 :         maOuter.Show();
     122             :     }
     123             :     else
     124             :     {
     125           0 :         maLeft.Show();
     126           0 :         maRight.Show();
     127           0 :         maInner.Hide();
     128           0 :         maOuter.Hide();
     129             :     }
     130             : 
     131           0 :     FreeResource();
     132           0 : }
     133             : 
     134           0 : PageMarginControl::~PageMarginControl(void)
     135             : {
     136           0 :     delete mpMarginValueSet;
     137             : 
     138           0 :     StoreUserCustomValues();
     139           0 : }
     140             : 
     141           0 : void PageMarginControl::SetMetricFieldMaxValues( const Size aPageSize )
     142             : {
     143           0 :     const long nML = maLeftMarginEdit.Denormalize( maLeftMarginEdit.GetValue(FUNIT_TWIP) );
     144           0 :     const long nMR = maRightMarginEdit.Denormalize( maRightMarginEdit.GetValue(FUNIT_TWIP) );
     145           0 :     const long nMT = maTopMarginEdit.Denormalize(maTopMarginEdit.GetValue(FUNIT_TWIP) );
     146           0 :     const long nMB = maBottomMarginEdit.Denormalize( maBottomMarginEdit.GetValue(FUNIT_TWIP) );
     147             : 
     148           0 :     const long nPH  = LogicToLogic( aPageSize.Height(), (MapUnit)meUnit, MAP_TWIP );
     149           0 :     const long nPW  = LogicToLogic( aPageSize.Width(),  (MapUnit)meUnit, MAP_TWIP );
     150             : 
     151             :     // Left
     152           0 :     long nMax = nPW - nMR - MINBODY;
     153           0 :     maLeftMarginEdit.SetMax(maLeftMarginEdit.Normalize(nMax), FUNIT_TWIP);
     154             : 
     155             :     // Right
     156           0 :     nMax = nPW - nML - MINBODY;
     157           0 :     maRightMarginEdit.SetMax(maRightMarginEdit.Normalize(nMax), FUNIT_TWIP);
     158             : 
     159             :     //Top
     160           0 :     nMax = nPH - nMB - MINBODY;
     161           0 :     maTopMarginEdit.SetMax(maTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
     162             : 
     163             :     //Bottom
     164           0 :     nMax = nPH - nMT -  MINBODY;
     165           0 :     maBottomMarginEdit.SetMax(maTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
     166           0 : }
     167             : 
     168           0 : void PageMarginControl::FillValueSet(
     169             :     const bool bLandscape,
     170             :     const bool bUserCustomValuesAvailable )
     171             : {
     172           0 :     const OUString aLeft = SW_RESSTR(STR_MARGIN_TOOLTIP_LEFT);
     173           0 :     const OUString aRight = SW_RESSTR(STR_MARGIN_TOOLTIP_RIGHT);
     174           0 :     const OUString aTop = SW_RESSTR(STR_MARGIN_TOOLTIP_TOP);
     175           0 :     const OUString aBottom = SW_RESSTR(STR_MARGIN_TOOLTIP_BOT);
     176             : 
     177           0 :     SetMetricValue( maWidthHeightField, SWPAGE_NARROW_VALUE, meUnit );
     178           0 :     const OUString aNarrowValText = maWidthHeightField.GetText();
     179           0 :     OUString aHelpText = aLeft;
     180           0 :     aHelpText += aNarrowValText;
     181           0 :     aHelpText += aRight;
     182           0 :     aHelpText += aNarrowValText;
     183           0 :     aHelpText += aTop;
     184           0 :     aHelpText += aNarrowValText;
     185           0 :     aHelpText += aBottom;
     186           0 :     aHelpText += aNarrowValText;
     187             :     mpMarginValueSet->AddItem(
     188             :         Image((bLandscape) ? SW_RES(IMG_NARROW_L) : SW_RES(IMG_NARROW)), 0,
     189           0 :         SW_RESSTR(STR_NARROW), &aHelpText );
     190             : 
     191           0 :     SetMetricValue( maWidthHeightField, SWPAGE_NORMAL_VALUE, meUnit );
     192           0 :     const OUString aNormalValText = maWidthHeightField.GetText();
     193           0 :     aHelpText = aLeft;
     194           0 :     aHelpText += aNormalValText;
     195           0 :     aHelpText += aRight;
     196           0 :     aHelpText += aNormalValText;
     197           0 :     aHelpText += aTop;
     198           0 :     aHelpText += aNormalValText;
     199           0 :     aHelpText += aBottom;
     200           0 :     aHelpText += aNormalValText;
     201             :     mpMarginValueSet->AddItem(
     202             :         Image((bLandscape) ? SW_RES(IMG_NORMAL_L) : SW_RES(IMG_NORMAL)), 0,
     203           0 :         SW_RESSTR(STR_NORMAL), &aHelpText );
     204             : 
     205           0 :     SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE1, meUnit );
     206           0 :     const OUString aWide1ValText = maWidthHeightField.GetText();
     207           0 :     SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE2, meUnit );
     208           0 :     const OUString aWide2ValText = maWidthHeightField.GetText();
     209           0 :     aHelpText = aLeft;
     210           0 :     aHelpText += aWide2ValText;
     211           0 :     aHelpText += aRight;
     212           0 :     aHelpText += aWide2ValText;
     213           0 :     aHelpText += aTop;
     214           0 :     aHelpText += aWide1ValText;
     215           0 :     aHelpText += aBottom;
     216           0 :     aHelpText += aWide1ValText;
     217             :     mpMarginValueSet->AddItem(
     218             :         Image((bLandscape) ? SW_RES(IMG_WIDE_L) : SW_RES(IMG_WIDE)), 0,
     219           0 :         SW_RESSTR(STR_WIDE), &aHelpText );
     220             : 
     221           0 :     const OUString aInner = SW_RESSTR(STR_MARGIN_TOOLTIP_INNER);
     222           0 :     const OUString aOuter = SW_RESSTR(STR_MARGIN_TOOLTIP_OUTER);
     223             : 
     224           0 :     SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE3, meUnit );
     225           0 :     const OUString aWide3ValText = maWidthHeightField.GetText();
     226           0 :     aHelpText = aInner;
     227           0 :     aHelpText += aWide3ValText;
     228           0 :     aHelpText += aOuter;
     229           0 :     aHelpText += aWide3ValText;
     230           0 :     aHelpText += aTop;
     231           0 :     aHelpText += aWide1ValText;
     232           0 :     aHelpText += aBottom;
     233           0 :     aHelpText += aWide1ValText;
     234             :     mpMarginValueSet->AddItem(
     235             :         Image((bLandscape) ? SW_RES(IMG_MIRRORED_L) : SW_RES(IMG_MIRRORED)), 0,
     236           0 :         SW_RESSTR(STR_MIRRORED), &aHelpText );
     237             : 
     238           0 :     if ( bUserCustomValuesAvailable )
     239             :     {
     240           0 :         aHelpText = mbUserCustomMirrored ? aInner : aLeft;
     241           0 :         SetMetricValue( maWidthHeightField, mnUserCustomPageLeftMargin, meUnit );
     242           0 :         aHelpText += maWidthHeightField.GetText();
     243           0 :         aHelpText += mbUserCustomMirrored ? aOuter : aRight;
     244           0 :         SetMetricValue( maWidthHeightField, mnUserCustomPageRightMargin, meUnit );
     245           0 :         aHelpText += maWidthHeightField.GetText();
     246           0 :         aHelpText += aTop;
     247           0 :         SetMetricValue( maWidthHeightField, mnUserCustomPageTopMargin, meUnit );
     248           0 :         aHelpText += maWidthHeightField.GetText();
     249           0 :         aHelpText += aBottom;
     250           0 :         SetMetricValue( maWidthHeightField, mnUserCustomPageBottomMargin, meUnit );
     251           0 :         aHelpText += maWidthHeightField.GetText();
     252             :     }
     253             :     else
     254             :     {
     255           0 :         aHelpText = OUString();
     256             :     }
     257             :     mpMarginValueSet->AddItem(
     258             :         Image((bUserCustomValuesAvailable) ? SW_RES(IMG_CUSTOM) : SW_RES(IMG_CUSTOM_DIS)), 0,
     259           0 :         SW_RESSTR(STR_LCVALUE), &aHelpText );
     260           0 : }
     261             : 
     262           0 : void PageMarginControl::SelectValueSetItem()
     263             : {
     264           0 :     const long cTolerance = 5;
     265             : 
     266           0 :     if( std::abs(mnPageLeftMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
     267           0 :         std::abs(mnPageRightMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
     268           0 :         std::abs(mnPageTopMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
     269           0 :         std::abs(mnPageBottomMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
     270           0 :         !mbMirrored )
     271             :     {
     272           0 :         mpMarginValueSet->SelectItem(1);
     273             :     }
     274           0 :     else if( std::abs(mnPageLeftMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
     275           0 :         std::abs(mnPageRightMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
     276           0 :         std::abs(mnPageTopMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
     277           0 :         std::abs(mnPageBottomMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
     278           0 :         !mbMirrored )
     279             :     {
     280           0 :         mpMarginValueSet->SelectItem(2);
     281             :     }
     282           0 :     else if( std::abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
     283           0 :         std::abs(mnPageRightMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
     284           0 :         std::abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
     285           0 :         std::abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
     286           0 :         !mbMirrored )
     287             :     {
     288           0 :         mpMarginValueSet->SelectItem(3);
     289             :     }
     290           0 :     else if( std::abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE3) <= cTolerance &&
     291           0 :         std::abs(mnPageRightMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
     292           0 :         std::abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
     293           0 :         std::abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
     294             :         mbMirrored )
     295             :     {
     296           0 :         mpMarginValueSet->SelectItem(4);
     297             :     }
     298             :     else
     299             :     {
     300           0 :         mpMarginValueSet->SelectItem(0);
     301             :     }
     302             : 
     303           0 :     mpMarginValueSet->Format();
     304           0 :     mpMarginValueSet->StartSelection();
     305           0 : };
     306             : 
     307           0 : IMPL_LINK(PageMarginControl, ImplMarginHdl, void *, pControl)
     308             : {
     309           0 :     if ( pControl == mpMarginValueSet )
     310             :     {
     311           0 :         const sal_uInt16 iPos = mpMarginValueSet->GetSelectItemId();
     312           0 :         bool bMirrored = false;
     313           0 :         bool bApplyNewPageMargins = true;
     314           0 :         switch ( iPos )
     315             :         {
     316             :         case 1:
     317           0 :             mnPageLeftMargin = SWPAGE_NARROW_VALUE;
     318           0 :             mnPageRightMargin = SWPAGE_NARROW_VALUE;
     319           0 :             mnPageTopMargin = SWPAGE_NARROW_VALUE;
     320           0 :             mnPageBottomMargin = SWPAGE_NARROW_VALUE;
     321           0 :             bMirrored = false;
     322           0 :             break;
     323             :         case 2:
     324           0 :             mnPageLeftMargin = SWPAGE_NORMAL_VALUE;
     325           0 :             mnPageRightMargin = SWPAGE_NORMAL_VALUE;
     326           0 :             mnPageTopMargin = SWPAGE_NORMAL_VALUE;
     327           0 :             mnPageBottomMargin = SWPAGE_NORMAL_VALUE;
     328           0 :             bMirrored = false;
     329           0 :             break;
     330             :         case 3:
     331           0 :             mnPageLeftMargin = SWPAGE_WIDE_VALUE2;
     332           0 :             mnPageRightMargin = SWPAGE_WIDE_VALUE2;
     333           0 :             mnPageTopMargin = SWPAGE_WIDE_VALUE1;
     334           0 :             mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
     335           0 :             bMirrored = false;
     336           0 :             break;
     337             :         case 4:
     338           0 :             mnPageLeftMargin = SWPAGE_WIDE_VALUE3;
     339           0 :             mnPageRightMargin = SWPAGE_WIDE_VALUE1;
     340           0 :             mnPageTopMargin = SWPAGE_WIDE_VALUE1;
     341           0 :             mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
     342           0 :             bMirrored = true;
     343           0 :             break;
     344             :         case 5:
     345           0 :             if ( mbUserCustomValuesAvailable )
     346             :             {
     347           0 :                 mnPageLeftMargin = mnUserCustomPageLeftMargin;
     348           0 :                 mnPageRightMargin = mnUserCustomPageRightMargin;
     349           0 :                 mnPageTopMargin = mnUserCustomPageTopMargin;
     350           0 :                 mnPageBottomMargin = mnUserCustomPageBottomMargin;
     351           0 :                 bMirrored = mbUserCustomMirrored;
     352             :             }
     353             :             else
     354             :             {
     355           0 :                 bApplyNewPageMargins = false;
     356             :             }
     357           0 :             break;
     358             :         }
     359             : 
     360           0 :         if ( bApplyNewPageMargins )
     361             :         {
     362           0 :             mrPagePropPanel.StartUndo();
     363           0 :             mpMarginValueSet->SetNoSelection();
     364           0 :             mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
     365           0 :             mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
     366           0 :             if ( mbMirrored != bMirrored )
     367             :             {
     368           0 :                 mbMirrored = bMirrored;
     369           0 :                 mrPagePropPanel.ExecutePageLayoutChange( mbMirrored );
     370             :             }
     371           0 :             mrPagePropPanel.EndUndo();
     372             : 
     373           0 :             mbCustomValuesUsed = false;
     374           0 :             mrPagePropPanel.ClosePageMarginPopup();
     375             :         }
     376             :         else
     377             :         {
     378             :             // back to initial selection
     379           0 :             SelectValueSetItem();
     380             :         }
     381             :     }
     382             : 
     383           0 :     return 0;
     384             : }
     385             : 
     386           0 : IMPL_LINK( PageMarginControl, ModifyLRMarginHdl, MetricField *, EMPTYARG )
     387             : {
     388           0 :     mpMarginValueSet->SetNoSelection();
     389           0 :     mpMarginValueSet->SelectItem(0);
     390           0 :     mpMarginValueSet->Format();
     391           0 :     mpMarginValueSet->StartSelection();
     392             : 
     393           0 :     mnPageLeftMargin = GetCoreValue( maLeftMarginEdit, meUnit );
     394           0 :     mnPageRightMargin = GetCoreValue( maRightMarginEdit, meUnit );
     395           0 :     mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
     396           0 :     mbCustomValuesUsed = true;
     397           0 :     return 0;
     398             : }
     399             : 
     400           0 : IMPL_LINK( PageMarginControl, ModifyULMarginHdl, MetricField *, EMPTYARG )
     401             : {
     402           0 :     mpMarginValueSet->SetNoSelection();
     403           0 :     mpMarginValueSet->SelectItem(0);
     404           0 :     mpMarginValueSet->Format();
     405           0 :     mpMarginValueSet->StartSelection();
     406             : 
     407           0 :     mnPageTopMargin = GetCoreValue( maTopMarginEdit, meUnit );
     408           0 :     mnPageBottomMargin = GetCoreValue( maBottomMarginEdit, meUnit );
     409           0 :     mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
     410           0 :     mbCustomValuesUsed = true;
     411           0 :     return 0;
     412             : }
     413             : 
     414           0 : bool PageMarginControl::GetUserCustomValues()
     415             : {
     416           0 :     bool bUserCustomValuesAvailable = false;
     417             : 
     418           0 :     SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
     419           0 :     if ( aWinOpt.Exists() )
     420             :     {
     421           0 :         ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
     422           0 :         ::rtl::OUString aTmp;
     423           0 :         if ( aSeq.getLength())
     424           0 :             aSeq[0].Value >>= aTmp;
     425           0 :         OUString aWinData( aTmp );
     426           0 :         mnUserCustomPageLeftMargin = aWinData.toInt32();
     427           0 :         bUserCustomValuesAvailable = true;
     428             :     }
     429             : 
     430           0 :     SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
     431           0 :     if ( aWinOpt2.Exists() )
     432             :     {
     433           0 :         ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
     434           0 :         ::rtl::OUString aTmp;
     435           0 :         if ( aSeq.getLength())
     436           0 :             aSeq[0].Value >>= aTmp;
     437           0 :         OUString aWinData( aTmp );
     438           0 :         mnUserCustomPageRightMargin = aWinData.toInt32();
     439           0 :         bUserCustomValuesAvailable = true;
     440             :     }
     441             : 
     442           0 :     SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
     443           0 :     if ( aWinOpt3.Exists() )
     444             :     {
     445           0 :         ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt3.GetUserData();
     446           0 :         ::rtl::OUString aTmp;
     447           0 :         if ( aSeq.getLength())
     448           0 :             aSeq[0].Value >>= aTmp;
     449           0 :         OUString aWinData( aTmp );
     450           0 :         mnUserCustomPageTopMargin = aWinData.toInt32();
     451           0 :         bUserCustomValuesAvailable = true;
     452             :     }
     453             : 
     454           0 :     SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
     455           0 :     if ( aWinOpt4.Exists() )
     456             :     {
     457           0 :         ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt4.GetUserData();
     458           0 :         ::rtl::OUString aTmp;
     459           0 :         if ( aSeq.getLength())
     460           0 :             aSeq[0].Value >>= aTmp;
     461           0 :         OUString aWinData( aTmp );
     462           0 :         mnUserCustomPageBottomMargin = aWinData.toInt32();
     463           0 :         bUserCustomValuesAvailable = true;
     464             :     }
     465             : 
     466           0 :     SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
     467           0 :     if ( aWinOpt5.Exists() )
     468             :     {
     469           0 :         ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt5.GetUserData();
     470           0 :         ::rtl::OUString aTmp;
     471           0 :         if ( aSeq.getLength())
     472           0 :             aSeq[0].Value >>= aTmp;
     473           0 :         OUString aWinData( aTmp );
     474           0 :         mbUserCustomMirrored = aWinData.toInt32() == 0 ? false : true;
     475           0 :         bUserCustomValuesAvailable = true;
     476             :     }
     477             : 
     478           0 :     return bUserCustomValuesAvailable;
     479             : }
     480             : 
     481           0 : void PageMarginControl::StoreUserCustomValues()
     482             : {
     483           0 :     if ( !mbCustomValuesUsed )
     484             :     {
     485           0 :         return;
     486             :     }
     487             : 
     488           0 :     ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
     489           0 :     SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
     490             : 
     491           0 :     aSeq[0].Name = "mnPageLeftMargin";
     492           0 :     aSeq[0].Value <<= ::rtl::OUString::number( mnPageLeftMargin );
     493           0 :     aWinOpt.SetUserData( aSeq );
     494             : 
     495           0 :     SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
     496           0 :     aSeq[0].Name = "mnPageRightMargin";
     497           0 :     aSeq[0].Value <<= ::rtl::OUString::number( mnPageRightMargin );
     498           0 :     aWinOpt2.SetUserData( aSeq );
     499             : 
     500           0 :     SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
     501           0 :     aSeq[0].Name = "mnPageTopMargin";
     502           0 :     aSeq[0].Value <<= ::rtl::OUString::number( mnPageTopMargin );
     503           0 :     aWinOpt3.SetUserData( aSeq );
     504             : 
     505           0 :     SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
     506           0 :     aSeq[0].Name = "mnPageBottomMargin";
     507           0 :     aSeq[0].Value <<= ::rtl::OUString::number( mnPageBottomMargin );
     508           0 :     aWinOpt4.SetUserData( aSeq );
     509             : 
     510           0 :     SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
     511           0 :     aSeq[0].Name = "mbMirrored";
     512           0 :     aSeq[0].Value <<= ::rtl::OUString::number( (mbMirrored ? 1 : 0) );
     513           0 :     aWinOpt5.SetUserData( aSeq );
     514             : }
     515             : 
     516             : } } // end of namespace sw::sidebar
     517             : 
     518             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10