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 <tools/debug.hxx>
22 #include "RptResId.hrc"
23 #include "rptui_slotid.hrc"
24 #include "ModuleHelper.hxx"
26 #include "helpids.hrc"
27 #include <vcl/msgbox.hxx>
28 #include <vcl/settings.hxx>
30 #include "UITools.hxx"
31 #include "uistrings.hrc"
32 #include "ReportController.hxx"
33 #include <com/sun/star/report/XFixedText.hpp>
38 using namespace ::com::sun::star
;
39 using namespace ::comphelper
;
42 // class OPageNumberDialog
44 OPageNumberDialog::OPageNumberDialog( vcl::Window
* _pParent
45 ,const uno::Reference
< report::XReportDefinition
>& _xHoldAlive
46 ,OReportController
* _pController
)
47 : ModalDialog( _pParent
, "PageNumberDialog" , "modules/dbreport/ui/pagenumberdialog.ui" )
48 ,m_pController(_pController
)
49 ,m_xHoldAlive(_xHoldAlive
)
51 get(m_pPageN
,"pagen");
52 get(m_pPageNofM
,"pagenofm");
53 get(m_pTopPage
,"toppage");
54 get(m_pBottomPage
,"bottompage");
55 get(m_pAlignmentLst
,"alignment");
56 get(m_pShowNumberOnFirstPage
,"shownumberonfirstpage");
59 m_pShowNumberOnFirstPage
->Hide();
64 OPageNumberDialog::~OPageNumberDialog()
69 void OPageNumberDialog::dispose()
74 m_pBottomPage
.clear();
75 m_pAlignmentLst
.clear();
76 m_pShowNumberOnFirstPage
.clear();
77 ModalDialog::dispose();
80 short OPageNumberDialog::Execute()
82 short nRet
= ModalDialog::Execute();
87 sal_Int32 nControlMaxSize
= 3000;
90 awt::Size aRptSize
= getStyleProperty
<awt::Size
>(m_xHoldAlive
,PROPERTY_PAPERSIZE
);
91 switch ( m_pAlignmentLst
->GetSelectEntryPos() )
94 nPosX
= getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_LEFTMARGIN
);
97 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;
100 nPosX
= (aRptSize
.Width
- getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_RIGHTMARGIN
) - nControlMaxSize
);
104 nPosX
= getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_LEFTMARGIN
);
105 nPos2X
= (aRptSize
.Width
- getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_RIGHTMARGIN
) - nControlMaxSize
);
110 if ( m_pAlignmentLst
->GetSelectEntryPos() > 2 )
113 sal_Int32 nLength
= 0;
114 uno::Sequence
<beans::PropertyValue
> aValues( 3 );
115 aValues
[nLength
].Name
= PROPERTY_POSITION
;
116 aValues
[nLength
++].Value
<<= awt::Point(nPosX
,0);
118 aValues
[nLength
].Name
= PROPERTY_PAGEHEADERON
;
119 aValues
[nLength
++].Value
<<= m_pTopPage
->IsChecked();
121 aValues
[nLength
].Name
= PROPERTY_STATE
;
122 aValues
[nLength
++].Value
<<= m_pPageNofM
->IsChecked();
124 m_pController
->executeChecked(SID_INSERT_FLD_PGNUMBER
,aValues
);
126 catch(uno::Exception
&)
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */