1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #include "precompiled_reportdesign.hxx" 28*cdf0e10cSrcweir #include "PageNumber.hxx" 29*cdf0e10cSrcweir #ifndef RPTUI_PAGENUMBER_HRC 30*cdf0e10cSrcweir #include "PageNumber.hrc" 31*cdf0e10cSrcweir #endif 32*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 33*cdf0e10cSrcweir #include <tools/debug.hxx> 34*cdf0e10cSrcweir #ifndef _RPTUI_DLGRESID_HRC 35*cdf0e10cSrcweir #include "RptResId.hrc" 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir #ifndef _RPTUI_SLOTID_HRC_ 38*cdf0e10cSrcweir #include "rptui_slotid.hrc" 39*cdf0e10cSrcweir #endif 40*cdf0e10cSrcweir #ifndef _RPTUI_MODULE_HELPER_DBU_HXX_ 41*cdf0e10cSrcweir #include "ModuleHelper.hxx" 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir #include "RptDef.hxx" 44*cdf0e10cSrcweir #ifndef RTPUI_REPORTDESIGN_HELPID_HRC 45*cdf0e10cSrcweir #include "helpids.hrc" 46*cdf0e10cSrcweir #endif 47*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 48*cdf0e10cSrcweir #ifndef _GLOBLMN_HRC 49*cdf0e10cSrcweir #include <svx/globlmn.hrc> 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #ifndef _SBASLTID_HRC 52*cdf0e10cSrcweir #include <svx/svxids.hrc> 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir #ifndef RPTUI_TOOLS_HXX 55*cdf0e10cSrcweir #include "UITools.hxx" 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC 58*cdf0e10cSrcweir #include "uistrings.hrc" 59*cdf0e10cSrcweir #endif 60*cdf0e10cSrcweir #include "ReportController.hxx" 61*cdf0e10cSrcweir #include <com/sun/star/report/XFixedText.hpp> 62*cdf0e10cSrcweir #include <algorithm> 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir namespace rptui 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir using namespace ::com::sun::star; 67*cdf0e10cSrcweir using namespace ::comphelper; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir DBG_NAME( rpt_OPageNumberDialog ) 70*cdf0e10cSrcweir //======================================================================== 71*cdf0e10cSrcweir // class OPageNumberDialog 72*cdf0e10cSrcweir //======================================================================== 73*cdf0e10cSrcweir OPageNumberDialog::OPageNumberDialog( Window* _pParent 74*cdf0e10cSrcweir ,const uno::Reference< report::XReportDefinition >& _xHoldAlive 75*cdf0e10cSrcweir ,OReportController* _pController) 76*cdf0e10cSrcweir : ModalDialog( _pParent, ModuleRes(RID_PAGENUMBERS) ) 77*cdf0e10cSrcweir ,m_aFormat(this, ModuleRes(FL_FORMAT) ) 78*cdf0e10cSrcweir ,m_aPageN(this, ModuleRes(RB_PAGE_N) ) 79*cdf0e10cSrcweir ,m_aPageNofM(this, ModuleRes(RB_PAGE_N_OF_M) ) 80*cdf0e10cSrcweir ,m_aPosition(this, ModuleRes(FL_POSITION) ) 81*cdf0e10cSrcweir ,m_aTopPage(this, ModuleRes(RB_PAGE_TOPPAGE) ) 82*cdf0e10cSrcweir ,m_aBottomPage(this, ModuleRes(RB_PAGE_BOTTOMPAGE) ) 83*cdf0e10cSrcweir ,m_aMisc(this, ModuleRes(FL_MISC) ) 84*cdf0e10cSrcweir ,m_aAlignment(this, ModuleRes(FL_ALIGNMENT) ) 85*cdf0e10cSrcweir ,m_aAlignmentLst(this, ModuleRes(LST_ALIGNMENT) ) 86*cdf0e10cSrcweir ,m_aShowNumberOnFirstPage(this, ModuleRes(CB_SHOWNUMBERONFIRSTPAGE) ) 87*cdf0e10cSrcweir ,m_aFl1(this, ModuleRes(FL_SEPARATOR1)) 88*cdf0e10cSrcweir ,m_aPB_OK(this, ModuleRes(PB_OK)) 89*cdf0e10cSrcweir ,m_aPB_CANCEL(this, ModuleRes(PB_CANCEL)) 90*cdf0e10cSrcweir ,m_aPB_Help(this, ModuleRes(PB_HELP)) 91*cdf0e10cSrcweir ,m_pController(_pController) 92*cdf0e10cSrcweir ,m_xHoldAlive(_xHoldAlive) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir DBG_CTOR( rpt_OPageNumberDialog,NULL); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir m_aShowNumberOnFirstPage.Hide(); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir FreeResource(); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir //------------------------------------------------------------------------ 102*cdf0e10cSrcweir OPageNumberDialog::~OPageNumberDialog() 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir DBG_DTOR( rpt_OPageNumberDialog,NULL); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 107*cdf0e10cSrcweir short OPageNumberDialog::Execute() 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir short nRet = ModalDialog::Execute(); 110*cdf0e10cSrcweir if ( nRet == RET_OK ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir try 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir sal_Int32 nControlMaxSize = 3000; 115*cdf0e10cSrcweir sal_Int32 nPosX = 0; 116*cdf0e10cSrcweir sal_Int32 nPos2X = 0; 117*cdf0e10cSrcweir awt::Size aRptSize = getStyleProperty<awt::Size>(m_xHoldAlive,PROPERTY_PAPERSIZE); 118*cdf0e10cSrcweir switch ( m_aAlignmentLst.GetSelectEntryPos() ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir case 0: // left 121*cdf0e10cSrcweir nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN); 122*cdf0e10cSrcweir break; 123*cdf0e10cSrcweir case 1: // middle 124*cdf0e10cSrcweir 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; 125*cdf0e10cSrcweir break; 126*cdf0e10cSrcweir case 2: // right 127*cdf0e10cSrcweir nPosX = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize); 128*cdf0e10cSrcweir break; 129*cdf0e10cSrcweir case 3: // inner 130*cdf0e10cSrcweir case 4: // outer 131*cdf0e10cSrcweir nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN); 132*cdf0e10cSrcweir nPos2X = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize); 133*cdf0e10cSrcweir break; 134*cdf0e10cSrcweir default: 135*cdf0e10cSrcweir break; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir if ( m_aAlignmentLst.GetSelectEntryPos() > 2 ) 138*cdf0e10cSrcweir nPosX = nPos2X; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir sal_Int32 nLength = 0; 141*cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aValues( 3 ); 142*cdf0e10cSrcweir aValues[nLength].Name = PROPERTY_POSITION; 143*cdf0e10cSrcweir aValues[nLength++].Value <<= awt::Point(nPosX,0); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir aValues[nLength].Name = PROPERTY_PAGEHEADERON; 146*cdf0e10cSrcweir aValues[nLength++].Value <<= m_aTopPage.IsChecked(); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir aValues[nLength].Name = PROPERTY_STATE; 149*cdf0e10cSrcweir aValues[nLength++].Value <<= m_aPageNofM.IsChecked(); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir m_pController->executeChecked(SID_INSERT_FLD_PGNUMBER,aValues); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir catch(uno::Exception&) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir nRet = RET_NO; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir return nRet; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir // ============================================================================= 161*cdf0e10cSrcweir } // rptui 162*cdf0e10cSrcweir // ============================================================================= 163