1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "vbapagebreak.hxx"
20 #include "vbarange.hxx"
21 #include <basic/sberrors.hxx>
22 #include <ooo/vba/excel/XlPageBreak.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/table/XCellRange.hpp>
27 using namespace ::com::sun::star
;
28 using namespace ::ooo::vba
;
30 template< typename
... Ifc
>
31 ScVbaPageBreak
< Ifc
... >::ScVbaPageBreak( const uno::Reference
< XHelperInterface
>& xParent
,
32 const uno::Reference
< uno::XComponentContext
>& xContext
,
33 uno::Reference
< beans::XPropertySet
> xProps
,
34 sheet::TablePageBreakData aTablePageBreakData
):
35 ScVbaPageBreak_BASE( xParent
, xContext
),
36 mxRowColPropertySet(std::move( xProps
)),
37 maTablePageBreakData( aTablePageBreakData
)
41 template< typename
... Ifc
>
42 sal_Int32 ScVbaPageBreak
< Ifc
... >::getType()
44 uno::Any aValue
= mxRowColPropertySet
->getPropertyValue(u
"IsStartOfNewPage"_ustr
);
45 bool hasPageBreak
= false;
46 aValue
>>= hasPageBreak
;
49 return excel::XlPageBreak::xlPageBreakNone
;
51 if( maTablePageBreakData
.ManualBreak
)
52 return excel::XlPageBreak::xlPageBreakManual
;
54 return excel::XlPageBreak::xlPageBreakAutomatic
;
57 template< typename
... Ifc
>
58 void ScVbaPageBreak
< Ifc
... >::setType(sal_Int32 type
)
60 if( (type
!= excel::XlPageBreak::xlPageBreakNone
) &&
61 (type
!= excel::XlPageBreak::xlPageBreakManual
) &&
62 (type
!= excel::XlPageBreak::xlPageBreakAutomatic
) )
64 DebugHelper::runtimeexception(ERRCODE_BASIC_BAD_PARAMETER
);
67 if( type
== excel::XlPageBreak::xlPageBreakNone
)
69 mxRowColPropertySet
->setPropertyValue(u
"IsStartOfNewPage"_ustr
, uno::Any(false));
73 mxRowColPropertySet
->setPropertyValue(u
"IsStartOfNewPage"_ustr
, uno::Any(true));
74 if( type
== excel::XlPageBreak::xlPageBreakManual
)
75 maTablePageBreakData
.ManualBreak
= true;
77 maTablePageBreakData
.ManualBreak
= false;
80 template< typename
... Ifc
>
81 void ScVbaPageBreak
< Ifc
... >::Delete()
83 mxRowColPropertySet
->setPropertyValue(u
"IsStartOfNewPage"_ustr
, uno::Any(false));
86 template< typename
... Ifc
>
87 uno::Reference
< excel::XRange
> ScVbaPageBreak
< Ifc
... >::Location()
89 uno::Reference
< table::XCellRange
> xRange( mxRowColPropertySet
, uno::UNO_QUERY_THROW
);
90 return new ScVbaRange( ScVbaPageBreak_BASE::getParent(), ScVbaPageBreak_BASE::mxContext
, xRange
);
93 template class ScVbaPageBreak
< excel::XHPageBreak
>;
95 /* class ScVbaHPageBreak */
97 ScVbaHPageBreak::getServiceImplName()
99 return u
"ScVbaHPageBreak"_ustr
;
102 uno::Sequence
< OUString
>
103 ScVbaHPageBreak::getServiceNames()
105 static uno::Sequence
< OUString
> const aServiceNames
107 u
"ooo.vba.excel.HPageBreak"_ustr
109 return aServiceNames
;
112 template class ScVbaPageBreak
< excel::XVPageBreak
>;
114 /* class ScVbaVPageBreak */
115 ScVbaVPageBreak::ScVbaVPageBreak( const css::uno::Reference
< ov::XHelperInterface
>& xParent
,
116 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
117 const css::uno::Reference
< css::beans::XPropertySet
>& xProps
,
118 css::sheet::TablePageBreakData aTablePageBreakData
)
119 : ScVbaVPageBreak_BASE( xParent
, xContext
, xProps
, aTablePageBreakData
)
123 ScVbaVPageBreak::~ScVbaVPageBreak()
128 ScVbaVPageBreak::getServiceImplName()
130 return u
"ScVbaVPageBreak"_ustr
;
133 uno::Sequence
< OUString
>
134 ScVbaVPageBreak::getServiceNames()
136 static uno::Sequence
< OUString
> const aServiceNames
138 u
"ooo.vba.excel.VPageBreak"_ustr
140 return aServiceNames
;
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */