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