LCOV - code coverage report
Current view: top level - sw/source/ui/table - instable.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 127 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 21 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             : 
      22             : #include "wrtsh.hxx"
      23             : #include "view.hxx"
      24             : #include "itabenum.hxx"
      25             : #include "instable.hxx"
      26             : #include "tblafmt.hxx"
      27             : #include "modcfg.hxx"
      28             : #include "swmodule.hxx"
      29             : #include <sfx2/htmlmode.hxx>
      30             : #include <viewopt.hxx>
      31             : 
      32             : #include "table.hrc"
      33             : 
      34             : #include "swabstdlg.hxx"
      35             : #include <boost/scoped_ptr.hpp>
      36             : #include <swuiexp.hxx>
      37             : 
      38             : #define ROW_COL_PROD 16384
      39             : 
      40           0 : void SwInsTableDlg::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
      41             :                                 SwInsertTableOptions& rInsTableOpts, OUString& rAutoName,
      42             :                                 SwTableAutoFormat *& prTAFormat )
      43             : {
      44           0 :     sal_uInt16 nInsMode = 0;
      45           0 :     rName = m_pNameEdit->GetText();
      46           0 :     rRow = (sal_uInt16)m_pRowNF->GetValue();
      47           0 :     rCol = (sal_uInt16)m_pColNF->GetValue();
      48             : 
      49           0 :     if (m_pBorderCB->IsChecked())
      50           0 :         nInsMode |= tabopts::DEFAULT_BORDER;
      51           0 :     if (m_pHeaderCB->IsChecked())
      52           0 :         nInsMode |= tabopts::HEADLINE;
      53           0 :     if (m_pRepeatHeaderCB->IsEnabled() && m_pRepeatHeaderCB->IsChecked())
      54           0 :         rInsTableOpts.mnRowsToRepeat = sal_uInt16( m_pRepeatHeaderNF->GetValue() );
      55             :     else
      56           0 :         rInsTableOpts.mnRowsToRepeat = 0;
      57           0 :     if (!m_pDontSplitCB->IsChecked())
      58           0 :         nInsMode |= tabopts::SPLIT_LAYOUT;
      59           0 :     if( pTAutoFormat )
      60             :     {
      61           0 :         prTAFormat = new SwTableAutoFormat( *pTAutoFormat );
      62           0 :         rAutoName = prTAFormat->GetName();
      63             :     }
      64             : 
      65           0 :     rInsTableOpts.mnInsMode = nInsMode;
      66           0 : }
      67             : 
      68           0 : SwInsTableDlg::SwInsTableDlg( SwView& rView )
      69             :     : SfxModalDialog(rView.GetWindow(), "InsertTableDialog", "modules/swriter/ui/inserttable.ui")
      70             :     , m_aTextFilter(" .<>")
      71           0 :     , pShell(&rView.GetWrtShell())
      72             :     , pTAutoFormat(0)
      73           0 :     , nEnteredValRepeatHeaderNF(-1)
      74             : {
      75           0 :     get(m_pNameEdit, "nameedit");
      76           0 :     m_pNameEdit->SetTextFilter(&m_aTextFilter);
      77           0 :     get(m_pColNF, "colspin");
      78           0 :     get(m_pRowNF, "rowspin");
      79           0 :     get(m_pHeaderCB, "headercb");
      80           0 :     get(m_pRepeatHeaderCB, "repeatcb");
      81           0 :     get(m_pDontSplitCB, "dontsplitcb");
      82           0 :     get(m_pBorderCB, "bordercb");
      83           0 :     get(m_pAutoFormatBtn, "autoformat");
      84           0 :     get(m_pInsertBtn, "ok");
      85           0 :     get(m_pRepeatGroup, "repeatgroup");
      86           0 :     get(m_pRepeatHeaderNF, "repeatheaderspin");
      87             : 
      88           0 :     m_pNameEdit->SetText(pShell->GetUniqueTableName());
      89           0 :     m_pNameEdit->SetModifyHdl(LINK(this, SwInsTableDlg, ModifyName));
      90           0 :     m_pColNF->SetModifyHdl(LINK(this, SwInsTableDlg, ModifyRowCol));
      91           0 :     m_pRowNF->SetModifyHdl(LINK(this, SwInsTableDlg, ModifyRowCol));
      92             : 
      93           0 :     m_pRowNF->SetMax(ROW_COL_PROD/m_pColNF->GetValue());
      94           0 :     m_pColNF->SetMax(ROW_COL_PROD/m_pRowNF->GetValue());
      95           0 :     m_pAutoFormatBtn->SetClickHdl(LINK(this, SwInsTableDlg, AutoFormatHdl));
      96             : 
      97           0 :     m_pInsertBtn->SetClickHdl(LINK(this, SwInsTableDlg, OKHdl));
      98             : 
      99           0 :     bool bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON);
     100           0 :     const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
     101             : 
     102           0 :     SwInsertTableOptions aInsOpts = pModOpt->GetInsTableFlags(bHTMLMode);
     103           0 :     sal_uInt16 nInsTableFlags = aInsOpts.mnInsMode;
     104             : 
     105           0 :     m_pHeaderCB->Check( 0 != (nInsTableFlags & tabopts::HEADLINE) );
     106           0 :     m_pRepeatHeaderCB->Check(aInsOpts.mnRowsToRepeat > 0);
     107           0 :     if(bHTMLMode)
     108             :     {
     109           0 :         m_pDontSplitCB->Hide();
     110           0 :         m_pBorderCB->SetPosPixel(m_pDontSplitCB->GetPosPixel());
     111             :     }
     112             :     else
     113             :     {
     114           0 :         m_pDontSplitCB->Check( 0 == (nInsTableFlags & tabopts::SPLIT_LAYOUT) );
     115             :     }
     116           0 :     m_pBorderCB->Check( 0 != (nInsTableFlags & tabopts::DEFAULT_BORDER) );
     117             : 
     118           0 :     m_pRepeatHeaderNF->SetModifyHdl( LINK( this, SwInsTableDlg, ModifyRepeatHeaderNF_Hdl ) );
     119           0 :     m_pHeaderCB->SetClickHdl(LINK(this, SwInsTableDlg, CheckBoxHdl));
     120           0 :     m_pRepeatHeaderCB->SetClickHdl(LINK(this, SwInsTableDlg, ReapeatHeaderCheckBoxHdl));
     121           0 :     ReapeatHeaderCheckBoxHdl();
     122           0 :     CheckBoxHdl();
     123             : 
     124           0 :     sal_Int64 nMax = m_pRowNF->GetValue();
     125           0 :     if( nMax <= 1 )
     126           0 :         nMax = 1;
     127             :     else
     128           0 :         --nMax;
     129           0 :     m_pRepeatHeaderNF->SetMax( nMax );
     130           0 : }
     131             : 
     132           0 : IMPL_LINK_NOARG(SwInsTableDlg, OKHdl)
     133             : {
     134           0 :     EndDialog(RET_OK);
     135           0 :     return 0;
     136             : }
     137             : 
     138           0 : SwInsTableDlg::~SwInsTableDlg()
     139             : {
     140           0 :     disposeOnce();
     141           0 : }
     142             : 
     143           0 : void SwInsTableDlg::dispose()
     144             : {
     145           0 :     delete pTAutoFormat;
     146           0 :     m_pNameEdit.clear();
     147           0 :     m_pColNF.clear();
     148           0 :     m_pRowNF.clear();
     149           0 :     m_pHeaderCB.clear();
     150           0 :     m_pRepeatHeaderCB.clear();
     151           0 :     m_pRepeatHeaderNF.clear();
     152           0 :     m_pRepeatGroup.clear();
     153           0 :     m_pDontSplitCB.clear();
     154           0 :     m_pBorderCB.clear();
     155           0 :     m_pInsertBtn.clear();
     156           0 :     m_pAutoFormatBtn.clear();
     157           0 :     SfxModalDialog::dispose();
     158           0 : }
     159             : 
     160           0 : IMPL_LINK( SwInsTableDlg, ModifyName, Edit *, pEdit )
     161             : {
     162           0 :     OUString sTableName = pEdit->GetText();
     163           0 :     if (sTableName.indexOf(' ') != -1)
     164             :     {
     165           0 :         sTableName = sTableName.replaceAll(" ", "");
     166           0 :         pEdit->SetText(sTableName);
     167             :     }
     168             : 
     169           0 :     m_pInsertBtn->Enable(pShell->GetTableStyle( sTableName ) == 0);
     170           0 :     return 0;
     171             : }
     172             : 
     173           0 : IMPL_LINK( SwInsTableDlg, ModifyRowCol, NumericField *, pField )
     174             : {
     175           0 :     if(pField == m_pColNF)
     176             :     {
     177           0 :         sal_Int64 nCol = m_pColNF->GetValue();
     178           0 :         if(!nCol)
     179           0 :             nCol = 1;
     180           0 :         m_pRowNF->SetMax(ROW_COL_PROD/nCol);
     181             :     }
     182             :     else
     183             :     {
     184           0 :         sal_Int64 nRow = m_pRowNF->GetValue();
     185           0 :         if(!nRow)
     186           0 :             nRow = 1;
     187           0 :         m_pColNF->SetMax(ROW_COL_PROD/nRow);
     188             : 
     189             :         // adjust depending NF for repeated rows
     190           0 :         sal_Int64 nMax = ( nRow == 1 )? 1 : nRow - 1 ;
     191           0 :         sal_Int64 nActVal = m_pRepeatHeaderNF->GetValue();
     192             : 
     193           0 :         m_pRepeatHeaderNF->SetMax( nMax );
     194             : 
     195           0 :         if( nActVal > nMax )
     196           0 :             m_pRepeatHeaderNF->SetValue( nMax );
     197           0 :         else if( nActVal < nEnteredValRepeatHeaderNF )
     198           0 :             m_pRepeatHeaderNF->SetValue( ( nEnteredValRepeatHeaderNF < nMax )? nEnteredValRepeatHeaderNF : nMax );
     199             :     }
     200           0 :     return 0;
     201             : }
     202             : 
     203           0 : IMPL_LINK( SwInsTableDlg, AutoFormatHdl, PushButton*, pButton )
     204             : {
     205           0 :     SwAbstractDialogFactory* pFact = swui::GetFactory();
     206             :     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     207             : 
     208           0 :     boost::scoped_ptr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton,pShell, false, pTAutoFormat));
     209             :     OSL_ENSURE(pDlg, "Dialog creation failed!");
     210           0 :     if( RET_OK == pDlg->Execute())
     211           0 :         pDlg->FillAutoFormatOfIndex( pTAutoFormat );
     212           0 :     return 0;
     213             : }
     214             : 
     215           0 : IMPL_LINK_NOARG(SwInsTableDlg, CheckBoxHdl)
     216             : {
     217           0 :     m_pRepeatHeaderCB->Enable(m_pHeaderCB->IsChecked());
     218           0 :     ReapeatHeaderCheckBoxHdl();
     219             : 
     220           0 :     return 0;
     221             : }
     222             : 
     223           0 : IMPL_LINK_NOARG(SwInsTableDlg, ReapeatHeaderCheckBoxHdl)
     224             : {
     225           0 :     m_pRepeatGroup->Enable(m_pHeaderCB->IsChecked() && m_pRepeatHeaderCB->IsChecked());
     226             : 
     227           0 :     return 0;
     228             : }
     229             : 
     230           0 : IMPL_LINK_NOARG(SwInsTableDlg, ModifyRepeatHeaderNF_Hdl)
     231             : {
     232           0 :     nEnteredValRepeatHeaderNF = m_pRepeatHeaderNF->GetValue();
     233           0 :     return 0;
     234           0 : }
     235             : 
     236             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11