LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/sidebar - PageMarginControl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 305 0.3 %
Date: 2013-07-09 Functions: 2 16 12.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10