Line data Source code
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 "PageNumber.hrc"
21 : #include <com/sun/star/beans/XPropertySet.hpp>
22 : #include <tools/debug.hxx>
23 : #include "RptResId.hrc"
24 : #include "rptui_slotid.hrc"
25 : #include "ModuleHelper.hxx"
26 : #include "RptDef.hxx"
27 : #include "helpids.hrc"
28 : #include <vcl/msgbox.hxx>
29 : #include "UITools.hxx"
30 : #include "uistrings.hrc"
31 : #include "ReportController.hxx"
32 : #include <com/sun/star/report/XFixedText.hpp>
33 : #include <algorithm>
34 :
35 : namespace rptui
36 : {
37 : using namespace ::com::sun::star;
38 : using namespace ::comphelper;
39 :
40 : DBG_NAME( rpt_OPageNumberDialog )
41 : //========================================================================
42 : // class OPageNumberDialog
43 : //========================================================================
44 0 : OPageNumberDialog::OPageNumberDialog( Window* _pParent
45 : ,const uno::Reference< report::XReportDefinition >& _xHoldAlive
46 : ,OReportController* _pController)
47 : : ModalDialog( _pParent, ModuleRes(RID_PAGENUMBERS) )
48 : ,m_aFormat(this, ModuleRes(FL_FORMAT) )
49 : ,m_aPageN(this, ModuleRes(RB_PAGE_N) )
50 : ,m_aPageNofM(this, ModuleRes(RB_PAGE_N_OF_M) )
51 : ,m_aPosition(this, ModuleRes(FL_POSITION) )
52 : ,m_aTopPage(this, ModuleRes(RB_PAGE_TOPPAGE) )
53 : ,m_aBottomPage(this, ModuleRes(RB_PAGE_BOTTOMPAGE) )
54 : ,m_aMisc(this, ModuleRes(FL_MISC) )
55 : ,m_aAlignment(this, ModuleRes(FL_ALIGNMENT) )
56 : ,m_aAlignmentLst(this, ModuleRes(LST_ALIGNMENT) )
57 : ,m_aShowNumberOnFirstPage(this, ModuleRes(CB_SHOWNUMBERONFIRSTPAGE) )
58 : ,m_aFl1(this, ModuleRes(FL_SEPARATOR1))
59 : ,m_aPB_OK(this, ModuleRes(PB_OK))
60 : ,m_aPB_CANCEL(this, ModuleRes(PB_CANCEL))
61 : ,m_aPB_Help(this, ModuleRes(PB_HELP))
62 : ,m_pController(_pController)
63 0 : ,m_xHoldAlive(_xHoldAlive)
64 : {
65 : DBG_CTOR( rpt_OPageNumberDialog,NULL);
66 :
67 0 : m_aShowNumberOnFirstPage.Hide();
68 :
69 0 : FreeResource();
70 0 : }
71 :
72 : //------------------------------------------------------------------------
73 0 : OPageNumberDialog::~OPageNumberDialog()
74 : {
75 : DBG_DTOR( rpt_OPageNumberDialog,NULL);
76 0 : }
77 : // -----------------------------------------------------------------------------
78 0 : short OPageNumberDialog::Execute()
79 : {
80 0 : short nRet = ModalDialog::Execute();
81 0 : if ( nRet == RET_OK )
82 : {
83 : try
84 : {
85 0 : sal_Int32 nControlMaxSize = 3000;
86 0 : sal_Int32 nPosX = 0;
87 0 : sal_Int32 nPos2X = 0;
88 0 : awt::Size aRptSize = getStyleProperty<awt::Size>(m_xHoldAlive,PROPERTY_PAPERSIZE);
89 0 : switch ( m_aAlignmentLst.GetSelectEntryPos() )
90 : {
91 : case 0: // left
92 0 : nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
93 0 : break;
94 : case 1: // middle
95 0 : 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;
96 0 : break;
97 : case 2: // right
98 0 : nPosX = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
99 0 : break;
100 : case 3: // inner
101 : case 4: // outer
102 0 : nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
103 0 : nPos2X = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
104 0 : break;
105 : default:
106 0 : break;
107 : }
108 0 : if ( m_aAlignmentLst.GetSelectEntryPos() > 2 )
109 0 : nPosX = nPos2X;
110 :
111 0 : sal_Int32 nLength = 0;
112 0 : uno::Sequence<beans::PropertyValue> aValues( 3 );
113 0 : aValues[nLength].Name = PROPERTY_POSITION;
114 0 : aValues[nLength++].Value <<= awt::Point(nPosX,0);
115 :
116 0 : aValues[nLength].Name = PROPERTY_PAGEHEADERON;
117 0 : aValues[nLength++].Value <<= m_aTopPage.IsChecked();
118 :
119 0 : aValues[nLength].Name = PROPERTY_STATE;
120 0 : aValues[nLength++].Value <<= m_aPageNofM.IsChecked();
121 :
122 0 : m_pController->executeChecked(SID_INSERT_FLD_PGNUMBER,aValues);
123 : }
124 0 : catch(uno::Exception&)
125 : {
126 0 : nRet = RET_NO;
127 : }
128 : }
129 0 : return nRet;
130 : }
131 : // =============================================================================
132 : } // rptui
133 : // =============================================================================
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|