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

Generated by: LCOV version 1.10