LCOV - code coverage report
Current view: top level - sw/source/ui/table - convert.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 113 0.0 %
Date: 2014-11-03 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             : #include <boost/scoped_ptr.hpp>
      38             : #include <swuiexp.hxx>
      39             : 
      40             : //keep the state of the buttons on runtime
      41             : static int nSaveButtonState = -1; // 0: tab, 1: semicolon, 2: paragraph, 3: other, -1: not yet used
      42             : static bool bIsKeepColumn = true;
      43             : static sal_Unicode uOther = ',';
      44             : 
      45           0 : void SwConvertTableDlg::GetValues(  sal_Unicode& rDelim,
      46             :                                     SwInsertTableOptions& rInsTblOpts,
      47             :                                     SwTableAutoFmt const*& prTAFmt )
      48             : {
      49           0 :     if( mpTabBtn->IsChecked() )
      50             :     {
      51             :         //0x0b mustn't be set when re-converting table into text
      52           0 :         bIsKeepColumn = !mpKeepColumn->IsVisible() || mpKeepColumn->IsChecked();
      53           0 :         rDelim = bIsKeepColumn ? 0x09 : 0x0b;
      54           0 :         nSaveButtonState = 0;
      55             :     }
      56           0 :     else if( mpSemiBtn->IsChecked() )
      57             :     {
      58           0 :         rDelim = ';';
      59           0 :         nSaveButtonState = 1;
      60             :     }
      61           0 :     else if( mpOtherBtn->IsChecked() && !mpOtherEd->GetText().isEmpty() )
      62             :     {
      63           0 :         uOther = mpOtherEd->GetText()[0];
      64           0 :         rDelim = uOther;
      65           0 :         nSaveButtonState = 3;
      66             :     }
      67             :     else
      68             :     {
      69           0 :         nSaveButtonState = 2;
      70           0 :         rDelim = cParaDelim;
      71           0 :         if(mpOtherBtn->IsChecked())
      72             :         {
      73           0 :             nSaveButtonState = 3;
      74           0 :             uOther = 0;
      75             :         }
      76             :     }
      77             : 
      78           0 :     sal_uInt16 nInsMode = 0;
      79           0 :     if (mpBorderCB->IsChecked())
      80           0 :         nInsMode |= tabopts::DEFAULT_BORDER;
      81           0 :     if (mpHeaderCB->IsChecked())
      82           0 :         nInsMode |= tabopts::HEADLINE;
      83           0 :     if (mpRepeatHeaderCB->IsEnabled() && mpRepeatHeaderCB->IsChecked())
      84           0 :         rInsTblOpts.mnRowsToRepeat = sal_uInt16( mpRepeatHeaderNF->GetValue() );
      85             :     else
      86           0 :         rInsTblOpts.mnRowsToRepeat = 0;
      87           0 :     if (!mpDontSplitCB->IsChecked())
      88           0 :         nInsMode |= tabopts::SPLIT_LAYOUT;
      89             : 
      90           0 :     if( pTAutoFmt )
      91           0 :         prTAFmt = new SwTableAutoFmt( *pTAutoFmt );
      92             : 
      93           0 :     rInsTblOpts.mnInsMode = nInsMode;
      94           0 : }
      95             : 
      96           0 : SwConvertTableDlg::SwConvertTableDlg( SwView& rView, bool bToTable )
      97           0 :     : SfxModalDialog(&rView.GetViewFrame()->GetWindow(), "ConvertTextTableDialog", "modules/swriter/ui/converttexttable.ui" )
      98             :     , sConvertTextTable(SW_RES(STR_CONVERT_TEXT_TABLE))
      99             :     , pTAutoFmt(0)
     100           0 :     , pShell(&rView.GetWrtShell())
     101             : {
     102           0 :     get(mpTabBtn, "tabs");
     103           0 :     get(mpSemiBtn, "semicolons");
     104           0 :     get(mpParaBtn, "paragraph");
     105           0 :     get(mpOtherBtn, "other");
     106           0 :     get(mpOtherEd, "othered");
     107           0 :     get(mpKeepColumn, "keepcolumn");
     108           0 :     get(mpOptions, "options");
     109           0 :     get(mpHeaderCB, "headingcb");
     110           0 :     get(mpRepeatHeaderCB, "repeatheading");
     111           0 :     get(mpRepeatRows, "repeatrows");
     112           0 :     get(mpRepeatHeaderNF, "repeatheadersb");
     113           0 :     get(mpDontSplitCB, "dontsplitcb");
     114           0 :     get(mpBorderCB, "bordercb");
     115           0 :     get(mpAutoFmtBtn, "autofmt");
     116             : 
     117           0 :     if(nSaveButtonState > -1)
     118             :     {
     119           0 :         switch (nSaveButtonState)
     120             :         {
     121             :             case 0:
     122           0 :                 mpTabBtn->Check();
     123           0 :                 mpKeepColumn->Check(bIsKeepColumn);
     124           0 :             break;
     125           0 :             case 1: mpSemiBtn->Check();break;
     126           0 :             case 2: mpParaBtn->Check();break;
     127             :             case 3:
     128           0 :                 mpOtherBtn->Check();
     129           0 :                 if(uOther)
     130           0 :                     mpOtherEd->SetText(OUString(uOther));
     131           0 :             break;
     132             :         }
     133             : 
     134             :     }
     135           0 :     if( bToTable )
     136             :     {
     137           0 :         SetText( sConvertTextTable );
     138           0 :         mpAutoFmtBtn->SetClickHdl(LINK(this, SwConvertTableDlg, AutoFmtHdl));
     139           0 :         mpAutoFmtBtn->Show();
     140           0 :         mpKeepColumn->Show();
     141           0 :         mpKeepColumn->Enable( mpTabBtn->IsChecked() );
     142             :     }
     143             :     else
     144             :     {
     145             :         //hide insert options
     146           0 :         mpOptions->Hide();
     147             :     }
     148           0 :     mpKeepColumn->SaveValue();
     149             : 
     150           0 :     Link aLk( LINK(this, SwConvertTableDlg, BtnHdl) );
     151           0 :     mpTabBtn->SetClickHdl( aLk );
     152           0 :     mpSemiBtn->SetClickHdl( aLk );
     153           0 :     mpParaBtn->SetClickHdl( aLk );
     154           0 :     mpOtherBtn->SetClickHdl(aLk );
     155           0 :     mpOtherEd->Enable( mpOtherBtn->IsChecked() );
     156             : 
     157           0 :     const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
     158             : 
     159           0 :     bool bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON);
     160             : 
     161           0 :     SwInsertTableOptions aInsOpts = pModOpt->GetInsTblFlags(bHTMLMode);
     162           0 :     sal_uInt16 nInsTblFlags = aInsOpts.mnInsMode;
     163             : 
     164           0 :     mpHeaderCB->Check( 0 != (nInsTblFlags & tabopts::HEADLINE) );
     165           0 :     mpRepeatHeaderCB->Check(aInsOpts.mnRowsToRepeat > 0);
     166           0 :     mpDontSplitCB->Check( 0 == (nInsTblFlags & tabopts::SPLIT_LAYOUT));
     167           0 :     mpBorderCB->Check( 0!= (nInsTblFlags & tabopts::DEFAULT_BORDER) );
     168             : 
     169           0 :     mpHeaderCB->SetClickHdl(LINK(this, SwConvertTableDlg, CheckBoxHdl));
     170           0 :     mpRepeatHeaderCB->SetClickHdl(LINK(this, SwConvertTableDlg, ReapeatHeaderCheckBoxHdl));
     171           0 :     ReapeatHeaderCheckBoxHdl();
     172           0 :     CheckBoxHdl();
     173           0 : }
     174             : 
     175           0 : SwConvertTableDlg:: ~SwConvertTableDlg()
     176             : {
     177           0 :     delete pTAutoFmt;
     178           0 : }
     179             : 
     180           0 : IMPL_LINK( SwConvertTableDlg, AutoFmtHdl, PushButton*, pButton )
     181             : {
     182           0 :     SwAbstractDialogFactory* pFact = swui::GetFactory();
     183             :     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     184             : 
     185           0 :     boost::scoped_ptr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton, pShell, false, pTAutoFmt));
     186             :     OSL_ENSURE(pDlg, "Dialog creation failed!");
     187           0 :     if( RET_OK == pDlg->Execute())
     188           0 :         pDlg->FillAutoFmtOfIndex( pTAutoFmt );
     189           0 :     return 0;
     190             : }
     191             : 
     192           0 : IMPL_LINK( SwConvertTableDlg, BtnHdl, Button*, pButton )
     193             : {
     194           0 :     if( pButton == mpTabBtn )
     195           0 :         mpKeepColumn->SetState( mpKeepColumn->GetSavedValue() );
     196             :     else
     197             :     {
     198           0 :         if( mpKeepColumn->IsEnabled() )
     199           0 :             mpKeepColumn->SaveValue();
     200           0 :         mpKeepColumn->Check( true );
     201             :     }
     202           0 :     mpKeepColumn->Enable( mpTabBtn->IsChecked() );
     203           0 :     mpOtherEd->Enable( mpOtherBtn->IsChecked() );
     204           0 :     return 0;
     205             : }
     206             : 
     207           0 : IMPL_LINK_NOARG(SwConvertTableDlg, CheckBoxHdl)
     208             : {
     209           0 :     mpRepeatHeaderCB->Enable(mpHeaderCB->IsChecked());
     210           0 :     ReapeatHeaderCheckBoxHdl();
     211             : 
     212           0 :     return 0;
     213             : }
     214             : 
     215           0 : IMPL_LINK_NOARG(SwConvertTableDlg, ReapeatHeaderCheckBoxHdl)
     216             : {
     217           0 :     bool bEnable = mpHeaderCB->IsChecked() && mpRepeatHeaderCB->IsChecked();
     218           0 :     mpRepeatRows->Enable(bEnable);
     219           0 :     return 0;
     220           0 : }
     221             : 
     222             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10