LibreOffice Module reportdesign (master) 1
PageNumber.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 <PageNumber.hxx>
20#include <rptui_slotid.hrc>
21#include <RptDef.hxx>
22
23#include <strings.hxx>
24#include <ReportController.hxx>
26#include <utility>
27
28namespace rptui
29{
30using namespace ::com::sun::star;
31using namespace ::comphelper;
32
33
34
36 uno::Reference< report::XReportDefinition > _xHoldAlive,
37 OReportController* _pController)
38 : GenericDialogController(pParent, "modules/dbreport/ui/pagenumberdialog.ui", "PageNumberDialog")
39 , m_pController(_pController)
40 , m_xHoldAlive(std::move(_xHoldAlive))
41 , m_xPageNofM(m_xBuilder->weld_radio_button("pagenofm"))
42 , m_xTopPage(m_xBuilder->weld_radio_button("toppage"))
43 , m_xAlignmentLst(m_xBuilder->weld_combo_box("alignment"))
44 , m_xShowNumberOnFirstPage(m_xBuilder->weld_check_button("shownumberonfirstpage"))
45{
46 m_xShowNumberOnFirstPage->hide();
47}
48
49OPageNumberDialog::~OPageNumberDialog()
50{
51}
52
53short OPageNumberDialog::run()
54{
55 short nRet = GenericDialogController::run();
56 if (nRet == RET_OK)
57 {
58 try
59 {
60 sal_Int32 nControlMaxSize = 3000;
61 sal_Int32 nPosX = 0;
62 sal_Int32 nPos2X = 0;
63 awt::Size aRptSize = getStyleProperty<awt::Size>(m_xHoldAlive,PROPERTY_PAPERSIZE);
64 switch (m_xAlignmentLst->get_active())
65 {
66 case 0: // left
67 nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
68 break;
69 case 1: // middle
70 nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN) + (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN) - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize) / 2;
71 break;
72 case 2: // right
73 nPosX = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
74 break;
75 case 3: // inner
76 case 4: // outer
77 nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
78 nPos2X = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
79 break;
80 default:
81 break;
82 }
83 if (m_xAlignmentLst->get_active() > 2)
84 nPosX = nPos2X;
85
86 uno::Sequence<beans::PropertyValue> aValues( comphelper::InitPropertySequence({
87 { PROPERTY_POSITION, uno::Any(awt::Point(nPosX,0)) },
88 { PROPERTY_PAGEHEADERON, uno::Any(m_xTopPage->get_active()) },
89 { PROPERTY_STATE, uno::Any(m_xPageNofM->get_active()) }
90 }));
91
92 m_pController->executeChecked(SID_INSERT_FLD_PGNUMBER,aValues);
93 }
94 catch(uno::Exception&)
95 {
96 }
97 }
98 return nRet;
99}
100
101} // rptui
102
103
104/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OPageNumberDialog(const OPageNumberDialog &)=delete
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
constexpr OUStringLiteral PROPERTY_POSITION
Definition: strings.hxx:257
constexpr OUStringLiteral PROPERTY_PAGEHEADERON
Definition: strings.hxx:69
constexpr OUStringLiteral PROPERTY_RIGHTMARGIN
Definition: strings.hxx:103
constexpr OUStringLiteral PROPERTY_STATE
Definition: strings.hxx:112
constexpr OUStringLiteral PROPERTY_LEFTMARGIN
Definition: strings.hxx:102
constexpr OUStringLiteral PROPERTY_PAPERSIZE
Definition: strings.hxx:62
RET_OK