1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
23 #include <vcl/settings.hxx>
25 #include <UITools.hxx>
26 #include <strings.hxx>
27 #include <ReportController.hxx>
28 #include <comphelper/propertysequence.hxx>
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();
66 sal_Int32 nControlMaxSize
= 3000;
69 awt::Size aRptSize
= getStyleProperty
<awt::Size
>(m_xHoldAlive
,PROPERTY_PAPERSIZE
);
70 switch (m_xAlignmentLst
->get_active())
73 nPosX
= getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_LEFTMARGIN
);
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;
79 nPosX
= (aRptSize
.Width
- getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_RIGHTMARGIN
) - nControlMaxSize
);
83 nPosX
= getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_LEFTMARGIN
);
84 nPos2X
= (aRptSize
.Width
- getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_RIGHTMARGIN
) - nControlMaxSize
);
89 if (m_xAlignmentLst
->get_active() > 2)
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()) }
98 m_pController
->executeChecked(SID_INSERT_FLD_PGNUMBER
,aValues
);
100 catch(uno::Exception
&)
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */