1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 33*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 38*cdf0e10cSrcweir #include <svl/stritem.hxx> 39*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 40*cdf0e10cSrcweir #include <modcfg.hxx> 41*cdf0e10cSrcweir #include <svx/htmlmode.hxx> 42*cdf0e10cSrcweir #include <viewopt.hxx> 43*cdf0e10cSrcweir #include "swmodule.hxx" 44*cdf0e10cSrcweir #include "cmdid.h" 45*cdf0e10cSrcweir #include "convert.hxx" 46*cdf0e10cSrcweir #include "tablemgr.hxx" 47*cdf0e10cSrcweir #include "wrtsh.hxx" 48*cdf0e10cSrcweir #include "view.hxx" 49*cdf0e10cSrcweir #include "tblafmt.hxx" 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include "table.hrc" 52*cdf0e10cSrcweir #include "convert.hrc" 53*cdf0e10cSrcweir #include "swabstdlg.hxx" 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace swui 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir SwAbstractDialogFactory * GetFactory(); 58*cdf0e10cSrcweir } 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir //keep the state of the buttons on runtime 61*cdf0e10cSrcweir static int nSaveButtonState = -1; // 0: tab, 1: semicolon, 2: paragraph, 3: other, -1: not yet used 62*cdf0e10cSrcweir static sal_Bool bIsKeepColumn = sal_True; 63*cdf0e10cSrcweir static sal_Unicode uOther = ','; 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir void SwConvertTableDlg::GetValues( sal_Unicode& rDelim, 66*cdf0e10cSrcweir SwInsertTableOptions& rInsTblOpts, 67*cdf0e10cSrcweir SwTableAutoFmt *& prTAFmt ) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir if( aTabBtn.IsChecked() ) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir //0x0b mustn't be set when re-converting table into text 72*cdf0e10cSrcweir bIsKeepColumn = !aKeepColumn.IsVisible() || aKeepColumn.IsChecked(); 73*cdf0e10cSrcweir rDelim = bIsKeepColumn ? 0x09 : 0x0b; 74*cdf0e10cSrcweir nSaveButtonState = 0; 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir else if( aSemiBtn.IsChecked() ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir rDelim = ';'; 79*cdf0e10cSrcweir nSaveButtonState = 1; 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir else if( aOtherBtn.IsChecked() && aOtherEd.GetText().Len() ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir uOther = aOtherEd.GetText().GetChar( 0 ); 84*cdf0e10cSrcweir rDelim = uOther; 85*cdf0e10cSrcweir nSaveButtonState = 3; 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir else 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir nSaveButtonState = 2; 90*cdf0e10cSrcweir rDelim = cParaDelim; 91*cdf0e10cSrcweir if(aOtherBtn.IsChecked()) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir nSaveButtonState = 3; 94*cdf0e10cSrcweir uOther = 0; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir sal_uInt16 nInsMode = 0; 100*cdf0e10cSrcweir if (aBorderCB.IsChecked()) 101*cdf0e10cSrcweir nInsMode |= tabopts::DEFAULT_BORDER; 102*cdf0e10cSrcweir if (aHeaderCB.IsChecked()) 103*cdf0e10cSrcweir nInsMode |= tabopts::HEADLINE; 104*cdf0e10cSrcweir if (aRepeatHeaderCB.IsEnabled() && aRepeatHeaderCB.IsChecked()) 105*cdf0e10cSrcweir rInsTblOpts.mnRowsToRepeat = sal_uInt16( aRepeatHeaderNF.GetValue() ); 106*cdf0e10cSrcweir else 107*cdf0e10cSrcweir rInsTblOpts.mnRowsToRepeat = 0; 108*cdf0e10cSrcweir if (!aDontSplitCB.IsChecked()) 109*cdf0e10cSrcweir nInsMode |= tabopts::SPLIT_LAYOUT; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir if( pTAutoFmt ) 112*cdf0e10cSrcweir prTAFmt = new SwTableAutoFmt( *pTAutoFmt ); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir rInsTblOpts.mnInsMode = nInsMode; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir SwConvertTableDlg::SwConvertTableDlg( SwView& rView, bool bToTable ) 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir : SfxModalDialog( &rView.GetViewFrame()->GetWindow(), SW_RES(DLG_CONV_TEXT_TABLE)), 121*cdf0e10cSrcweir #ifdef MSC 122*cdf0e10cSrcweir #pragma warning (disable : 4355) 123*cdf0e10cSrcweir #endif 124*cdf0e10cSrcweir aTabBtn (this, SW_RES(CB_TAB)), 125*cdf0e10cSrcweir aSemiBtn (this, SW_RES(CB_SEMI)), 126*cdf0e10cSrcweir aParaBtn (this, SW_RES(CB_PARA)), 127*cdf0e10cSrcweir aOtherBtn (this, SW_RES(RB_OTHER)), 128*cdf0e10cSrcweir aOtherEd (this, SW_RES(ED_OTHER)), 129*cdf0e10cSrcweir aKeepColumn (this, SW_RES(CB_KEEPCOLUMN)), 130*cdf0e10cSrcweir aDelimFL (this, SW_RES(FL_DELIM)), 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir aHeaderCB (this, SW_RES(CB_HEADER)), 133*cdf0e10cSrcweir aRepeatHeaderCB (this, SW_RES(CB_REPEAT_HEADER)), 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir aRepeatHeaderFT (this, SW_RES(FT_REPEAT_HEADER)), 136*cdf0e10cSrcweir aRepeatHeaderBeforeFT (this), 137*cdf0e10cSrcweir aRepeatHeaderNF (this, SW_RES(NF_REPEAT_HEADER)), 138*cdf0e10cSrcweir aRepeatHeaderAfterFT (this), 139*cdf0e10cSrcweir aRepeatHeaderCombo (this, SW_RES(WIN_REPEAT_HEADER), aRepeatHeaderNF, aRepeatHeaderBeforeFT, aRepeatHeaderAfterFT), 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir aOptionsFL (this, SW_RES(FL_OPTIONS)), 142*cdf0e10cSrcweir aDontSplitCB (this, SW_RES(CB_DONT_SPLIT)), 143*cdf0e10cSrcweir aBorderCB (this, SW_RES(CB_BORDER)), 144*cdf0e10cSrcweir aAutoFmtBtn(this,SW_RES(BT_AUTOFORMAT)), 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir aOkBtn(this,SW_RES(BT_OK)), 147*cdf0e10cSrcweir aCancelBtn(this,SW_RES(BT_CANCEL)), 148*cdf0e10cSrcweir aHelpBtn(this, SW_RES(BT_HELP)), 149*cdf0e10cSrcweir #ifdef MSC 150*cdf0e10cSrcweir #pragma warning (default : 4355) 151*cdf0e10cSrcweir #endif 152*cdf0e10cSrcweir sConvertTextTable(SW_RES(STR_CONVERT_TEXT_TABLE)), 153*cdf0e10cSrcweir pTAutoFmt( 0 ), 154*cdf0e10cSrcweir pShell( &rView.GetWrtShell() ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir aOtherEd.SetAccessibleName(String(SW_RES(STR_SYMBOL))); 157*cdf0e10cSrcweir aOtherEd.SetAccessibleRelationLabeledBy(&aOtherBtn); 158*cdf0e10cSrcweir FreeResource(); 159*cdf0e10cSrcweir if(nSaveButtonState > -1) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir switch (nSaveButtonState) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir case 0: 164*cdf0e10cSrcweir aTabBtn.Check(); 165*cdf0e10cSrcweir aKeepColumn.Check(bIsKeepColumn); 166*cdf0e10cSrcweir break; 167*cdf0e10cSrcweir case 1: aSemiBtn.Check();break; 168*cdf0e10cSrcweir case 2: aParaBtn.Check();break; 169*cdf0e10cSrcweir case 3: 170*cdf0e10cSrcweir aOtherBtn.Check(); 171*cdf0e10cSrcweir if(uOther) 172*cdf0e10cSrcweir aOtherEd.SetText(uOther); 173*cdf0e10cSrcweir break; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir if( bToTable ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir SetText( sConvertTextTable ); 180*cdf0e10cSrcweir aAutoFmtBtn.SetClickHdl(LINK(this, SwConvertTableDlg, AutoFmtHdl)); 181*cdf0e10cSrcweir aAutoFmtBtn.Show(); 182*cdf0e10cSrcweir aKeepColumn.Show(); 183*cdf0e10cSrcweir aKeepColumn.Enable( aTabBtn.IsChecked() ); 184*cdf0e10cSrcweir aRepeatHeaderCombo.Arrange( aRepeatHeaderFT ); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir else 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir //Einfuege-Optionen verstecken 189*cdf0e10cSrcweir aHeaderCB .Show(sal_False); 190*cdf0e10cSrcweir aRepeatHeaderCB .Show(sal_False); 191*cdf0e10cSrcweir aDontSplitCB .Show(sal_False); 192*cdf0e10cSrcweir aBorderCB .Show(sal_False); 193*cdf0e10cSrcweir aOptionsFL .Show(sal_False); 194*cdf0e10cSrcweir aRepeatHeaderCombo.Show(sal_False); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir //Groesse anpassen 197*cdf0e10cSrcweir Size aSize(GetSizePixel()); 198*cdf0e10cSrcweir aSize.Height() = 8 + aHelpBtn.GetSizePixel().Height() + aHelpBtn.GetPosPixel().Y(); 199*cdf0e10cSrcweir SetOutputSizePixel(aSize); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir aKeepColumn.SaveValue(); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir Link aLk( LINK(this, SwConvertTableDlg, BtnHdl) ); 204*cdf0e10cSrcweir aTabBtn.SetClickHdl( aLk ); 205*cdf0e10cSrcweir aSemiBtn.SetClickHdl( aLk ); 206*cdf0e10cSrcweir aParaBtn.SetClickHdl( aLk ); 207*cdf0e10cSrcweir aOtherBtn.SetClickHdl(aLk ); 208*cdf0e10cSrcweir aOtherEd.Enable( aOtherBtn.IsChecked() ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir sal_Bool bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir SwInsertTableOptions aInsOpts = pModOpt->GetInsTblFlags(bHTMLMode); 215*cdf0e10cSrcweir sal_uInt16 nInsTblFlags = aInsOpts.mnInsMode; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir aHeaderCB.Check( 0 != (nInsTblFlags & tabopts::HEADLINE) ); 218*cdf0e10cSrcweir aRepeatHeaderCB.Check(aInsOpts.mnRowsToRepeat > 0); 219*cdf0e10cSrcweir aDontSplitCB.Check( 0 == (nInsTblFlags & tabopts::SPLIT_LAYOUT)); 220*cdf0e10cSrcweir aBorderCB.Check( 0!= (nInsTblFlags & tabopts::DEFAULT_BORDER) ); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir aHeaderCB.SetClickHdl(LINK(this, SwConvertTableDlg, CheckBoxHdl)); 223*cdf0e10cSrcweir aRepeatHeaderCB.SetClickHdl(LINK(this, SwConvertTableDlg, ReapeatHeaderCheckBoxHdl)); 224*cdf0e10cSrcweir ReapeatHeaderCheckBoxHdl(); 225*cdf0e10cSrcweir CheckBoxHdl(); 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir SwConvertTableDlg:: ~SwConvertTableDlg() 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir delete pTAutoFmt; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir IMPL_LINK( SwConvertTableDlg, AutoFmtHdl, PushButton*, pButton ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = swui::GetFactory(); 236*cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton, pShell, DLG_AUTOFMT_TABLE, sal_False, pTAutoFmt); 239*cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 240*cdf0e10cSrcweir if( RET_OK == pDlg->Execute()) 241*cdf0e10cSrcweir pDlg->FillAutoFmtOfIndex( pTAutoFmt ); 242*cdf0e10cSrcweir delete pDlg; 243*cdf0e10cSrcweir return 0; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir IMPL_LINK( SwConvertTableDlg, BtnHdl, Button*, pButton ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir if( pButton == &aTabBtn ) 249*cdf0e10cSrcweir aKeepColumn.SetState( aKeepColumn.GetSavedValue() ); 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir if( aKeepColumn.IsEnabled() ) 253*cdf0e10cSrcweir aKeepColumn.SaveValue(); 254*cdf0e10cSrcweir aKeepColumn.Check( sal_True ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir aKeepColumn.Enable( aTabBtn.IsChecked() ); 257*cdf0e10cSrcweir aOtherEd.Enable( aOtherBtn.IsChecked() ); 258*cdf0e10cSrcweir return 0; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir /*********************************************************************/ 262*cdf0e10cSrcweir /* */ 263*cdf0e10cSrcweir /*********************************************************************/ 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir IMPL_LINK(SwConvertTableDlg, CheckBoxHdl, CheckBox*, EMPTYARG) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir aRepeatHeaderCB.Enable(aHeaderCB.IsChecked()); 268*cdf0e10cSrcweir ReapeatHeaderCheckBoxHdl(); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir return 0; 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir IMPL_LINK(SwConvertTableDlg, ReapeatHeaderCheckBoxHdl, void*, EMPTYARG) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir sal_Bool bEnable = aHeaderCB.IsChecked() && aRepeatHeaderCB.IsChecked(); 276*cdf0e10cSrcweir aRepeatHeaderBeforeFT.Enable(bEnable); 277*cdf0e10cSrcweir aRepeatHeaderAfterFT.Enable(bEnable); 278*cdf0e10cSrcweir aRepeatHeaderNF.Enable(bEnable); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir return 0; 281*cdf0e10cSrcweir } 282