bump product version to 6.3.0.0.beta1
[LibreOffice.git] / reportdesign / source / ui / dlg / PageNumber.cxx
blobda9faa591aae85a520333bc59433d89088de4c22
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <PageNumber.hxx>
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <rptui_slotid.hrc>
22 #include <RptDef.hxx>
23 #include <vcl/settings.hxx>
25 #include <UITools.hxx>
26 #include <strings.hxx>
27 #include <ReportController.hxx>
28 #include <comphelper/propertysequence.hxx>
29 #include <algorithm>
31 namespace rptui
33 using namespace ::com::sun::star;
34 using namespace ::comphelper;
37 // class OPageNumberDialog
39 OPageNumberDialog::OPageNumberDialog(weld::Window* pParent,
40 const uno::Reference< report::XReportDefinition >& _xHoldAlive,
41 OReportController* _pController)
42 : GenericDialogController(pParent, "modules/dbreport/ui/pagenumberdialog.ui", "PageNumberDialog")
43 , m_pController(_pController)
44 , m_xHoldAlive(_xHoldAlive)
45 , m_xPageN(m_xBuilder->weld_radio_button("pagen"))
46 , m_xPageNofM(m_xBuilder->weld_radio_button("pagenofm"))
47 , m_xTopPage(m_xBuilder->weld_radio_button("toppage"))
48 , m_xBottomPage(m_xBuilder->weld_radio_button("bottompage"))
49 , m_xAlignmentLst(m_xBuilder->weld_combo_box("alignment"))
50 , m_xShowNumberOnFirstPage(m_xBuilder->weld_check_button("shownumberonfirstpage"))
52 m_xShowNumberOnFirstPage->hide();
55 OPageNumberDialog::~OPageNumberDialog()
59 short OPageNumberDialog::run()
61 short nRet = GenericDialogController::run();
62 if (nRet == RET_OK)
64 try
66 sal_Int32 nControlMaxSize = 3000;
67 sal_Int32 nPosX = 0;
68 sal_Int32 nPos2X = 0;
69 awt::Size aRptSize = getStyleProperty<awt::Size>(m_xHoldAlive,PROPERTY_PAPERSIZE);
70 switch (m_xAlignmentLst->get_active())
72 case 0: // left
73 nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
74 break;
75 case 1: // middle
76 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;
77 break;
78 case 2: // right
79 nPosX = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
80 break;
81 case 3: // inner
82 case 4: // outer
83 nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
84 nPos2X = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
85 break;
86 default:
87 break;
89 if (m_xAlignmentLst->get_active() > 2)
90 nPosX = nPos2X;
92 uno::Sequence<beans::PropertyValue> aValues( comphelper::InitPropertySequence({
93 { PROPERTY_POSITION, uno::Any(awt::Point(nPosX,0)) },
94 { PROPERTY_PAGEHEADERON, uno::Any(m_xTopPage->get_active()) },
95 { PROPERTY_STATE, uno::Any(m_xPageNofM->get_active()) }
96 }));
98 m_pController->executeChecked(SID_INSERT_FLD_PGNUMBER,aValues);
100 catch(uno::Exception&)
104 return nRet;
107 } // rptui
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */