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

Generated by: LCOV version 1.10