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