LCOV - code coverage report
Current view: top level - sw/source/ui/table - instable.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 113 0.0 %
Date: 2014-11-03 Functions: 0 20 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& rInsTblOpts, OUString& rAutoName,
      42             :                                 SwTableAutoFmt *& prTAFmt )
      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 :         rInsTblOpts.mnRowsToRepeat = sal_uInt16( m_pRepeatHeaderNF->GetValue() );
      55             :     else
      56           0 :         rInsTblOpts.mnRowsToRepeat = 0;
      57           0 :     if (!m_pDontSplitCB->IsChecked())
      58           0 :         nInsMode |= tabopts::SPLIT_LAYOUT;
      59           0 :     if( pTAutoFmt )
      60             :     {
      61           0 :         prTAFmt = new SwTableAutoFmt( *pTAutoFmt );
      62           0 :         rAutoName = prTAFmt->GetName();
      63             :     }
      64             : 
      65           0 :     rInsTblOpts.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             :     , pTAutoFmt(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_pAutoFmtBtn, "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->GetUniqueTblName());
      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_pAutoFmtBtn->SetClickHdl(LINK(this, SwInsTableDlg, AutoFmtHdl));
      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->GetInsTblFlags(bHTMLMode);
     103           0 :     sal_uInt16 nInsTblFlags = aInsOpts.mnInsMode;
     104             : 
     105           0 :     m_pHeaderCB->Check( 0 != (nInsTblFlags & 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 == (nInsTblFlags & tabopts::SPLIT_LAYOUT) );
     115             :     }
     116           0 :     m_pBorderCB->Check( 0 != (nInsTblFlags & 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 :     delete pTAutoFmt;
     141           0 : }
     142             : 
     143           0 : IMPL_LINK_INLINE_START( SwInsTableDlg, ModifyName, Edit *, pEdit )
     144             : {
     145           0 :     OUString sTblName = pEdit->GetText();
     146           0 :     if (sTblName.indexOf(' ') != -1)
     147             :     {
     148           0 :         sTblName = sTblName.replaceAll(" ", "");
     149           0 :         pEdit->SetText(sTblName);
     150             :     }
     151             : 
     152           0 :     m_pInsertBtn->Enable(pShell->GetTblStyle( sTblName ) == 0);
     153           0 :     return 0;
     154             : }
     155           0 : IMPL_LINK_INLINE_END( SwInsTableDlg, ModifyName, Edit *, pEdit )
     156             : 
     157           0 : IMPL_LINK( SwInsTableDlg, ModifyRowCol, NumericField *, pField )
     158             : {
     159           0 :     if(pField == m_pColNF)
     160             :     {
     161           0 :         sal_Int64 nCol = m_pColNF->GetValue();
     162           0 :         if(!nCol)
     163           0 :             nCol = 1;
     164           0 :         m_pRowNF->SetMax(ROW_COL_PROD/nCol);
     165             :     }
     166             :     else
     167             :     {
     168           0 :         sal_Int64 nRow = m_pRowNF->GetValue();
     169           0 :         if(!nRow)
     170           0 :             nRow = 1;
     171           0 :         m_pColNF->SetMax(ROW_COL_PROD/nRow);
     172             : 
     173             :         // adjust depending NF for repeated rows
     174           0 :         sal_Int64 nMax = ( nRow == 1 )? 1 : nRow - 1 ;
     175           0 :         sal_Int64 nActVal = m_pRepeatHeaderNF->GetValue();
     176             : 
     177           0 :         m_pRepeatHeaderNF->SetMax( nMax );
     178             : 
     179           0 :         if( nActVal > nMax )
     180           0 :             m_pRepeatHeaderNF->SetValue( nMax );
     181           0 :         else if( nActVal < nEnteredValRepeatHeaderNF )
     182           0 :             m_pRepeatHeaderNF->SetValue( ( nEnteredValRepeatHeaderNF < nMax )? nEnteredValRepeatHeaderNF : nMax );
     183             :     }
     184           0 :     return 0;
     185             : }
     186             : 
     187           0 : IMPL_LINK( SwInsTableDlg, AutoFmtHdl, PushButton*, pButton )
     188             : {
     189           0 :     SwAbstractDialogFactory* pFact = swui::GetFactory();
     190             :     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     191             : 
     192           0 :     boost::scoped_ptr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton,pShell, false, pTAutoFmt));
     193             :     OSL_ENSURE(pDlg, "Dialog creation failed!");
     194           0 :     if( RET_OK == pDlg->Execute())
     195           0 :         pDlg->FillAutoFmtOfIndex( pTAutoFmt );
     196           0 :     return 0;
     197             : }
     198             : 
     199           0 : IMPL_LINK_NOARG(SwInsTableDlg, CheckBoxHdl)
     200             : {
     201           0 :     m_pRepeatHeaderCB->Enable(m_pHeaderCB->IsChecked());
     202           0 :     ReapeatHeaderCheckBoxHdl();
     203             : 
     204           0 :     return 0;
     205             : }
     206             : 
     207           0 : IMPL_LINK_NOARG(SwInsTableDlg, ReapeatHeaderCheckBoxHdl)
     208             : {
     209           0 :     m_pRepeatGroup->Enable(m_pHeaderCB->IsChecked() && m_pRepeatHeaderCB->IsChecked());
     210             : 
     211           0 :     return 0;
     212             : }
     213             : 
     214           0 : IMPL_LINK_NOARG(SwInsTableDlg, ModifyRepeatHeaderNF_Hdl)
     215             : {
     216           0 :     nEnteredValRepeatHeaderNF = m_pRepeatHeaderNF->GetValue();
     217           0 :     return 0;
     218           0 : }
     219             : 
     220             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10