LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - inscodlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 276 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 24 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             : #undef SC_DLLIMPLEMENTATION
      21             : 
      22             : #include "inscodlg.hxx"
      23             : #include "scresid.hxx"
      24             : #include "miscdlgs.hrc"
      25             : 
      26             : bool       ScInsertContentsDlg::bPreviousAllCheck = false;
      27           0 : InsertDeleteFlags ScInsertContentsDlg::nPreviousChecks   = (IDF_VALUE | IDF_DATETIME | IDF_STRING);
      28             : sal_uInt16 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
      29             : sal_uInt16 ScInsertContentsDlg::nPreviousChecks2 = 0;
      30             : sal_uInt16 ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;   // enum InsCellCmd
      31             : 
      32           0 : ScInsertContentsDlg::ScInsertContentsDlg( vcl::Window*       pParent,
      33             :                                           InsertDeleteFlags nCheckDefaults,
      34             :                                           const OUString* pStrTitle )
      35             : 
      36             :  :  ModalDialog     ( pParent, "PasteSpecial", "modules/scalc/ui/pastespecial.ui" ),
      37             :     bOtherDoc       ( false ),
      38             :     bFillMode       ( false ),
      39             :     bChangeTrack    ( false ),
      40             :     bMoveDownDisabled( false ),
      41             :     bMoveRightDisabled( false ),
      42             :     bUsedShortCut   ( false ),
      43             :     nShortCutInsContentsCmdBits( IDF_NONE ),
      44             :     nShortCutFormulaCmdBits(0),
      45             :     bShortCutSkipEmptyCells(false),
      46             :     bShortCutTranspose(false),
      47             :     bShortCutIsLink(false),
      48           0 :     nShortCutMoveMode(INS_NONE)
      49             : {
      50           0 :     get( mpBtnInsAll, "paste_all" );
      51           0 :     get( mpBtnInsStrings, "text" );
      52           0 :     get( mpBtnInsNumbers, "numbers" );
      53           0 :     get( mpBtnInsDateTime, "datetime" );
      54           0 :     get( mpBtnInsFormulas, "formulas" );
      55           0 :     get( mpBtnInsNotes, "comments" );
      56           0 :     get( mpBtnInsAttrs, "formats" );
      57           0 :     get( mpBtnInsObjects, "objects" );
      58           0 :     get( mpBtnSkipEmptyCells, "skip_empty" );
      59           0 :     get( mpBtnTranspose, "transpose" );
      60           0 :     get( mpBtnLink, "link" );
      61           0 :     get( mpRbNoOp, "none" );
      62           0 :     get( mpRbAdd, "add" );
      63           0 :     get( mpRbSub, "subtract" );
      64           0 :     get( mpRbMul, "multiply" );
      65           0 :     get( mpRbDiv, "divide" );
      66           0 :     get( mpRbMoveNone, "no_shift" );
      67           0 :     get( mpRbMoveDown, "move_down" );
      68           0 :     get( mpRbMoveRight, "move_right" );
      69           0 :     get( mpBtnShortCutPasteValuesOnly, "paste_values_only");
      70           0 :     get( mpBtnShortCutPasteValuesFormats, "paste_values_formats");
      71           0 :     get( mpBtnShortCutPasteTranspose, "paste_transpose");
      72             : 
      73           0 :     if ( pStrTitle )
      74           0 :         SetText( *pStrTitle );
      75             : 
      76           0 :     if ( nCheckDefaults != IDF_NONE )
      77             :     {
      78           0 :         ScInsertContentsDlg::nPreviousChecks = nCheckDefaults;
      79           0 :         ScInsertContentsDlg::bPreviousAllCheck = false;
      80           0 :         ScInsertContentsDlg::nPreviousChecks2 = 0;
      81             :     }
      82             : 
      83           0 :     mpBtnInsAll->Check     ( ScInsertContentsDlg::bPreviousAllCheck );
      84           0 :     mpBtnInsStrings->Check ( IS_SET( IDF_STRING,
      85           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      86           0 :     mpBtnInsNumbers->Check ( IS_SET( IDF_VALUE,
      87           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      88           0 :     mpBtnInsDateTime->Check( IS_SET( IDF_DATETIME,
      89           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      90           0 :     mpBtnInsFormulas->Check( IS_SET( IDF_FORMULA,
      91           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      92           0 :     mpBtnInsNotes->Check   ( IS_SET( IDF_NOTE,
      93           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      94           0 :     mpBtnInsAttrs->Check   ( IS_SET( IDF_ATTRIB,
      95           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      96           0 :     mpBtnInsObjects->Check ( IS_SET( IDF_OBJECTS,
      97           0 :                                    ScInsertContentsDlg::nPreviousChecks ) );
      98             : 
      99           0 :     switch( ScInsertContentsDlg::nPreviousFormulaChecks )
     100             :     {
     101           0 :         case PASTE_NOFUNC: mpRbNoOp->Check(true); break;
     102           0 :         case PASTE_ADD:    mpRbAdd->Check(true); break;
     103           0 :         case PASTE_SUB:    mpRbSub->Check(true); break;
     104           0 :         case PASTE_MUL:    mpRbMul->Check(true); break;
     105           0 :         case PASTE_DIV:    mpRbDiv->Check(true); break;
     106             :     }
     107             : 
     108           0 :     switch( ScInsertContentsDlg::nPreviousMoveMode )
     109             :     {
     110           0 :         case INS_NONE:       mpRbMoveNone->Check(true); break;
     111           0 :         case INS_CELLSDOWN:  mpRbMoveDown->Check(true); break;
     112           0 :         case INS_CELLSRIGHT: mpRbMoveRight->Check(true); break;
     113             :     }
     114             : 
     115           0 :     mpBtnSkipEmptyCells->Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_NOEMPTY ) != 0);
     116           0 :     mpBtnTranspose->Check( ( ScInsertContentsDlg::nPreviousChecks2    & INS_CONT_TRANS ) != 0);
     117           0 :     mpBtnLink->Check( ( ScInsertContentsDlg::nPreviousChecks2             & INS_CONT_LINK  ) != 0);
     118             : 
     119           0 :     DisableChecks( mpBtnInsAll->IsChecked() );
     120             : 
     121           0 :     mpBtnInsAll->SetClickHdl( LINK( this, ScInsertContentsDlg, InsAllHdl ) );
     122           0 :     mpBtnLink->SetClickHdl( LINK( this, ScInsertContentsDlg, LinkBtnHdl ) );
     123             : 
     124           0 :     mpBtnShortCutPasteValuesOnly->SetClickHdl( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );;
     125           0 :     mpBtnShortCutPasteValuesFormats->SetClickHdl( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );;
     126           0 :     mpBtnShortCutPasteTranspose->SetClickHdl( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );
     127           0 : }
     128             : 
     129           0 : InsertDeleteFlags ScInsertContentsDlg::GetInsContentsCmdBits() const
     130             : {
     131           0 :     ScInsertContentsDlg::nPreviousChecks = IDF_NONE;
     132             : 
     133           0 :     if ( mpBtnInsStrings->IsChecked() )
     134           0 :         ScInsertContentsDlg::nPreviousChecks = IDF_STRING;
     135           0 :     if ( mpBtnInsNumbers->IsChecked() )
     136           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_VALUE;
     137           0 :     if ( mpBtnInsDateTime->IsChecked())
     138           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_DATETIME;
     139           0 :     if ( mpBtnInsFormulas->IsChecked())
     140           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_FORMULA;
     141           0 :     if ( mpBtnInsNotes->IsChecked()   )
     142           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_NOTE;
     143           0 :     if ( mpBtnInsAttrs->IsChecked()   )
     144           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_ATTRIB;
     145           0 :     if ( mpBtnInsObjects->IsChecked() )
     146           0 :         ScInsertContentsDlg::nPreviousChecks |= IDF_OBJECTS;
     147             : 
     148           0 :     ScInsertContentsDlg::bPreviousAllCheck = mpBtnInsAll->IsChecked();
     149             : 
     150           0 :     if (bUsedShortCut)
     151           0 :         return nShortCutInsContentsCmdBits;
     152             : 
     153             :     return ( (ScInsertContentsDlg::bPreviousAllCheck)
     154             :                 ? IDF_ALL
     155           0 :                 : ScInsertContentsDlg::nPreviousChecks );
     156             : }
     157             : 
     158           0 : InsCellCmd ScInsertContentsDlg::GetMoveMode()
     159             : {
     160           0 :     if (bUsedShortCut)
     161           0 :         return nShortCutMoveMode;
     162           0 :     if ( mpRbMoveDown->IsChecked() )
     163           0 :         return INS_CELLSDOWN;
     164           0 :     if ( mpRbMoveRight->IsChecked() )
     165           0 :         return INS_CELLSRIGHT;
     166             : 
     167           0 :     return INS_NONE;
     168             : }
     169             : 
     170           0 : bool ScInsertContentsDlg::IsSkipEmptyCells() const
     171             : {
     172           0 :     if (bUsedShortCut)
     173           0 :         return bShortCutSkipEmptyCells;
     174           0 :     return mpBtnSkipEmptyCells->IsChecked();
     175             : }
     176             : 
     177           0 : bool ScInsertContentsDlg::IsTranspose() const
     178             : {
     179           0 :     if (bUsedShortCut)
     180           0 :         return bShortCutTranspose;
     181           0 :     return mpBtnTranspose->IsChecked();
     182             : }
     183             : 
     184           0 : bool ScInsertContentsDlg::IsLink() const
     185             : {
     186           0 :     if (bUsedShortCut)
     187           0 :         return bShortCutIsLink;
     188           0 :     return mpBtnLink->IsChecked();
     189             : }
     190             : 
     191           0 : void ScInsertContentsDlg::DisableChecks( bool bInsAllChecked )
     192             : {
     193           0 :     if ( bInsAllChecked )
     194             :     {
     195           0 :         mpBtnInsStrings->Disable();
     196           0 :         mpBtnInsNumbers->Disable();
     197           0 :         mpBtnInsDateTime->Disable();
     198           0 :         mpBtnInsFormulas->Disable();
     199           0 :         mpBtnInsNotes->Disable();
     200           0 :         mpBtnInsAttrs->Disable();
     201           0 :         mpBtnInsObjects->Disable();
     202             :     }
     203             :     else
     204             :     {
     205           0 :         mpBtnInsStrings->Enable();
     206           0 :         mpBtnInsNumbers->Enable();
     207           0 :         mpBtnInsDateTime->Enable();
     208           0 :         mpBtnInsFormulas->Enable();
     209           0 :         mpBtnInsNotes->Enable();
     210           0 :         mpBtnInsAttrs->Enable();
     211             : 
     212             :         //  "Objects" is disabled for "Fill Tables"
     213           0 :         if ( bFillMode )
     214           0 :             mpBtnInsObjects->Disable();
     215             :         else
     216           0 :             mpBtnInsObjects->Enable();
     217             :     }
     218           0 : }
     219             : 
     220             : // Link to other document -> everything else is disabled
     221             : 
     222           0 : void ScInsertContentsDlg::TestModes()
     223             : {
     224           0 :     if ( bOtherDoc && mpBtnLink->IsChecked() )
     225             :     {
     226           0 :         mpBtnSkipEmptyCells->Disable();
     227           0 :         mpBtnTranspose->Disable();
     228           0 :         mpRbNoOp->Disable();
     229           0 :         mpRbAdd->Disable();
     230           0 :         mpRbSub->Disable();
     231           0 :         mpRbMul->Disable();
     232           0 :         mpRbDiv->Disable();
     233             : 
     234           0 :         mpRbMoveNone->Disable();
     235           0 :         mpRbMoveDown->Disable();
     236           0 :         mpRbMoveRight->Disable();
     237             : 
     238           0 :         mpBtnInsAll->Disable();
     239           0 :         DisableChecks(true);
     240             :     }
     241             :     else
     242             :     {
     243           0 :         mpBtnSkipEmptyCells->Enable();
     244           0 :         mpBtnTranspose->Enable(!bFillMode);
     245           0 :         mpRbNoOp->Enable();
     246           0 :         mpRbAdd->Enable();
     247           0 :         mpRbSub->Enable();
     248           0 :         mpRbMul->Enable();
     249           0 :         mpRbDiv->Enable();
     250             : 
     251           0 :         mpRbMoveNone->Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
     252           0 :         mpRbMoveDown->Enable(!bFillMode && !bChangeTrack && !bMoveDownDisabled);
     253           0 :         mpRbMoveRight->Enable(!bFillMode && !bChangeTrack && !bMoveRightDisabled);
     254             : 
     255           0 :         mpBtnInsAll->Enable();
     256           0 :         DisableChecks( mpBtnInsAll->IsChecked() );
     257             :     }
     258           0 : }
     259             : 
     260           0 : void ScInsertContentsDlg::SetOtherDoc( bool bSet )
     261             : {
     262           0 :     if ( bSet != bOtherDoc )
     263             :     {
     264           0 :         bOtherDoc = bSet;
     265           0 :         TestModes();
     266           0 :         if ( bSet )
     267           0 :             mpRbMoveNone->Check(true);
     268             :     }
     269           0 : }
     270             : 
     271           0 : void ScInsertContentsDlg::SetFillMode( bool bSet )
     272             : {
     273           0 :     if ( bSet != bFillMode )
     274             :     {
     275           0 :         bFillMode = bSet;
     276           0 :         TestModes();
     277           0 :         if ( bSet )
     278           0 :             mpRbMoveNone->Check(true);
     279             :     }
     280           0 : }
     281             : 
     282           0 : void ScInsertContentsDlg::SetChangeTrack( bool bSet )
     283             : {
     284           0 :     if ( bSet != bChangeTrack )
     285             :     {
     286           0 :         bChangeTrack = bSet;
     287           0 :         TestModes();
     288           0 :         if ( bSet )
     289           0 :             mpRbMoveNone->Check(true);
     290             :     }
     291           0 : }
     292             : 
     293           0 : void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable )
     294             : {
     295           0 :     bool bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0);
     296           0 :     bool bRight = ((nDisable & SC_CELL_SHIFT_DISABLE_RIGHT) != 0);
     297           0 :     if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
     298             :     {
     299           0 :         bMoveDownDisabled = bDown;
     300           0 :         bMoveRightDisabled = bRight;
     301           0 :         TestModes();
     302           0 :         if ( bMoveDownDisabled && mpRbMoveDown->IsChecked() )
     303           0 :             mpRbMoveNone->Check(true);
     304           0 :         if ( bMoveRightDisabled && mpRbMoveRight->IsChecked() )
     305           0 :             mpRbMoveNone->Check(true);
     306             :     }
     307           0 : }
     308             : 
     309           0 : IMPL_LINK( ScInsertContentsDlg, ShortCutHdl, PushButton*, pBtn )
     310             : {
     311           0 :     if ( pBtn == mpBtnShortCutPasteValuesOnly )
     312             :     {
     313           0 :         bUsedShortCut = true;
     314           0 :         nShortCutInsContentsCmdBits = IDF_STRING | IDF_VALUE | IDF_DATETIME;
     315           0 :         nShortCutFormulaCmdBits = PASTE_NOFUNC;
     316           0 :         bShortCutSkipEmptyCells = false;
     317           0 :         bShortCutTranspose = false;
     318           0 :         bShortCutIsLink = false;
     319           0 :         nShortCutMoveMode = INS_NONE;
     320           0 :         EndDialog(RET_OK);
     321             :     }
     322           0 :     else if ( pBtn == mpBtnShortCutPasteValuesFormats )
     323             :     {
     324           0 :         bUsedShortCut = true;
     325           0 :         nShortCutInsContentsCmdBits = IDF_STRING | IDF_VALUE | IDF_DATETIME | IDF_ATTRIB;
     326           0 :         nShortCutFormulaCmdBits = PASTE_NOFUNC;
     327           0 :         bShortCutSkipEmptyCells = false;
     328           0 :         bShortCutTranspose = false;
     329           0 :         bShortCutIsLink = false;
     330           0 :         nShortCutMoveMode = INS_NONE;
     331           0 :         EndDialog(RET_OK);
     332             :     }
     333           0 :     else if ( pBtn == mpBtnShortCutPasteTranspose )
     334             :     {
     335           0 :         bUsedShortCut = true;
     336           0 :         nShortCutInsContentsCmdBits = IDF_ALL;
     337           0 :         nShortCutFormulaCmdBits = PASTE_NOFUNC;
     338           0 :         bShortCutSkipEmptyCells = false;
     339           0 :         bShortCutTranspose = true;
     340           0 :         bShortCutIsLink = false;
     341           0 :         nShortCutMoveMode = INS_NONE;
     342           0 :         EndDialog(RET_OK);
     343             :     }
     344           0 :     return 0;
     345             : }
     346             : 
     347             : 
     348           0 : IMPL_LINK_NOARG(ScInsertContentsDlg, InsAllHdl)
     349             : {
     350           0 :     DisableChecks( mpBtnInsAll->IsChecked() );
     351             : 
     352           0 :     return 0;
     353             : }
     354             : 
     355           0 : IMPL_LINK_NOARG(ScInsertContentsDlg, LinkBtnHdl)
     356             : {
     357           0 :     TestModes();
     358             : 
     359           0 :     return 0;
     360             : }
     361             : 
     362           0 : ScInsertContentsDlg::~ScInsertContentsDlg()
     363             : {
     364           0 :     disposeOnce();
     365           0 : }
     366             : 
     367           0 : void ScInsertContentsDlg::dispose()
     368             : {
     369           0 :     ScInsertContentsDlg::nPreviousChecks2 = 0;
     370           0 :     if(mpBtnSkipEmptyCells->IsChecked())
     371           0 :         ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_NOEMPTY;
     372           0 :     if( mpBtnTranspose->IsChecked())
     373           0 :         ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_TRANS;
     374           0 :     if( mpBtnLink->IsChecked() )
     375           0 :         ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_LINK;
     376             : 
     377           0 :     if (!bFillMode)     // in FillMode, None is checked and all three options are disabled
     378             :     {
     379           0 :         if ( mpRbMoveNone->IsChecked() )
     380           0 :             ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;
     381           0 :         else if ( mpRbMoveDown->IsChecked() )
     382           0 :             ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSDOWN;
     383           0 :         else if ( mpRbMoveRight->IsChecked() )
     384           0 :             ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSRIGHT;
     385             :     }
     386           0 :     mpBtnInsAll.clear();
     387           0 :     mpBtnInsStrings.clear();
     388           0 :     mpBtnInsNumbers.clear();
     389           0 :     mpBtnInsDateTime.clear();
     390           0 :     mpBtnInsFormulas.clear();
     391           0 :     mpBtnInsNotes.clear();
     392           0 :     mpBtnInsAttrs.clear();
     393           0 :     mpBtnInsObjects.clear();
     394           0 :     mpBtnSkipEmptyCells.clear();
     395           0 :     mpBtnTranspose.clear();
     396           0 :     mpBtnLink.clear();
     397           0 :     mpRbNoOp.clear();
     398           0 :     mpRbAdd.clear();
     399           0 :     mpRbSub.clear();
     400           0 :     mpRbMul.clear();
     401           0 :     mpRbDiv.clear();
     402           0 :     mpRbMoveNone.clear();
     403           0 :     mpRbMoveDown.clear();
     404           0 :     mpRbMoveRight.clear();
     405           0 :     mpBtnShortCutPasteValuesOnly.clear();
     406           0 :     mpBtnShortCutPasteValuesFormats.clear();
     407           0 :     mpBtnShortCutPasteTranspose.clear();
     408           0 :     ModalDialog::dispose();
     409           0 : }
     410             : 
     411           0 : sal_uInt16  ScInsertContentsDlg::GetFormulaCmdBits() const
     412             : {
     413           0 :     ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
     414           0 :     if(mpRbAdd->IsChecked())
     415           0 :         ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_ADD;
     416           0 :     else if(mpRbSub->IsChecked())
     417           0 :         ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_SUB;
     418           0 :     else if(mpRbMul->IsChecked())
     419           0 :         ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_MUL;
     420           0 :     else if(mpRbDiv->IsChecked())
     421           0 :         ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_DIV;
     422           0 :     if (bUsedShortCut)
     423           0 :         return nShortCutFormulaCmdBits;
     424           0 :     return ScInsertContentsDlg::nPreviousFormulaChecks;
     425           0 : }
     426             : 
     427             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11