LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbapagesetup.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 225 315 71.4 %
Date: 2014-11-03 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         112 : 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         112 :            ScVbaPageSetup_BASE( xParent, xContext ), mxSheet( xSheet ), mbIsLandscape( false )
      49             : {
      50             :     // query for current page style
      51         112 :     mxModel.set( xModel, uno::UNO_QUERY_THROW );
      52         112 :     uno::Reference< beans::XPropertySet > xSheetProps( mxSheet, uno::UNO_QUERY_THROW );
      53         224 :     uno::Any aValue = xSheetProps->getPropertyValue("PageStyle");
      54         224 :     OUString aStyleName;
      55         112 :     aValue >>= aStyleName;
      56             : 
      57         224 :     uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSup( mxModel, uno::UNO_QUERY_THROW );
      58         224 :     uno::Reference< container::XNameAccess > xStyleFamilies = xStyleFamiliesSup->getStyleFamilies();
      59         224 :     uno::Reference< container::XNameAccess > xPageStyle( xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY_THROW );
      60         112 :     mxPageProps.set( xPageStyle->getByName(aStyleName), uno::UNO_QUERY_THROW );
      61         112 :     mnOrientLandscape = excel::XlPageOrientation::xlLandscape;
      62         112 :     mnOrientPortrait = excel::XlPageOrientation::xlPortrait;
      63         224 :     mxPageProps->getPropertyValue("IsLandscape") >>= mbIsLandscape;
      64         112 : }
      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           2 : double SAL_CALL ScVbaPageSetup::getHeaderMargin() throw (css::uno::RuntimeException)
     121             : {
     122           2 :     return VbaPageSetupBase::getHeaderMargin();
     123             : }
     124             : 
     125           2 : void SAL_CALL ScVbaPageSetup::setHeaderMargin( double margin ) throw (css::uno::RuntimeException)
     126             : {
     127           2 :     VbaPageSetupBase::setHeaderMargin( margin );
     128           2 : }
     129             : 
     130           2 : double SAL_CALL ScVbaPageSetup::getFooterMargin() throw (css::uno::RuntimeException)
     131             : {
     132           2 :     return VbaPageSetupBase::getFooterMargin();
     133             : }
     134             : 
     135           2 : void SAL_CALL ScVbaPageSetup::setFooterMargin( double margin ) throw (css::uno::RuntimeException)
     136             : {
     137           2 :     VbaPageSetupBase::setFooterMargin( margin );
     138           2 : }
     139             : 
     140           6 : uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesTall() throw (css::uno::RuntimeException, std::exception)
     141             : {
     142           6 :     return mxPageProps->getPropertyValue("ScaleToPagesY");
     143             : }
     144             : 
     145           2 : void SAL_CALL ScVbaPageSetup::setFitToPagesTall( const uno::Any& fitToPagesTall) throw (css::uno::RuntimeException, std::exception)
     146             : {
     147           2 :     sal_uInt16 scaleToPageY = 0;
     148             :     try
     149             :     {
     150             :         bool aValue;
     151           2 :         if( fitToPagesTall.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesTall >>= aValue))
     152             :         {
     153           2 :             fitToPagesTall >>= scaleToPageY;
     154             :         }
     155             : 
     156           2 :         mxPageProps->setPropertyValue("ScaleToPagesY", uno::makeAny( scaleToPageY ));
     157             :     }
     158           0 :     catch( uno::Exception& )
     159             :     {
     160             :     }
     161           2 : }
     162             : 
     163           6 : uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesWide() throw (css::uno::RuntimeException, std::exception)
     164             : {
     165           6 :     return mxPageProps->getPropertyValue("ScaleToPagesX");
     166             : }
     167             : 
     168           2 : void SAL_CALL ScVbaPageSetup::setFitToPagesWide( const uno::Any& fitToPagesWide) throw (css::uno::RuntimeException, std::exception)
     169             : {
     170           2 :     sal_uInt16 scaleToPageX = 0;
     171             :     try
     172             :     {
     173           2 :         bool aValue = false;
     174           2 :         if( fitToPagesWide.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesWide >>= aValue))
     175             :         {
     176           2 :             fitToPagesWide >>= scaleToPageX;
     177             :         }
     178             : 
     179           2 :         mxPageProps->setPropertyValue("ScaleToPagesX", uno::makeAny( scaleToPageX ));
     180             :     }
     181           0 :     catch( uno::Exception& )
     182             :     {
     183             :     }
     184           2 : }
     185             : 
     186          10 : uno::Any SAL_CALL ScVbaPageSetup::getZoom() throw (css::uno::RuntimeException, std::exception)
     187             : {
     188          10 :     return mxPageProps->getPropertyValue("PageScale");
     189             : }
     190             : 
     191           6 : void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::RuntimeException, std::exception)
     192             : {
     193           6 :     sal_uInt16 pageScale = 0;
     194             :     try
     195             :     {
     196           6 :         if( zoom.getValueTypeClass() == uno::TypeClass_BOOLEAN )
     197             :         {
     198           4 :             bool aValue = false;
     199           4 :             zoom >>= aValue;
     200           4 :             if( aValue )
     201             :             {
     202           0 :                 DebugHelper::runtimeexception(SbERR_BAD_PARAMETER, OUString() );
     203             :             }
     204             :         }
     205             :         else
     206             :         {
     207           2 :             zoom >>= pageScale;
     208           2 :             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           6 :         sal_uInt16 nScale = 0;
     216           6 :         mxPageProps->setPropertyValue("ScaleToPages", uno::makeAny( nScale ));
     217           6 :         mxPageProps->setPropertyValue("ScaleToPagesX", uno::makeAny( nScale ));
     218           6 :         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           6 :     mxPageProps->setPropertyValue("PageScale", uno::makeAny( pageScale ));
     232           6 : }
     233             : 
     234           2 : OUString SAL_CALL ScVbaPageSetup::getLeftHeader() throw (css::uno::RuntimeException, std::exception)
     235             : {
     236           2 :     OUString leftHeader;
     237             :     try
     238             :     {
     239           2 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     240           2 :         if( xHeaderContent.is() )
     241             :         {
     242           2 :             uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
     243           2 :             leftHeader = xText->getString();
     244           2 :         }
     245             :     }
     246           0 :     catch( uno::Exception& )
     247             :     {
     248             :     }
     249             : 
     250           2 :     return leftHeader;
     251             : }
     252             : 
     253           2 : void SAL_CALL ScVbaPageSetup::setLeftHeader( const OUString& leftHeader) throw (css::uno::RuntimeException, std::exception)
     254             : {
     255             :     try
     256             :     {
     257           2 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     258           2 :         if( xHeaderContent.is() )
     259             :         {
     260           2 :             uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
     261           2 :             xText->setString( leftHeader );
     262           2 :             mxPageProps->setPropertyValue("RightPageHeaderContent", uno::makeAny(xHeaderContent) );
     263           2 :         }
     264             :     }
     265           0 :     catch( uno::Exception& )
     266             :     {
     267             :     }
     268           2 : }
     269             : 
     270           2 : OUString SAL_CALL ScVbaPageSetup::getCenterHeader() throw (css::uno::RuntimeException, std::exception)
     271             : {
     272           2 :     OUString centerHeader;
     273             :     try
     274             :     {
     275           2 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     276           2 :         if( xHeaderContent.is() )
     277             :         {
     278           2 :             uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
     279           2 :             centerHeader = xText->getString();
     280           2 :         }
     281             :     }
     282           0 :     catch( uno::Exception& )
     283             :     {
     284             :     }
     285             : 
     286           2 :     return centerHeader;
     287             : }
     288             : 
     289           2 : void SAL_CALL ScVbaPageSetup::setCenterHeader( const OUString& centerHeader) throw (css::uno::RuntimeException, std::exception)
     290             : {
     291             :     try
     292             :     {
     293           2 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     294           2 :         if( xHeaderContent.is() )
     295             :         {
     296           2 :             uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
     297           2 :             xText->setString( centerHeader );
     298           2 :             mxPageProps->setPropertyValue("RightPageHeaderContent", uno::makeAny(xHeaderContent) );
     299           2 :         }
     300             :     }
     301           0 :     catch( uno::Exception& )
     302             :     {
     303             :     }
     304           2 : }
     305             : 
     306           2 : OUString SAL_CALL ScVbaPageSetup::getRightHeader() throw (css::uno::RuntimeException, std::exception)
     307             : {
     308           2 :     OUString rightHeader;
     309             :     try
     310             :     {
     311           2 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     312           2 :         if( xHeaderContent.is() )
     313             :         {
     314           2 :             uno::Reference< text::XText > xText = xHeaderContent->getRightText();
     315           2 :             rightHeader = xText->getString();
     316           2 :         }
     317             :     }
     318           0 :     catch( uno::Exception& )
     319             :     {
     320             :     }
     321             : 
     322           2 :     return rightHeader;
     323             : }
     324             : 
     325           2 : void SAL_CALL ScVbaPageSetup::setRightHeader( const OUString& rightHeader) throw (css::uno::RuntimeException, std::exception)
     326             : {
     327             :     try
     328             :     {
     329           2 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
     330           2 :         if( xHeaderContent.is() )
     331             :         {
     332           2 :             uno::Reference< text::XText > xText = xHeaderContent->getRightText();
     333           2 :             xText->setString( rightHeader );
     334           2 :             mxPageProps->setPropertyValue("RightPageHeaderContent", uno::makeAny(xHeaderContent) );
     335           2 :         }
     336             :     }
     337           0 :     catch( uno::Exception& )
     338             :     {
     339             :     }
     340           2 : }
     341             : 
     342           2 : OUString SAL_CALL ScVbaPageSetup::getLeftFooter() throw (css::uno::RuntimeException, std::exception)
     343             : {
     344           2 :     OUString leftFooter;
     345             :     try
     346             :     {
     347           2 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     348           2 :         if( xFooterContent.is() )
     349             :         {
     350           2 :             uno::Reference< text::XText > xText = xFooterContent->getLeftText();
     351           2 :             leftFooter = xText->getString();
     352           2 :         }
     353             :     }
     354           0 :     catch( uno::Exception& )
     355             :     {
     356             :     }
     357             : 
     358           2 :     return leftFooter;
     359             : }
     360             : 
     361           2 : void SAL_CALL ScVbaPageSetup::setLeftFooter( const OUString& leftFooter) throw (css::uno::RuntimeException, std::exception)
     362             : {
     363             :     try
     364             :     {
     365           2 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     366           2 :         if( xFooterContent.is() )
     367             :         {
     368           2 :             uno::Reference< text::XText > xText = xFooterContent->getLeftText();
     369           2 :             xText->setString( leftFooter );
     370           2 :             mxPageProps->setPropertyValue("RightPageFooterContent", uno::makeAny(xFooterContent) );
     371           2 :         }
     372             :     }
     373           0 :     catch( uno::Exception& )
     374             :     {
     375             :     }
     376           2 : }
     377             : 
     378           2 : OUString SAL_CALL ScVbaPageSetup::getCenterFooter() throw (css::uno::RuntimeException, std::exception)
     379             : {
     380           2 :     OUString centerFooter;
     381             :     try
     382             :     {
     383           2 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     384           2 :         if( xFooterContent.is() )
     385             :         {
     386           2 :             uno::Reference< text::XText > xText = xFooterContent->getCenterText();
     387           2 :             centerFooter = xText->getString();
     388           2 :         }
     389             :     }
     390           0 :     catch( uno::Exception& )
     391             :     {
     392             :     }
     393             : 
     394           2 :     return centerFooter;
     395             : }
     396             : 
     397           2 : void SAL_CALL ScVbaPageSetup::setCenterFooter( const OUString& centerFooter) throw (css::uno::RuntimeException, std::exception)
     398             : {
     399             :     try
     400             :     {
     401           2 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     402           2 :         if( xFooterContent.is() )
     403             :         {
     404           2 :             uno::Reference< text::XText > xText = xFooterContent->getCenterText();
     405           2 :             xText->setString( centerFooter );
     406           2 :             mxPageProps->setPropertyValue("RightPageFooterContent", uno::makeAny(xFooterContent) );
     407           2 :         }
     408             :     }
     409           0 :     catch( uno::Exception& )
     410             :     {
     411             :     }
     412             : 
     413           2 : }
     414             : 
     415           2 : OUString SAL_CALL ScVbaPageSetup::getRightFooter() throw (css::uno::RuntimeException, std::exception)
     416             : {
     417           2 :     OUString rightFooter;
     418             :     try
     419             :     {
     420           2 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     421           2 :         if( xFooterContent.is() )
     422             :         {
     423           2 :             uno::Reference< text::XText > xText = xFooterContent->getRightText();
     424           2 :             rightFooter = xText->getString();
     425           2 :         }
     426             :     }
     427           0 :     catch( uno::Exception& )
     428             :     {
     429             :     }
     430             : 
     431           2 :     return rightFooter;
     432             : }
     433             : 
     434           2 : void SAL_CALL ScVbaPageSetup::setRightFooter( const OUString& rightFooter) throw (css::uno::RuntimeException, std::exception)
     435             : {
     436             :     try
     437             :     {
     438           2 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue("RightPageFooterContent"), uno::UNO_QUERY_THROW);
     439           2 :         if( xFooterContent.is() )
     440             :         {
     441           2 :             uno::Reference< text::XText > xText = xFooterContent->getRightText();
     442           2 :             xText->setString( rightFooter );
     443           2 :             mxPageProps->setPropertyValue("RightPageFooterContent", uno::makeAny(xFooterContent) );
     444           2 :         }
     445             :     }
     446           0 :     catch( uno::Exception& )
     447             :     {
     448             :     }
     449           2 : }
     450             : 
     451           4 : sal_Int32 SAL_CALL ScVbaPageSetup::getOrder() throw (css::uno::RuntimeException, std::exception)
     452             : {
     453           4 :     sal_Int32 order = excel::XlOrder::xlDownThenOver;
     454             :     try
     455             :     {
     456           4 :         uno::Any aValue = mxPageProps->getPropertyValue("PrintDownFirst");
     457           4 :         bool bPrintDownFirst = false;
     458           4 :         aValue >>= bPrintDownFirst;
     459           4 :         if( !bPrintDownFirst )
     460           2 :             order = excel::XlOrder::xlOverThenDown;
     461             :     }
     462           0 :     catch( uno::Exception& )
     463             :     {
     464             :     }
     465             : 
     466           4 :     return order;
     467             : }
     468             : 
     469           2 : void SAL_CALL ScVbaPageSetup::setOrder(sal_Int32 order) throw (css::uno::RuntimeException, std::exception)
     470             : {
     471           2 :     bool bOrder = true;
     472           2 :     switch( order )
     473             :     {
     474             :         case excel::XlOrder::xlDownThenOver:
     475           0 :             break;
     476             :         case excel::XlOrder::xlOverThenDown:
     477           2 :             bOrder = false;
     478           2 :             break;
     479             :         default:
     480           0 :             DebugHelper::runtimeexception(SbERR_BAD_PARAMETER, OUString() );
     481             :     }
     482             : 
     483             :     try
     484             :     {
     485           2 :         mxPageProps->setPropertyValue("PrintDownFirst", uno::makeAny( bOrder ));
     486             :     }
     487           0 :     catch (const uno::Exception&)
     488             :     {
     489             :     }
     490           2 : }
     491             : 
     492           4 : sal_Int32 SAL_CALL ScVbaPageSetup::getFirstPageNumber() throw (css::uno::RuntimeException, std::exception)
     493             : {
     494           4 :     sal_Int16 number = 0;
     495             :     try
     496             :     {
     497           4 :         uno::Any aValue = mxPageProps->getPropertyValue("FirstPageNumber");
     498           4 :         aValue >>= number;
     499             :     }
     500           0 :     catch( uno::Exception& )
     501             :     {
     502             :     }
     503             : 
     504           4 :     if( number ==0 )
     505             :     {
     506           2 :         number = excel::Constants::xlAutomatic;
     507             :     }
     508             : 
     509           4 :     return number;
     510             : }
     511             : 
     512           2 : void SAL_CALL ScVbaPageSetup::setFirstPageNumber( sal_Int32 firstPageNumber) throw (css::uno::RuntimeException, std::exception)
     513             : {
     514           2 :     if( firstPageNumber == excel::Constants::xlAutomatic )
     515           0 :         firstPageNumber = 0;
     516             : 
     517             :     try
     518             :     {
     519           2 :         uno::Any aValue;
     520           2 :         aValue <<= (sal_Int16)firstPageNumber;
     521           2 :         mxPageProps->setPropertyValue("FirstPageNumber", aValue );
     522             :     }
     523           0 :     catch (const uno::Exception&)
     524             :     {
     525             :     }
     526           2 : }
     527             : 
     528           4 : sal_Bool SAL_CALL ScVbaPageSetup::getCenterVertically() throw (css::uno::RuntimeException, std::exception)
     529             : {
     530           4 :     bool centerVertically = false;
     531             :     try
     532             :     {
     533           4 :         uno::Any aValue = mxPageProps->getPropertyValue("CenterVertically");
     534           4 :         aValue >>= centerVertically;
     535             :     }
     536           0 :     catch (const uno::Exception&)
     537             :     {
     538             :     }
     539           4 :     return centerVertically;
     540             : }
     541             : 
     542           2 : void SAL_CALL ScVbaPageSetup::setCenterVertically( sal_Bool centerVertically) throw (css::uno::RuntimeException, std::exception)
     543             : {
     544             :     try
     545             :     {
     546           2 :         mxPageProps->setPropertyValue("CenterVertically", uno::makeAny( centerVertically ));
     547             :     }
     548           0 :     catch (const uno::Exception&)
     549             :     {
     550             :     }
     551           2 : }
     552             : 
     553           4 : sal_Bool SAL_CALL ScVbaPageSetup::getCenterHorizontally() throw (css::uno::RuntimeException, std::exception)
     554             : {
     555           4 :     bool centerHorizontally = false;
     556             :     try
     557             :     {
     558           4 :         uno::Any aValue = mxPageProps->getPropertyValue("CenterHorizontally");
     559           4 :         aValue >>= centerHorizontally;
     560             :     }
     561           0 :     catch (const uno::Exception&)
     562             :     {
     563             :     }
     564           4 :     return centerHorizontally;
     565             : }
     566             : 
     567           2 : void SAL_CALL ScVbaPageSetup::setCenterHorizontally( sal_Bool centerHorizontally) throw (css::uno::RuntimeException, std::exception)
     568             : {
     569             :     try
     570             :     {
     571           2 :         mxPageProps->setPropertyValue("CenterHorizontally", uno::makeAny( centerHorizontally ));
     572             :     }
     573           0 :     catch (const uno::Exception&)
     574             :     {
     575             :     }
     576           2 : }
     577             : 
     578           4 : sal_Bool SAL_CALL ScVbaPageSetup::getPrintHeadings() throw (css::uno::RuntimeException, std::exception)
     579             : {
     580           4 :     bool printHeadings = false;
     581             :     try
     582             :     {
     583           4 :         uno::Any aValue = mxPageProps->getPropertyValue("PrintHeaders");
     584           4 :         aValue >>= printHeadings;
     585             :     }
     586           0 :     catch (const uno::Exception&)
     587             :     {
     588             :     }
     589           4 :     return printHeadings;
     590             : }
     591             : 
     592           2 : void SAL_CALL ScVbaPageSetup::setPrintHeadings( sal_Bool printHeadings) throw (css::uno::RuntimeException, std::exception)
     593             : {
     594             :     try
     595             :     {
     596           2 :         mxPageProps->setPropertyValue("PrintHeaders", uno::makeAny( printHeadings ));
     597             :     }
     598           0 :     catch( uno::Exception& )
     599             :     {
     600             :     }
     601           2 : }
     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           4 : sal_Int32 SAL_CALL ScVbaPageSetup::getPaperSize() throw (uno::RuntimeException, std::exception)
     629             : {
     630           4 :     awt::Size aSize; // current papersize
     631           4 :     mxPageProps->getPropertyValue( "Size" ) >>= aSize;
     632           4 :     if ( mbIsLandscape )
     633           4 :         ::std::swap( aSize.Width, aSize.Height );
     634             : 
     635           4 :     sal_Int32 nPaperSizeIndex = msfilter::util::PaperSizeConv::getMSPaperSizeIndex( aSize );
     636           4 :     if ( nPaperSizeIndex == 0 )
     637           0 :         nPaperSizeIndex = excel::XlPaperSize::xlPaperUser;
     638           4 :     return nPaperSizeIndex;
     639             : }
     640             : 
     641           2 : void SAL_CALL ScVbaPageSetup::setPaperSize( sal_Int32 papersize ) throw (uno::RuntimeException, std::exception)
     642             : {
     643           2 :     if ( papersize != excel::XlPaperSize::xlPaperUser )
     644             :     {
     645           2 :         awt::Size aPaperSize;
     646           2 :         const msfilter::util::ApiPaperSize& rConvertedSize = msfilter::util::PaperSizeConv::getApiSizeForMSPaperSizeIndex( papersize );
     647           2 :         aPaperSize.Height = rConvertedSize.mnHeight;
     648           2 :         aPaperSize.Width = rConvertedSize.mnWidth;
     649           2 :         if ( mbIsLandscape )
     650           2 :             ::std::swap( aPaperSize.Width, aPaperSize.Height );
     651           2 :         mxPageProps->setPropertyValue( "Size", uno::makeAny( aPaperSize ) );
     652             :     }
     653           2 : }
     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          12 : }
     672             : 
     673             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10