xref: /aoo41x/main/sc/source/ui/vba/vbapagebreak.cxx (revision cdf0e10c)
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 "vbapagebreak.hxx"
28 #include "vbarange.hxx"
29 #include <ooo/vba/excel/XlPageBreak.hpp>
30 using namespace ::com::sun::star;
31 using namespace ::ooo::vba;
32 
33 template< typename Ifc1 >
34 ScVbaPageBreak<Ifc1>::ScVbaPageBreak( const uno::Reference< XHelperInterface >& xParent,
35                     const uno::Reference< uno::XComponentContext >& xContext,
36             		uno::Reference< beans::XPropertySet >& xProps,
37                     sheet::TablePageBreakData aTablePageBreakData) throw (uno::RuntimeException):
38             ScVbaPageBreak_BASE( xParent, xContext ),
39             mxRowColPropertySet( xProps ),
40             maTablePageBreakData( aTablePageBreakData )
41 {
42 }
43 
44 template< typename Ifc1 >
45 sal_Int32 ScVbaPageBreak<Ifc1>::getType() throw (uno::RuntimeException)
46 {
47     uno::Any aValue = mxRowColPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )));
48     sal_Bool hasPageBreak = sal_False;
49     aValue >>= hasPageBreak;
50 
51     if( !hasPageBreak )
52         return excel::XlPageBreak::xlPageBreakNone;
53 
54     if( maTablePageBreakData.ManualBreak )
55         return excel::XlPageBreak::xlPageBreakManual;
56 
57     return excel::XlPageBreak::xlPageBreakAutomatic;
58 }
59 
60 template< typename Ifc1 >
61 void ScVbaPageBreak<Ifc1>::setType(sal_Int32 type) throw (uno::RuntimeException)
62 {
63     if( (type != excel::XlPageBreak::xlPageBreakNone) &&
64         (type != excel::XlPageBreak::xlPageBreakManual) &&
65         (type != excel::XlPageBreak::xlPageBreakAutomatic) )
66     {
67         DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
68     }
69 
70     if( type == excel::XlPageBreak::xlPageBreakNone )
71     {
72         mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False));
73         return;
74     }
75 
76     mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_True));
77     if( type == excel::XlPageBreak::xlPageBreakManual )
78         maTablePageBreakData.ManualBreak = sal_True;
79     else
80         maTablePageBreakData.ManualBreak = sal_False;
81 }
82 
83 template< typename Ifc1 >
84 void ScVbaPageBreak<Ifc1>::Delete() throw ( script::BasicErrorException, uno::RuntimeException)
85 {
86     mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False));
87 }
88 
89 template< typename Ifc1 >
90 uno::Reference< excel::XRange> ScVbaPageBreak<Ifc1>::Location() throw ( script::BasicErrorException, uno::RuntimeException)
91 {
92     uno::Reference< table::XCellRange > xRange( mxRowColPropertySet, uno::UNO_QUERY_THROW );
93     return new ScVbaRange( ScVbaPageBreak_BASE::getParent(), ScVbaPageBreak_BASE::mxContext, xRange);
94 }
95 
96 template< typename Ifc1 >
97 rtl::OUString&
98 ScVbaPageBreak<Ifc1>::getServiceImplName()
99 {
100 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPageBreak") );
101 	return sImplName;
102 }
103 
104 template< typename Ifc1 >
105 uno::Sequence< rtl::OUString >
106 ScVbaPageBreak<Ifc1>::getServiceNames()
107 {
108 	static uno::Sequence< rtl::OUString > aServiceNames;
109 	if ( aServiceNames.getLength() == 0 )
110 	{
111 		aServiceNames.realloc( 1 );
112 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PageBreak" ) );
113 	}
114 	return aServiceNames;
115 }
116 
117 template class ScVbaPageBreak< excel::XHPageBreak >;
118 
119 /* class ScVbaHPageBreak */
120 rtl::OUString&
121 ScVbaHPageBreak::getServiceImplName()
122 {
123 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaHPageBreak") );
124 	return sImplName;
125 }
126 
127 uno::Sequence< rtl::OUString >
128 ScVbaHPageBreak::getServiceNames()
129 {
130 	static uno::Sequence< rtl::OUString > aServiceNames;
131 	if ( aServiceNames.getLength() == 0 )
132 	{
133 		aServiceNames.realloc( 1 );
134 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.HPageBreak" ) );
135 	}
136 	return aServiceNames;
137 }
138 
139 template class ScVbaPageBreak< excel::XVPageBreak >;
140 
141 /* class ScVbaVPageBreak */
142 ScVbaVPageBreak::ScVbaVPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent,
143 								  const css::uno::Reference< css::uno::XComponentContext >& xContext,
144 								  css::uno::Reference< css::beans::XPropertySet >& xProps,
145 								  css::sheet::TablePageBreakData aTablePageBreakData ) throw ( css::uno::RuntimeException )
146 :   ScVbaVPageBreak_BASE( xParent, xContext, xProps, aTablePageBreakData )
147 {
148 }
149 
150 ScVbaVPageBreak::~ScVbaVPageBreak()
151 {
152 }
153 
154 rtl::OUString&
155 ScVbaVPageBreak::getServiceImplName()
156 {
157 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaVPageBreak") );
158 	return sImplName;
159 }
160 
161 uno::Sequence< rtl::OUString >
162 ScVbaVPageBreak::getServiceNames()
163 {
164 	static uno::Sequence< rtl::OUString > aServiceNames;
165 	if ( aServiceNames.getLength() == 0 )
166 	{
167 		aServiceNames.realloc( 1 );
168 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.VPageBreak" ) );
169 	}
170 	return aServiceNames;
171 }
172 
173