LCOV - code coverage report
Current view: top level - sw/source/ui/table - convert.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 131 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 15 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& rInsTableOpts,
      47             :                                     SwTableAutoFormat const*& prTAFormat )
      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 :         rInsTableOpts.mnRowsToRepeat = sal_uInt16( mpRepeatHeaderNF->GetValue() );
      85             :     else
      86           0 :         rInsTableOpts.mnRowsToRepeat = 0;
      87           0 :     if (!mpDontSplitCB->IsChecked())
      88           0 :         nInsMode |= tabopts::SPLIT_LAYOUT;
      89             : 
      90           0 :     if( pTAutoFormat )
      91           0 :         prTAFormat = new SwTableAutoFormat( *pTAutoFormat );
      92             : 
      93           0 :     rInsTableOpts.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             :     , pTAutoFormat(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(mpAutoFormatBtn, "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 :         mpAutoFormatBtn->SetClickHdl(LINK(this, SwConvertTableDlg, AutoFormatHdl));
     139           0 :         mpAutoFormatBtn->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->GetInsTableFlags(bHTMLMode);
     162           0 :     sal_uInt16 nInsTableFlags = aInsOpts.mnInsMode;
     163             : 
     164           0 :     mpHeaderCB->Check( 0 != (nInsTableFlags & tabopts::HEADLINE) );
     165           0 :     mpRepeatHeaderCB->Check(aInsOpts.mnRowsToRepeat > 0);
     166           0 :     mpDontSplitCB->Check( 0 == (nInsTableFlags & tabopts::SPLIT_LAYOUT));
     167           0 :     mpBorderCB->Check( 0!= (nInsTableFlags & 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 :     disposeOnce();
     178           0 : }
     179             : 
     180           0 : void SwConvertTableDlg::dispose()
     181             : {
     182           0 :     delete pTAutoFormat;
     183           0 :     mpTabBtn.clear();
     184           0 :     mpSemiBtn.clear();
     185           0 :     mpParaBtn.clear();
     186           0 :     mpOtherBtn.clear();
     187           0 :     mpOtherEd.clear();
     188           0 :     mpKeepColumn.clear();
     189           0 :     mpOptions.clear();
     190           0 :     mpHeaderCB.clear();
     191           0 :     mpRepeatHeaderCB.clear();
     192           0 :     mpRepeatRows.clear();
     193           0 :     mpRepeatHeaderNF.clear();
     194           0 :     mpDontSplitCB.clear();
     195           0 :     mpBorderCB.clear();
     196           0 :     mpAutoFormatBtn.clear();
     197           0 :     SfxModalDialog::dispose();
     198           0 : }
     199             : 
     200           0 : IMPL_LINK( SwConvertTableDlg, AutoFormatHdl, PushButton*, pButton )
     201             : {
     202           0 :     SwAbstractDialogFactory* pFact = swui::GetFactory();
     203             :     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     204             : 
     205           0 :     boost::scoped_ptr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton, pShell, false, pTAutoFormat));
     206             :     OSL_ENSURE(pDlg, "Dialog creation failed!");
     207           0 :     if( RET_OK == pDlg->Execute())
     208           0 :         pDlg->FillAutoFormatOfIndex( pTAutoFormat );
     209           0 :     return 0;
     210             : }
     211             : 
     212           0 : IMPL_LINK( SwConvertTableDlg, BtnHdl, Button*, pButton )
     213             : {
     214           0 :     if( pButton == mpTabBtn )
     215           0 :         mpKeepColumn->SetState( mpKeepColumn->GetSavedValue() );
     216             :     else
     217             :     {
     218           0 :         if( mpKeepColumn->IsEnabled() )
     219           0 :             mpKeepColumn->SaveValue();
     220           0 :         mpKeepColumn->Check( true );
     221             :     }
     222           0 :     mpKeepColumn->Enable( mpTabBtn->IsChecked() );
     223           0 :     mpOtherEd->Enable( mpOtherBtn->IsChecked() );
     224           0 :     return 0;
     225             : }
     226             : 
     227           0 : IMPL_LINK_NOARG(SwConvertTableDlg, CheckBoxHdl)
     228             : {
     229           0 :     mpRepeatHeaderCB->Enable(mpHeaderCB->IsChecked());
     230           0 :     ReapeatHeaderCheckBoxHdl();
     231             : 
     232           0 :     return 0;
     233             : }
     234             : 
     235           0 : IMPL_LINK_NOARG(SwConvertTableDlg, ReapeatHeaderCheckBoxHdl)
     236             : {
     237           0 :     bool bEnable = mpHeaderCB->IsChecked() && mpRepeatHeaderCB->IsChecked();
     238           0 :     mpRepeatRows->Enable(bEnable);
     239           0 :     return 0;
     240           0 : }
     241             : 
     242             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11