1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 #ifdef SW_DLLIMPLEMENTATION 32 #undef SW_DLLIMPLEMENTATION 33 #endif 34 35 36 #include <sfx2/dispatch.hxx> 37 #include <svx/dlgutil.hxx> 38 #include <colwd.hxx> 39 #include <tablemgr.hxx> 40 #include <wrtsh.hxx> 41 #ifndef _WDOCSH_HXX 42 #include <wdocsh.hxx> 43 #endif 44 #ifndef _VIEW_HXX 45 #include <view.hxx> 46 #endif 47 #include <swmodule.hxx> 48 #ifndef _MODCFG_HXX 49 #include <modcfg.hxx> 50 #endif 51 #include <usrpref.hxx> 52 53 #ifndef _CMDID_H 54 #include <cmdid.h> 55 #endif 56 #ifndef _COLWD_HRC 57 #include <colwd.hrc> 58 #endif 59 #ifndef _TABLE_HRC 60 #include <table.hrc> 61 #endif 62 63 64 IMPL_LINK_INLINE_START( SwTableWidthDlg, LoseFocusHdl, Edit *, EMPTYARG ) 65 { 66 sal_uInt16 nId = (sal_uInt16)aColEdit.GetValue()-1; 67 const SwTwips lWidth = rFnc.GetColWidth(nId); 68 aWidthEdit.SetValue(aWidthEdit.Normalize(lWidth), FUNIT_TWIP); 69 aWidthEdit.SetMax(aWidthEdit.Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP); 70 return 0; 71 } 72 IMPL_LINK_INLINE_END( SwTableWidthDlg, LoseFocusHdl, Edit *, EMPTYARG ) 73 74 75 76 SwTableWidthDlg::SwTableWidthDlg(Window *pParent, SwTableFUNC &rTableFnc ) : 77 78 SvxStandardDialog( pParent, SW_RES(DLG_COL_WIDTH) ), 79 aWidthFL(this, SW_RES(FL_WIDTH)), 80 81 aColFT(this, SW_RES(FT_COL)), 82 aColEdit(this, SW_RES(ED_COL)), 83 aWidthFT(this, SW_RES(FT_WIDTH)), 84 aWidthEdit(this, SW_RES(ED_WIDTH)), 85 aOKBtn(this, SW_RES(BT_OK)), 86 aCancelBtn(this, SW_RES(BT_CANCEL)), 87 aHelpBtn(this, SW_RES(BT_HELP)), 88 rFnc(rTableFnc) 89 { 90 FreeResource(); 91 92 sal_Bool bIsWeb = rTableFnc.GetShell() 93 ? static_cast< sal_Bool >(0 != PTR_CAST( SwWebDocShell, 94 rTableFnc.GetShell()->GetView().GetDocShell()) ) 95 : sal_False; 96 FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric(); 97 ::SetFieldUnit(aWidthEdit, eFieldUnit ); 98 99 aColEdit.SetValue( rFnc.GetCurColNum() +1 ); 100 aWidthEdit.SetMin(aWidthEdit.Normalize(MINLAY), FUNIT_TWIP); 101 if(!aWidthEdit.GetMin()) 102 aWidthEdit.SetMin(1); 103 104 if(rFnc.GetColCount() == 0) 105 aWidthEdit.SetMin(aWidthEdit.Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP); 106 aColEdit.SetMax(rFnc.GetColCount() +1 ); 107 aColEdit.SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl)); 108 LoseFocusHdl(); 109 } 110 111 112 113 void SwTableWidthDlg::Apply() 114 { 115 rFnc.InitTabCols(); 116 rFnc.SetColWidth( 117 static_cast< sal_uInt16 >(aColEdit.GetValue() - 1), 118 static_cast< sal_uInt16 >(aWidthEdit.Denormalize(aWidthEdit.GetValue(FUNIT_TWIP)))); 119 } 120 121 122 123 124