merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / vba / vbapagebreak.cxx
blob25b458745908d436da911dd872da2cc5fb8efa86
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile$
10 * $Revision$
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "vbapagebreak.hxx"
31 #include "vbarange.hxx"
32 #include <ooo/vba/excel/XlPageBreak.hpp>
33 using namespace ::com::sun::star;
34 using namespace ::ooo::vba;
36 template< typename Ifc1 >
37 ScVbaPageBreak<Ifc1>::ScVbaPageBreak( const uno::Reference< XHelperInterface >& xParent,
38 const uno::Reference< uno::XComponentContext >& xContext,
39 uno::Reference< beans::XPropertySet >& xProps,
40 sheet::TablePageBreakData aTablePageBreakData) throw (uno::RuntimeException):
41 ScVbaPageBreak_BASE( xParent, xContext ),
42 mxRowColPropertySet( xProps ),
43 maTablePageBreakData( aTablePageBreakData )
47 template< typename Ifc1 >
48 sal_Int32 ScVbaPageBreak<Ifc1>::getType() throw (uno::RuntimeException)
50 uno::Any aValue = mxRowColPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )));
51 sal_Bool hasPageBreak = sal_False;
52 aValue >>= hasPageBreak;
54 if( !hasPageBreak )
55 return excel::XlPageBreak::xlPageBreakNone;
57 if( maTablePageBreakData.ManualBreak )
58 return excel::XlPageBreak::xlPageBreakManual;
60 return excel::XlPageBreak::xlPageBreakAutomatic;
63 template< typename Ifc1 >
64 void ScVbaPageBreak<Ifc1>::setType(sal_Int32 type) throw (uno::RuntimeException)
66 if( (type != excel::XlPageBreak::xlPageBreakNone) &&
67 (type != excel::XlPageBreak::xlPageBreakManual) &&
68 (type != excel::XlPageBreak::xlPageBreakAutomatic) )
70 DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
73 if( type == excel::XlPageBreak::xlPageBreakNone )
75 mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False));
76 return;
79 mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_True));
80 if( type == excel::XlPageBreak::xlPageBreakManual )
81 maTablePageBreakData.ManualBreak = sal_True;
82 else
83 maTablePageBreakData.ManualBreak = sal_False;
86 template< typename Ifc1 >
87 void ScVbaPageBreak<Ifc1>::Delete() throw ( script::BasicErrorException, uno::RuntimeException)
89 mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False));
92 template< typename Ifc1 >
93 uno::Reference< excel::XRange> ScVbaPageBreak<Ifc1>::Location() throw ( script::BasicErrorException, uno::RuntimeException)
95 uno::Reference< table::XCellRange > xRange( mxRowColPropertySet, uno::UNO_QUERY_THROW );
96 return new ScVbaRange( ScVbaPageBreak_BASE::getParent(), ScVbaPageBreak_BASE::mxContext, xRange);
99 template< typename Ifc1 >
100 rtl::OUString&
101 ScVbaPageBreak<Ifc1>::getServiceImplName()
103 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPageBreak") );
104 return sImplName;
107 template< typename Ifc1 >
108 uno::Sequence< rtl::OUString >
109 ScVbaPageBreak<Ifc1>::getServiceNames()
111 static uno::Sequence< rtl::OUString > aServiceNames;
112 if ( aServiceNames.getLength() == 0 )
114 aServiceNames.realloc( 1 );
115 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PageBreak" ) );
117 return aServiceNames;
120 template class ScVbaPageBreak< excel::XHPageBreak >;
122 /* class ScVbaHPageBreak */
123 rtl::OUString&
124 ScVbaHPageBreak::getServiceImplName()
126 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaHPageBreak") );
127 return sImplName;
130 uno::Sequence< rtl::OUString >
131 ScVbaHPageBreak::getServiceNames()
133 static uno::Sequence< rtl::OUString > aServiceNames;
134 if ( aServiceNames.getLength() == 0 )
136 aServiceNames.realloc( 1 );
137 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.HPageBreak" ) );
139 return aServiceNames;
142 template class ScVbaPageBreak< excel::XVPageBreak >;
144 /* class ScVbaVPageBreak */
145 ScVbaVPageBreak::ScVbaVPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent,
146 const css::uno::Reference< css::uno::XComponentContext >& xContext,
147 css::uno::Reference< css::beans::XPropertySet >& xProps,
148 css::sheet::TablePageBreakData aTablePageBreakData ) throw ( css::uno::RuntimeException )
149 : ScVbaVPageBreak_BASE( xParent, xContext, xProps, aTablePageBreakData )
153 ScVbaVPageBreak::~ScVbaVPageBreak()
157 rtl::OUString&
158 ScVbaVPageBreak::getServiceImplName()
160 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaVPageBreak") );
161 return sImplName;
164 uno::Sequence< rtl::OUString >
165 ScVbaVPageBreak::getServiceNames()
167 static uno::Sequence< rtl::OUString > aServiceNames;
168 if ( aServiceNames.getLength() == 0 )
170 aServiceNames.realloc( 1 );
171 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.VPageBreak" ) );
173 return aServiceNames;