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 
26 using namespace ::com::sun::star;
27 using namespace ::ooo::vba;
28 
29 template< typename... Ifc >
30 ScVbaPageBreak< Ifc... >::ScVbaPageBreak( const uno::Reference< XHelperInterface >& xParent,
31  const uno::Reference< uno::XComponentContext >& xContext,
32  const uno::Reference< beans::XPropertySet >& xProps,
33  sheet::TablePageBreakData aTablePageBreakData):
34  ScVbaPageBreak_BASE( xParent, xContext ),
35  mxRowColPropertySet( xProps ),
36  maTablePageBreakData( aTablePageBreakData )
37 {
38 }
39 
40 template< typename... Ifc >
42 {
43  uno::Any aValue = mxRowColPropertySet->getPropertyValue("IsStartOfNewPage");
44  bool hasPageBreak = 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... Ifc >
58 {
59  if( (type != excel::XlPageBreak::xlPageBreakNone) &&
60  (type != excel::XlPageBreak::xlPageBreakManual) &&
61  (type != excel::XlPageBreak::xlPageBreakAutomatic) )
62  {
63  DebugHelper::runtimeexception(ERRCODE_BASIC_BAD_PARAMETER);
64  }
65 
66  if( type == excel::XlPageBreak::xlPageBreakNone )
67  {
68  mxRowColPropertySet->setPropertyValue("IsStartOfNewPage", uno::makeAny(false));
69  return;
70  }
71 
72  mxRowColPropertySet->setPropertyValue("IsStartOfNewPage", uno::makeAny(true));
73  if( type == excel::XlPageBreak::xlPageBreakManual )
74  maTablePageBreakData.ManualBreak = true;
75  else
76  maTablePageBreakData.ManualBreak = false;
77 }
78 
79 template< typename... Ifc >
81 {
82  mxRowColPropertySet->setPropertyValue("IsStartOfNewPage", uno::makeAny(false));
83 }
84 
85 template< typename... Ifc >
86 uno::Reference< excel::XRange> ScVbaPageBreak< Ifc... >::Location()
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 
93 
94 /* class ScVbaHPageBreak */
95 OUString
97 {
98  return "ScVbaHPageBreak";
99 }
100 
101 uno::Sequence< OUString >
103 {
104  static uno::Sequence< OUString > const aServiceNames
105  {
106  "ooo.vba.excel.HPageBreak"
107  };
108  return aServiceNames;
109 }
110 
112 
113 /* class ScVbaVPageBreak */
114 ScVbaVPageBreak::ScVbaVPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent,
115  const css::uno::Reference< css::uno::XComponentContext >& xContext,
116  const css::uno::Reference< css::beans::XPropertySet >& xProps,
117  css::sheet::TablePageBreakData aTablePageBreakData )
118 : ScVbaVPageBreak_BASE( xParent, xContext, xProps, aTablePageBreakData )
119 {
120 }
121 
123 {
124 }
125 
126 OUString
128 {
129  return "ScVbaVPageBreak";
130 }
131 
132 uno::Sequence< OUString >
134 {
135  static uno::Sequence< OUString > const aServiceNames
136  {
137  "ooo.vba.excel.VPageBreak"
138  };
139  return aServiceNames;
140 }
141 
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString getServiceImplName() override
Sequence< OUString > aServiceNames
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual void SAL_CALL setType(sal_Int32 type) override
virtual OUString getServiceImplName() override
#define ERRCODE_BASIC_BAD_PARAMETER
virtual sal_Int32 SAL_CALL getType() 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 css::uno::Reference< ov::excel::XRange > SAL_CALL Location() override
virtual void SAL_CALL Delete() override
ScVbaPageBreak(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