LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbapagesetup.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 313 0.0 %
Date: 2012-08-25 Functions: 0 41 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 590 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #include "vbapagesetup.hxx"
      29                 :            : #include "cellsuno.hxx"
      30                 :            : #include "convuno.hxx"
      31                 :            : #include "rangelst.hxx"
      32                 :            : #include "excelvbahelper.hxx"
      33                 :            : #include <com/sun/star/sheet/XPrintAreas.hpp>
      34                 :            : #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
      35                 :            : #include <com/sun/star/text/XText.hpp>
      36                 :            : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      37                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      38                 :            : #include <ooo/vba/excel/XlPageOrientation.hpp>
      39                 :            : #include <ooo/vba/excel/XlOrder.hpp>
      40                 :            : #include <ooo/vba/excel/Constants.hpp>
      41                 :            : #include <i18nutil/paper.hxx>
      42                 :            : #include <editeng/paperinf.hxx>
      43                 :            : #include <ooo/vba/excel/XlPaperSize.hpp>
      44                 :            : #include <sal/macros.h>
      45                 :            : 
      46                 :            : using namespace ::com::sun::star;
      47                 :            : using namespace ::ooo::vba;
      48                 :            : 
      49                 :            : #define ZOOM_IN 10
      50                 :            : #define ZOOM_MAX 400
      51                 :            : 
      52                 :            : bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, ScRange& refRange, ScRangeList& aCellRanges, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException );
      53                 :            : 
      54                 :          0 : ScVbaPageSetup::ScVbaPageSetup(const uno::Reference< XHelperInterface >& xParent,
      55                 :            :                 const uno::Reference< uno::XComponentContext >& xContext,
      56                 :            :                 const uno::Reference< sheet::XSpreadsheet >& xSheet,
      57                 :            :                 const uno::Reference< frame::XModel >& xModel) throw (uno::RuntimeException):
      58                 :          0 :            ScVbaPageSetup_BASE( xParent, xContext ), mxSheet( xSheet )
      59                 :            : {
      60                 :            :     // query for current page style
      61         [ #  # ]:          0 :     mxModel.set( xModel, uno::UNO_QUERY_THROW );
      62         [ #  # ]:          0 :     uno::Reference< beans::XPropertySet > xSheetProps( mxSheet, uno::UNO_QUERY_THROW );
      63 [ #  # ][ #  # ]:          0 :     uno::Any aValue = xSheetProps->getPropertyValue( rtl::OUString(  "PageStyle" ));
      64                 :          0 :     rtl::OUString aStyleName;
      65                 :          0 :     aValue >>= aStyleName;
      66                 :            : 
      67         [ #  # ]:          0 :     uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSup( mxModel, uno::UNO_QUERY_THROW );
      68 [ #  # ][ #  # ]:          0 :     uno::Reference< container::XNameAccess > xStyleFamilies = xStyleFamiliesSup->getStyleFamilies();
      69 [ #  # ][ #  # ]:          0 :     uno::Reference< container::XNameAccess > xPageStyle( xStyleFamilies->getByName(rtl::OUString( "PageStyles")), uno::UNO_QUERY_THROW );
                 [ #  # ]
      70 [ #  # ][ #  # ]:          0 :     mxPageProps.set( xPageStyle->getByName(aStyleName), uno::UNO_QUERY_THROW );
                 [ #  # ]
      71                 :          0 :     mnOrientLandscape = excel::XlPageOrientation::xlLandscape;
      72                 :          0 :     mnOrientPortrait = excel::XlPageOrientation::xlPortrait;
      73                 :          0 : }
      74                 :            : 
      75                 :          0 : rtl::OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeException)
      76                 :            : {
      77         [ #  # ]:          0 :     String aPrintArea;
      78         [ #  # ]:          0 :     uno::Reference< sheet::XPrintAreas > xPrintAreas( mxSheet, uno::UNO_QUERY_THROW );
      79 [ #  # ][ #  # ]:          0 :     uno::Sequence< table::CellRangeAddress > aSeq = xPrintAreas->getPrintAreas();
      80                 :          0 :     sal_Int32 nCount = aSeq.getLength();
      81         [ #  # ]:          0 :     if( nCount )
      82                 :            :     {
      83                 :          0 :         ScAddress::Details aDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
      84                 :          0 :         sal_uInt16 nFlags = SCA_VALID;
      85                 :          0 :         nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE );
      86         [ #  # ]:          0 :         ScRangeList aRangeList;
      87         [ #  # ]:          0 :         for( sal_Int32 i=0; i<nCount; i++ )
      88                 :            :         {
      89                 :          0 :             ScRange aRange;
      90         [ #  # ]:          0 :             ScUnoConversion::FillScRange( aRange, aSeq[i] );
      91         [ #  # ]:          0 :             aRangeList.Append( aRange );
      92                 :            :         }
      93         [ #  # ]:          0 :         ScDocument* pDoc = excel::getDocShell( mxModel )->GetDocument();
      94 [ #  # ][ #  # ]:          0 :         aRangeList.Format( aPrintArea, nFlags, pDoc, formula::FormulaGrammar::CONV_XL_A1, ','  );
      95                 :            :     }
      96                 :            : 
      97 [ #  # ][ #  # ]:          0 :     return aPrintArea;
                 [ #  # ]
      98                 :            : }
      99                 :            : 
     100                 :          0 : void SAL_CALL ScVbaPageSetup::setPrintArea( const rtl::OUString& rAreas ) throw (css::uno::RuntimeException)
     101                 :            : {
     102         [ #  # ]:          0 :     uno::Reference< sheet::XPrintAreas > xPrintAreas( mxSheet, uno::UNO_QUERY_THROW );
     103   [ #  #  #  # ]:          0 :     if( rAreas.isEmpty() ||
                 [ #  # ]
     104 [ #  # ][ #  # ]:          0 :         rAreas.equalsIgnoreAsciiCase ( rtl::OUString("FALSE") ) )
     105                 :            :     {
     106                 :            :         // print the whole sheet
     107         [ #  # ]:          0 :         uno::Sequence< table::CellRangeAddress > aSeq;
     108 [ #  # ][ #  # ]:          0 :         xPrintAreas->setPrintAreas( aSeq );
                 [ #  # ]
     109                 :            :     }
     110                 :            :     else
     111                 :            :     {
     112         [ #  # ]:          0 :         ScRangeList aCellRanges;
     113                 :          0 :         ScRange aRange;
     114 [ #  # ][ #  # ]:          0 :         if( getScRangeListForAddress( rAreas, excel::getDocShell( mxModel ) , aRange, aCellRanges ) )
                 [ #  # ]
     115                 :            :         {
     116 [ #  # ][ #  # ]:          0 :             uno::Sequence< table::CellRangeAddress > aSeq( aCellRanges.size() );
     117 [ #  # ][ #  # ]:          0 :             for ( size_t i = 0, nRanges = aCellRanges.size(); i < nRanges; ++i )
     118                 :            :             {
     119         [ #  # ]:          0 :                 ScRange* pRange = aCellRanges[ i ];
     120                 :          0 :                 table::CellRangeAddress aRangeAddress;
     121                 :          0 :                 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
     122         [ #  # ]:          0 :                 aSeq[ i++ ] = aRangeAddress;
     123                 :            :             }
     124 [ #  # ][ #  # ]:          0 :             xPrintAreas->setPrintAreas( aSeq );
                 [ #  # ]
     125         [ #  # ]:          0 :         }
     126                 :          0 :     }
     127                 :          0 : }
     128                 :            : 
     129                 :          0 : double SAL_CALL ScVbaPageSetup::getHeaderMargin() throw (css::uno::RuntimeException)
     130                 :            : {
     131                 :          0 :     return VbaPageSetupBase::getHeaderMargin();
     132                 :            : }
     133                 :            : 
     134                 :          0 : void SAL_CALL ScVbaPageSetup::setHeaderMargin( double margin ) throw (css::uno::RuntimeException)
     135                 :            : {
     136                 :          0 :     VbaPageSetupBase::setHeaderMargin( margin );
     137                 :          0 : }
     138                 :            : 
     139                 :          0 : double SAL_CALL ScVbaPageSetup::getFooterMargin() throw (css::uno::RuntimeException)
     140                 :            : {
     141                 :          0 :     return VbaPageSetupBase::getFooterMargin();
     142                 :            : }
     143                 :            : 
     144                 :          0 : void SAL_CALL ScVbaPageSetup::setFooterMargin( double margin ) throw (css::uno::RuntimeException)
     145                 :            : {
     146                 :          0 :     VbaPageSetupBase::setFooterMargin( margin );
     147                 :          0 : }
     148                 :            : 
     149                 :          0 : uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesTall() throw (css::uno::RuntimeException)
     150                 :            : {
     151         [ #  # ]:          0 :     return mxPageProps->getPropertyValue( rtl::OUString( "ScaleToPagesY"));
     152                 :            : }
     153                 :            : 
     154                 :          0 : void SAL_CALL ScVbaPageSetup::setFitToPagesTall( const uno::Any& fitToPagesTall) throw (css::uno::RuntimeException)
     155                 :            : {
     156                 :          0 :     sal_uInt16 scaleToPageY = 0;
     157                 :            :     try
     158                 :            :     {
     159                 :            :         sal_Bool aValue;
     160 [ #  # ][ #  # ]:          0 :         if( fitToPagesTall.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesTall >>= aValue))
                 [ #  # ]
     161                 :            :         {
     162                 :          0 :             fitToPagesTall >>= scaleToPageY;
     163                 :            :         }
     164                 :            : 
     165 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "ScaleToPagesY"), uno::makeAny( scaleToPageY ));
         [ #  # ][ #  # ]
     166                 :            :     }
     167         [ #  # ]:          0 :     catch( uno::Exception& )
     168                 :            :     {
     169                 :            :     }
     170                 :          0 : }
     171                 :            : 
     172                 :          0 : uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesWide() throw (css::uno::RuntimeException)
     173                 :            : {
     174         [ #  # ]:          0 :     return mxPageProps->getPropertyValue( rtl::OUString( "ScaleToPagesX"));
     175                 :            : }
     176                 :            : 
     177                 :          0 : void SAL_CALL ScVbaPageSetup::setFitToPagesWide( const uno::Any& fitToPagesWide) throw (css::uno::RuntimeException)
     178                 :            : {
     179                 :          0 :     sal_uInt16 scaleToPageX = 0;
     180                 :            :     try
     181                 :            :     {
     182                 :          0 :         sal_Bool aValue = false;
     183 [ #  # ][ #  # ]:          0 :         if( fitToPagesWide.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesWide >>= aValue))
                 [ #  # ]
     184                 :            :         {
     185                 :          0 :             fitToPagesWide >>= scaleToPageX;
     186                 :            :         }
     187                 :            : 
     188 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "ScaleToPagesX"), uno::makeAny( scaleToPageX ));
         [ #  # ][ #  # ]
     189                 :            :     }
     190         [ #  # ]:          0 :     catch( uno::Exception& )
     191                 :            :     {
     192                 :            :     }
     193                 :          0 : }
     194                 :            : 
     195                 :          0 : uno::Any SAL_CALL ScVbaPageSetup::getZoom() throw (css::uno::RuntimeException)
     196                 :            : {
     197         [ #  # ]:          0 :     return mxPageProps->getPropertyValue( rtl::OUString( "PageScale"));
     198                 :            : }
     199                 :            : 
     200                 :          0 : void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::RuntimeException)
     201                 :            : {
     202                 :          0 :     sal_uInt16 pageScale = 0;
     203                 :            :     try
     204                 :            :     {
     205         [ #  # ]:          0 :         if( zoom.getValueTypeClass() == uno::TypeClass_BOOLEAN )
     206                 :            :         {
     207                 :          0 :             sal_Bool aValue = false;
     208                 :          0 :             zoom >>= aValue;
     209         [ #  # ]:          0 :             if( aValue )
     210                 :            :             {
     211         [ #  # ]:          0 :                 DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
     212                 :            :             }
     213                 :            :         }
     214                 :            :         else
     215                 :            :         {
     216                 :          0 :             zoom >>= pageScale;
     217 [ #  # ][ #  # ]:          0 :             if(( pageScale < ZOOM_IN )||( pageScale > ZOOM_MAX ))
     218                 :            :             {
     219         [ #  # ]:          0 :                 DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
     220                 :            :             }
     221                 :            :         }
     222                 :            : 
     223                 :            :         // these only exist in S08
     224                 :          0 :         sal_uInt16 nScale = 0;
     225 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "ScaleToPages"), uno::makeAny( nScale ));
                 [ #  # ]
     226 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "ScaleToPagesX"), uno::makeAny( nScale ));
                 [ #  # ]
     227 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "ScaleToPagesY"), uno::makeAny( nScale ));
                 [ #  # ]
     228                 :            :     }
     229   [ #  #  #  #  :          0 :     catch( beans::UnknownPropertyException& )
                      # ]
     230                 :            :     {
     231         [ #  # ]:          0 :         if( pageScale == 0 )
     232                 :            :         {
     233         [ #  # ]:          0 :             DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
     234                 :            :         }
     235                 :            :     }
     236         [ #  # ]:          0 :     catch( uno::Exception& )
     237                 :            :     {
     238                 :            :     }
     239                 :            : 
     240 [ #  # ][ #  # ]:          0 :     mxPageProps->setPropertyValue( rtl::OUString( "PageScale"), uno::makeAny( pageScale ));
                 [ #  # ]
     241                 :          0 : }
     242                 :            : 
     243                 :          0 : rtl::OUString SAL_CALL ScVbaPageSetup::getLeftHeader() throw (css::uno::RuntimeException)
     244                 :            : {
     245                 :          0 :     rtl::OUString leftHeader;
     246                 :            :     try
     247                 :            :     {
     248 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageHeaderContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     249         [ #  # ]:          0 :         if( xHeaderContent.is() )
     250                 :            :         {
     251 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
     252 [ #  # ][ #  # ]:          0 :             leftHeader = xText->getString();
     253         [ #  # ]:          0 :         }
     254                 :            :     }
     255         [ #  # ]:          0 :     catch( uno::Exception& )
     256                 :            :     {
     257                 :            :     }
     258                 :            : 
     259                 :          0 :     return leftHeader;
     260                 :            : }
     261                 :            : 
     262                 :          0 : void SAL_CALL ScVbaPageSetup::setLeftHeader( const rtl::OUString& leftHeader) throw (css::uno::RuntimeException)
     263                 :            : {
     264                 :            :     try
     265                 :            :     {
     266 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageHeaderContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     267         [ #  # ]:          0 :         if( xHeaderContent.is() )
     268                 :            :         {
     269 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
     270 [ #  # ][ #  # ]:          0 :             xText->setString( leftHeader );
     271 [ #  # ][ #  # ]:          0 :             mxPageProps->setPropertyValue( rtl::OUString( "RightPageHeaderContent"), uno::makeAny(xHeaderContent) );
                 [ #  # ]
     272         [ #  # ]:          0 :         }
     273                 :            :     }
     274                 :          0 :     catch( uno::Exception& )
     275                 :            :     {
     276                 :            :     }
     277                 :          0 : }
     278                 :            : 
     279                 :          0 : rtl::OUString SAL_CALL ScVbaPageSetup::getCenterHeader() throw (css::uno::RuntimeException)
     280                 :            : {
     281                 :          0 :     rtl::OUString centerHeader;
     282                 :            :     try
     283                 :            :     {
     284 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageHeaderContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     285         [ #  # ]:          0 :         if( xHeaderContent.is() )
     286                 :            :         {
     287 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
     288 [ #  # ][ #  # ]:          0 :             centerHeader = xText->getString();
     289         [ #  # ]:          0 :         }
     290                 :            :     }
     291         [ #  # ]:          0 :     catch( uno::Exception& )
     292                 :            :     {
     293                 :            :     }
     294                 :            : 
     295                 :          0 :     return centerHeader;
     296                 :            : }
     297                 :            : 
     298                 :          0 : void SAL_CALL ScVbaPageSetup::setCenterHeader( const rtl::OUString& centerHeader) throw (css::uno::RuntimeException)
     299                 :            : {
     300                 :            :     try
     301                 :            :     {
     302 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageHeaderContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     303         [ #  # ]:          0 :         if( xHeaderContent.is() )
     304                 :            :         {
     305 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
     306 [ #  # ][ #  # ]:          0 :             xText->setString( centerHeader );
     307 [ #  # ][ #  # ]:          0 :             mxPageProps->setPropertyValue( rtl::OUString( "RightPageHeaderContent"), uno::makeAny(xHeaderContent) );
                 [ #  # ]
     308         [ #  # ]:          0 :         }
     309                 :            :     }
     310                 :          0 :     catch( uno::Exception& )
     311                 :            :     {
     312                 :            :     }
     313                 :          0 : }
     314                 :            : 
     315                 :          0 : rtl::OUString SAL_CALL ScVbaPageSetup::getRightHeader() throw (css::uno::RuntimeException)
     316                 :            : {
     317                 :          0 :     rtl::OUString rightHeader;
     318                 :            :     try
     319                 :            :     {
     320 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageHeaderContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     321         [ #  # ]:          0 :         if( xHeaderContent.is() )
     322                 :            :         {
     323 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xHeaderContent->getRightText();
     324 [ #  # ][ #  # ]:          0 :             rightHeader = xText->getString();
     325         [ #  # ]:          0 :         }
     326                 :            :     }
     327         [ #  # ]:          0 :     catch( uno::Exception& )
     328                 :            :     {
     329                 :            :     }
     330                 :            : 
     331                 :          0 :     return rightHeader;
     332                 :            : }
     333                 :            : 
     334                 :          0 : void SAL_CALL ScVbaPageSetup::setRightHeader( const rtl::OUString& rightHeader) throw (css::uno::RuntimeException)
     335                 :            : {
     336                 :            :     try
     337                 :            :     {
     338 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageHeaderContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     339         [ #  # ]:          0 :         if( xHeaderContent.is() )
     340                 :            :         {
     341 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xHeaderContent->getRightText();
     342 [ #  # ][ #  # ]:          0 :             xText->setString( rightHeader );
     343 [ #  # ][ #  # ]:          0 :             mxPageProps->setPropertyValue( rtl::OUString( "RightPageHeaderContent"), uno::makeAny(xHeaderContent) );
                 [ #  # ]
     344         [ #  # ]:          0 :         }
     345                 :            :     }
     346                 :          0 :     catch( uno::Exception& )
     347                 :            :     {
     348                 :            :     }
     349                 :          0 : }
     350                 :            : 
     351                 :          0 : rtl::OUString SAL_CALL ScVbaPageSetup::getLeftFooter() throw (css::uno::RuntimeException)
     352                 :            : {
     353                 :          0 :     rtl::OUString leftFooter;
     354                 :            :     try
     355                 :            :     {
     356 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageFooterContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     357         [ #  # ]:          0 :         if( xFooterContent.is() )
     358                 :            :         {
     359 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xFooterContent->getLeftText();
     360 [ #  # ][ #  # ]:          0 :             leftFooter = xText->getString();
     361         [ #  # ]:          0 :         }
     362                 :            :     }
     363         [ #  # ]:          0 :     catch( uno::Exception& )
     364                 :            :     {
     365                 :            :     }
     366                 :            : 
     367                 :          0 :     return leftFooter;
     368                 :            : }
     369                 :            : 
     370                 :          0 : void SAL_CALL ScVbaPageSetup::setLeftFooter( const rtl::OUString& leftFooter) throw (css::uno::RuntimeException)
     371                 :            : {
     372                 :            :     try
     373                 :            :     {
     374 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageFooterContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     375         [ #  # ]:          0 :         if( xFooterContent.is() )
     376                 :            :         {
     377 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xFooterContent->getLeftText();
     378 [ #  # ][ #  # ]:          0 :             xText->setString( leftFooter );
     379 [ #  # ][ #  # ]:          0 :             mxPageProps->setPropertyValue( rtl::OUString( "RightPageFooterContent"), uno::makeAny(xFooterContent) );
                 [ #  # ]
     380         [ #  # ]:          0 :         }
     381                 :            :     }
     382                 :          0 :     catch( uno::Exception& )
     383                 :            :     {
     384                 :            :     }
     385                 :          0 : }
     386                 :            : 
     387                 :          0 : rtl::OUString SAL_CALL ScVbaPageSetup::getCenterFooter() throw (css::uno::RuntimeException)
     388                 :            : {
     389                 :          0 :     rtl::OUString centerFooter;
     390                 :            :     try
     391                 :            :     {
     392 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageFooterContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     393         [ #  # ]:          0 :         if( xFooterContent.is() )
     394                 :            :         {
     395 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xFooterContent->getCenterText();
     396 [ #  # ][ #  # ]:          0 :             centerFooter = xText->getString();
     397         [ #  # ]:          0 :         }
     398                 :            :     }
     399         [ #  # ]:          0 :     catch( uno::Exception& )
     400                 :            :     {
     401                 :            :     }
     402                 :            : 
     403                 :          0 :     return centerFooter;
     404                 :            : }
     405                 :            : 
     406                 :          0 : void SAL_CALL ScVbaPageSetup::setCenterFooter( const rtl::OUString& centerFooter) throw (css::uno::RuntimeException)
     407                 :            : {
     408                 :            :     try
     409                 :            :     {
     410 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageFooterContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     411         [ #  # ]:          0 :         if( xFooterContent.is() )
     412                 :            :         {
     413 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xFooterContent->getCenterText();
     414 [ #  # ][ #  # ]:          0 :             xText->setString( centerFooter );
     415 [ #  # ][ #  # ]:          0 :             mxPageProps->setPropertyValue( rtl::OUString( "RightPageFooterContent"), uno::makeAny(xFooterContent) );
                 [ #  # ]
     416         [ #  # ]:          0 :         }
     417                 :            :     }
     418                 :          0 :     catch( uno::Exception& )
     419                 :            :     {
     420                 :            :     }
     421                 :            : 
     422                 :          0 : }
     423                 :            : 
     424                 :          0 : rtl::OUString SAL_CALL ScVbaPageSetup::getRightFooter() throw (css::uno::RuntimeException)
     425                 :            : {
     426                 :          0 :     rtl::OUString rightFooter;
     427                 :            :     try
     428                 :            :     {
     429 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageFooterContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     430         [ #  # ]:          0 :         if( xFooterContent.is() )
     431                 :            :         {
     432 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xFooterContent->getRightText();
     433 [ #  # ][ #  # ]:          0 :             rightFooter = xText->getString();
     434         [ #  # ]:          0 :         }
     435                 :            :     }
     436         [ #  # ]:          0 :     catch( uno::Exception& )
     437                 :            :     {
     438                 :            :     }
     439                 :            : 
     440                 :          0 :     return rightFooter;
     441                 :            : }
     442                 :            : 
     443                 :          0 : void SAL_CALL ScVbaPageSetup::setRightFooter( const rtl::OUString& rightFooter) throw (css::uno::RuntimeException)
     444                 :            : {
     445                 :            :     try
     446                 :            :     {
     447 [ #  # ][ #  # ]:          0 :         uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( "RightPageFooterContent")), uno::UNO_QUERY_THROW);
                 [ #  # ]
     448         [ #  # ]:          0 :         if( xFooterContent.is() )
     449                 :            :         {
     450 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XText > xText = xFooterContent->getRightText();
     451 [ #  # ][ #  # ]:          0 :             xText->setString( rightFooter );
     452 [ #  # ][ #  # ]:          0 :             mxPageProps->setPropertyValue( rtl::OUString( "RightPageFooterContent"), uno::makeAny(xFooterContent) );
                 [ #  # ]
     453         [ #  # ]:          0 :         }
     454                 :            :     }
     455                 :          0 :     catch( uno::Exception& )
     456                 :            :     {
     457                 :            :     }
     458                 :          0 : }
     459                 :            : 
     460                 :          0 : sal_Int32 SAL_CALL ScVbaPageSetup::getOrder() throw (css::uno::RuntimeException)
     461                 :            : {
     462                 :          0 :     sal_Int32 order = excel::XlOrder::xlDownThenOver;
     463                 :            :     try
     464                 :            :     {
     465 [ #  # ][ #  # ]:          0 :         uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( "PrintDownFirst"));
                 [ #  # ]
     466                 :          0 :         sal_Bool bPrintDownFirst = false;
     467                 :          0 :         aValue >>= bPrintDownFirst;
     468         [ #  # ]:          0 :         if( !bPrintDownFirst )
     469                 :          0 :             order = excel::XlOrder::xlOverThenDown;
     470                 :            :     }
     471                 :          0 :     catch( uno::Exception& )
     472                 :            :     {
     473                 :            :     }
     474                 :            : 
     475                 :          0 :     return order;
     476                 :            : }
     477                 :            : 
     478                 :          0 : void SAL_CALL ScVbaPageSetup::setOrder( sal_Int32 order) throw (css::uno::RuntimeException)
     479                 :            : {
     480                 :          0 :     sal_Bool bOrder = sal_True;
     481      [ #  #  # ]:          0 :     switch( order )
     482                 :            :     {
     483                 :            :         case excel::XlOrder::xlDownThenOver:
     484                 :          0 :             break;
     485                 :            :         case excel::XlOrder::xlOverThenDown:
     486                 :          0 :             bOrder = false;
     487                 :          0 :             break;
     488                 :            :         default:
     489         [ #  # ]:          0 :             DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
     490                 :            :     }
     491                 :            : 
     492                 :            :     try
     493                 :            :     {
     494 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "PrintDownFirst"), uno::makeAny( bOrder ));
         [ #  # ][ #  # ]
     495                 :            :     }
     496         [ #  # ]:          0 :     catch( uno::Exception& )
     497                 :            :     {
     498                 :            :     }
     499                 :          0 : }
     500                 :            : 
     501                 :          0 : sal_Int32 SAL_CALL ScVbaPageSetup::getFirstPageNumber() throw (css::uno::RuntimeException)
     502                 :            : {
     503                 :          0 :     sal_Int16 number = 0;
     504                 :            :     try
     505                 :            :     {
     506 [ #  # ][ #  # ]:          0 :         uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( "FirstPageNumber"));
                 [ #  # ]
     507                 :          0 :         aValue >>= number;
     508                 :            :     }
     509         [ #  # ]:          0 :     catch( uno::Exception& )
     510                 :            :     {
     511                 :            :     }
     512                 :            : 
     513         [ #  # ]:          0 :     if( number ==0 )
     514                 :            :     {
     515                 :          0 :         number = excel::Constants::xlAutomatic;
     516                 :            :     }
     517                 :            : 
     518                 :          0 :     return number;
     519                 :            : }
     520                 :            : 
     521                 :          0 : void SAL_CALL ScVbaPageSetup::setFirstPageNumber( sal_Int32 firstPageNumber) throw (css::uno::RuntimeException)
     522                 :            : {
     523         [ #  # ]:          0 :     if( firstPageNumber < 0 )
     524         [ #  # ]:          0 :         DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
     525         [ #  # ]:          0 :     if( firstPageNumber == excel::Constants::xlAutomatic )
     526                 :          0 :         firstPageNumber = 0;
     527                 :            : 
     528                 :            :     try
     529                 :            :     {
     530                 :          0 :         uno::Any aValue;
     531         [ #  # ]:          0 :         aValue <<= (sal_Int16)firstPageNumber;
     532 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "FirstPageNumber"), aValue );
                 [ #  # ]
     533                 :            :     }
     534                 :          0 :     catch( uno::Exception& )
     535                 :            :     {
     536                 :            :     }
     537                 :          0 : }
     538                 :            : 
     539                 :          0 : sal_Bool SAL_CALL ScVbaPageSetup::getCenterVertically() throw (css::uno::RuntimeException)
     540                 :            : {
     541                 :          0 :     sal_Bool centerVertically = false;
     542                 :            :     try
     543                 :            :     {
     544 [ #  # ][ #  # ]:          0 :         uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( "CenterVertically"));
                 [ #  # ]
     545                 :          0 :         aValue >>= centerVertically;
     546                 :            :     }
     547         [ #  # ]:          0 :     catch( uno::Exception& )
     548                 :            :     {
     549                 :            :     }
     550                 :          0 :     return centerVertically;
     551                 :            : }
     552                 :            : 
     553                 :          0 : void SAL_CALL ScVbaPageSetup::setCenterVertically( sal_Bool centerVertically) throw (css::uno::RuntimeException)
     554                 :            : {
     555                 :            :     try
     556                 :            :     {
     557 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "CenterVertically"), uno::makeAny( centerVertically ));
         [ #  # ][ #  # ]
     558                 :            :     }
     559                 :          0 :     catch( uno::Exception& )
     560                 :            :     {
     561                 :            :     }
     562                 :          0 : }
     563                 :            : 
     564                 :          0 : sal_Bool SAL_CALL ScVbaPageSetup::getCenterHorizontally() throw (css::uno::RuntimeException)
     565                 :            : {
     566                 :          0 :     sal_Bool centerHorizontally = false;
     567                 :            :     try
     568                 :            :     {
     569 [ #  # ][ #  # ]:          0 :         uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( "CenterHorizontally"));
                 [ #  # ]
     570                 :          0 :         aValue >>= centerHorizontally;
     571                 :            :     }
     572         [ #  # ]:          0 :     catch( uno::Exception& )
     573                 :            :     {
     574                 :            :     }
     575                 :          0 :     return centerHorizontally;
     576                 :            : }
     577                 :            : 
     578                 :          0 : void SAL_CALL ScVbaPageSetup::setCenterHorizontally( sal_Bool centerHorizontally) throw (css::uno::RuntimeException)
     579                 :            : {
     580                 :            :     try
     581                 :            :     {
     582 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "CenterHorizontally"), uno::makeAny( centerHorizontally ));
         [ #  # ][ #  # ]
     583                 :            :     }
     584                 :          0 :     catch( uno::Exception& )
     585                 :            :     {
     586                 :            :     }
     587                 :          0 : }
     588                 :            : 
     589                 :          0 : sal_Bool SAL_CALL ScVbaPageSetup::getPrintHeadings() throw (css::uno::RuntimeException)
     590                 :            : {
     591                 :          0 :     sal_Bool printHeadings = false;
     592                 :            :     try
     593                 :            :     {
     594 [ #  # ][ #  # ]:          0 :         uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( "PrintHeaders"));
                 [ #  # ]
     595                 :          0 :         aValue >>= printHeadings;
     596                 :            :     }
     597         [ #  # ]:          0 :     catch( uno::Exception& )
     598                 :            :     {
     599                 :            :     }
     600                 :          0 :     return printHeadings;
     601                 :            : }
     602                 :            : 
     603                 :          0 : void SAL_CALL ScVbaPageSetup::setPrintHeadings( sal_Bool printHeadings) throw (css::uno::RuntimeException)
     604                 :            : {
     605                 :            :     try
     606                 :            :     {
     607 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "PrintHeaders"), uno::makeAny( printHeadings ));
         [ #  # ][ #  # ]
     608                 :            :     }
     609                 :          0 :     catch( uno::Exception& )
     610                 :            :     {
     611                 :            :     }
     612                 :          0 : }
     613                 :            : 
     614                 :            : rtl::OUString
     615                 :          0 : ScVbaPageSetup::getServiceImplName()
     616                 :            : {
     617                 :          0 :     return rtl::OUString("ScVbaPageSetup");
     618                 :            : }
     619                 :            : 
     620                 :            : uno::Sequence< rtl::OUString >
     621                 :          0 : ScVbaPageSetup::getServiceNames()
     622                 :            : {
     623 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
     624         [ #  # ]:          0 :     if ( aServiceNames.getLength() == 0 )
     625                 :            :     {
     626                 :          0 :         aServiceNames.realloc( 1 );
     627         [ #  # ]:          0 :         aServiceNames[ 0 ] = rtl::OUString( "ooo.vba.excel.PageSetup"  );
     628                 :            :     }
     629                 :          0 :     return aServiceNames;
     630                 :            : }
     631                 :            : 
     632                 :            : struct PaperSizeMap
     633                 :            : {
     634                 :            :     Paper ePaper;
     635                 :            :     sal_Int32 xlPaper;
     636                 :            : };
     637                 :            : 
     638                 :            : static PaperSizeMap paperSizeMappings[] =
     639                 :            : {
     640                 :            :     { PAPER_A3, ooo::vba::excel::XlPaperSize::xlPaperA3 },
     641                 :            :     { PAPER_A4, ooo::vba::excel::XlPaperSize::xlPaperA4 },
     642                 :            :     { PAPER_A5, ooo::vba::excel::XlPaperSize::xlPaperA5 },
     643                 :            :     { PAPER_B4_ISO, ooo::vba::excel::XlPaperSize::xlPaperB4 },
     644                 :            :     { PAPER_B5_ISO, ooo::vba::excel::XlPaperSize::xlPaperB5 },
     645                 :            :     { PAPER_LETTER, ooo::vba::excel::XlPaperSize::xlPaperLetter },
     646                 :            :     { PAPER_LEGAL, ooo::vba::excel::XlPaperSize::xlPaperLegal },
     647                 :            :     { PAPER_TABLOID, ooo::vba::excel::XlPaperSize::xlPaperTabloid },
     648                 :            :     { PAPER_USER, ooo::vba::excel::XlPaperSize::xlPaperUser },
     649                 :            :     { PAPER_B6_ISO, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeB6 },
     650                 :            :     { PAPER_ENV_C4, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC4 },
     651                 :            :     { PAPER_ENV_C5, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC5 },
     652                 :            :     { PAPER_ENV_C6, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC6 },
     653                 :            :     { PAPER_ENV_C65, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC65 },
     654                 :            :     { PAPER_ENV_DL, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeDL },
     655                 :            :     { PAPER_C, ooo::vba::excel::XlPaperSize::xlPaperCsheet },
     656                 :            :     { PAPER_D, ooo::vba::excel::XlPaperSize::xlPaperDsheet },
     657                 :            :     { PAPER_E, ooo::vba::excel::XlPaperSize::xlPaperEsheet },
     658                 :            :     { PAPER_ENV_MONARCH, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeMonarch },
     659                 :            :     { PAPER_ENV_PERSONAL, ooo::vba::excel::XlPaperSize::xlPaperEnvelopePersonal },
     660                 :            :     { PAPER_ENV_9, ooo::vba::excel::XlPaperSize::xlPaperEnvelope9 },
     661                 :            :     { PAPER_ENV_10, ooo::vba::excel::XlPaperSize::xlPaperEnvelope10 },
     662                 :            :     { PAPER_ENV_11, ooo::vba::excel::XlPaperSize::xlPaperEnvelope11 },
     663                 :            :     { PAPER_ENV_12, ooo::vba::excel::XlPaperSize::xlPaperEnvelope12 }
     664                 :            : };
     665                 :            : 
     666                 :            : static const int nMapSize = SAL_N_ELEMENTS(paperSizeMappings);
     667                 :            : 
     668                 :          0 : sal_Int32 PaperSizeOOoToExcel(Paper ePaper)
     669                 :            : {
     670                 :          0 :     sal_Int32 nPaperSize = ooo::vba::excel::XlPaperSize::xlPaperUser;
     671                 :            : 
     672         [ #  # ]:          0 :     for (int i = 0; i < nMapSize; i++)
     673                 :            :     {
     674         [ #  # ]:          0 :         if (ePaper == paperSizeMappings[i].ePaper)
     675                 :            :         {
     676                 :          0 :             nPaperSize = paperSizeMappings[i].xlPaper;
     677                 :          0 :             break;
     678                 :            :         }
     679                 :            :     }
     680                 :            : 
     681                 :          0 :     return nPaperSize;
     682                 :            : }
     683                 :            : 
     684                 :          0 : sal_Int32 SAL_CALL ScVbaPageSetup::getPaperSize() throw (css::uno::RuntimeException)
     685                 :            : {
     686                 :          0 :     com::sun::star::awt::Size size;
     687                 :          0 :     Paper ePaper = PAPER_USER;
     688                 :            : 
     689                 :            :     try
     690                 :            :     {
     691 [ #  # ][ #  # ]:          0 :         uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( "Size"));
     692         [ #  # ]:          0 :         aValue >>= size;
     693 [ #  # ][ #  # ]:          0 :         ePaper = SvxPaperInfo::GetSvxPaper( Size(size.Width, size.Height), MAP_100TH_MM, true);
     694                 :            :     }
     695         [ #  # ]:          0 :     catch( uno::Exception& )
     696                 :            :     {
     697                 :            :     }
     698                 :            : 
     699                 :          0 :     return PaperSizeOOoToExcel(ePaper);
     700                 :            : }
     701                 :            : 
     702                 :          0 : Paper PaperSizeExcelToOOo( sal_Int32 xlPaper)
     703                 :            : {
     704                 :          0 :     Paper ePaper = PAPER_USER;
     705                 :            : 
     706         [ #  # ]:          0 :     for (int i = 0; i < nMapSize; i++)
     707                 :            :     {
     708         [ #  # ]:          0 :         if (xlPaper == paperSizeMappings[i].xlPaper)
     709                 :            :         {
     710                 :          0 :             ePaper = paperSizeMappings[i].ePaper;
     711                 :          0 :             break;
     712                 :            :         }
     713                 :            :     }
     714                 :            : 
     715                 :          0 :     return ePaper;
     716                 :            : }
     717                 :          0 : void SAL_CALL ScVbaPageSetup::setPaperSize( sal_Int32 paperSize) throw (css::uno::RuntimeException)
     718                 :            : {
     719                 :          0 :     Paper ePaper = PaperSizeExcelToOOo( paperSize );
     720                 :            : 
     721                 :            :     try
     722                 :            :     {
     723         [ #  # ]:          0 :         Size size1 = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM );
     724                 :          0 :         com::sun::star::awt::Size size(size1.Width(), size1.Height());
     725 [ #  # ][ #  # ]:          0 :         mxPageProps->setPropertyValue( rtl::OUString( "Size"), uno::makeAny( size ));
         [ #  # ][ #  # ]
     726                 :            :     }
     727                 :          0 :     catch( uno::Exception& )
     728                 :            :     {
     729                 :            :     }
     730                 :          0 : }
     731                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10