LCOV - code coverage report
Current view: top level - libreoffice/vbahelper/source/vbahelper - vbapagesetupbase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 143 0.0 %
Date: 2012-12-27 Functions: 0 15 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             : #include <vbahelper/vbapagesetupbase.hxx>
      20             : 
      21             : using namespace ::com::sun::star;
      22             : using namespace ::ooo::vba;
      23             : 
      24           0 : VbaPageSetupBase::VbaPageSetupBase(const uno::Reference< XHelperInterface >& xParent,
      25           0 :                 const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException): VbaPageSetupBase_BASE( xParent, xContext )
      26             : {
      27           0 : }
      28             : 
      29           0 : double SAL_CALL VbaPageSetupBase::getTopMargin() throw (css::uno::RuntimeException)
      30             : {
      31           0 :     sal_Bool headerOn = sal_False;
      32           0 :     sal_Int32 topMargin = 0;
      33           0 :     sal_Int32 headerHeight = 0;
      34             : 
      35             :     try
      36             :     {
      37           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "HeaderIsOn" );
      38           0 :         aValue >>= headerOn;
      39             : 
      40           0 :         aValue = mxPageProps->getPropertyValue( "TopMargin" );
      41           0 :         aValue >>= topMargin;
      42             : 
      43           0 :         if( headerOn )
      44             :         {
      45           0 :             aValue = mxPageProps->getPropertyValue( "HeaderHeight" );
      46           0 :             aValue >>= headerHeight;
      47           0 :             topMargin = topMargin + headerHeight;
      48           0 :         }
      49             :     }
      50           0 :     catch( uno::Exception& )
      51             :     {
      52             :     }
      53             : 
      54           0 :     return Millimeter::getInPoints( topMargin );
      55             : }
      56             : 
      57           0 : void SAL_CALL VbaPageSetupBase::setTopMargin( double margin ) throw (css::uno::RuntimeException)
      58             : {
      59           0 :     sal_Int32 topMargin = Millimeter::getInHundredthsOfOneMillimeter( margin );
      60           0 :     sal_Bool headerOn = sal_False;
      61           0 :     sal_Int32 headerHeight = 0;
      62             : 
      63             :     try
      64             :     {
      65           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "HeaderIsOn" );
      66           0 :         aValue >>= headerOn;
      67             : 
      68           0 :         if( headerOn )
      69             :         {
      70           0 :             aValue = mxPageProps->getPropertyValue( "HeaderHeight" );
      71           0 :             aValue >>= headerHeight;
      72           0 :             topMargin -= headerHeight;
      73             :         }
      74             : 
      75           0 :         aValue <<= topMargin;
      76           0 :         mxPageProps->setPropertyValue( "TopMargin" , aValue );
      77             :     }
      78           0 :     catch( uno::Exception& )
      79             :     {
      80             :     }
      81           0 : }
      82             : 
      83           0 : double SAL_CALL VbaPageSetupBase::getBottomMargin() throw (css::uno::RuntimeException)
      84             : {
      85           0 :     sal_Bool footerOn = sal_False;
      86           0 :     sal_Int32 bottomMargin = 0;
      87           0 :     sal_Int32 footerHeight = 0;
      88             : 
      89             :     try
      90             :     {
      91           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "FooterIsOn" );
      92           0 :         aValue >>= footerOn;
      93             : 
      94           0 :         aValue = mxPageProps->getPropertyValue( "BottomMargin" );
      95           0 :         aValue >>= bottomMargin;
      96             : 
      97           0 :         if( footerOn )
      98             :         {
      99           0 :             aValue = mxPageProps->getPropertyValue( "FooterHeight" );
     100           0 :             aValue >>= footerHeight;
     101           0 :             bottomMargin += footerHeight;
     102           0 :         }
     103             :     }
     104           0 :     catch( uno::Exception& )
     105             :     {
     106             :     }
     107             : 
     108           0 :     return Millimeter::getInPoints( bottomMargin );
     109             : }
     110             : 
     111           0 : void SAL_CALL VbaPageSetupBase::setBottomMargin( double margin ) throw (css::uno::RuntimeException)
     112             : {
     113           0 :     sal_Int32 bottomMargin = Millimeter::getInHundredthsOfOneMillimeter( margin );
     114           0 :     sal_Bool footerOn = sal_False;
     115           0 :     sal_Int32 footerHeight = 0;
     116             : 
     117             :     try
     118             :     {
     119           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "FooterIsOn" );
     120           0 :         aValue >>= footerOn;
     121             : 
     122           0 :         if( footerOn )
     123             :         {
     124           0 :             aValue = mxPageProps->getPropertyValue( "FooterHeight" );
     125           0 :             aValue >>= footerHeight;
     126           0 :             bottomMargin -= footerHeight;
     127             :         }
     128             : 
     129           0 :         aValue <<= bottomMargin;
     130           0 :         mxPageProps->setPropertyValue( "BottomMargin" , aValue );
     131             :     }
     132           0 :     catch( uno::Exception& )
     133             :     {
     134             :     }
     135           0 : }
     136             : 
     137           0 : double SAL_CALL VbaPageSetupBase::getRightMargin() throw (css::uno::RuntimeException)
     138             : {
     139           0 :     sal_Int32 rightMargin = 0;
     140             :     try
     141             :     {
     142           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "RightMargin" );
     143           0 :         aValue >>= rightMargin;
     144             :     }
     145           0 :     catch( uno::Exception& )
     146             :     {
     147             :     }
     148             : 
     149           0 :     return Millimeter::getInPoints( rightMargin );
     150             : }
     151             : 
     152           0 : void SAL_CALL VbaPageSetupBase::setRightMargin( double margin ) throw (css::uno::RuntimeException)
     153             : {
     154           0 :     sal_Int32 rightMargin = Millimeter::getInHundredthsOfOneMillimeter( margin );
     155             :     try
     156             :     {
     157           0 :         uno::Any aValue;
     158           0 :         aValue <<= rightMargin;
     159           0 :         mxPageProps->setPropertyValue( "RightMargin" , aValue );
     160             :     }
     161           0 :     catch( uno::Exception& )
     162             :     {
     163             :     }
     164             : 
     165           0 : }
     166             : 
     167           0 : double SAL_CALL VbaPageSetupBase::getLeftMargin() throw (css::uno::RuntimeException)
     168             : {
     169           0 :     sal_Int32 leftMargin = 0;
     170             :     try
     171             :     {
     172           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "LeftMargin" );
     173           0 :         aValue >>= leftMargin;
     174             :     }
     175           0 :     catch( uno::Exception& )
     176             :     {
     177             :     }
     178             : 
     179           0 :     return Millimeter::getInPoints( leftMargin );
     180             : }
     181             : 
     182           0 : void SAL_CALL VbaPageSetupBase::setLeftMargin( double margin ) throw (css::uno::RuntimeException)
     183             : {
     184           0 :     sal_Int32 leftMargin = Millimeter::getInHundredthsOfOneMillimeter( margin );
     185             :     try
     186             :     {
     187           0 :         uno::Any aValue;
     188           0 :         aValue <<= leftMargin;
     189           0 :         mxPageProps->setPropertyValue( "LeftMargin" , aValue );
     190             :     }
     191           0 :     catch( uno::Exception& )
     192             :     {
     193             :     }
     194           0 : }
     195             : 
     196           0 : double SAL_CALL VbaPageSetupBase::getHeaderMargin() throw (css::uno::RuntimeException)
     197             : {
     198           0 :     sal_Int32 headerMargin = 0;
     199             :     try
     200             :     {
     201           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "TopMargin" );
     202           0 :         aValue >>= headerMargin;
     203             :     }
     204           0 :     catch( uno::Exception& )
     205             :     {
     206             :     }
     207             : 
     208           0 :     return Millimeter::getInPoints( headerMargin );
     209             : }
     210             : 
     211           0 : void SAL_CALL VbaPageSetupBase::setHeaderMargin( double margin ) throw (css::uno::RuntimeException)
     212             : {
     213           0 :     sal_Int32 headerMargin = Millimeter::getInHundredthsOfOneMillimeter( margin );
     214             :     try
     215             :     {
     216           0 :         uno::Any aValue;
     217           0 :         aValue <<= headerMargin;
     218           0 :         mxPageProps->setPropertyValue( "TopMargin" , aValue );
     219             :     }
     220           0 :     catch( uno::Exception& )
     221             :     {
     222             :     }
     223           0 : }
     224             : 
     225           0 : double SAL_CALL VbaPageSetupBase::getFooterMargin() throw (css::uno::RuntimeException)
     226             : {
     227           0 :     sal_Int32 footerMargin = 0;
     228             :     try
     229             :     {
     230           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "BottomMargin" );
     231           0 :         aValue >>= footerMargin;
     232             :     }
     233           0 :     catch( uno::Exception& )
     234             :     {
     235             :     }
     236             : 
     237           0 :     return Millimeter::getInPoints( footerMargin );
     238             : }
     239             : 
     240           0 : void SAL_CALL VbaPageSetupBase::setFooterMargin( double margin ) throw (css::uno::RuntimeException)
     241             : {
     242           0 :     sal_Int32 footerMargin = Millimeter::getInHundredthsOfOneMillimeter( margin );
     243             :     try
     244             :     {
     245           0 :         uno::Any aValue;
     246           0 :         aValue <<= footerMargin;
     247           0 :         mxPageProps->setPropertyValue( "BottomMargin" , aValue );
     248             :     }
     249           0 :     catch( uno::Exception& )
     250             :     {
     251             :     }
     252           0 : }
     253             : 
     254           0 : sal_Int32 SAL_CALL VbaPageSetupBase::getOrientation() throw (css::uno::RuntimeException)
     255             : {
     256           0 :     sal_Int32 orientation = mnOrientPortrait;
     257             :     try
     258             :     {
     259           0 :         sal_Bool isLandscape = sal_False;
     260           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "IsLandscape" );
     261           0 :         aValue >>= isLandscape;
     262             : 
     263           0 :         if( isLandscape )
     264             :         {
     265           0 :             orientation = mnOrientLandscape;
     266           0 :         }
     267             :     }
     268           0 :     catch( uno::Exception& )
     269             :     {
     270             :     }
     271           0 :     return orientation;
     272             : }
     273             : 
     274           0 : void SAL_CALL VbaPageSetupBase::setOrientation( sal_Int32 orientation ) throw (css::uno::RuntimeException)
     275             : {
     276           0 :     if( ( orientation != mnOrientPortrait ) &&
     277             :         ( orientation != mnOrientLandscape ) )
     278             :     {
     279           0 :         DebugHelper::exception(SbERR_BAD_PARAMETER, OUString() );
     280             :     }
     281             : 
     282             :     try
     283             :     {
     284           0 :         sal_Bool isLandscape = sal_False;
     285           0 :         uno::Any aValue = mxPageProps->getPropertyValue( "IsLandscape" );
     286           0 :         aValue >>= isLandscape;
     287             : 
     288           0 :         sal_Bool switchOrientation = sal_False;
     289           0 :         if(( isLandscape && orientation != mnOrientLandscape ) ||
     290           0 :             ( !isLandscape && orientation != mnOrientPortrait ))
     291             :         {
     292           0 :             switchOrientation = sal_True;
     293             :         }
     294             : 
     295           0 :         if( switchOrientation )
     296             :         {
     297           0 :             aValue <<= !isLandscape;
     298           0 :             uno::Any aHeight = mxPageProps->getPropertyValue( "Height" );
     299           0 :             uno::Any aWidth = mxPageProps->getPropertyValue( "Width" );
     300           0 :             mxPageProps->setPropertyValue( "IsLandscape" , aValue );
     301           0 :             mxPageProps->setPropertyValue( "Width" ,  aHeight );
     302           0 :             mxPageProps->setPropertyValue( "Height" , aWidth );
     303           0 :         }
     304             :     }
     305           0 :     catch( uno::Exception& )
     306             :     {
     307             :     }
     308           0 : }
     309             : 
     310             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10