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