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