LCOV - code coverage report
Current view: top level - sw/source/ui/table - convert.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 113 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10