LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - simpref.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 95 0.0 %
Date: 2012-08-25 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 132 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <vcl/msgbox.hxx>
      30                 :            : #include <sfx2/app.hxx>
      31                 :            : 
      32                 :            : #include "reffact.hxx"
      33                 :            : #include "document.hxx"
      34                 :            : #include "scresid.hxx"
      35                 :            : #include "globstr.hrc"
      36                 :            : #include "simpref.hrc"
      37                 :            : #include "rangenam.hxx"     // IsNameValid
      38                 :            : #include "simpref.hxx"
      39                 :            : #include "scmod.hxx"
      40                 :            : 
      41                 :            : //============================================================================
      42                 :            : 
      43                 :            : #define ABS_SREF          SCA_VALID \
      44                 :            :                         | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
      45                 :            : #define ABS_DREF          ABS_SREF \
      46                 :            :                         | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
      47                 :            : #define ABS_SREF3D      ABS_SREF | SCA_TAB_3D
      48                 :            : #define ABS_DREF3D      ABS_DREF | SCA_TAB_3D
      49                 :            : 
      50                 :            : //----------------------------------------------------------------------------
      51                 :            : 
      52                 :            : #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
      53                 :            : #define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
      54                 :            : 
      55                 :            : //============================================================================
      56                 :            : //  class ScSimpleRefDlg
      57                 :            : 
      58                 :            : //----------------------------------------------------------------------------
      59                 :          0 : ScSimpleRefDlg::ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
      60                 :            :                           ScViewData*   ptrViewData )
      61                 :            : 
      62                 :            :     :   ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SIMPLEREF ),
      63                 :            :         //
      64                 :            :         aFtAssign       ( this, ScResId( FT_ASSIGN ) ),
      65                 :            :         aEdAssign       ( this, this, ScResId( ED_ASSIGN ) ),
      66                 :            :         aRbAssign       ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
      67                 :            : 
      68                 :            :         aBtnOk          ( this, ScResId( BTN_OK ) ),
      69                 :            :         aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
      70                 :            :         aBtnHelp        ( this, ScResId( BTN_HELP ) ),
      71                 :            : 
      72                 :            :         //
      73                 :            :         pViewData       ( ptrViewData ),
      74         [ #  # ]:          0 :         pDoc            ( ptrViewData->GetDocument() ),
      75                 :            :         bRefInputMode   ( false ),
      76                 :            :         bAutoReOpen     ( sal_True ),
      77                 :            :         bCloseOnButtonUp( false ),
      78                 :            :         bSingleCell     ( false ),
      79 [ #  # ][ #  # ]:          0 :         bMultiSelection ( false )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      80                 :            : {
      81                 :            :     //  damit die Strings in der Resource bei den FixedTexten bleiben koennen:
      82         [ #  # ]:          0 :     Init();
      83         [ #  # ]:          0 :     FreeResource();
      84         [ #  # ]:          0 :     SetDispatcherLock( sal_True ); // Modal-Modus einschalten
      85                 :          0 : }
      86                 :            : 
      87                 :            : //----------------------------------------------------------------------------
      88 [ #  # ][ #  # ]:          0 : ScSimpleRefDlg::~ScSimpleRefDlg()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      89                 :            : {
      90         [ #  # ]:          0 :     SetDispatcherLock( false ); // Modal-Modus einschalten
      91         [ #  # ]:          0 : }
      92                 :            : 
      93                 :            : //----------------------------------------------------------------------------
      94                 :          0 : void ScSimpleRefDlg::FillInfo(SfxChildWinInfo& rWinInfo) const
      95                 :            : {
      96                 :          0 :     ScAnyRefDlg::FillInfo(rWinInfo);
      97                 :          0 :     rWinInfo.bVisible=bAutoReOpen;
      98                 :          0 : }
      99                 :            : 
     100                 :            : //----------------------------------------------------------------------------
     101                 :          0 : void ScSimpleRefDlg::SetRefString(const String &rStr)
     102                 :            : {
     103                 :          0 :     aEdAssign.SetText(rStr);
     104                 :          0 : }
     105                 :            : 
     106                 :            : //----------------------------------------------------------------------------
     107                 :          0 : void ScSimpleRefDlg::Init()
     108                 :            : {
     109                 :          0 :     aBtnOk.SetClickHdl      ( LINK( this, ScSimpleRefDlg, OkBtnHdl ) );
     110                 :          0 :     aBtnCancel.SetClickHdl  ( LINK( this, ScSimpleRefDlg, CancelBtnHdl ) );
     111                 :          0 :     bCloseFlag=false;
     112                 :          0 : }
     113                 :            : 
     114                 :            : //----------------------------------------------------------------------------
     115                 :            : // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
     116                 :            : //  neue Selektion im Referenz-Fenster angezeigt wird.
     117                 :          0 : void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
     118                 :            : {
     119         [ #  # ]:          0 :     if ( aEdAssign.IsEnabled() )
     120                 :            :     {
     121         [ #  # ]:          0 :         if ( rRef.aStart != rRef.aEnd )
     122         [ #  # ]:          0 :             RefInputStart( &aEdAssign );
     123                 :            : 
     124                 :          0 :         theCurArea = rRef;
     125         [ #  # ]:          0 :         String aRefStr;
     126         [ #  # ]:          0 :         if ( bSingleCell )
     127                 :            :         {
     128                 :          0 :             ScAddress aAdr = rRef.aStart;
     129 [ #  # ][ #  # ]:          0 :             aAdr.Format( aRefStr, SCA_ABS_3D, pDocP, pDocP->GetAddressConvention() );
     130                 :            :         }
     131                 :            :         else
     132 [ #  # ][ #  # ]:          0 :             theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() );
     133                 :            : 
     134         [ #  # ]:          0 :         if ( bMultiSelection )
     135                 :            :         {
     136         [ #  # ]:          0 :             String aVal = aEdAssign.GetText();
     137         [ #  # ]:          0 :             Selection aSel = aEdAssign.GetSelection();
     138                 :          0 :             aSel.Justify();
     139         [ #  # ]:          0 :             aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
     140         [ #  # ]:          0 :             aVal.Insert( aRefStr, (xub_StrLen)aSel.Min() );
     141                 :          0 :             Selection aNewSel( aSel.Min(), aSel.Min()+aRefStr.Len() );
     142         [ #  # ]:          0 :             aEdAssign.SetRefString( aVal );
     143 [ #  # ][ #  # ]:          0 :             aEdAssign.SetSelection( aNewSel );
     144                 :            :         }
     145                 :            :         else
     146         [ #  # ]:          0 :             aEdAssign.SetRefString( aRefStr );
     147                 :            : 
     148 [ #  # ][ #  # ]:          0 :         aChangeHdl.Call( &aRefStr );
     149                 :            :     }
     150                 :          0 : }
     151                 :            : 
     152                 :            : 
     153                 :            : //----------------------------------------------------------------------------
     154                 :          0 : sal_Bool ScSimpleRefDlg::Close()
     155                 :            : {
     156                 :          0 :     CancelBtnHdl(&aBtnCancel);
     157                 :          0 :     return sal_True;
     158                 :            : }
     159                 :            : 
     160                 :            : //------------------------------------------------------------------------
     161                 :          0 : void ScSimpleRefDlg::SetActive()
     162                 :            : {
     163                 :          0 :     aEdAssign.GrabFocus();
     164                 :            : 
     165                 :            :     //  kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
     166                 :            :     //  (nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
     167                 :            :     //  (der ausgewaehlte DB-Name hat sich auch nicht veraendert)
     168                 :            : 
     169                 :          0 :     RefInputDone();
     170                 :          0 : }
     171                 :            : //------------------------------------------------------------------------
     172                 :          0 : sal_Bool ScSimpleRefDlg::IsRefInputMode() const
     173                 :            : {
     174                 :          0 :     return sal_True;
     175                 :            : }
     176                 :            : 
     177                 :          0 : String ScSimpleRefDlg::GetRefString() const
     178                 :            : {
     179                 :          0 :     return aEdAssign.GetText();
     180                 :            : }
     181                 :            : 
     182                 :          0 : void ScSimpleRefDlg::SetCloseHdl( const Link& rLink )
     183                 :            : {
     184                 :          0 :     aCloseHdl=rLink;
     185                 :          0 : }
     186                 :            : 
     187                 :          0 : void ScSimpleRefDlg::SetUnoLinks( const Link& rDone, const Link& rAbort,
     188                 :            :                                     const Link& rChange )
     189                 :            : {
     190                 :          0 :     aDoneHdl    = rDone;
     191                 :          0 :     aAbortedHdl = rAbort;
     192                 :          0 :     aChangeHdl  = rChange;
     193                 :          0 : }
     194                 :            : 
     195                 :          0 : void ScSimpleRefDlg::SetFlags( sal_Bool bSetCloseOnButtonUp, sal_Bool bSetSingleCell, sal_Bool bSetMultiSelection )
     196                 :            : {
     197                 :          0 :     bCloseOnButtonUp = bSetCloseOnButtonUp;
     198                 :          0 :     bSingleCell = bSetSingleCell;
     199                 :          0 :     bMultiSelection = bSetMultiSelection;
     200                 :          0 : }
     201                 :            : 
     202                 :          0 : void ScSimpleRefDlg::StartRefInput()
     203                 :            : {
     204         [ #  # ]:          0 :     if ( bMultiSelection )
     205                 :            :     {
     206                 :            :         // initially select the whole string, so it gets replaced by default
     207         [ #  # ]:          0 :         aEdAssign.SetSelection( Selection( 0, aEdAssign.GetText().Len() ) );
     208                 :            :     }
     209                 :            : 
     210                 :          0 :     aRbAssign.DoRef();
     211                 :          0 :     bCloseFlag=sal_True;
     212                 :          0 : }
     213                 :            : 
     214                 :          0 : void ScSimpleRefDlg::RefInputDone( sal_Bool bForced)
     215                 :            : {
     216                 :          0 :     ScAnyRefDlg::RefInputDone(bForced);
     217 [ #  # ][ #  # ]:          0 :     if ( (bForced || bCloseOnButtonUp) && bCloseFlag )
                 [ #  # ]
     218                 :          0 :         OkBtnHdl(&aBtnOk);
     219                 :          0 : }
     220                 :            : //------------------------------------------------------------------------
     221                 :            : // Handler:
     222                 :            : // ========
     223                 :          0 : IMPL_LINK_NOARG(ScSimpleRefDlg, OkBtnHdl)
     224                 :            : {
     225                 :          0 :     bAutoReOpen=false;
     226         [ #  # ]:          0 :     String aResult=aEdAssign.GetText();
     227         [ #  # ]:          0 :     aCloseHdl.Call(&aResult);
     228                 :          0 :     Link aUnoLink = aDoneHdl;       // stack var because this is deleted in DoClose
     229 [ #  # ][ #  # ]:          0 :     DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() );
     230         [ #  # ]:          0 :     aUnoLink.Call( &aResult );
     231         [ #  # ]:          0 :     return 0;
     232                 :            : }
     233                 :            : 
     234                 :            : //------------------------------------------------------------------------
     235                 :          0 : IMPL_LINK_NOARG(ScSimpleRefDlg, CancelBtnHdl)
     236                 :            : {
     237                 :          0 :     bAutoReOpen=false;
     238         [ #  # ]:          0 :     String aResult=aEdAssign.GetText();
     239         [ #  # ]:          0 :     aCloseHdl.Call(NULL);
     240                 :          0 :     Link aUnoLink = aAbortedHdl;    // stack var because this is deleted in DoClose
     241 [ #  # ][ #  # ]:          0 :     DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() );
     242         [ #  # ]:          0 :     aUnoLink.Call( &aResult );
     243         [ #  # ]:          0 :     return 0;
     244                 :            : }
     245                 :            : 
     246                 :            : 
     247                 :            : 
     248                 :            : //------------------------------------------------------------------------
     249                 :            : 
     250                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10