Update ooo320-m1
[ooovba.git] / goodies / source / filter.vcl / eos2met / dlgeos2.cxx
blob5d8719773f7c14df37fb51ce594f2897c82c7d9d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlgeos2.cxx,v $
10 * $Revision: 1.10 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_goodies.hxx"
33 #ifndef GCC
34 #endif
35 #include <com/sun/star/awt/Size.hpp>
36 #include <vcl/msgbox.hxx>
37 #include <svtools/FilterConfigItem.hxx>
38 #include "dlgeos2.hxx"
39 #include "dlgeos2.hrc"
40 #include "strings.hrc"
42 /*************************************************************************
44 |* Ctor
46 \************************************************************************/
48 DlgExportEMET::DlgExportEMET( FltCallDialogParameter& rPara ) :
49 ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_EMET, *rPara.pResMgr ) ),
50 rFltCallPara ( rPara ),
51 aBtnOK ( this, ResId( BTN_OK, *rPara.pResMgr ) ),
52 aBtnCancel ( this, ResId( BTN_CANCEL, *rPara.pResMgr ) ),
53 aBtnHelp ( this, ResId( BTN_HELP, *rPara.pResMgr ) ),
54 aRbOriginal ( this, ResId( RB_ORIGINAL, *rPara.pResMgr ) ),
55 aRbSize ( this, ResId( RB_SIZE, *rPara.pResMgr ) ),
56 aGrpMode ( this, ResId( GRP_MODE, *rPara.pResMgr ) ),
57 aFtSizeX ( this, ResId( FT_SIZEX, *rPara.pResMgr ) ),
58 aMtfSizeX ( this, ResId( MTF_SIZEX, *rPara.pResMgr ) ),
59 aFtSizeY ( this, ResId( FT_SIZEY, *rPara.pResMgr ) ),
60 aMtfSizeY ( this, ResId( MTF_SIZEY, *rPara.pResMgr ) ),
61 aGrpSize ( this, ResId( GRP_SIZE, *rPara.pResMgr ) ),
62 pMgr ( rPara.pResMgr )
64 FreeResource();
66 String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Export/MET" ) );
67 pConfigItem = new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData );
69 aBtnOK.SetClickHdl( LINK( this, DlgExportEMET, OK ) );
70 aRbOriginal.SetClickHdl( LINK( this, DlgExportEMET, ClickRbOriginal ) );
71 aRbSize.SetClickHdl( LINK( this, DlgExportEMET, ClickRbSize ) );
73 // Config-Parameter lesen
74 sal_Int32 nMode = pConfigItem->ReadInt32( String( ResId( KEY_MODE, *pMgr ) ), 0 );
75 ::com::sun::star::awt::Size aDefault( 10000, 10000 );
76 ::com::sun::star::awt::Size aSize;
77 aSize = pConfigItem->ReadSize( String( ResId( KEY_SIZE, *pMgr ) ), aDefault );
79 aMtfSizeX.SetDefaultUnit( FUNIT_MM );
80 aMtfSizeY.SetDefaultUnit( FUNIT_MM );
82 aMtfSizeX.SetValue( aSize.Width );
83 aMtfSizeY.SetValue( aSize.Height );
85 switch ( rPara.eFieldUnit )
87 // case FUNIT_NONE :
88 // case FUNIT_KM :
89 // case FUNIT_PERCENT :
90 // case FUNIT_CUSTOM :
91 // case FUNIT_MILE :
92 // case FUNIT_FOOT :
93 // case FUNIT_M :
94 case FUNIT_MM :
95 case FUNIT_CM :
96 case FUNIT_TWIP :
97 case FUNIT_POINT :
98 case FUNIT_PICA :
99 case FUNIT_INCH :
100 case FUNIT_100TH_MM :
102 aMtfSizeX.SetUnit( rPara.eFieldUnit );
103 aMtfSizeY.SetUnit( rPara.eFieldUnit );
105 break;
106 default:
107 break; // multiple other value not handled -Wall
109 if ( nMode == 1 )
111 aRbSize.Check( TRUE );
112 ClickRbSize( NULL );
114 else
116 aRbOriginal.Check( TRUE );
117 ClickRbOriginal( NULL );
121 DlgExportEMET::~DlgExportEMET()
123 delete pConfigItem;
126 /*************************************************************************
128 |* Speichert eingestellte Werte in ini-Datei
130 \************************************************************************/
132 IMPL_LINK( DlgExportEMET, OK, void *, EMPTYARG )
134 // Config-Parameter schreiben
135 ::com::sun::star::awt::Size aSize(
136 (sal_Int32)MetricField::ConvertDoubleValue( aMtfSizeX.GetValue(), 2, aMtfSizeX.GetUnit(), MAP_100TH_MM ),
137 (sal_Int32)MetricField::ConvertDoubleValue( aMtfSizeY.GetValue(), 2, aMtfSizeY.GetUnit(), MAP_100TH_MM ) );
138 sal_Int32 nStrMode = ( aRbSize.IsChecked() ) ? 1 : 0;
140 pConfigItem->WriteInt32( String( ResId( KEY_MODE, *pMgr ) ), nStrMode );
141 pConfigItem->WriteSize( String( ResId( KEY_SIZE, *pMgr ) ), aSize );
142 rFltCallPara.aFilterData = pConfigItem->GetFilterData();
143 EndDialog( RET_OK );
145 return 0;
148 /*************************************************************************
150 |* Enabled/Disabled Controls
152 \************************************************************************/
154 IMPL_LINK( DlgExportEMET, ClickRbOriginal, void*, EMPTYARG )
156 aGrpSize.Disable();
157 aFtSizeX.Disable();
158 aMtfSizeX.Disable();
159 aFtSizeY.Disable();
160 aMtfSizeY.Disable();
162 return 0;
166 /*************************************************************************
168 |* Enabled/Disabled Controls
170 \************************************************************************/
172 IMPL_LINK( DlgExportEMET, ClickRbSize, void*, EMPTYARG )
174 aGrpSize.Enable();
175 aFtSizeX.Enable();
176 aMtfSizeX.Enable();
177 aFtSizeY.Enable();
178 aMtfSizeY.Enable();
180 return 0;