1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PageNumber.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
31 #include "PageNumber.hxx"
32 #ifndef RPTUI_PAGENUMBER_HRC
33 #include "PageNumber.hrc"
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <tools/debug.hxx>
37 #ifndef _RPTUI_DLGRESID_HRC
38 #include "RptResId.hrc"
40 #ifndef _RPTUI_SLOTID_HRC_
41 #include "rptui_slotid.hrc"
43 #ifndef _RPTUI_MODULE_HELPER_DBU_HXX_
44 #include "ModuleHelper.hxx"
47 #ifndef RTPUI_REPORTDESIGN_HELPID_HRC
48 #include "helpids.hrc"
50 #include <vcl/msgbox.hxx>
52 #include <svx/globlmn.hrc>
55 #include <svx/svxids.hrc>
57 #ifndef RPTUI_TOOLS_HXX
58 #include "UITools.hxx"
60 #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC
61 #include "uistrings.hrc"
63 #include "ReportController.hxx"
64 #include <com/sun/star/report/XFixedText.hpp>
69 using namespace ::com::sun::star
;
70 using namespace ::comphelper
;
72 DBG_NAME( rpt_OPageNumberDialog
)
73 //========================================================================
74 // class OPageNumberDialog
75 //========================================================================
76 OPageNumberDialog::OPageNumberDialog( Window
* _pParent
77 ,const uno::Reference
< report::XReportDefinition
>& _xHoldAlive
78 ,OReportController
* _pController
)
79 : ModalDialog( _pParent
, ModuleRes(RID_PAGENUMBERS
) )
80 ,m_aFormat(this, ModuleRes(FL_FORMAT
) )
81 ,m_aPageN(this, ModuleRes(RB_PAGE_N
) )
82 ,m_aPageNofM(this, ModuleRes(RB_PAGE_N_OF_M
) )
83 ,m_aPosition(this, ModuleRes(FL_POSITION
) )
84 ,m_aTopPage(this, ModuleRes(RB_PAGE_TOPPAGE
) )
85 ,m_aBottomPage(this, ModuleRes(RB_PAGE_BOTTOMPAGE
) )
86 ,m_aMisc(this, ModuleRes(FL_MISC
) )
87 ,m_aAlignment(this, ModuleRes(FL_ALIGNMENT
) )
88 ,m_aAlignmentLst(this, ModuleRes(LST_ALIGNMENT
) )
89 ,m_aShowNumberOnFirstPage(this, ModuleRes(CB_SHOWNUMBERONFIRSTPAGE
) )
90 ,m_aFl1(this, ModuleRes(FL_SEPARATOR1
))
91 ,m_aPB_OK(this, ModuleRes(PB_OK
))
92 ,m_aPB_CANCEL(this, ModuleRes(PB_CANCEL
))
93 ,m_aPB_Help(this, ModuleRes(PB_HELP
))
94 ,m_pController(_pController
)
95 ,m_xHoldAlive(_xHoldAlive
)
97 DBG_CTOR( rpt_OPageNumberDialog
,NULL
);
99 m_aShowNumberOnFirstPage
.Hide();
104 //------------------------------------------------------------------------
105 OPageNumberDialog::~OPageNumberDialog()
107 DBG_DTOR( rpt_OPageNumberDialog
,NULL
);
109 // -----------------------------------------------------------------------------
110 short OPageNumberDialog::Execute()
112 short nRet
= ModalDialog::Execute();
113 if ( nRet
== RET_OK
)
117 sal_Int32 nControlMaxSize
= 3000;
119 sal_Int32 nPos2X
= 0;
120 awt::Size aRptSize
= getStyleProperty
<awt::Size
>(m_xHoldAlive
,PROPERTY_PAPERSIZE
);
121 switch ( m_aAlignmentLst
.GetSelectEntryPos() )
124 nPosX
= getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_LEFTMARGIN
);
127 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;
130 nPosX
= (aRptSize
.Width
- getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_RIGHTMARGIN
) - nControlMaxSize
);
134 nPosX
= getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_LEFTMARGIN
);
135 nPos2X
= (aRptSize
.Width
- getStyleProperty
<sal_Int32
>(m_xHoldAlive
,PROPERTY_RIGHTMARGIN
) - nControlMaxSize
);
140 if ( m_aAlignmentLst
.GetSelectEntryPos() > 2 )
143 sal_Int32 nLength
= 0;
144 uno::Sequence
<beans::PropertyValue
> aValues( 3 );
145 aValues
[nLength
].Name
= PROPERTY_POSITION
;
146 aValues
[nLength
++].Value
<<= awt::Point(nPosX
,0);
148 aValues
[nLength
].Name
= PROPERTY_PAGEHEADERON
;
149 aValues
[nLength
++].Value
<<= m_aTopPage
.IsChecked();
151 aValues
[nLength
].Name
= PROPERTY_STATE
;
152 aValues
[nLength
++].Value
<<= m_aPageNofM
.IsChecked();
154 m_pController
->executeChecked(SID_INSERT_FLD_PGNUMBER
,aValues
);
156 catch(uno::Exception
&)
163 // =============================================================================
165 // =============================================================================