1 /* AbiWord
2  * Copyright (C) 1998 AbiSource, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA.
18  */
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include "ut_types.h"
23 #include "ut_string.h"
24 #include "ap_Dialog_PageSetup.h"
25 
AP_Dialog_PageSetup(XAP_DialogFactory * pDlgFactory,XAP_Dialog_Id id)26 AP_Dialog_PageSetup::AP_Dialog_PageSetup (XAP_DialogFactory * pDlgFactory,
27 					  XAP_Dialog_Id id)
28 :	XAP_Dialog_NonPersistent(pDlgFactory,id, "interface/dialogpagesetup"),
29 	m_answer(a_OK),
30 	m_PageSize(fp_PageSize::psLetter), // isn't this leaked when setPageSize called?
31 	m_PageUnits(DIM_IN),
32 	m_PageOrientation(PORTRAIT),
33 	m_PageScale(100),
34 	m_MarginUnits(DIM_IN),
35 	m_MarginTop(1.0f),
36 	m_MarginBottom(1.0f),
37 	m_MarginLeft(1.0f),
38 	m_MarginRight(1.0f),
39 	m_MarginHeader(0.0f),
40 	m_MarginFooter(0.0f)
41 {
42 }
43 
~AP_Dialog_PageSetup(void)44 AP_Dialog_PageSetup::~AP_Dialog_PageSetup(void)
45 {
46   //
47 }
48 
49 
validatePageSettings(void) const50 bool AP_Dialog_PageSetup::validatePageSettings(void) const
51 {
52 	// Require at least 0.3in for headers and footers.
53 
54 /*	double fudge = UT_convertInchesToDimension(0.3, m_MarginUnits);
55 
56 
57   (m_MarginFooter + fudge > m_MarginBottom) ||
58   (m_MarginHeader + fudge > m_MarginTop))
59 */
60 
61 	if ( (m_MarginLeft + m_MarginRight >= m_PageSize.Width(m_MarginUnits)) ||
62 		 (m_MarginTop + m_MarginBottom >= m_PageSize.Height(m_MarginUnits)) )
63 		return false;
64 
65 	return true;
66 }
67