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