LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/miscdlgs - inscodlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 178 0.0 %
Date: 2012-12-27 Functions: 0 16 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             : 
      21             : #undef SC_DLLIMPLEMENTATION
      22             : 
      23             : 
      24             : 
      25             : //------------------------------------------------------------------
      26             : 
      27             : #include "inscodlg.hxx"
      28             : #include "scresid.hxx"
      29             : #include "miscdlgs.hrc"
      30             : 
      31             : 
      32             : //==================================================================
      33             : 
      34             : sal_Bool   ScInsertContentsDlg::bPreviousAllCheck = sal_True;
      35             : sal_uInt16 ScInsertContentsDlg::nPreviousChecks   = (IDF_DATETIME | IDF_STRING  |
      36             :                                                  IDF_NOTE     | IDF_FORMULA |
      37             :                                                  IDF_ATTRIB   | IDF_OBJECTS);
      38             : sal_uInt16 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
      39             : sal_uInt16 ScInsertContentsDlg::nPreviousChecks2 = 0;
      40             : sal_uInt16 ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;   // enum InsCellCmd
      41             : 
      42             : //-----------------------------------------------------------------------
      43             : 
      44           0 : ScInsertContentsDlg::ScInsertContentsDlg( Window*       pParent,
      45             :                                           sal_uInt16        nCheckDefaults,
      46             :                                           const String* pStrTitle )
      47             : 
      48             :  :  ModalDialog     ( pParent, ScResId( RID_SCDLG_INSCONT ) ),
      49             :     //
      50             :     aFlFrame        ( this, ScResId( FL_FRAME ) ),
      51             :     aBtnInsAll      ( this, ScResId( BTN_INSALL ) ),
      52             :     aBtnInsStrings  ( this, ScResId( BTN_INSSTRINGS ) ),
      53             :     aBtnInsNumbers  ( this, ScResId( BTN_INSNUMBERS ) ),
      54             :     aBtnInsDateTime ( this, ScResId( BTN_INSDATETIME ) ),
      55             :     aBtnInsFormulas ( this, ScResId( BTN_INSFORMULAS ) ),
      56             :     aBtnInsNotes    ( this, ScResId( BTN_INSNOTES ) ),
      57             :     aBtnInsAttrs    ( this, ScResId( BTN_INSATTRS ) ),
      58             :     aBtnInsObjects  ( this, ScResId( BTN_INSOBJECTS ) ),
      59             :     aFlSep1         ( this, ScResId( FL_SEP1 ) ),
      60             :     aFlOptions      ( this, ScResId( FL_OPTIONS ) ),
      61             :     aBtnSkipEmptyCells( this, ScResId(BTN_SKIP_EMPTY ) ),
      62             :     aBtnTranspose   ( this, ScResId( BTN_TRANSPOSE ) ),
      63             :     aBtnLink        ( this, ScResId( BTN_LINK ) ),
      64             :     aFlOperation    ( this, ScResId( FL_OPERATION ) ),
      65             :     aRbNoOp         ( this, ScResId( BTN_OP_NOOP ) ),
      66             :     aRbAdd          ( this, ScResId( BTN_OP_ADD ) ),
      67             :     aRbSub          ( this, ScResId( BTN_OP_SUB  ) ),
      68             :     aRbMul          ( this, ScResId( BTN_OP_MUL  ) ),
      69             :     aRbDiv          ( this, ScResId( BTN_OP_DIV  ) ),
      70             :     aFlSep2         ( this, ScResId( FL_SEP2 ) ),
      71             :     aFlMove         ( this, ScResId( FL_MOVE ) ),
      72             :     aRbMoveNone     ( this, ScResId( BTN_MV_NONE ) ),
      73             :     aRbMoveDown     ( this, ScResId( BTN_MV_DOWN ) ),
      74             :     aRbMoveRight    ( this, ScResId( BTN_MV_RIGHT ) ),
      75             :     aBtnOk          ( this, ScResId( BTN_OK ) ),
      76             :     aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
      77             :     aBtnHelp        ( this, ScResId( BTN_HELP ) ),
      78             :     bOtherDoc       ( false ),
      79             :     bFillMode       ( false ),
      80             :     bChangeTrack    ( false ),
      81             :     bMoveDownDisabled( false ),
      82           0 :     bMoveRightDisabled( false )
      83             : {
      84           0 :     if ( pStrTitle )
      85           0 :         SetText( *pStrTitle );
      86             : 
      87           0 :     if ( nCheckDefaults != 0 )
      88             :     {
      89           0 :         ScInsertContentsDlg::nPreviousChecks = nCheckDefaults;
      90           0 :         ScInsertContentsDlg::bPreviousAllCheck = false;
      91           0 :         ScInsertContentsDlg::nPreviousChecks2 = 0;
      92             :     }
      93             : 
      94           0 :     aBtnInsAll.Check     ( ScInsertContentsDlg::bPreviousAllCheck );
      95             :     aBtnInsStrings.Check ( IS_SET( IDF_STRING,
      96           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      97             :     aBtnInsNumbers.Check ( IS_SET( IDF_VALUE,
      98           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      99             :     aBtnInsDateTime.Check( IS_SET( IDF_DATETIME,
     100           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
     101             :     aBtnInsFormulas.Check( IS_SET( IDF_FORMULA,
     102           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
     103             :     aBtnInsNotes.Check   ( IS_SET( IDF_NOTE,
     104           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
     105             :     aBtnInsAttrs.Check   ( IS_SET( IDF_ATTRIB,
     106           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
     107             :     aBtnInsObjects.Check ( IS_SET( IDF_OBJECTS,
     108           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
     109             : 
     110           0 :     switch( ScInsertContentsDlg::nPreviousFormulaChecks )
     111             :     {
     112           0 :         case PASTE_NOFUNC: aRbNoOp.Check(sal_True); break;
     113           0 :         case PASTE_ADD:    aRbAdd.Check(sal_True); break;
     114           0 :         case PASTE_SUB:    aRbSub.Check(sal_True); break;
     115           0 :         case PASTE_MUL:    aRbMul.Check(sal_True); break;
     116           0 :         case PASTE_DIV:    aRbDiv.Check(sal_True); break;
     117             :     }
     118             : 
     119           0 :     switch( ScInsertContentsDlg::nPreviousMoveMode )
     120             :     {
     121           0 :         case INS_NONE:       aRbMoveNone.Check(sal_True); break;
     122           0 :         case INS_CELLSDOWN:  aRbMoveDown.Check(sal_True); break;
     123           0 :         case INS_CELLSRIGHT: aRbMoveRight.Check(sal_True); break;
     124             :     }
     125             : 
     126           0 :     aBtnSkipEmptyCells.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_NOEMPTY ) != 0);
     127           0 :     aBtnTranspose.Check( ( ScInsertContentsDlg::nPreviousChecks2    & INS_CONT_TRANS ) != 0);
     128           0 :     aBtnLink.Check( ( ScInsertContentsDlg::nPreviousChecks2             & INS_CONT_LINK  ) != 0);
     129             : 
     130           0 :     DisableChecks( aBtnInsAll.IsChecked() );
     131             : 
     132           0 :     aFlSep1.SetStyle( aFlSep1.GetStyle() | WB_VERT );
     133           0 :     aFlSep2.SetStyle( aFlSep2.GetStyle() | WB_VERT );
     134             : 
     135           0 :     aBtnInsAll.SetClickHdl( LINK( this, ScInsertContentsDlg, InsAllHdl ) );
     136           0 :     aBtnLink.SetClickHdl( LINK( this, ScInsertContentsDlg, LinkBtnHdl ) );
     137             : 
     138             :     //-------------
     139           0 :     FreeResource();
     140           0 : }
     141             : 
     142             : //------------------------------------------------------------------------
     143             : 
     144           0 : sal_uInt16 ScInsertContentsDlg::GetInsContentsCmdBits() const
     145             : {
     146           0 :     ScInsertContentsDlg::nPreviousChecks = 0;
     147             : 
     148           0 :     if ( aBtnInsStrings.IsChecked() )
     149           0 :         ScInsertContentsDlg::nPreviousChecks = IDF_STRING;
     150           0 :     if ( aBtnInsNumbers.IsChecked() )
     151           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_VALUE;
     152           0 :     if ( aBtnInsDateTime.IsChecked())
     153           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_DATETIME;
     154           0 :     if ( aBtnInsFormulas.IsChecked())
     155           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_FORMULA;
     156           0 :     if ( aBtnInsNotes.IsChecked()   )
     157           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_NOTE;
     158           0 :     if ( aBtnInsAttrs.IsChecked()   )
     159           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_ATTRIB;
     160           0 :     if ( aBtnInsObjects.IsChecked() )
     161           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_OBJECTS;
     162             : 
     163           0 :     ScInsertContentsDlg::bPreviousAllCheck = aBtnInsAll.IsChecked();
     164             : 
     165             :     return ( (ScInsertContentsDlg::bPreviousAllCheck)
     166             :                 ? IDF_ALL
     167           0 :                 : ScInsertContentsDlg::nPreviousChecks );
     168             : }
     169             : 
     170             : //------------------------------------------------------------------------
     171             : 
     172           0 : InsCellCmd ScInsertContentsDlg::GetMoveMode()
     173             : {
     174           0 :     if ( aRbMoveDown.IsChecked() )
     175           0 :         return INS_CELLSDOWN;
     176           0 :     if ( aRbMoveRight.IsChecked() )
     177           0 :         return INS_CELLSRIGHT;
     178             : 
     179           0 :     return INS_NONE;
     180             : }
     181             : 
     182             : //------------------------------------------------------------------------
     183             : 
     184           0 : void ScInsertContentsDlg::DisableChecks( sal_Bool bInsAllChecked )
     185             : {
     186           0 :     if ( bInsAllChecked )
     187             :     {
     188           0 :         aBtnInsStrings.Disable();
     189           0 :         aBtnInsNumbers.Disable();
     190           0 :         aBtnInsDateTime.Disable();
     191           0 :         aBtnInsFormulas.Disable();
     192           0 :         aBtnInsNotes.Disable();
     193           0 :         aBtnInsAttrs.Disable();
     194           0 :         aBtnInsObjects.Disable();
     195             :     }
     196             :     else
     197             :     {
     198           0 :         aBtnInsStrings.Enable();
     199           0 :         aBtnInsNumbers.Enable();
     200           0 :         aBtnInsDateTime.Enable();
     201           0 :         aBtnInsFormulas.Enable();
     202           0 :         aBtnInsNotes.Enable();
     203           0 :         aBtnInsAttrs.Enable();
     204             : 
     205             :         //  "Objects" is disabled for "Fill Tables"
     206           0 :         if ( bFillMode )
     207           0 :             aBtnInsObjects.Disable();
     208             :         else
     209           0 :             aBtnInsObjects.Enable();
     210             :     }
     211           0 : }
     212             : 
     213             : // Link in anderes Dokument -> alles andere disabled
     214             : 
     215           0 : void ScInsertContentsDlg::TestModes()
     216             : {
     217           0 :     if ( bOtherDoc && aBtnLink.IsChecked() )
     218             :     {
     219           0 :         aBtnSkipEmptyCells.Disable();
     220           0 :         aBtnTranspose.Disable();
     221           0 :         aRbNoOp.Disable();
     222           0 :         aRbAdd.Disable();
     223           0 :         aRbSub.Disable();
     224           0 :         aRbMul.Disable();
     225           0 :         aRbDiv.Disable();
     226           0 :         aFlOperation.Disable();
     227             : 
     228           0 :         aRbMoveNone.Disable();
     229           0 :         aRbMoveDown.Disable();
     230           0 :         aRbMoveRight.Disable();
     231           0 :         aFlMove.Disable();
     232             : 
     233           0 :         aFlFrame.Disable();
     234           0 :         aBtnInsAll.Disable();
     235           0 :         DisableChecks(sal_True);
     236             :     }
     237             :     else
     238             :     {
     239           0 :         aBtnSkipEmptyCells.Enable();
     240           0 :         aBtnTranspose.Enable(!bFillMode);
     241           0 :         aRbNoOp.Enable();
     242           0 :         aRbAdd.Enable();
     243           0 :         aRbSub.Enable();
     244           0 :         aRbMul.Enable();
     245           0 :         aRbDiv.Enable();
     246           0 :         aFlOperation.Enable();
     247             : 
     248           0 :         aRbMoveNone.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
     249           0 :         aRbMoveDown.Enable(!bFillMode && !bChangeTrack && !bMoveDownDisabled);
     250           0 :         aRbMoveRight.Enable(!bFillMode && !bChangeTrack && !bMoveRightDisabled);
     251           0 :         aFlMove.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
     252             : 
     253           0 :         aFlFrame.Enable();
     254           0 :         aBtnInsAll.Enable();
     255           0 :         DisableChecks( aBtnInsAll.IsChecked() );
     256             :     }
     257           0 : }
     258             : 
     259           0 : void ScInsertContentsDlg::SetOtherDoc( sal_Bool bSet )
     260             : {
     261           0 :     if ( bSet != bOtherDoc )
     262             :     {
     263           0 :         bOtherDoc = bSet;
     264           0 :         TestModes();
     265           0 :         if ( bSet )
     266           0 :             aRbMoveNone.Check(sal_True);
     267             :     }
     268           0 : }
     269             : 
     270           0 : void ScInsertContentsDlg::SetFillMode( sal_Bool bSet )
     271             : {
     272           0 :     if ( bSet != bFillMode )
     273             :     {
     274           0 :         bFillMode = bSet;
     275           0 :         TestModes();
     276           0 :         if ( bSet )
     277           0 :             aRbMoveNone.Check(sal_True);
     278             :     }
     279           0 : }
     280             : 
     281           0 : void ScInsertContentsDlg::SetChangeTrack( sal_Bool bSet )
     282             : {
     283           0 :     if ( bSet != bChangeTrack )
     284             :     {
     285           0 :         bChangeTrack = bSet;
     286           0 :         TestModes();
     287           0 :         if ( bSet )
     288           0 :             aRbMoveNone.Check(sal_True);
     289             :     }
     290           0 : }
     291             : 
     292           0 : void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable )
     293             : {
     294           0 :     sal_Bool bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0);
     295           0 :     sal_Bool bRight = ((nDisable & SC_CELL_SHIFT_DISABLE_RIGHT) != 0);
     296           0 :     if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
     297             :     {
     298           0 :         bMoveDownDisabled = bDown;
     299           0 :         bMoveRightDisabled = bRight;
     300           0 :         TestModes();
     301           0 :         if ( bMoveDownDisabled && aRbMoveDown.IsChecked() )
     302           0 :             aRbMoveNone.Check(sal_True);
     303           0 :         if ( bMoveRightDisabled && aRbMoveRight.IsChecked() )
     304           0 :             aRbMoveNone.Check(sal_True);
     305             :     }
     306           0 : }
     307             : 
     308             : 
     309             : //------------------------------------------------------------------------
     310             : 
     311           0 : IMPL_LINK_NOARG(ScInsertContentsDlg, InsAllHdl)
     312             : {
     313           0 :     DisableChecks( aBtnInsAll.IsChecked() );
     314             : 
     315           0 :     return 0;
     316             : }
     317             : 
     318           0 : IMPL_LINK_NOARG(ScInsertContentsDlg, LinkBtnHdl)
     319             : {
     320           0 :     TestModes();
     321             : 
     322           0 :     return 0;
     323             : }
     324             : 
     325           0 : ScInsertContentsDlg::~ScInsertContentsDlg()
     326             : {
     327           0 :     ScInsertContentsDlg::nPreviousChecks2 = 0;
     328           0 :     if(aBtnSkipEmptyCells.IsChecked())
     329           0 :         ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_NOEMPTY;
     330           0 :     if( aBtnTranspose.IsChecked())
     331           0 :         ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_TRANS;
     332           0 :     if( aBtnLink.IsChecked() )
     333           0 :         ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_LINK;
     334             : 
     335           0 :     if (!bFillMode)     // im FillMode ist None gecheckt und alle 3 disabled
     336             :     {
     337           0 :         if ( aRbMoveNone.IsChecked() )
     338           0 :             ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;
     339           0 :         else if ( aRbMoveDown.IsChecked() )
     340           0 :             ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSDOWN;
     341           0 :         else if ( aRbMoveRight.IsChecked() )
     342           0 :             ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSRIGHT;
     343             :     }
     344           0 : }
     345             : 
     346           0 : sal_uInt16  ScInsertContentsDlg::GetFormulaCmdBits() const
     347             : {
     348           0 :     ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
     349           0 :     if(aRbAdd.IsChecked())
     350           0 :         ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_ADD;
     351           0 :     else if(aRbSub.IsChecked())
     352           0 :         ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_SUB;
     353           0 :     else if(aRbMul.IsChecked())
     354           0 :         ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_MUL;
     355           0 :     else if(aRbDiv.IsChecked())
     356           0 :         ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_DIV;
     357             :     // Bits fuer Checkboxen ausblenden
     358           0 :     return ScInsertContentsDlg::nPreviousFormulaChecks;
     359             : }
     360             : 
     361             : 
     362             : 
     363             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10