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

Generated by: LCOV version 1.10