Update ooo320-m1
[ooovba.git] / goodies / source / filter.vcl / epict / dlgepct.cxx
blob6098c8a20a1bec2f592819cb44e8f3f82e269409
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: dlgepct.cxx,v $
10 * $Revision: 1.9 $
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
36 #include <vcl/msgbox.hxx>
37 #include <svtools/FilterConfigItem.hxx>
38 #include <com/sun/star/awt/Size.hpp>
39 #include "dlgepct.hxx"
40 #include "dlgepct.hrc"
41 #include "strings.hrc"
43 /*************************************************************************
45 |* Ctor
47 \************************************************************************/
49 DlgExportEPCT::DlgExportEPCT( FltCallDialogParameter& rPara ) :
50 ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_EPCT, *rPara.pResMgr ) ),
51 rFltCallPara ( rPara ),
52 aBtnOK ( this, ResId( BTN_OK, *rPara.pResMgr ) ),
53 aBtnCancel ( this, ResId( BTN_CANCEL, *rPara.pResMgr ) ),
54 aBtnHelp ( this, ResId( BTN_HELP, *rPara.pResMgr ) ),
55 aRbOriginal ( this, ResId( RB_ORIGINAL, *rPara.pResMgr ) ),
56 aRbSize ( this, ResId( RB_SIZE, *rPara.pResMgr ) ),
57 aGrpMode ( this, ResId( GRP_MODE, *rPara.pResMgr ) ),
58 aFtSizeX ( this, ResId( FT_SIZEX, *rPara.pResMgr ) ),
59 aMtfSizeX ( this, ResId( MTF_SIZEX, *rPara.pResMgr ) ),
60 aFtSizeY ( this, ResId( FT_SIZEY, *rPara.pResMgr ) ),
61 aMtfSizeY ( this, ResId( MTF_SIZEY, *rPara.pResMgr ) ),
62 aGrpSize ( this, ResId( GRP_SIZE, *rPara.pResMgr ) ),
63 pMgr ( rPara.pResMgr )
65 FreeResource();
67 String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Export/PCT" ) );
68 pConfigItem = new FilterConfigItem( aFilterConfigPath, &rPara.aFilterData );
70 aBtnOK.SetClickHdl( LINK( this, DlgExportEPCT, OK ) );
71 aRbOriginal.SetClickHdl( LINK( this, DlgExportEPCT, ClickRbOriginal ) );
72 aRbSize.SetClickHdl( LINK( this, DlgExportEPCT, ClickRbSize ) );
74 // Config-Parameter lesen
75 sal_Int32 nStrMode = pConfigItem->ReadInt32( String( ResId( KEY_MODE, *pMgr ) ), 0 );
76 ::com::sun::star::awt::Size aDefault( 10000, 10000 );
77 ::com::sun::star::awt::Size aSize;
78 aSize = pConfigItem->ReadSize( String( ResId( KEY_SIZE, *pMgr ) ), aDefault );
80 aMtfSizeX.SetDefaultUnit( FUNIT_MM );
81 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 break; // -Wall not handled.
95 case FUNIT_MM :
96 case FUNIT_CM :
97 case FUNIT_TWIP :
98 case FUNIT_POINT :
99 case FUNIT_PICA :
100 case FUNIT_INCH :
101 case FUNIT_100TH_MM :
103 aMtfSizeX.SetUnit( rPara.eFieldUnit );
104 aMtfSizeY.SetUnit( rPara.eFieldUnit );
106 break;
108 if ( nStrMode == 1 )
110 aRbSize.Check( TRUE );
111 ClickRbSize( NULL );
113 else
115 aRbOriginal.Check( TRUE );
116 ClickRbOriginal( NULL );
120 DlgExportEPCT::~DlgExportEPCT()
122 delete pConfigItem;
125 /*************************************************************************
127 |* Speichert eingestellte Werte in ini-Datei
129 \**************************************** ********************************/
131 IMPL_LINK( DlgExportEPCT, OK, void *, EMPTYARG )
133 // Config-Parameter schreiben
134 ::com::sun::star::awt::Size aSize(
135 (sal_Int32)MetricField::ConvertDoubleValue( aMtfSizeX.GetValue(), 2, aMtfSizeX.GetUnit(), MAP_100TH_MM ),
136 (sal_Int32)MetricField::ConvertDoubleValue( aMtfSizeY.GetValue(), 2, aMtfSizeY.GetUnit(), MAP_100TH_MM ) );
138 sal_Int32 nStrMode = 0;
139 if ( aRbSize.IsChecked() )
140 nStrMode++;
142 pConfigItem->WriteInt32( String( ResId( KEY_MODE, *pMgr ) ), nStrMode );
143 pConfigItem->WriteSize( String( ResId( KEY_SIZE, *pMgr ) ), aSize );
144 rFltCallPara.aFilterData = pConfigItem->GetFilterData();
145 EndDialog( RET_OK );
147 return 0;
150 /*************************************************************************
152 |* Enabled/Disabled Controls
154 \************************************************************************/
156 IMPL_LINK( DlgExportEPCT, ClickRbOriginal, void*, EMPTYARG )
158 aGrpSize.Disable();
159 aFtSizeX.Disable();
160 aMtfSizeX.Disable();
161 aFtSizeY.Disable();
162 aMtfSizeY.Disable();
164 return 0;
168 /*************************************************************************
170 |* Enabled/Disabled Controls
172 \************************************************************************/
174 IMPL_LINK( DlgExportEPCT, ClickRbSize, void*, EMPTYARG )
176 aGrpSize.Enable();
177 aFtSizeX.Enable();
178 aMtfSizeX.Enable();
179 aFtSizeY.Enable();
180 aMtfSizeY.Enable();
182 return 0;