LibreOffice Module sc (master) 1
vbapagebreak.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
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>
25#include <utility>
26
27using namespace ::com::sun::star;
28using namespace ::ooo::vba;
29
30template< typename... Ifc >
31ScVbaPageBreak< 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 )
38{
39}
40
41template< typename... Ifc >
43{
44 uno::Any aValue = mxRowColPropertySet->getPropertyValue("IsStartOfNewPage");
45 bool hasPageBreak = false;
46 aValue >>= hasPageBreak;
47
48 if( !hasPageBreak )
49 return excel::XlPageBreak::xlPageBreakNone;
50
51 if( maTablePageBreakData.ManualBreak )
52 return excel::XlPageBreak::xlPageBreakManual;
53
54 return excel::XlPageBreak::xlPageBreakAutomatic;
55}
56
57template< typename... Ifc >
59{
60 if( (type != excel::XlPageBreak::xlPageBreakNone) &&
61 (type != excel::XlPageBreak::xlPageBreakManual) &&
62 (type != excel::XlPageBreak::xlPageBreakAutomatic) )
63 {
64 DebugHelper::runtimeexception(ERRCODE_BASIC_BAD_PARAMETER);
65 }
66
67 if( type == excel::XlPageBreak::xlPageBreakNone )
68 {
69 mxRowColPropertySet->setPropertyValue("IsStartOfNewPage", uno::Any(false));
70 return;
71 }
72
73 mxRowColPropertySet->setPropertyValue("IsStartOfNewPage", uno::Any(true));
74 if( type == excel::XlPageBreak::xlPageBreakManual )
75 maTablePageBreakData.ManualBreak = true;
76 else
77 maTablePageBreakData.ManualBreak = false;
78}
79
80template< typename... Ifc >
82{
83 mxRowColPropertySet->setPropertyValue("IsStartOfNewPage", uno::Any(false));
84}
85
86template< typename... Ifc >
87uno::Reference< excel::XRange> ScVbaPageBreak< Ifc... >::Location()
88{
89 uno::Reference< table::XCellRange > xRange( mxRowColPropertySet, uno::UNO_QUERY_THROW );
90 return new ScVbaRange( ScVbaPageBreak_BASE::getParent(), ScVbaPageBreak_BASE::mxContext, xRange);
91}
92
94
95/* class ScVbaHPageBreak */
96OUString
98{
99 return "ScVbaHPageBreak";
100}
101
102uno::Sequence< OUString >
104{
105 static uno::Sequence< OUString > const aServiceNames
106 {
107 "ooo.vba.excel.HPageBreak"
108 };
109 return aServiceNames;
110}
111
113
114/* class ScVbaVPageBreak */
115ScVbaVPageBreak::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 )
120{
121}
122
124{
125}
126
127OUString
129{
130 return "ScVbaVPageBreak";
131}
132
133uno::Sequence< OUString >
135{
136 static uno::Sequence< OUString > const aServiceNames
137 {
138 "ooo.vba.excel.VPageBreak"
139 };
140 return aServiceNames;
141}
142
143/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual OUString getServiceImplName() override
ScVbaPageBreak(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)
virtual sal_Int32 SAL_CALL getType() override
virtual void SAL_CALL Delete() override
virtual void SAL_CALL setType(sal_Int32 type) override
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Location() override
virtual css::uno::Sequence< OUString > getServiceNames() override
ScVbaVPageBreak(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::beans::XPropertySet > &xProps, css::sheet::TablePageBreakData aTablePageBreakData)
virtual ~ScVbaVPageBreak() override
virtual OUString getServiceImplName() override
Sequence< OUString > aServiceNames
#define ERRCODE_BASIC_BAD_PARAMETER
ResultType type