LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/table - convert.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 116 0.0 %
Date: 2012-12-27 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 <svx/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().Len() )
      65             :     {
      66           0 :         uOther = mpOtherEd->GetText().GetChar( 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             : 
      82           0 :     sal_uInt16 nInsMode = 0;
      83           0 :     if (mpBorderCB->IsChecked())
      84           0 :         nInsMode |= tabopts::DEFAULT_BORDER;
      85           0 :     if (mpHeaderCB->IsChecked())
      86           0 :         nInsMode |= tabopts::HEADLINE;
      87           0 :     if (mpRepeatHeaderCB->IsEnabled() && mpRepeatHeaderCB->IsChecked())
      88           0 :         rInsTblOpts.mnRowsToRepeat = sal_uInt16( mpRepeatHeaderNF->GetValue() );
      89             :     else
      90           0 :         rInsTblOpts.mnRowsToRepeat = 0;
      91           0 :     if (!mpDontSplitCB->IsChecked())
      92           0 :         nInsMode |= tabopts::SPLIT_LAYOUT;
      93             : 
      94           0 :     if( pTAutoFmt )
      95           0 :         prTAFmt = new SwTableAutoFmt( *pTAutoFmt );
      96             : 
      97           0 :     rInsTblOpts.mnInsMode = nInsMode;
      98           0 : }
      99             : 
     100             : 
     101           0 : SwConvertTableDlg::SwConvertTableDlg( SwView& rView, bool bToTable )
     102           0 :     : SfxModalDialog(&rView.GetViewFrame()->GetWindow(), "ConvertTextTableDialog", "modules/swriter/ui/converttexttable.ui" )
     103             :     , sConvertTextTable(SW_RES(STR_CONVERT_TEXT_TABLE))
     104             :     , pTAutoFmt(0)
     105           0 :     , pShell(&rView.GetWrtShell())
     106             : {
     107           0 :     get(mpTabBtn, "tabs");
     108           0 :     get(mpSemiBtn, "semicolons");
     109           0 :     get(mpParaBtn, "paragraph");
     110           0 :     get(mpOtherBtn, "other");
     111           0 :     get(mpOtherEd, "othered");
     112           0 :     get(mpKeepColumn, "keepcolumn");
     113           0 :     get(mpOptions, "options");
     114           0 :     get(mpHeaderCB, "headingcb");
     115           0 :     get(mpRepeatHeaderCB, "repeatheading");
     116           0 :     get(mpRepeatRows, "repeatrows");
     117           0 :     get(mpRepeatHeaderNF, "repeatheadersb");
     118           0 :     get(mpDontSplitCB, "dontsplitcb");
     119           0 :     get(mpBorderCB, "bordercb");
     120           0 :     get(mpAutoFmtBtn, "autofmt");
     121             : 
     122           0 :     mpOtherEd->SetAccessibleName(String(SW_RES(STR_SYMBOL)));
     123           0 :     mpOtherEd->SetAccessibleRelationLabeledBy(mpOtherBtn);
     124             : 
     125           0 :     if(nSaveButtonState > -1)
     126             :     {
     127           0 :         switch (nSaveButtonState)
     128             :         {
     129             :             case 0:
     130           0 :                 mpTabBtn->Check();
     131           0 :                 mpKeepColumn->Check(bIsKeepColumn);
     132           0 :             break;
     133           0 :             case 1: mpSemiBtn->Check();break;
     134           0 :             case 2: mpParaBtn->Check();break;
     135             :             case 3:
     136           0 :                 mpOtherBtn->Check();
     137           0 :                 if(uOther)
     138           0 :                     mpOtherEd->SetText(rtl::OUString(uOther));
     139           0 :             break;
     140             :         }
     141             : 
     142             :     }
     143           0 :     if( bToTable )
     144             :     {
     145           0 :         SetText( sConvertTextTable );
     146           0 :         mpAutoFmtBtn->SetClickHdl(LINK(this, SwConvertTableDlg, AutoFmtHdl));
     147           0 :         mpAutoFmtBtn->Show();
     148           0 :         mpKeepColumn->Show();
     149           0 :         mpKeepColumn->Enable( mpTabBtn->IsChecked() );
     150             :     }
     151             :     else
     152             :     {
     153             :         //Einfuege-Optionen verstecken
     154           0 :         mpOptions->Hide();
     155             :     }
     156           0 :     mpKeepColumn->SaveValue();
     157             : 
     158           0 :     Link aLk( LINK(this, SwConvertTableDlg, BtnHdl) );
     159           0 :     mpTabBtn->SetClickHdl( aLk );
     160           0 :     mpSemiBtn->SetClickHdl( aLk );
     161           0 :     mpParaBtn->SetClickHdl( aLk );
     162           0 :     mpOtherBtn->SetClickHdl(aLk );
     163           0 :     mpOtherEd->Enable( mpOtherBtn->IsChecked() );
     164             : 
     165           0 :     const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
     166             : 
     167           0 :     sal_Bool bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON);
     168             : 
     169           0 :     SwInsertTableOptions aInsOpts = pModOpt->GetInsTblFlags(bHTMLMode);
     170           0 :     sal_uInt16 nInsTblFlags = aInsOpts.mnInsMode;
     171             : 
     172           0 :     mpHeaderCB->Check( 0 != (nInsTblFlags & tabopts::HEADLINE) );
     173           0 :     mpRepeatHeaderCB->Check(aInsOpts.mnRowsToRepeat > 0);
     174           0 :     mpDontSplitCB->Check( 0 == (nInsTblFlags & tabopts::SPLIT_LAYOUT));
     175           0 :     mpBorderCB->Check( 0!= (nInsTblFlags & tabopts::DEFAULT_BORDER) );
     176             : 
     177           0 :     mpHeaderCB->SetClickHdl(LINK(this, SwConvertTableDlg, CheckBoxHdl));
     178           0 :     mpRepeatHeaderCB->SetClickHdl(LINK(this, SwConvertTableDlg, ReapeatHeaderCheckBoxHdl));
     179           0 :     ReapeatHeaderCheckBoxHdl();
     180           0 :     CheckBoxHdl();
     181           0 : }
     182             : 
     183           0 : SwConvertTableDlg:: ~SwConvertTableDlg()
     184             : {
     185           0 :     delete pTAutoFmt;
     186           0 : }
     187             : 
     188           0 : IMPL_LINK( SwConvertTableDlg, AutoFmtHdl, PushButton*, pButton )
     189             : {
     190           0 :     SwAbstractDialogFactory* pFact = swui::GetFactory();
     191             :     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     192             : 
     193           0 :     AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton, pShell, sal_False, pTAutoFmt);
     194             :     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     195           0 :     if( RET_OK == pDlg->Execute())
     196           0 :         pDlg->FillAutoFmtOfIndex( pTAutoFmt );
     197           0 :     delete pDlg;
     198           0 :     return 0;
     199             : }
     200             : 
     201           0 : IMPL_LINK( SwConvertTableDlg, BtnHdl, Button*, pButton )
     202             : {
     203           0 :     if( pButton == mpTabBtn )
     204           0 :         mpKeepColumn->SetState( mpKeepColumn->GetSavedValue() );
     205             :     else
     206             :     {
     207           0 :         if( mpKeepColumn->IsEnabled() )
     208           0 :             mpKeepColumn->SaveValue();
     209           0 :         mpKeepColumn->Check( sal_True );
     210             :     }
     211           0 :     mpKeepColumn->Enable( mpTabBtn->IsChecked() );
     212           0 :     mpOtherEd->Enable( mpOtherBtn->IsChecked() );
     213           0 :     return 0;
     214             : }
     215             : 
     216           0 : IMPL_LINK_NOARG(SwConvertTableDlg, CheckBoxHdl)
     217             : {
     218           0 :     mpRepeatHeaderCB->Enable(mpHeaderCB->IsChecked());
     219           0 :     ReapeatHeaderCheckBoxHdl();
     220             : 
     221           0 :     return 0;
     222             : }
     223             : 
     224           0 : IMPL_LINK_NOARG(SwConvertTableDlg, ReapeatHeaderCheckBoxHdl)
     225             : {
     226           0 :     bool bEnable = mpHeaderCB->IsChecked() && mpRepeatHeaderCB->IsChecked();
     227           0 :     mpRepeatRows->Enable(bEnable);
     228           0 :     return 0;
     229           0 : }
     230             : 
     231             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10