update emoji autocorrect entries from po-files
[LibreOffice.git] / reportdesign / source / ui / dlg / PageNumber.cxx
blobf7a799a538321dbd26b785a8d38b91f835c5a457
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
25 #include "RptDef.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>
34 #include <algorithm>
36 namespace rptui
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()
66 disposeOnce();
69 void OPageNumberDialog::dispose()
71 m_pPageN.clear();
72 m_pPageNofM.clear();
73 m_pTopPage.clear();
74 m_pBottomPage.clear();
75 m_pAlignmentLst.clear();
76 m_pShowNumberOnFirstPage.clear();
77 ModalDialog::dispose();
80 short OPageNumberDialog::Execute()
82 short nRet = ModalDialog::Execute();
83 if ( nRet == RET_OK )
85 try
87 sal_Int32 nControlMaxSize = 3000;
88 sal_Int32 nPosX = 0;
89 sal_Int32 nPos2X = 0;
90 awt::Size aRptSize = getStyleProperty<awt::Size>(m_xHoldAlive,PROPERTY_PAPERSIZE);
91 switch ( m_pAlignmentLst->GetSelectEntryPos() )
93 case 0: // left
94 nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
95 break;
96 case 1: // middle
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;
98 break;
99 case 2: // right
100 nPosX = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
101 break;
102 case 3: // inner
103 case 4: // outer
104 nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
105 nPos2X = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
106 break;
107 default:
108 break;
110 if ( m_pAlignmentLst->GetSelectEntryPos() > 2 )
111 nPosX = nPos2X;
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&)
128 nRet = RET_NO;
131 return nRet;
134 } // rptui
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */