LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbapagesetup.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 225 315 71.4 %
Date: 2015-06-13 12:38:46 Functions: 37 47 78.7 %
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 "vbapagesetup.hxx"
      20             : #include "cellsuno.hxx"
      21             : #include "convuno.hxx"
      22             : #include "rangelst.hxx"
      23             : #include "excelvbahelper.hxx"
      24             : #include "vbarange.hxx"
      25             : #include <com/sun/star/sheet/XPrintAreas.hpp>
      26             : #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
      27             : #include <com/sun/star/text/XText.hpp>
      28             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      29             : #include <com/sun/star/container/XNameAccess.hpp>
      30             : #include <ooo/vba/excel/XlPageOrientation.hpp>
      31             : #include <ooo/vba/excel/XlOrder.hpp>
      32             : #include <ooo/vba/excel/Constants.hpp>
      33             : #include <i18nutil/paper.hxx>
      34             : #include <sal/macros.h>
      35             : #include <algorithm>
      36             : #include <filter/msfilter/util.hxx>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::ooo::vba;
      40             : 
      41             : #define ZOOM_IN 10
      42             : #define ZOOM_MAX 400
      43             : 
      44          56 : ScVbaPageSetup::ScVbaPageSetup(const uno::Reference< XHelperInterface >& xParent,
      45             :                 const uno::Reference< uno::XComponentContext >& xContext,
      46             :                 const uno::Reference< sheet::XSpreadsheet >& xSheet,
      47             :                 const uno::Reference< frame::XModel >& xModel) throw (uno::RuntimeException):
      48          56 :            ScVbaPageSetup_BASE( xParent, xContext ), mxSheet( xSheet ), mbIsLandscape( false )
      49             : {
      50             :     // query for current page style
      51          56 :     mxModel.set( xModel, uno::UNO_QUERY_THROW );
      52          56 :     uno::Reference< beans::XPropertySet > xSheetProps( mxSheet, uno::UNO_QUERY_THROW );
      53         112 :     uno::Any aValue = xSheetProps->getPropertyValue("PageStyle");
      54         112 :     OUString aStyleName;
      55          56 :     aValue >>= aStyleName;
      56             : 
      57         112 :     uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSup( mxModel, uno::UNO_QUERY_THROW );
      58         112 :     uno::Reference< container::XNameAccess > xStyleFamilies = xStyleFamiliesSup->getStyleFamilies();
      59         112 :     uno::Reference< container::XNameAccess > xPageStyle( xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY_THROW );
      60          56 :     mxPageProps.set( xPageStyle->getByName(aStyleName), uno::UNO_QUERY_THROW );
      61          56 :     mnOrientLandscape = excel::XlPageOrientation::xlLandscape;
      62          56 :     mnOrientPortrait = excel::XlPageOrientation::xlPortrait;
      63         112 :     mxPageProps->getPropertyValue("IsLandscape") >>= mbIsLandscape;
      64          56 : }
      65             : 
      66           0 : OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeException, std::exception)
      67             : {
      68           0 :     OUString aPrintArea;
      69           0 :     uno::Reference< sheet::XPrintAreas > xPrintAreas( mxSheet, uno::UNO_QUERY_THROW );
      70           0 :     uno::Sequence< table::CellRangeAddress > aSeq = xPrintAreas->getPrintAreas();
      71           0 :     sal_Int32 nCount = aSeq.getLength();
      72           0 :     if( nCount )
      73             :     {
      74           0 :         ScAddress::Details aDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
      75           0 :         sal_uInt16 nFlags = SCA_VALID;
      76           0 :         nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE );
      77           0 :         ScRangeList aRangeList;
      78           0 :         for( sal_Int32 i=0; i<nCount; i++ )
      79             :         {
      80           0 :             ScRange aRange;
      81           0 :             ScUnoConversion::FillScRange( aRange, aSeq[i] );
      82           0 :             aRangeList.Append( aRange );
      83             :         }
      84           0 :         ScDocument& rDoc = excel::getDocShell( mxModel )->GetDocument();
      85           0 :         aRangeList.Format( aPrintArea, nFlags, &rDoc, formula::FormulaGrammar::CONV_XL_A1, ','  );
      86             :     }
      87             : 
      88           0 :     return aPrintArea;
      89             : }
      90             : 
      91           0 : void SAL_CALL ScVbaPageSetup::setPrintArea( const OUString& rAreas ) throw (css::uno::RuntimeException, std::exception)
      92             : {
      93           0 :     uno::Reference< sheet::XPrintAreas > xPrintAreas( mxSheet, uno::UNO_QUERY_THROW );
      94           0 :     if( rAreas.isEmpty() ||
      95           0 :         rAreas.equalsIgnoreAsciiCase( "FALSE" ) )
      96             :     {
      97             :         // print the whole sheet
      98           0 :         uno::Sequence< table::CellRangeAddress > aSeq;
      99           0 :         xPrintAreas->setPrintAreas( aSeq );
     100             :     }
     101             :     else
     102             :     {
     103           0 :         ScRangeList aCellRanges;
     104           0 :         ScRange aRange;
     105           0 :         if( getScRangeListForAddress( rAreas, excel::getDocShell( mxModel ) , aRange, aCellRanges ) )
     106             :         {
     107           0 :             uno::Sequence< table::CellRangeAddress > aSeq( aCellRanges.size() );
     108           0 :             for ( size_t i = 0, nRanges = aCellRanges.size(); i < nRanges; ++i )
     109             :             {
     110           0 :                 ScRange* pRange = aCellRanges[ i ];
     111           0 :                 table::CellRangeAddress aRangeAddress;
     112           0 :                 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
     113           0 :                 aSeq[ i++ ] = aRangeAddress;
     114             :             }
     115           0 :             xPrintAreas->setPrintAreas( aSeq );
     116           0 :         }
     117           0 :     }
     118           0 : }
     119             : 
     120           1 : double SAL_CALL ScVbaPageSetup::getHeaderMargin() throw (css::uno::RuntimeException)
     121             : {
     122           1 :     return VbaPageSetupBase::getHeaderMargin();
     123             : }
     124             : 
     125           1 : void SAL_CALL ScVbaPageSetup::setHeaderMargin( double margin ) throw (css::uno::RuntimeException)
     126             : {
     127           1 :     VbaPageSetupBase::setHeaderMargin( margin );
     128           1 : }
     129             : 
     130           1 : double SAL_CALL ScVbaPageSetup::getFooterMargin() throw (css::uno::RuntimeException)
     131             : {
     132           1 :     return VbaPageSetupBase::getFooterMargin();
     133             : }
     134             : 
     135           1 : void SAL_CALL ScVbaPageSetup::setFooterMargin( double margin ) throw (css::uno::RuntimeException)
     136             : {
     137           1 :     VbaPageSetupBase::setFooterMargin( margin );
     138           1 : }
     139             : 
     140           3 : uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesTall() throw (css::uno::RuntimeException, std::exception)
     141             : {
     142           3 :     return mxPageProps->getPropertyValue("ScaleToPagesY");
     143             : }
     144             : 
     145           1 : void SAL_CALL ScVbaPageSetup::setFitToPagesTall( const uno::Any& fitToPagesTall) throw (css::uno::RuntimeException, std::exception)
     146             : {
     147           1 :     sal_uInt16 scaleToPageY = 0;
     148             :     try
     149             :     {
     150             :         bool aValue;
     151           1 :         if( fitToPagesTall.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesTall >>= aValue))
     152             :         {
     153           1 :             fitToPagesTall >>= scaleToPageY;
     154             :         }
     155             : 
     156           1 :         mxPageProps->setPropertyValue("ScaleToPagesY", uno::makeAny( scaleToPageY ));
     157             :     }
     158           0 :     catch( uno::Exception& )
     159             :     {
     160             :     }
     161           1 : }
     162             : 
     163           3 : uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesWide() throw (css::uno::RuntimeException, std::exception)
     164             : {
     165           3 :     return mxPageProps->getPropertyValue("ScaleToPagesX");
     166             : }
     167             : 
     168           1 : void SAL_CALL ScVbaPageSetup::setFitToPagesWide( const uno::Any& fitToPagesWide) throw (css::uno::RuntimeException, std::exception)
     169             : {
     170           1 :     sal_uInt16 scaleToPageX = 0;
     171             :     try
     172             :     {
     173           1 :         bool aValue = false;
     174           1 :         if( fitToPagesWide.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesWide >>= aValue))
     175             :         {
     176           1 :             fitToPagesWide >>= scaleToPageX;
     177             :         }
     178             : 
     179           1 :         mxPageProps->setPropertyValue("ScaleToPagesX", uno::makeAny( scaleToPageX ));
     180             :     }
     181           0 :     catch( uno::Exception& )
     182             :     {
     183             :     }
     184           1 : }
     185             : 
     186           5 : uno::Any SAL_CALL ScVbaPageSetup::getZoom() throw (css::uno::RuntimeException, std::exception)
     187             : {
     188           5 :     return mxPageProps->getPropertyValue("PageScale");
     189             : }
     190             : 
     191           3 : void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::RuntimeException, std::exception)
     192             : {
     193           3 :     sal_uInt16 pageScale = 0;
     194             :     try
     195             :     {
     196           3 :         if( zoom.getValueTypeClass() == uno::TypeClass_BOOLEAN )
     197             :         {
     198           2 :             bool aValue = false;
     199           2 :             zoom >>= aValue;
     200           2 :             if( aValue )
     201             :             {
     202           0 :                 DebugHelper::runtimeexception(SbERR_BAD_PARAMETER, OUString() );
     203             :             }
     204             :         }
     205             :         else
     206             :         {
     207           1 :             zoom >>= pageScale;
     208           1 :             if(( pageScale < ZOOM_IN )||( pageScale > ZOOM_MAX ))
     209             :             {
     210           0 :                 DebugHelper::runtimeexception(SbERR_BAD_PARAMETER, OUString() );
     211             :             }
     212             :         }
     213             : 
     214             :         // these only exist in S08
     215           3 :         sal_uInt16 nScale = 0;
     216           3 :         mxPageProps->setPropertyValue("ScaleToPages", uno::makeAny( nScale ));
     217           3 :         mxPageProps->setPropertyValue("ScaleToPagesX", uno::makeAny( nScale ));
     218           3 :         mxPageProps->setPropertyValue("ScaleToPagesY", uno::makeAny( nScale ));
     219             :     }
     220           0 :     catch (const beans::UnknownPropertyException&)
     221             :     {
     222           0 :         if( pageScale == 0 )
     223             :         {
     224           0 :             DebugHelper::runtimeexception(SbERR_BAD_PARAMETER, OUString() );
     225             :         }
     226             :     }
     227           0 :     catch (const uno::Exception&)
     228             :     {
     229             :     }
     230             : 
     231           3 :     mxPageProps->setPropertyValue("PageScale", uno::makeAny( pageScale ));
     232           3 : }
     233             : 
     234           1 : OUString SAL_CALL ScVbaPageSetup::getLeftHeader() throw (css::uno::RuntimeException, std::exception)
     235             : {
     236           1 :     OUString leftHeader;
     237             :     try
     238             :     {
     239           1 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     240           1 :         if( xHeaderContent.is() )
     241             :         {
     242           1 :             uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
     243           1 :             leftHeader = xText->getString();
     244           1 :         }
     245             :     }
     246           0 :     catch( uno::Exception& )
     247             :     {
     248             :     }
     249             : 
     250           1 :     return leftHeader;
     251             : }
     252             : 
     253           1 : void SAL_CALL ScVbaPageSetup::setLeftHeader( const OUString& leftHeader) throw (css::uno::RuntimeException, std::exception)
     254             : {
     255             :     try
     256             :     {
     257           1 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     258           1 :         if( xHeaderContent.is() )
     259             :         {
     260           1 :             uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
     261           1 :             xText->setString( leftHeader );
     262           1 :             mxPageProps->setPropertyValue("RightPageHeaderContent", uno::makeAny(xHeaderContent) );
     263           1 :         }
     264             :     }
     265           0 :     catch( uno::Exception& )
     266             :     {
     267             :     }
     268           1 : }
     269             : 
     270           1 : OUString SAL_CALL ScVbaPageSetup::getCenterHeader() throw (css::uno::RuntimeException, std::exception)
     271             : {
     272           1 :     OUString centerHeader;
     273             :     try
     274             :     {
     275           1 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     276           1 :         if( xHeaderContent.is() )
     277             :         {
     278           1 :             uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
     279           1 :             centerHeader = xText->getString();
     280           1 :         }
     281             :     }
     282           0 :     catch( uno::Exception& )
     283             :     {
     284             :     }
     285             : 
     286           1 :     return centerHeader;
     287             : }
     288             : 
     289           1 : void SAL_CALL ScVbaPageSetup::setCenterHeader( const OUString& centerHeader) throw (css::uno::RuntimeException, std::exception)
     290             : {
     291             :     try
     292             :     {
     293           1 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     294           1 :         if( xHeaderContent.is() )
     295             :         {
     296           1 :             uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
     297           1 :             xText->setString( centerHeader );
     298           1 :             mxPageProps->setPropertyValue("RightPageHeaderContent", uno::makeAny(xHeaderContent) );
     299           1 :         }
     300             :     }
     301           0 :     catch( uno::Exception& )
     302             :     {
     303             :     }
     304           1 : }
     305             : 
     306           1 : OUString SAL_CALL ScVbaPageSetup::getRightHeader() throw (css::uno::RuntimeException, std::exception)
     307             : {
     308           1 :     OUString rightHeader;
     309             :     try
     310             :     {
     311           1 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     312           1 :         if( xHeaderContent.is() )
     313             :         {
     314           1 :             uno::Reference< text::XText > xText = xHeaderContent->getRightText();
     315           1 :             rightHeader = xText->getString();
     316           1 :         }
     317             :     }
     318           0 :     catch( uno::Exception& )
     319             :     {
     320             :     }
     321             : 
     322           1 :     return rightHeader;
     323             : }
     324             : 
     325           1 : void SAL_CALL ScVbaPageSetup::setRightHeader( const OUString& rightHeader) throw (css::uno::RuntimeException, std::exception)
     326             : {
     327             :     try
     328             :     {
     329           1 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     330           1 :         if( xHeaderContent.is() )
     331             :         {
     332           1 :             uno::Reference< text::XText > xText = xHeaderContent->getRightText();
     333           1 :             xText->setString( rightHeader );
     334           1 :             mxPageProps->setPropertyValue("RightPageHeaderContent", uno::makeAny(xHeaderContent) );
     335           1 :         }
     336             :     }
     337           0 :     catch( uno::Exception& )
     338             :     {
     339             :     }
     340           1 : }
     341             : 
     342           1 : OUString SAL_CALL ScVbaPageSetup::getLeftFooter() throw (css::uno::RuntimeException, std::exception)
     343             : {
     344           1 :     OUString leftFooter;
     345             :     try
     346             :     {
     347           1 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     348           1 :         if( xFooterContent.is() )
     349             :         {
     350           1 :             uno::Reference< text::XText > xText = xFooterContent->getLeftText();
     351           1 :             leftFooter = xText->getString();
     352           1 :         }
     353             :     }
     354           0 :     catch( uno::Exception& )
     355             :     {
     356             :     }
     357             : 
     358           1 :     return leftFooter;
     359             : }
     360             : 
     361           1 : void SAL_CALL ScVbaPageSetup::setLeftFooter( const OUString& leftFooter) throw (css::uno::RuntimeException, std::exception)
     362             : {
     363             :     try
     364             :     {
     365           1 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     366           1 :         if( xFooterContent.is() )
     367             :         {
     368           1 :             uno::Reference< text::XText > xText = xFooterContent->getLeftText();
     369           1 :             xText->setString( leftFooter );
     370           1 :             mxPageProps->setPropertyValue("RightPageFooterContent", uno::makeAny(xFooterContent) );
     371           1 :         }
     372             :     }
     373           0 :     catch( uno::Exception& )
     374             :     {
     375             :     }
     376           1 : }
     377             : 
     378           1 : OUString SAL_CALL ScVbaPageSetup::getCenterFooter() throw (css::uno::RuntimeException, std::exception)
     379             : {
     380           1 :     OUString centerFooter;
     381             :     try
     382             :     {
     383           1 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     384           1 :         if( xFooterContent.is() )
     385             :         {
     386           1 :             uno::Reference< text::XText > xText = xFooterContent->getCenterText();
     387           1 :             centerFooter = xText->getString();
     388           1 :         }
     389             :     }
     390           0 :     catch( uno::Exception& )
     391             :     {
     392             :     }
     393             : 
     394           1 :     return centerFooter;
     395             : }
     396             : 
     397           1 : void SAL_CALL ScVbaPageSetup::setCenterFooter( const OUString& centerFooter) throw (css::uno::RuntimeException, std::exception)
     398             : {
     399             :     try
     400             :     {
     401           1 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     402           1 :         if( xFooterContent.is() )
     403             :         {
     404           1 :             uno::Reference< text::XText > xText = xFooterContent->getCenterText();
     405           1 :             xText->setString( centerFooter );
     406           1 :             mxPageProps->setPropertyValue("RightPageFooterContent", uno::makeAny(xFooterContent) );
     407           1 :         }
     408             :     }
     409           0 :     catch( uno::Exception& )
     410             :     {
     411             :     }
     412             : 
     413           1 : }
     414             : 
     415           1 : OUString SAL_CALL ScVbaPageSetup::getRightFooter() throw (css::uno::RuntimeException, std::exception)
     416             : {
     417           1 :     OUString rightFooter;
     418             :     try
     419             :     {
     420           1 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     421           1 :         if( xFooterContent.is() )
     422             :         {
     423           1 :             uno::Reference< text::XText > xText = xFooterContent->getRightText();
     424           1 :             rightFooter = xText->getString();
     425           1 :         }
     426             :     }
     427           0 :     catch( uno::Exception& )
     428             :     {
     429             :     }
     430             : 
     431           1 :     return rightFooter;
     432             : }
     433             : 
     434           1 : void SAL_CALL ScVbaPageSetup::setRightFooter( const OUString& rightFooter) throw (css::uno::RuntimeException, std::exception)
     435             : {
     436             :     try
     437             :     {
     438           1 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     439           1 :         if( xFooterContent.is() )
     440             :         {
     441           1 :             uno::Reference< text::XText > xText = xFooterContent->getRightText();
     442           1 :             xText->setString( rightFooter );
     443           1 :             mxPageProps->setPropertyValue("RightPageFooterContent", uno::makeAny(xFooterContent) );
     444           1 :         }
     445             :     }
     446           0 :     catch( uno::Exception& )
     447             :     {
     448             :     }
     449           1 : }
     450             : 
     451           2 : sal_Int32 SAL_CALL ScVbaPageSetup::getOrder() throw (css::uno::RuntimeException, std::exception)
     452             : {
     453           2 :     sal_Int32 order = excel::XlOrder::xlDownThenOver;
     454             :     try
     455             :     {
     456           2 :         uno::Any aValue = mxPageProps->getPropertyValue("PrintDownFirst");
     457           2 :         bool bPrintDownFirst = false;
     458           2 :         aValue >>= bPrintDownFirst;
     459           2 :         if( !bPrintDownFirst )
     460           1 :             order = excel::XlOrder::xlOverThenDown;
     461             :     }
     462           0 :     catch( uno::Exception& )
     463             :     {
     464             :     }
     465             : 
     466           2 :     return order;
     467             : }
     468             : 
     469           1 : void SAL_CALL ScVbaPageSetup::setOrder(sal_Int32 order) throw (css::uno::RuntimeException, std::exception)
     470             : {
     471           1 :     bool bOrder = true;
     472           1 :     switch( order )
     473             :     {
     474             :         case excel::XlOrder::xlDownThenOver:
     475           0 :             break;
     476             :         case excel::XlOrder::xlOverThenDown:
     477           1 :             bOrder = false;
     478           1 :             break;
     479             :         default:
     480           0 :             DebugHelper::runtimeexception(SbERR_BAD_PARAMETER, OUString() );
     481             :     }
     482             : 
     483             :     try
     484             :     {
     485           1 :         mxPageProps->setPropertyValue("PrintDownFirst", uno::makeAny( bOrder ));
     486             :     }
     487           0 :     catch (const uno::Exception&)
     488             :     {
     489             :     }
     490           1 : }
     491             : 
     492           2 : sal_Int32 SAL_CALL ScVbaPageSetup::getFirstPageNumber() throw (css::uno::RuntimeException, std::exception)
     493             : {
     494           2 :     sal_Int16 number = 0;
     495             :     try
     496             :     {
     497           2 :         uno::Any aValue = mxPageProps->getPropertyValue("FirstPageNumber");
     498           2 :         aValue >>= number;
     499             :     }
     500           0 :     catch( uno::Exception& )
     501             :     {
     502             :     }
     503             : 
     504           2 :     if( number ==0 )
     505             :     {
     506           1 :         number = excel::Constants::xlAutomatic;
     507             :     }
     508             : 
     509           2 :     return number;
     510             : }
     511             : 
     512           1 : void SAL_CALL ScVbaPageSetup::setFirstPageNumber( sal_Int32 firstPageNumber) throw (css::uno::RuntimeException, std::exception)
     513             : {
     514           1 :     if( firstPageNumber == excel::Constants::xlAutomatic )
     515           0 :         firstPageNumber = 0;
     516             : 
     517             :     try
     518             :     {
     519           1 :         uno::Any aValue;
     520           1 :         aValue <<= (sal_Int16)firstPageNumber;
     521           1 :         mxPageProps->setPropertyValue("FirstPageNumber", aValue );
     522             :     }
     523           0 :     catch (const uno::Exception&)
     524             :     {
     525             :     }
     526           1 : }
     527             : 
     528           2 : sal_Bool SAL_CALL ScVbaPageSetup::getCenterVertically() throw (css::uno::RuntimeException, std::exception)
     529             : {
     530           2 :     bool centerVertically = false;
     531             :     try
     532             :     {
     533           2 :         uno::Any aValue = mxPageProps->getPropertyValue("CenterVertically");
     534           2 :         aValue >>= centerVertically;
     535             :     }
     536           0 :     catch (const uno::Exception&)
     537             :     {
     538             :     }
     539           2 :     return centerVertically;
     540             : }
     541             : 
     542           1 : void SAL_CALL ScVbaPageSetup::setCenterVertically( sal_Bool centerVertically) throw (css::uno::RuntimeException, std::exception)
     543             : {
     544             :     try
     545             :     {
     546           1 :         mxPageProps->setPropertyValue("CenterVertically", uno::makeAny( centerVertically ));
     547             :     }
     548           0 :     catch (const uno::Exception&)
     549             :     {
     550             :     }
     551           1 : }
     552             : 
     553           2 : sal_Bool SAL_CALL ScVbaPageSetup::getCenterHorizontally() throw (css::uno::RuntimeException, std::exception)
     554             : {
     555           2 :     bool centerHorizontally = false;
     556             :     try
     557             :     {
     558           2 :         uno::Any aValue = mxPageProps->getPropertyValue("CenterHorizontally");
     559           2 :         aValue >>= centerHorizontally;
     560             :     }
     561           0 :     catch (const uno::Exception&)
     562             :     {
     563             :     }
     564           2 :     return centerHorizontally;
     565             : }
     566             : 
     567           1 : void SAL_CALL ScVbaPageSetup::setCenterHorizontally( sal_Bool centerHorizontally) throw (css::uno::RuntimeException, std::exception)
     568             : {
     569             :     try
     570             :     {
     571           1 :         mxPageProps->setPropertyValue("CenterHorizontally", uno::makeAny( centerHorizontally ));
     572             :     }
     573           0 :     catch (const uno::Exception&)
     574             :     {
     575             :     }
     576           1 : }
     577             : 
     578           2 : sal_Bool SAL_CALL ScVbaPageSetup::getPrintHeadings() throw (css::uno::RuntimeException, std::exception)
     579             : {
     580           2 :     bool printHeadings = false;
     581             :     try
     582             :     {
     583           2 :         uno::Any aValue = mxPageProps->getPropertyValue("PrintHeaders");
     584           2 :         aValue >>= printHeadings;
     585             :     }
     586           0 :     catch (const uno::Exception&)
     587             :     {
     588             :     }
     589           2 :     return printHeadings;
     590             : }
     591             : 
     592           1 : void SAL_CALL ScVbaPageSetup::setPrintHeadings( sal_Bool printHeadings) throw (css::uno::RuntimeException, std::exception)
     593             : {
     594             :     try
     595             :     {
     596           1 :         mxPageProps->setPropertyValue("PrintHeaders", uno::makeAny( printHeadings ));
     597             :     }
     598           0 :     catch( uno::Exception& )
     599             :     {
     600             :     }
     601           1 : }
     602             : 
     603           0 : sal_Bool SAL_CALL ScVbaPageSetup::getPrintGridlines() throw (uno::RuntimeException, std::exception)
     604             : {
     605           0 :     return false;
     606             : }
     607             : 
     608           0 : void SAL_CALL ScVbaPageSetup::setPrintGridlines( sal_Bool /*_printgridlines*/ ) throw (uno::RuntimeException, std::exception)
     609             : {
     610           0 : }
     611             : 
     612           0 : OUString SAL_CALL ScVbaPageSetup::getPrintTitleRows() throw (uno::RuntimeException, std::exception)
     613             : {
     614           0 :     return OUString();
     615             : }
     616           0 : void SAL_CALL ScVbaPageSetup::setPrintTitleRows( const OUString& /*_printtitlerows*/ ) throw (css::uno::RuntimeException, std::exception)
     617             : {
     618           0 : }
     619           0 : OUString SAL_CALL ScVbaPageSetup::getPrintTitleColumns() throw (uno::RuntimeException, std::exception)
     620             : {
     621           0 :     return OUString();
     622             : }
     623             : 
     624           0 : void SAL_CALL ScVbaPageSetup::setPrintTitleColumns( const OUString& /*_printtitlecolumns*/ ) throw (uno::RuntimeException, std::exception)
     625             : {
     626           0 : }
     627             : 
     628           2 : sal_Int32 SAL_CALL ScVbaPageSetup::getPaperSize() throw (uno::RuntimeException, std::exception)
     629             : {
     630           2 :     awt::Size aSize; // current papersize
     631           2 :     mxPageProps->getPropertyValue( "Size" ) >>= aSize;
     632           2 :     if ( mbIsLandscape )
     633           2 :         ::std::swap( aSize.Width, aSize.Height );
     634             : 
     635           2 :     sal_Int32 nPaperSizeIndex = msfilter::util::PaperSizeConv::getMSPaperSizeIndex( aSize );
     636           2 :     if ( nPaperSizeIndex == 0 )
     637           0 :         nPaperSizeIndex = excel::XlPaperSize::xlPaperUser;
     638           2 :     return nPaperSizeIndex;
     639             : }
     640             : 
     641           1 : void SAL_CALL ScVbaPageSetup::setPaperSize( sal_Int32 papersize ) throw (uno::RuntimeException, std::exception)
     642             : {
     643           1 :     if ( papersize != excel::XlPaperSize::xlPaperUser )
     644             :     {
     645           1 :         awt::Size aPaperSize;
     646           1 :         const msfilter::util::ApiPaperSize& rConvertedSize = msfilter::util::PaperSizeConv::getApiSizeForMSPaperSizeIndex( papersize );
     647           1 :         aPaperSize.Height = rConvertedSize.mnHeight;
     648           1 :         aPaperSize.Width = rConvertedSize.mnWidth;
     649           1 :         if ( mbIsLandscape )
     650           1 :             ::std::swap( aPaperSize.Width, aPaperSize.Height );
     651           1 :         mxPageProps->setPropertyValue( "Size", uno::makeAny( aPaperSize ) );
     652             :     }
     653           1 : }
     654             : 
     655             : OUString
     656           0 : ScVbaPageSetup::getServiceImplName()
     657             : {
     658           0 :     return OUString("ScVbaPageSetup");
     659             : }
     660             : 
     661             : uno::Sequence< OUString >
     662           0 : ScVbaPageSetup::getServiceNames()
     663             : {
     664           0 :     static uno::Sequence< OUString > aServiceNames;
     665           0 :     if ( aServiceNames.getLength() == 0 )
     666             :     {
     667           0 :         aServiceNames.realloc( 1 );
     668           0 :         aServiceNames[ 0 ] = "ooo.vba.excel.PageSetup";
     669             :     }
     670           0 :     return aServiceNames;
     671           9 : }
     672             : 
     673             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11