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