2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2009-02-13 13:03:24 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2009-02-13 13:03:24 +00:00
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#include "vbapagesetup.hxx"
|
|
|
|
#include "cellsuno.hxx"
|
|
|
|
#include "convuno.hxx"
|
|
|
|
#include "rangelst.hxx"
|
2009-09-18 15:24:22 +00:00
|
|
|
#include "excelvbahelper.hxx"
|
2009-02-13 13:03:24 +00:00
|
|
|
#include <com/sun/star/sheet/XPrintAreas.hpp>
|
|
|
|
#include <com/sun/star/sheet/XHeaderFooterContent.hpp>
|
|
|
|
#include <com/sun/star/text/XText.hpp>
|
|
|
|
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#include <ooo/vba/excel/XlPageOrientation.hpp>
|
|
|
|
#include <ooo/vba/excel/XlOrder.hpp>
|
|
|
|
#include <ooo/vba/excel/Constants.hpp>
|
2012-03-08 00:40:31 +00:00
|
|
|
#include <i18nutil/paper.hxx>
|
2010-10-06 10:15:43 +01:00
|
|
|
#include <editeng/paperinf.hxx>
|
|
|
|
#include <ooo/vba/excel/XlPaperSize.hpp>
|
2010-10-16 20:56:56 +01:00
|
|
|
#include <sal/macros.h>
|
2009-02-13 13:03:24 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::ooo::vba;
|
|
|
|
|
|
|
|
#define ZOOM_IN 10
|
|
|
|
#define ZOOM_MAX 400
|
|
|
|
|
|
|
|
bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, ScRange& refRange, ScRangeList& aCellRanges, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException );
|
|
|
|
|
|
|
|
ScVbaPageSetup::ScVbaPageSetup(const uno::Reference< XHelperInterface >& xParent,
|
|
|
|
const uno::Reference< uno::XComponentContext >& xContext,
|
|
|
|
const uno::Reference< sheet::XSpreadsheet >& xSheet,
|
|
|
|
const uno::Reference< frame::XModel >& xModel) throw (uno::RuntimeException):
|
2009-09-18 15:24:22 +00:00
|
|
|
ScVbaPageSetup_BASE( xParent, xContext ), mxSheet( xSheet )
|
2009-02-13 13:03:24 +00:00
|
|
|
{
|
|
|
|
// query for current page style
|
2009-09-18 15:24:22 +00:00
|
|
|
mxModel.set( xModel, uno::UNO_QUERY_THROW );
|
2009-02-13 13:03:24 +00:00
|
|
|
uno::Reference< beans::XPropertySet > xSheetProps( mxSheet, uno::UNO_QUERY_THROW );
|
|
|
|
uno::Any aValue = xSheetProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageStyle" )));
|
|
|
|
rtl::OUString aStyleName;
|
|
|
|
aValue >>= aStyleName;
|
|
|
|
|
|
|
|
uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSup( mxModel, uno::UNO_QUERY_THROW );
|
|
|
|
uno::Reference< container::XNameAccess > xStyleFamilies = xStyleFamiliesSup->getStyleFamilies();
|
|
|
|
uno::Reference< container::XNameAccess > xPageStyle( xStyleFamilies->getByName(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyles"))), uno::UNO_QUERY_THROW );
|
|
|
|
mxPageProps.set( xPageStyle->getByName(aStyleName), uno::UNO_QUERY_THROW );
|
2009-09-18 15:24:22 +00:00
|
|
|
mnOrientLandscape = excel::XlPageOrientation::xlLandscape;
|
|
|
|
mnOrientPortrait = excel::XlPageOrientation::xlPortrait;
|
2009-02-13 13:03:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
String aPrintArea;
|
|
|
|
uno::Reference< sheet::XPrintAreas > xPrintAreas( mxSheet, uno::UNO_QUERY_THROW );
|
|
|
|
uno::Sequence< table::CellRangeAddress > aSeq = xPrintAreas->getPrintAreas();
|
|
|
|
sal_Int32 nCount = aSeq.getLength();
|
|
|
|
if( nCount )
|
|
|
|
{
|
|
|
|
ScAddress::Details aDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nFlags = SCA_VALID;
|
2009-02-13 13:03:24 +00:00
|
|
|
nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE );
|
|
|
|
ScRangeList aRangeList;
|
|
|
|
for( sal_Int32 i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
ScRange aRange;
|
|
|
|
ScUnoConversion::FillScRange( aRange, aSeq[i] );
|
|
|
|
aRangeList.Append( aRange );
|
|
|
|
}
|
2009-09-18 15:24:22 +00:00
|
|
|
ScDocument* pDoc = excel::getDocShell( mxModel )->GetDocument();
|
2009-02-13 13:03:24 +00:00
|
|
|
aRangeList.Format( aPrintArea, nFlags, pDoc, formula::FormulaGrammar::CONV_XL_A1, ',' );
|
|
|
|
}
|
|
|
|
|
|
|
|
return aPrintArea;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setPrintArea( const rtl::OUString& rAreas ) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
uno::Reference< sheet::XPrintAreas > xPrintAreas( mxSheet, uno::UNO_QUERY_THROW );
|
2012-01-06 14:22:10 -02:00
|
|
|
if( rAreas.isEmpty() ||
|
2010-11-02 09:18:15 +01:00
|
|
|
rAreas.equalsIgnoreAsciiCase ( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FALSE")) ) )
|
2009-02-13 13:03:24 +00:00
|
|
|
{
|
|
|
|
// print the whole sheet
|
|
|
|
uno::Sequence< table::CellRangeAddress > aSeq;
|
|
|
|
xPrintAreas->setPrintAreas( aSeq );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ScRangeList aCellRanges;
|
|
|
|
ScRange aRange;
|
2009-09-18 15:24:22 +00:00
|
|
|
if( getScRangeListForAddress( rAreas, excel::getDocShell( mxModel ) , aRange, aCellRanges ) )
|
2009-02-13 13:03:24 +00:00
|
|
|
{
|
2010-12-08 22:38:24 -08:00
|
|
|
uno::Sequence< table::CellRangeAddress > aSeq( aCellRanges.size() );
|
|
|
|
for ( size_t i = 0, nRanges = aCellRanges.size(); i < nRanges; ++i )
|
2009-02-13 13:03:24 +00:00
|
|
|
{
|
2010-12-10 13:45:31 -05:00
|
|
|
ScRange* pRange = aCellRanges[ i ];
|
2009-02-13 13:03:24 +00:00
|
|
|
table::CellRangeAddress aRangeAddress;
|
|
|
|
ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
|
|
|
|
aSeq[ i++ ] = aRangeAddress;
|
|
|
|
}
|
|
|
|
xPrintAreas->setPrintAreas( aSeq );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double SAL_CALL ScVbaPageSetup::getHeaderMargin() throw (css::uno::RuntimeException)
|
|
|
|
{
|
2009-09-18 15:24:22 +00:00
|
|
|
return VbaPageSetupBase::getHeaderMargin();
|
2009-02-13 13:03:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setHeaderMargin( double margin ) throw (css::uno::RuntimeException)
|
|
|
|
{
|
2009-09-18 15:24:22 +00:00
|
|
|
VbaPageSetupBase::setHeaderMargin( margin );
|
2009-02-13 13:03:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double SAL_CALL ScVbaPageSetup::getFooterMargin() throw (css::uno::RuntimeException)
|
|
|
|
{
|
2009-09-18 15:24:22 +00:00
|
|
|
return VbaPageSetupBase::getFooterMargin();
|
2009-02-13 13:03:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setFooterMargin( double margin ) throw (css::uno::RuntimeException)
|
|
|
|
{
|
2009-09-18 15:24:22 +00:00
|
|
|
VbaPageSetupBase::setFooterMargin( margin );
|
2009-02-13 13:03:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesTall() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesY")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setFitToPagesTall( const uno::Any& fitToPagesTall) throw (css::uno::RuntimeException)
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 scaleToPageY = 0;
|
2009-02-13 13:03:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
sal_Bool aValue;
|
|
|
|
if( fitToPagesTall.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesTall >>= aValue))
|
|
|
|
{
|
|
|
|
fitToPagesTall >>= scaleToPageY;
|
|
|
|
}
|
|
|
|
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesY")), uno::makeAny( scaleToPageY ));
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesWide() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesX")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setFitToPagesWide( const uno::Any& fitToPagesWide) throw (css::uno::RuntimeException)
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 scaleToPageX = 0;
|
2009-02-13 13:03:24 +00:00
|
|
|
try
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool aValue = false;
|
2009-02-13 13:03:24 +00:00
|
|
|
if( fitToPagesWide.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesWide >>= aValue))
|
|
|
|
{
|
|
|
|
fitToPagesWide >>= scaleToPageX;
|
|
|
|
}
|
|
|
|
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesX")), uno::makeAny( scaleToPageX ));
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any SAL_CALL ScVbaPageSetup::getZoom() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageScale")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::RuntimeException)
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 pageScale = 0;
|
2009-02-13 13:03:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if( zoom.getValueTypeClass() == uno::TypeClass_BOOLEAN )
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool aValue = false;
|
2009-02-13 13:03:24 +00:00
|
|
|
zoom >>= aValue;
|
|
|
|
if( aValue )
|
|
|
|
{
|
|
|
|
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
zoom >>= pageScale;
|
|
|
|
if(( pageScale < ZOOM_IN )||( pageScale > ZOOM_MAX ))
|
|
|
|
{
|
|
|
|
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// these only exist in S08
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nScale = 0;
|
2009-02-13 13:03:24 +00:00
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPages")), uno::makeAny( nScale ));
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesX")), uno::makeAny( nScale ));
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesY")), uno::makeAny( nScale ));
|
|
|
|
}
|
|
|
|
catch( beans::UnknownPropertyException& )
|
|
|
|
{
|
|
|
|
if( pageScale == 0 )
|
|
|
|
{
|
|
|
|
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageScale")), uno::makeAny( pageScale ));
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString SAL_CALL ScVbaPageSetup::getLeftHeader() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
rtl::OUString leftHeader;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xHeaderContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
|
|
|
|
leftHeader = xText->getString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return leftHeader;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setLeftHeader( const rtl::OUString& leftHeader) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xHeaderContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
|
|
|
|
xText->setString( leftHeader );
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent")), uno::makeAny(xHeaderContent) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString SAL_CALL ScVbaPageSetup::getCenterHeader() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
rtl::OUString centerHeader;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xHeaderContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
|
|
|
|
centerHeader = xText->getString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return centerHeader;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setCenterHeader( const rtl::OUString& centerHeader) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xHeaderContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
|
|
|
|
xText->setString( centerHeader );
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent")), uno::makeAny(xHeaderContent) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString SAL_CALL ScVbaPageSetup::getRightHeader() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
rtl::OUString rightHeader;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xHeaderContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xHeaderContent->getRightText();
|
|
|
|
rightHeader = xText->getString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return rightHeader;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setRightHeader( const rtl::OUString& rightHeader) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xHeaderContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xHeaderContent->getRightText();
|
|
|
|
xText->setString( rightHeader );
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent")), uno::makeAny(xHeaderContent) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString SAL_CALL ScVbaPageSetup::getLeftFooter() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
rtl::OUString leftFooter;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xFooterContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xFooterContent->getLeftText();
|
|
|
|
leftFooter = xText->getString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return leftFooter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setLeftFooter( const rtl::OUString& leftFooter) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xFooterContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xFooterContent->getLeftText();
|
|
|
|
xText->setString( leftFooter );
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent")), uno::makeAny(xFooterContent) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString SAL_CALL ScVbaPageSetup::getCenterFooter() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
rtl::OUString centerFooter;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xFooterContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xFooterContent->getCenterText();
|
|
|
|
centerFooter = xText->getString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return centerFooter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setCenterFooter( const rtl::OUString& centerFooter) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xFooterContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xFooterContent->getCenterText();
|
|
|
|
xText->setString( centerFooter );
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent")), uno::makeAny(xFooterContent) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString SAL_CALL ScVbaPageSetup::getRightFooter() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
rtl::OUString rightFooter;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xFooterContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xFooterContent->getRightText();
|
|
|
|
rightFooter = xText->getString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return rightFooter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setRightFooter( const rtl::OUString& rightFooter) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
|
|
|
|
if( xFooterContent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< text::XText > xText = xFooterContent->getRightText();
|
|
|
|
xText->setString( rightFooter );
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent")), uno::makeAny(xFooterContent) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL ScVbaPageSetup::getOrder() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
sal_Int32 order = excel::XlOrder::xlDownThenOver;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintDownFirst")));
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool bPrintDownFirst = false;
|
2009-02-13 13:03:24 +00:00
|
|
|
aValue >>= bPrintDownFirst;
|
|
|
|
if( !bPrintDownFirst )
|
|
|
|
order = excel::XlOrder::xlOverThenDown;
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setOrder( sal_Int32 order) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
sal_Bool bOrder = sal_True;
|
|
|
|
switch( order )
|
|
|
|
{
|
|
|
|
case excel::XlOrder::xlDownThenOver:
|
|
|
|
break;
|
|
|
|
case excel::XlOrder::xlOverThenDown:
|
2011-03-10 16:55:21 -05:00
|
|
|
bOrder = false;
|
2009-02-13 13:03:24 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintDownFirst")), uno::makeAny( bOrder ));
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL ScVbaPageSetup::getFirstPageNumber() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
sal_Int16 number = 0;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstPageNumber")));
|
|
|
|
aValue >>= number;
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if( number ==0 )
|
|
|
|
{
|
|
|
|
number = excel::Constants::xlAutomatic;
|
|
|
|
}
|
|
|
|
|
|
|
|
return number;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setFirstPageNumber( sal_Int32 firstPageNumber) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
if( firstPageNumber < 0 )
|
|
|
|
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
|
|
|
|
if( firstPageNumber == excel::Constants::xlAutomatic )
|
|
|
|
firstPageNumber = 0;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue;
|
|
|
|
aValue <<= (sal_Int16)firstPageNumber;
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstPageNumber")), aValue );
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL ScVbaPageSetup::getCenterVertically() throw (css::uno::RuntimeException)
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool centerVertically = false;
|
2009-02-13 13:03:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterVertically")));
|
|
|
|
aValue >>= centerVertically;
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return centerVertically;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setCenterVertically( sal_Bool centerVertically) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterVertically")), uno::makeAny( centerVertically ));
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL ScVbaPageSetup::getCenterHorizontally() throw (css::uno::RuntimeException)
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool centerHorizontally = false;
|
2009-02-13 13:03:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterHorizontally")));
|
|
|
|
aValue >>= centerHorizontally;
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return centerHorizontally;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setCenterHorizontally( sal_Bool centerHorizontally) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterHorizontally")), uno::makeAny( centerHorizontally ));
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL ScVbaPageSetup::getPrintHeadings() throw (css::uno::RuntimeException)
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool printHeadings = false;
|
2009-02-13 13:03:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintHeaders")));
|
|
|
|
aValue >>= printHeadings;
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return printHeadings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ScVbaPageSetup::setPrintHeadings( sal_Bool printHeadings) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintHeaders")), uno::makeAny( printHeadings ));
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 14:00:06 +00:00
|
|
|
rtl::OUString
|
2009-02-13 13:03:24 +00:00
|
|
|
ScVbaPageSetup::getServiceImplName()
|
|
|
|
{
|
2012-03-24 14:00:06 +00:00
|
|
|
return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaPageSetup"));
|
2009-02-13 13:03:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< rtl::OUString >
|
|
|
|
ScVbaPageSetup::getServiceNames()
|
|
|
|
{
|
|
|
|
static uno::Sequence< rtl::OUString > aServiceNames;
|
|
|
|
if ( aServiceNames.getLength() == 0 )
|
|
|
|
{
|
|
|
|
aServiceNames.realloc( 1 );
|
|
|
|
aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PageSetup" ) );
|
|
|
|
}
|
|
|
|
return aServiceNames;
|
|
|
|
}
|
2010-10-06 10:15:43 +01:00
|
|
|
|
|
|
|
struct PaperSizeMap
|
|
|
|
{
|
|
|
|
Paper ePaper;
|
|
|
|
sal_Int32 xlPaper;
|
|
|
|
};
|
|
|
|
|
|
|
|
static PaperSizeMap paperSizeMappings[] =
|
|
|
|
{
|
|
|
|
{ PAPER_A3, ooo::vba::excel::XlPaperSize::xlPaperA3 },
|
|
|
|
{ PAPER_A4, ooo::vba::excel::XlPaperSize::xlPaperA4 },
|
|
|
|
{ PAPER_A5, ooo::vba::excel::XlPaperSize::xlPaperA5 },
|
|
|
|
{ PAPER_B4_ISO, ooo::vba::excel::XlPaperSize::xlPaperB4 },
|
|
|
|
{ PAPER_B5_ISO, ooo::vba::excel::XlPaperSize::xlPaperB5 },
|
|
|
|
{ PAPER_LETTER, ooo::vba::excel::XlPaperSize::xlPaperLetter },
|
|
|
|
{ PAPER_LEGAL, ooo::vba::excel::XlPaperSize::xlPaperLegal },
|
|
|
|
{ PAPER_TABLOID, ooo::vba::excel::XlPaperSize::xlPaperTabloid },
|
|
|
|
{ PAPER_USER, ooo::vba::excel::XlPaperSize::xlPaperUser },
|
|
|
|
{ PAPER_B6_ISO, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeB6 },
|
|
|
|
{ PAPER_ENV_C4, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC4 },
|
|
|
|
{ PAPER_ENV_C5, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC5 },
|
|
|
|
{ PAPER_ENV_C6, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC6 },
|
|
|
|
{ PAPER_ENV_C65, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC65 },
|
|
|
|
{ PAPER_ENV_DL, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeDL },
|
|
|
|
{ PAPER_C, ooo::vba::excel::XlPaperSize::xlPaperCsheet },
|
|
|
|
{ PAPER_D, ooo::vba::excel::XlPaperSize::xlPaperDsheet },
|
|
|
|
{ PAPER_E, ooo::vba::excel::XlPaperSize::xlPaperEsheet },
|
|
|
|
{ PAPER_ENV_MONARCH, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeMonarch },
|
|
|
|
{ PAPER_ENV_PERSONAL, ooo::vba::excel::XlPaperSize::xlPaperEnvelopePersonal },
|
|
|
|
{ PAPER_ENV_9, ooo::vba::excel::XlPaperSize::xlPaperEnvelope9 },
|
|
|
|
{ PAPER_ENV_10, ooo::vba::excel::XlPaperSize::xlPaperEnvelope10 },
|
|
|
|
{ PAPER_ENV_11, ooo::vba::excel::XlPaperSize::xlPaperEnvelope11 },
|
|
|
|
{ PAPER_ENV_12, ooo::vba::excel::XlPaperSize::xlPaperEnvelope12 }
|
|
|
|
};
|
|
|
|
|
2010-10-16 20:56:56 +01:00
|
|
|
static const int nMapSize = SAL_N_ELEMENTS(paperSizeMappings);
|
2010-10-06 10:15:43 +01:00
|
|
|
|
|
|
|
sal_Int32 PaperSizeOOoToExcel(Paper ePaper)
|
|
|
|
{
|
|
|
|
sal_Int32 nPaperSize = ooo::vba::excel::XlPaperSize::xlPaperUser;
|
|
|
|
|
|
|
|
for (int i = 0; i < nMapSize; i++)
|
|
|
|
{
|
|
|
|
if (ePaper == paperSizeMappings[i].ePaper)
|
|
|
|
{
|
|
|
|
nPaperSize = paperSizeMappings[i].xlPaper;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nPaperSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL ScVbaPageSetup::getPaperSize() throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
com::sun::star::awt::Size size;
|
|
|
|
Paper ePaper = PAPER_USER;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Size")));
|
|
|
|
aValue >>= size;
|
2011-03-10 16:55:21 -05:00
|
|
|
ePaper = SvxPaperInfo::GetSvxPaper( Size(size.Width, size.Height), MAP_100TH_MM, true);
|
2010-10-06 10:15:43 +01:00
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return PaperSizeOOoToExcel(ePaper);
|
|
|
|
}
|
|
|
|
|
|
|
|
Paper PaperSizeExcelToOOo( sal_Int32 xlPaper)
|
|
|
|
{
|
|
|
|
Paper ePaper = PAPER_USER;
|
|
|
|
|
|
|
|
for (int i = 0; i < nMapSize; i++)
|
|
|
|
{
|
|
|
|
if (xlPaper == paperSizeMappings[i].xlPaper)
|
|
|
|
{
|
|
|
|
ePaper = paperSizeMappings[i].ePaper;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ePaper;
|
|
|
|
}
|
|
|
|
void SAL_CALL ScVbaPageSetup::setPaperSize( sal_Int32 paperSize) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
Paper ePaper = PaperSizeExcelToOOo( paperSize );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Size size1 = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM );
|
|
|
|
com::sun::star::awt::Size size(size1.Width(), size1.Height());
|
|
|
|
mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Size")), uno::makeAny( size ));
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|