LCOV - code coverage report
Current view: top level - sw/source/ui/table - convert.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 114 0.0 %
Date: 2014-04-14 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <vcl/msgbox.hxx>
      21             : #include <svl/stritem.hxx>
      22             : #include <sfx2/viewfrm.hxx>
      23             : #include <modcfg.hxx>
      24             : #include <sfx2/htmlmode.hxx>
      25             : #include <viewopt.hxx>
      26             : #include "swmodule.hxx"
      27             : #include "cmdid.h"
      28             : #include "convert.hxx"
      29             : #include "tablemgr.hxx"
      30             : #include "wrtsh.hxx"
      31             : #include "view.hxx"
      32             : #include "tblafmt.hxx"
      33             : 
      34             : #include "app.hrc"
      35             : #include "table.hrc"
      36             : #include "swabstdlg.hxx"
      37             : 
      38             : namespace swui
      39             : {
      40             :     SwAbstractDialogFactory * GetFactory();
      41             : }
      42             : 
      43             : //keep the state of the buttons on runtime
      44             : static int nSaveButtonState = -1; // 0: tab, 1: semicolon, 2: paragraph, 3: other, -1: not yet used
      45             : static sal_Bool bIsKeepColumn = sal_True;
      46             : static sal_Unicode uOther = ',';
      47             : 
      48           0 : void SwConvertTableDlg::GetValues(  sal_Unicode& rDelim,
      49             :                                     SwInsertTableOptions& rInsTblOpts,
      50             :                                     SwTableAutoFmt const*& prTAFmt )
      51             : {
      52           0 :     if( mpTabBtn->IsChecked() )
      53             :     {
      54             :         //0x0b mustn't be set when re-converting table into text
      55           0 :         bIsKeepColumn = !mpKeepColumn->IsVisible() || mpKeepColumn->IsChecked();
      56           0 :         rDelim = bIsKeepColumn ? 0x09 : 0x0b;
      57           0 :         nSaveButtonState = 0;
      58             :     }
      59           0 :     else if( mpSemiBtn->IsChecked() )
      60             :     {
      61           0 :         rDelim = ';';
      62           0 :         nSaveButtonState = 1;
      63             :     }
      64           0 :     else if( mpOtherBtn->IsChecked() && !mpOtherEd->GetText().isEmpty() )
      65             :     {
      66           0 :         uOther = mpOtherEd->GetText()[0];
      67           0 :         rDelim = uOther;
      68           0 :         nSaveButtonState = 3;
      69             :     }
      70             :     else
      71             :     {
      72           0 :         nSaveButtonState = 2;
      73           0 :         rDelim = cParaDelim;
      74           0 :         if(mpOtherBtn->IsChecked())
      75             :         {
      76           0 :             nSaveButtonState = 3;
      77           0 :             uOther = 0;
      78             :         }
      79             :     }
      80             : 
      81           0 :     sal_uInt16 nInsMode = 0;
      82           0 :     if (mpBorderCB->IsChecked())
      83           0 :         nInsMode |= tabopts::DEFAULT_BORDER;
      84           0 :     if (mpHeaderCB->IsChecked())
      85           0 :         nInsMode |= tabopts::HEADLINE;
      86           0 :     if (mpRepeatHeaderCB->IsEnabled() && mpRepeatHeaderCB->IsChecked())
      87           0 :         rInsTblOpts.mnRowsToRepeat = sal_uInt16( mpRepeatHeaderNF->GetValue() );
      88             :     else
      89           0 :         rInsTblOpts.mnRowsToRepeat = 0;
      90           0 :     if (!mpDontSplitCB->IsChecked())
      91           0 :         nInsMode |= tabopts::SPLIT_LAYOUT;
      92             : 
      93           0 :     if( pTAutoFmt )
      94           0 :         prTAFmt = new SwTableAutoFmt( *pTAutoFmt );
      95             : 
      96           0 :     rInsTblOpts.mnInsMode = nInsMode;
      97           0 : }
      98             : 
      99           0 : SwConvertTableDlg::SwConvertTableDlg( SwView& rView, bool bToTable )
     100           0 :     : SfxModalDialog(&rView.GetViewFrame()->GetWindow(), "ConvertTextTableDialog", "modules/swriter/ui/converttexttable.ui" )
     101             :     , sConvertTextTable(SW_RES(STR_CONVERT_TEXT_TABLE))
     102             :     , pTAutoFmt(0)
     103           0 :     , pShell(&rView.GetWrtShell())
     104             : {
     105           0 :     get(mpTabBtn, "tabs");
     106           0 :     get(mpSemiBtn, "semicolons");
     107           0 :     get(mpParaBtn, "paragraph");
     108           0 :     get(mpOtherBtn, "other");
     109           0 :     get(mpOtherEd, "othered");
     110           0 :     get(mpKeepColumn, "keepcolumn");
     111           0 :     get(mpOptions, "options");
     112           0 :     get(mpHeaderCB, "headingcb");
     113           0 :     get(mpRepeatHeaderCB, "repeatheading");
     114           0 :     get(mpRepeatRows, "repeatrows");
     115           0 :     get(mpRepeatHeaderNF, "repeatheadersb");
     116           0 :     get(mpDontSplitCB, "dontsplitcb");
     117           0 :     get(mpBorderCB, "bordercb");
     118           0 :     get(mpAutoFmtBtn, "autofmt");
     119             : 
     120           0 :     if(nSaveButtonState > -1)
     121             :     {
     122           0 :         switch (nSaveButtonState)
     123             :         {
     124             :             case 0:
     125           0 :                 mpTabBtn->Check();
     126           0 :                 mpKeepColumn->Check(bIsKeepColumn);
     127           0 :             break;
     128           0 :             case 1: mpSemiBtn->Check();break;
     129           0 :             case 2: mpParaBtn->Check();break;
     130             :             case 3:
     131           0 :                 mpOtherBtn->Check();
     132           0 :                 if(uOther)
     133           0 :                     mpOtherEd->SetText(OUString(uOther));
     134           0 :             break;
     135             :         }
     136             : 
     137             :     }
     138           0 :     if( bToTable )
     139             :     {
     140           0 :         SetText( sConvertTextTable );
     141           0 :         mpAutoFmtBtn->SetClickHdl(LINK(this, SwConvertTableDlg, AutoFmtHdl));
     142           0 :         mpAutoFmtBtn->Show();
     143           0 :         mpKeepColumn->Show();
     144           0 :         mpKeepColumn->Enable( mpTabBtn->IsChecked() );
     145             :     }
     146             :     else
     147             :     {
     148             :         //hide insert options
     149           0 :         mpOptions->Hide();
     150             :     }
     151           0 :     mpKeepColumn->SaveValue();
     152             : 
     153           0 :     Link aLk( LINK(this, SwConvertTableDlg, BtnHdl) );
     154           0 :     mpTabBtn->SetClickHdl( aLk );
     155           0 :     mpSemiBtn->SetClickHdl( aLk );
     156           0 :     mpParaBtn->SetClickHdl( aLk );
     157           0 :     mpOtherBtn->SetClickHdl(aLk );
     158           0 :     mpOtherEd->Enable( mpOtherBtn->IsChecked() );
     159             : 
     160           0 :     const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
     161             : 
     162           0 :     sal_Bool bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON);
     163             : 
     164           0 :     SwInsertTableOptions aInsOpts = pModOpt->GetInsTblFlags(bHTMLMode);
     165           0 :     sal_uInt16 nInsTblFlags = aInsOpts.mnInsMode;
     166             : 
     167           0 :     mpHeaderCB->Check( 0 != (nInsTblFlags & tabopts::HEADLINE) );
     168           0 :     mpRepeatHeaderCB->Check(aInsOpts.mnRowsToRepeat > 0);
     169           0 :     mpDontSplitCB->Check( 0 == (nInsTblFlags & tabopts::SPLIT_LAYOUT));
     170           0 :     mpBorderCB->Check( 0!= (nInsTblFlags & tabopts::DEFAULT_BORDER) );
     171             : 
     172           0 :     mpHeaderCB->SetClickHdl(LINK(this, SwConvertTableDlg, CheckBoxHdl));
     173           0 :     mpRepeatHeaderCB->SetClickHdl(LINK(this, SwConvertTableDlg, ReapeatHeaderCheckBoxHdl));
     174           0 :     ReapeatHeaderCheckBoxHdl();
     175           0 :     CheckBoxHdl();
     176           0 : }
     177             : 
     178           0 : SwConvertTableDlg:: ~SwConvertTableDlg()
     179             : {
     180           0 :     delete pTAutoFmt;
     181           0 : }
     182             : 
     183           0 : IMPL_LINK( SwConvertTableDlg, AutoFmtHdl, PushButton*, pButton )
     184             : {
     185           0 :     SwAbstractDialogFactory* pFact = swui::GetFactory();
     186             :     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     187             : 
     188           0 :     AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton, pShell, sal_False, pTAutoFmt);
     189             :     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     190           0 :     if( RET_OK == pDlg->Execute())
     191           0 :         pDlg->FillAutoFmtOfIndex( pTAutoFmt );
     192           0 :     delete pDlg;
     193           0 :     return 0;
     194             : }
     195             : 
     196           0 : IMPL_LINK( SwConvertTableDlg, BtnHdl, Button*, pButton )
     197             : {
     198           0 :     if( pButton == mpTabBtn )
     199           0 :         mpKeepColumn->SetState( mpKeepColumn->GetSavedValue() );
     200             :     else
     201             :     {
     202           0 :         if( mpKeepColumn->IsEnabled() )
     203           0 :             mpKeepColumn->SaveValue();
     204           0 :         mpKeepColumn->Check( true );
     205             :     }
     206           0 :     mpKeepColumn->Enable( mpTabBtn->IsChecked() );
     207           0 :     mpOtherEd->Enable( mpOtherBtn->IsChecked() );
     208           0 :     return 0;
     209             : }
     210             : 
     211           0 : IMPL_LINK_NOARG(SwConvertTableDlg, CheckBoxHdl)
     212             : {
     213           0 :     mpRepeatHeaderCB->Enable(mpHeaderCB->IsChecked());
     214           0 :     ReapeatHeaderCheckBoxHdl();
     215             : 
     216           0 :     return 0;
     217             : }
     218             : 
     219           0 : IMPL_LINK_NOARG(SwConvertTableDlg, ReapeatHeaderCheckBoxHdl)
     220             : {
     221           0 :     bool bEnable = mpHeaderCB->IsChecked() && mpRepeatHeaderCB->IsChecked();
     222           0 :     mpRepeatRows->Enable(bEnable);
     223           0 :     return 0;
     224           0 : }
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10