LCOV - code coverage report
Current view: top level - formula/source/ui/dlg - funcutl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 324 0.0 %
Date: 2012-08-25 Functions: 0 68 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 302 0.0 %

           Branch data     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/svapp.hxx>
      21                 :            : #include <vcl/scrbar.hxx>
      22                 :            : 
      23                 :            : #include "formula/funcutl.hxx"
      24                 :            : #include "formula/IControlReferenceHandler.hxx"
      25                 :            : #include "ControlHelper.hxx"
      26                 :            : #include "ModuleHelper.hxx"
      27                 :            : #include "ForResId.hrc"
      28                 :            : 
      29                 :            : 
      30                 :            : namespace formula
      31                 :            : {
      32                 :            : //============================================================================
      33                 :            : // class ValWnd
      34                 :            : //----------------------------------------------------------------------------
      35                 :            : 
      36 [ #  # ][ #  # ]:          0 : ValWnd::ValWnd( Window* pParent, const ResId& rId ) : Window( pParent, rId )
      37                 :            : {
      38         [ #  # ]:          0 :     Font aFnt( GetFont() );
      39         [ #  # ]:          0 :     aFnt.SetTransparent( sal_True );
      40         [ #  # ]:          0 :     aFnt.SetWeight( WEIGHT_LIGHT );
      41         [ #  # ]:          0 :     if ( pParent->IsBackground() )
      42                 :            :     {
      43         [ #  # ]:          0 :         Wallpaper aBack = pParent->GetBackground();
      44 [ #  # ][ #  # ]:          0 :         SetFillColor( aBack.GetColor() );
      45         [ #  # ]:          0 :         SetBackground( aBack );
      46 [ #  # ][ #  # ]:          0 :         aFnt.SetFillColor( aBack.GetColor() );
                 [ #  # ]
      47                 :            :     }
      48                 :            :     else
      49                 :            :     {
      50         [ #  # ]:          0 :         SetFillColor();
      51         [ #  # ]:          0 :         SetBackground();
      52                 :            :     }
      53         [ #  # ]:          0 :     SetFont( aFnt );
      54         [ #  # ]:          0 :     SetLineColor();
      55                 :            : 
      56                 :          0 :     Size aSzWnd  = GetOutputSizePixel();
      57         [ #  # ]:          0 :     long nHeight = GetTextHeight();
      58                 :          0 :     long nDiff   = aSzWnd.Height()-nHeight;
      59                 :            : 
      60                 :            :     aRectOut = Rectangle( Point( 1, ( nDiff<2 ) ? 1 : nDiff/2),
      61 [ #  # ][ #  # ]:          0 :                           Size ( aSzWnd.Width()-2, nHeight ) );
      62 [ #  # ][ #  # ]:          0 :     SetClipRegion( Region( aRectOut ) );
         [ #  # ][ #  # ]
      63                 :          0 : }
      64                 :            : 
      65                 :            : //----------------------------------------------------------------------------
      66                 :            : 
      67                 :          0 : void ValWnd::Paint( const Rectangle& )
      68                 :            : {
      69         [ #  # ]:          0 :     DrawText( aRectOut.TopLeft(), aStrValue );
      70                 :          0 : }
      71                 :            : 
      72                 :            : //----------------------------------------------------------------------------
      73                 :            : 
      74                 :          0 : void ValWnd::SetValue( const String& rStrVal )
      75                 :            : {
      76         [ #  # ]:          0 :     if ( aStrValue != rStrVal )
      77                 :            :     {
      78                 :          0 :         aStrValue = rStrVal;
      79                 :          0 :         DrawRect( aRectOut );   // alten Text loeschen
      80                 :          0 :         Paint( aRectOut );      // and neu malen
      81                 :            :     }
      82                 :          0 : }
      83                 :            : 
      84                 :            : //============================================================================
      85                 :            : // class ArgEdit
      86                 :            : //----------------------------------------------------------------------------
      87                 :            : 
      88                 :          0 : ArgEdit::ArgEdit( Window* pParent, const ResId& rResId )
      89                 :            :     :   RefEdit( pParent, rResId ),
      90                 :            :         pEdPrev ( NULL ),
      91                 :            :         pEdNext ( NULL ),
      92                 :            :         pSlider ( NULL ),
      93                 :          0 :         nArgs   ( 0 )
      94                 :            : {
      95                 :          0 : }
      96                 :            : 
      97                 :            : //----------------------------------------------------------------------------
      98                 :            : 
      99                 :          0 : void ArgEdit::Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit,
     100                 :            :                     ScrollBar& rArgSlider, sal_uInt16 nArgCount )
     101                 :            : {
     102                 :          0 :     pEdPrev = pPrevEdit;
     103                 :          0 :     pEdNext = pNextEdit;
     104                 :          0 :     pSlider = &rArgSlider;
     105                 :          0 :     nArgs   = nArgCount;
     106                 :          0 : }
     107                 :            : 
     108                 :            : //----------------------------------------------------------------------------
     109                 :            : 
     110                 :            : // Cursor control for Edit Fields in Argument Dialog
     111                 :            : 
     112                 :          0 : void ArgEdit::KeyInput( const KeyEvent& rKEvt )
     113                 :            : {
     114                 :          0 :     KeyCode     aCode   = rKEvt.GetKeyCode();
     115                 :          0 :     sal_Bool        bUp     = (aCode.GetCode() == KEY_UP);
     116                 :          0 :     sal_Bool        bDown   = (aCode.GetCode() == KEY_DOWN);
     117                 :          0 :     ArgEdit*    pEd     = NULL;
     118                 :            : 
     119 [ #  # ][ #  # ]:          0 :     if (   pSlider
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     120                 :          0 :         && ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
     121                 :            :         && ( bUp || bDown ) )
     122                 :            :     {
     123         [ #  # ]:          0 :         if ( nArgs > 1 )
     124                 :            :         {
     125                 :          0 :             long    nThumb       = pSlider->GetThumbPos();
     126                 :          0 :             sal_Bool    bDoScroll    = sal_False;
     127                 :          0 :             sal_Bool    bChangeFocus = sal_False;
     128                 :            : 
     129         [ #  # ]:          0 :             if ( bDown )
     130                 :            :             {
     131         [ #  # ]:          0 :                 if ( nArgs > 4 )
     132                 :            :                 {
     133         [ #  # ]:          0 :                     if ( !pEdNext )
     134                 :            :                     {
     135                 :          0 :                         nThumb++;
     136                 :          0 :                         bDoScroll = ( nThumb+3 < (long)nArgs );
     137                 :            :                     }
     138                 :            :                     else
     139                 :            :                     {
     140                 :          0 :                         pEd = pEdNext;
     141                 :          0 :                         bChangeFocus = sal_True;
     142                 :            :                     }
     143                 :            :                 }
     144         [ #  # ]:          0 :                 else if ( pEdNext )
     145                 :            :                 {
     146                 :          0 :                     pEd = pEdNext;
     147                 :          0 :                     bChangeFocus = sal_True;
     148                 :            :                 }
     149                 :            :             }
     150                 :            :             else // if ( bUp )
     151                 :            :             {
     152         [ #  # ]:          0 :                 if ( nArgs > 4 )
     153                 :            :                 {
     154         [ #  # ]:          0 :                     if ( !pEdPrev )
     155                 :            :                     {
     156                 :          0 :                         nThumb--;
     157                 :          0 :                         bDoScroll = ( nThumb >= 0 );
     158                 :            :                     }
     159                 :            :                     else
     160                 :            :                     {
     161                 :          0 :                         pEd = pEdPrev;
     162                 :          0 :                         bChangeFocus = sal_True;
     163                 :            :                     }
     164                 :            :                 }
     165         [ #  # ]:          0 :                 else if ( pEdPrev )
     166                 :            :                 {
     167                 :          0 :                     pEd = pEdPrev;
     168                 :          0 :                     bChangeFocus = sal_True;
     169                 :            :                 }
     170                 :            :             }
     171                 :            : 
     172         [ #  # ]:          0 :             if ( bDoScroll )
     173                 :            :             {
     174         [ #  # ]:          0 :                 pSlider->SetThumbPos( nThumb );
     175         [ #  # ]:          0 :                 ((Link&)pSlider->GetEndScrollHdl()).Call( pSlider );
     176                 :            :             }
     177         [ #  # ]:          0 :             else if ( bChangeFocus )
     178                 :            :             {
     179         [ #  # ]:          0 :                 pEd->GrabFocus();
     180                 :            :             }
     181                 :            :         }
     182                 :            :     }
     183                 :            :     else
     184         [ #  # ]:          0 :         RefEdit::KeyInput( rKEvt );
     185                 :          0 : }
     186                 :            : 
     187                 :            : 
     188                 :            : 
     189                 :            : 
     190                 :            : /*************************************************************************
     191                 :            : #*  Member:     ArgInput                                    Date:13.01.97
     192                 :            : #*------------------------------------------------------------------------
     193                 :            : #*
     194                 :            : #*  Class:      ArgInput
     195                 :            : #*
     196                 :            : #*  Function:   ArgInput class constructor
     197                 :            : #*
     198                 :            : #*  Input:      ---
     199                 :            : #*
     200                 :            : #*  Output:     ---
     201                 :            : #*
     202                 :            : #************************************************************************/
     203                 :            : 
     204                 :          0 : ArgInput::ArgInput()
     205                 :            : {
     206                 :          0 :     pFtArg=NULL;
     207                 :          0 :     pBtnFx=NULL;
     208                 :          0 :     pEdArg=NULL;
     209                 :          0 :     pRefBtn=NULL;
     210                 :          0 : }
     211                 :            : 
     212                 :            : /*************************************************************************
     213                 :            : #*  Member:     InitArgInput                                Date:13.01.97
     214                 :            : #*------------------------------------------------------------------------
     215                 :            : #*
     216                 :            : #*  Class:      ArgInput
     217                 :            : #*
     218                 :            : #*  Function:   Initializes the class' Pointer
     219                 :            : #*
     220                 :            : #*  Input:      ---
     221                 :            : #*
     222                 :            : #*  Output:     ---
     223                 :            : #*
     224                 :            : #************************************************************************/
     225                 :            : 
     226                 :          0 : void ArgInput::InitArgInput(FixedText*      pftArg,
     227                 :            :                             ImageButton*    pbtnFx,
     228                 :            :                             ArgEdit*        pedArg,
     229                 :            :                             RefButton*  prefBtn)
     230                 :            : {
     231                 :          0 :     pFtArg =pftArg;
     232                 :          0 :     pBtnFx =pbtnFx;
     233                 :          0 :     pEdArg =pedArg;
     234                 :          0 :     pRefBtn=prefBtn;
     235                 :            : 
     236         [ #  # ]:          0 :     if(pBtnFx!=NULL)
     237                 :            :     {
     238                 :          0 :         pBtnFx->SetClickHdl   ( LINK( this, ArgInput, FxBtnClickHdl ) );
     239                 :          0 :         pBtnFx->SetGetFocusHdl( LINK( this, ArgInput, FxBtnFocusHdl ) );
     240                 :            :     }
     241         [ #  # ]:          0 :     if(pRefBtn!=NULL)
     242                 :            :     {
     243                 :          0 :         pRefBtn->SetClickHdl   ( LINK( this, ArgInput, RefBtnClickHdl ) );
     244                 :          0 :         pRefBtn->SetGetFocusHdl( LINK( this, ArgInput, RefBtnFocusHdl ) );
     245                 :            :     }
     246         [ #  # ]:          0 :     if(pEdArg!=NULL)
     247                 :            :     {
     248                 :          0 :         pEdArg->SetGetFocusHdl ( LINK( this, ArgInput, EdFocusHdl ) );
     249         [ #  # ]:          0 :         pEdArg->SetModifyHdl   ( LINK( this, ArgInput, EdModifyHdl ) );
     250                 :            :     }
     251                 :            : 
     252                 :          0 : }
     253                 :            : 
     254                 :            : /*************************************************************************
     255                 :            : #*  Member:     SetArgName                                  Date:13.01.97
     256                 :            : #*------------------------------------------------------------------------
     257                 :            : #*
     258                 :            : #*  Class:      ArgInput
     259                 :            : #*
     260                 :            : #*  Function:   Sets the Name for the Argument
     261                 :            : #*
     262                 :            : #*  Input:      String
     263                 :            : #*
     264                 :            : #*  Output:     ---
     265                 :            : #*
     266                 :            : #************************************************************************/
     267                 :          0 : void ArgInput::SetArgName(const String &aArg)
     268                 :            : {
     269         [ #  # ]:          0 :     if(pFtArg !=NULL) pFtArg->SetText(aArg );
     270                 :          0 : }
     271                 :            : 
     272                 :            : /*************************************************************************
     273                 :            : #*  Member:     GetArgName                                  Date:06.02.97
     274                 :            : #*------------------------------------------------------------------------
     275                 :            : #*
     276                 :            : #*  Class:      ArgInput
     277                 :            : #*
     278                 :            : #*  Function:   Returns the Name for the Argument
     279                 :            : #*
     280                 :            : #*  Input:      String
     281                 :            : #*
     282                 :            : #*  Output:     ---
     283                 :            : #*
     284                 :            : #************************************************************************/
     285                 :          0 : String ArgInput::GetArgName()
     286                 :            : {
     287                 :          0 :     String aPrivArgName;
     288         [ #  # ]:          0 :     if(pFtArg !=NULL)
     289 [ #  # ][ #  # ]:          0 :         aPrivArgName=pFtArg->GetText();
                 [ #  # ]
     290                 :            : 
     291                 :          0 :     return aPrivArgName;
     292                 :            : }
     293                 :            : 
     294                 :            : /*************************************************************************
     295                 :            : #*  Member:     SetArgName                                  Date:13.01.97
     296                 :            : #*------------------------------------------------------------------------
     297                 :            : #*
     298                 :            : #*  Class:      ArgInput
     299                 :            : #*
     300                 :            : #*  Function:   Sets the Name for the Argument
     301                 :            : #*
     302                 :            : #*  Input:      String
     303                 :            : #*
     304                 :            : #*  Output:     ---
     305                 :            : #*
     306                 :            : #************************************************************************/
     307                 :          0 : void ArgInput::SetArgNameFont   (const Font &aFont)
     308                 :            : {
     309         [ #  # ]:          0 :     if(pFtArg !=NULL) pFtArg->SetFont(aFont);
     310                 :          0 : }
     311                 :            : 
     312                 :            : /*************************************************************************
     313                 :            : #*  Member:     SetArgSelection                             Date:13.01.97
     314                 :            : #*------------------------------------------------------------------------
     315                 :            : #*
     316                 :            : #*  Class:      ArgInput
     317                 :            : #*
     318                 :            : #*  Function:   Sets up the Selection for the EditBox.
     319                 :            : #*
     320                 :            : #*  Input:      String
     321                 :            : #*
     322                 :            : #*  Output:     ---
     323                 :            : #*
     324                 :            : #************************************************************************/
     325                 :          0 : void ArgInput::SetArgSelection  (const Selection& rSel )
     326                 :            : {
     327         [ #  # ]:          0 :     if(pEdArg !=NULL) pEdArg ->SetSelection(rSel );
     328                 :          0 : }
     329                 :            : 
     330                 :            : 
     331                 :            : /*************************************************************************
     332                 :            : #*  Member:     SetArgVal                                   Date:13.01.97
     333                 :            : #*------------------------------------------------------------------------
     334                 :            : #*
     335                 :            : #*  Class:      ArgInput
     336                 :            : #*
     337                 :            : #*  Function:   Sets the Value for the Argument
     338                 :            : #*
     339                 :            : #*  Input:      String
     340                 :            : #*
     341                 :            : #*  Output:     ---
     342                 :            : #*
     343                 :            : #************************************************************************/
     344                 :          0 : void ArgInput::SetArgVal(const String &aVal)
     345                 :            : {
     346         [ #  # ]:          0 :     if(pEdArg !=NULL)
     347                 :            :     {
     348                 :          0 :         pEdArg ->SetRefString(aVal );
     349                 :            :     }
     350                 :          0 : }
     351                 :            : 
     352                 :            : /*************************************************************************
     353                 :            : #*  Member:     SetArgName                                  Date:13.01.97
     354                 :            : #*------------------------------------------------------------------------
     355                 :            : #*
     356                 :            : #*  Class:      ArgInput
     357                 :            : #*
     358                 :            : #*  Function:   Returns the Value for the Argument
     359                 :            : #*
     360                 :            : #*  Input:      ---
     361                 :            : #*
     362                 :            : #*  Output:     String
     363                 :            : #*
     364                 :            : #************************************************************************/
     365                 :          0 : String ArgInput::GetArgVal()
     366                 :            : {
     367                 :          0 :     String aResult;
     368         [ #  # ]:          0 :     if(pEdArg!=NULL)
     369                 :            :     {
     370 [ #  # ][ #  # ]:          0 :         aResult=pEdArg->GetText();
                 [ #  # ]
     371                 :            :     }
     372                 :          0 :     return aResult;
     373                 :            : }
     374                 :            : 
     375                 :            : /*************************************************************************
     376                 :            : #*  Member:     SetArgName                                  Date:13.01.97
     377                 :            : #*------------------------------------------------------------------------
     378                 :            : #*
     379                 :            : #*  Class:      ArgInput
     380                 :            : #*
     381                 :            : #*  Function:   Hides the Controls
     382                 :            : #*
     383                 :            : #*  Input:      ---
     384                 :            : #*
     385                 :            : #*  Output:     ---
     386                 :            : #*
     387                 :            : #************************************************************************/
     388                 :          0 : void ArgInput::Hide()
     389                 :            : {
     390 [ #  # ][ #  # ]:          0 :     if ( pFtArg && pBtnFx && pEdArg && pRefBtn)
         [ #  # ][ #  # ]
     391                 :            :     {
     392                 :          0 :         pFtArg->Hide();
     393                 :          0 :         pBtnFx->Hide();
     394                 :          0 :         pEdArg->Hide();
     395                 :          0 :         pRefBtn->Hide();
     396                 :            :     }
     397                 :          0 : }
     398                 :            : 
     399                 :            : /*************************************************************************
     400                 :            : #*  Member:     SetArgName                                  Date:13.01.97
     401                 :            : #*------------------------------------------------------------------------
     402                 :            : #*
     403                 :            : #*  Class:      ArgInput
     404                 :            : #*
     405                 :            : #*  Function:   Casts the Controls again.
     406                 :            : #*
     407                 :            : #*  Input:      ---
     408                 :            : #*
     409                 :            : #*  Output:     ---
     410                 :            : #*
     411                 :            : #************************************************************************/
     412                 :          0 : void ArgInput::Show()
     413                 :            : {
     414 [ #  # ][ #  # ]:          0 :     if ( pFtArg && pBtnFx && pEdArg && pRefBtn)
         [ #  # ][ #  # ]
     415                 :            :     {
     416                 :          0 :         pFtArg->Show();
     417                 :          0 :         pBtnFx->Show();
     418                 :          0 :         pEdArg->Show();
     419                 :          0 :         pRefBtn->Show();
     420                 :            :     }
     421                 :          0 : }
     422                 :            : 
     423                 :            : /*************************************************************************
     424                 :            : #*  Member:     FxClick                                     Date:13.01.97
     425                 :            : #*------------------------------------------------------------------------
     426                 :            : #*
     427                 :            : #*  Class:      ArgInput
     428                 :            : #*
     429                 :            : #*  Function:   Forwards the Event.
     430                 :            : #*
     431                 :            : #*  Input:      ---
     432                 :            : #*
     433                 :            : #*  Output:     ---
     434                 :            : #*
     435                 :            : #************************************************************************/
     436                 :          0 : void ArgInput::FxClick()
     437                 :            : {
     438                 :          0 :     aFxClickLink.Call(this);
     439                 :          0 : }
     440                 :            : 
     441                 :            : /*************************************************************************
     442                 :            : #*  Member:     RefClick                                    Date:13.01.97
     443                 :            : #*------------------------------------------------------------------------
     444                 :            : #*
     445                 :            : #*  Class:      ArgInput
     446                 :            : #*
     447                 :            : #*  Function:   Forwards the Event.
     448                 :            : #*
     449                 :            : #*  Input:      ---
     450                 :            : #*
     451                 :            : #*  Output:     ---
     452                 :            : #*
     453                 :            : #************************************************************************/
     454                 :          0 : void ArgInput::RefClick()
     455                 :            : {
     456                 :          0 :     aRefClickLink.Call(this);
     457                 :          0 : }
     458                 :            : 
     459                 :            : /*************************************************************************
     460                 :            : #*  Member:     FxFocus                                     Date:13.01.97
     461                 :            : #*------------------------------------------------------------------------
     462                 :            : #*
     463                 :            : #*  Class:      ArgInput
     464                 :            : #*
     465                 :            : #*  Function:   Forwards the Event.
     466                 :            : #*
     467                 :            : #*  Input:      ---
     468                 :            : #*
     469                 :            : #*  Output:     ---
     470                 :            : #*
     471                 :            : #************************************************************************/
     472                 :          0 : void ArgInput::FxFocus()
     473                 :            : {
     474                 :          0 :     aFxFocusLink.Call(this);
     475                 :          0 : }
     476                 :            : 
     477                 :            : /*************************************************************************
     478                 :            : #*  Member:     RefFocus                                    Date:13.01.97
     479                 :            : #*------------------------------------------------------------------------
     480                 :            : #*
     481                 :            : #*  Class:      ArgInput
     482                 :            : #*
     483                 :            : #*  Function:   Forwards the Event.
     484                 :            : #*
     485                 :            : #*  Input:      ---
     486                 :            : #*
     487                 :            : #*  Output:     ---
     488                 :            : #*
     489                 :            : #************************************************************************/
     490                 :          0 : void ArgInput::RefFocus()
     491                 :            : {
     492                 :          0 :     aRefFocusLink.Call(this);
     493                 :          0 : }
     494                 :            : 
     495                 :            : /*************************************************************************
     496                 :            : #*  Member:     EdFocus                                     Date:13.01.97
     497                 :            : #*------------------------------------------------------------------------
     498                 :            : #*
     499                 :            : #*  Class:      ArgInput
     500                 :            : #*
     501                 :            : #*  Function:   Forwards the Event.
     502                 :            : #*
     503                 :            : #*  Input:      ---
     504                 :            : #*
     505                 :            : #*  Output:     ---
     506                 :            : #*
     507                 :            : #************************************************************************/
     508                 :          0 : void ArgInput::EdFocus()
     509                 :            : {
     510                 :          0 :     aEdFocusLink.Call(this);
     511                 :          0 : }
     512                 :            : 
     513                 :            : /*************************************************************************
     514                 :            : #*  Member:     EdModify                                    Date:13.01.97
     515                 :            : #*------------------------------------------------------------------------
     516                 :            : #*
     517                 :            : #*  Class:      ArgInput
     518                 :            : #*
     519                 :            : #*  Function:   Forwards the Event.
     520                 :            : #*
     521                 :            : #*  Input:      ---
     522                 :            : #*
     523                 :            : #*  Output:     ---
     524                 :            : #*
     525                 :            : #************************************************************************/
     526                 :          0 : void ArgInput::EdModify()
     527                 :            : {
     528                 :          0 :     aEdModifyLink.Call(this);
     529                 :          0 : }
     530                 :            : 
     531                 :            : /*************************************************************************
     532                 :            : #*  Handle:     FxBtnHdl                                    Date:13.01.97
     533                 :            : #*------------------------------------------------------------------------
     534                 :            : #*
     535                 :            : #*  Class:      ArgInput
     536                 :            : #*
     537                 :            : #*  Function:   Handle for Fx-Button Click-Event.
     538                 :            : #*
     539                 :            : #*  Input:      ---
     540                 :            : #*
     541                 :            : #*  Output:     ---
     542                 :            : #*
     543                 :            : #************************************************************************/
     544                 :          0 : IMPL_LINK( ArgInput, FxBtnClickHdl, ImageButton*, pBtn )
     545                 :            : {
     546         [ #  # ]:          0 :     if(pBtn==pBtnFx) FxClick();
     547                 :            : 
     548                 :          0 :     return 0;
     549                 :            : }
     550                 :            : 
     551                 :            : /*************************************************************************
     552                 :            : #*  Handle:     RefBtnClickHdl                              Date:13.01.97
     553                 :            : #*------------------------------------------------------------------------
     554                 :            : #*
     555                 :            : #*  Class:      ArgInput
     556                 :            : #*
     557                 :            : #*  Function:   Handle for Fx-Button Click-Event.
     558                 :            : #*
     559                 :            : #*  Input:      ---
     560                 :            : #*
     561                 :            : #*  Output:     ---
     562                 :            : #*
     563                 :            : #************************************************************************/
     564                 :          0 : IMPL_LINK( ArgInput, RefBtnClickHdl,RefButton*, pBtn )
     565                 :            : {
     566         [ #  # ]:          0 :     if(pRefBtn==pBtn) RefClick();
     567                 :            : 
     568                 :          0 :     return 0;
     569                 :            : }
     570                 :            : 
     571                 :            : /*************************************************************************
     572                 :            : #*  Handle:     FxBtnFocusHdl                               Date:13.01.97
     573                 :            : #*------------------------------------------------------------------------
     574                 :            : #*
     575                 :            : #*  Class:      ArgInput
     576                 :            : #*
     577                 :            : #*  Function:   Handle for Fx-Button Focus-Event.
     578                 :            : #*
     579                 :            : #*  Input:      ---
     580                 :            : #*
     581                 :            : #*  Output:     ---
     582                 :            : #*
     583                 :            : #************************************************************************/
     584                 :          0 : IMPL_LINK( ArgInput, FxBtnFocusHdl, ImageButton*, pBtn )
     585                 :            : {
     586         [ #  # ]:          0 :     if(pBtn==pBtnFx) FxFocus();
     587                 :            : 
     588                 :          0 :     return 0;
     589                 :            : }
     590                 :            : 
     591                 :            : /*************************************************************************
     592                 :            : #*  Handle:     RefBtnFocusHdl                              Date:13.01.97
     593                 :            : #*------------------------------------------------------------------------
     594                 :            : #*
     595                 :            : #*  Class:      ArgInput
     596                 :            : #*
     597                 :            : #*  Function:   Handle for Fx-Button Focus-Event.
     598                 :            : #*
     599                 :            : #*  Input:      ---
     600                 :            : #*
     601                 :            : #*  Output:     ---
     602                 :            : #*
     603                 :            : #************************************************************************/
     604                 :          0 : IMPL_LINK( ArgInput, RefBtnFocusHdl,RefButton*, pBtn )
     605                 :            : {
     606         [ #  # ]:          0 :     if(pRefBtn==pBtn) RefFocus();
     607                 :            : 
     608                 :          0 :     return 0;
     609                 :            : }
     610                 :            : 
     611                 :            : /*************************************************************************
     612                 :            : #*  Handle:     EdFocusHdl                                  Date:13.01.97
     613                 :            : #*------------------------------------------------------------------------
     614                 :            : #*
     615                 :            : #*  Class:      ArgInput
     616                 :            : #*
     617                 :            : #*  Function:   Handle for Fx-Button Focus-Event.
     618                 :            : #*
     619                 :            : #*  Input:      ---
     620                 :            : #*
     621                 :            : #*  Output:     ---
     622                 :            : #*
     623                 :            : #************************************************************************/
     624                 :          0 : IMPL_LINK( ArgInput, EdFocusHdl, ArgEdit*, pEd )
     625                 :            : {
     626         [ #  # ]:          0 :     if(pEd==pEdArg) EdFocus();
     627                 :            : 
     628                 :          0 :     return 0;
     629                 :            : }
     630                 :            : 
     631                 :            : /*************************************************************************
     632                 :            : #*  Handle:     RefBtnClickHdl                              Date:13.01.97
     633                 :            : #*------------------------------------------------------------------------
     634                 :            : #*
     635                 :            : #*  Class:      ArgInput
     636                 :            : #*
     637                 :            : #*  Function:   Handle for Fx-Button Focus-Event.
     638                 :            : #*
     639                 :            : #*  Input:      ---
     640                 :            : #*
     641                 :            : #*  Output:     ---
     642                 :            : #*
     643                 :            : #************************************************************************/
     644                 :          0 : IMPL_LINK( ArgInput, EdModifyHdl,ArgEdit*, pEd )
     645                 :            : {
     646         [ #  # ]:          0 :     if(pEd==pEdArg) EdModify();
     647                 :            : 
     648                 :          0 :     return 0;
     649                 :            : }
     650                 :            : 
     651                 :            : /*************************************************************************
     652                 :            : #*  Member:     EditBox                                 Date:20.01.97
     653                 :            : #*------------------------------------------------------------------------
     654                 :            : #*
     655                 :            : #*  Class:      EditBox
     656                 :            : #*
     657                 :            : #*  Function:   Constructor from Class ArgInput
     658                 :            : #*
     659                 :            : #*  Input:      Parent, Resource
     660                 :            : #*
     661                 :            : #*  Output:     ---
     662                 :            : #*
     663                 :            : #************************************************************************/
     664                 :          0 : EditBox::EditBox( Window* pParent, const ResId& rResId )
     665                 :            :         :Control(pParent,rResId),
     666         [ #  # ]:          0 :         bMouseFlag(sal_False)
     667                 :            : {
     668         [ #  # ]:          0 :     WinBits nStyle=GetStyle();
     669         [ #  # ]:          0 :     SetStyle( nStyle| WB_DIALOGCONTROL);
     670                 :            : 
     671                 :            :     pMEdit=new MultiLineEdit(this,WB_LEFT | WB_VSCROLL | (nStyle & WB_TABSTOP) |
     672 [ #  # ][ #  # ]:          0 :                     WB_NOBORDER | WB_NOHIDESELECTION | WB_IGNORETAB);
     673         [ #  # ]:          0 :     pMEdit->Show();
     674         [ #  # ]:          0 :     aOldSel=pMEdit->GetSelection();
     675         [ #  # ]:          0 :     Resize();
     676         [ #  # ]:          0 :     WinBits nWinStyle=GetStyle() | WB_DIALOGCONTROL;
     677         [ #  # ]:          0 :     SetStyle(nWinStyle);
     678                 :            : 
     679                 :            :     //  #105582# the HelpId from the resource must be set for the MultiLineEdit,
     680                 :            :     //  not for the control that contains it.
     681 [ #  # ][ #  # ]:          0 :     pMEdit->SetHelpId( GetHelpId() );
     682         [ #  # ]:          0 :     SetHelpId( "" );
     683                 :          0 : }
     684                 :            : 
     685                 :          0 : EditBox::~EditBox()
     686                 :            : {
     687                 :          0 :     MultiLineEdit* pTheEdit=pMEdit;
     688         [ #  # ]:          0 :     pMEdit->Disable();
     689                 :          0 :     pMEdit=NULL;
     690 [ #  # ][ #  # ]:          0 :     delete pTheEdit;
     691         [ #  # ]:          0 : }
     692                 :            : /*************************************************************************
     693                 :            : #*  Member:     EditBox                                 Date:20.01.97
     694                 :            : #*------------------------------------------------------------------------
     695                 :            : #*
     696                 :            : #*  Class:      EditBox
     697                 :            : #*
     698                 :            : #*  Function:   When the seleccion is changed this function will be called
     699                 :            : #*
     700                 :            : #*  Input:      ---
     701                 :            : #*
     702                 :            : #*  Output:     ---
     703                 :            : #*
     704                 :            : #************************************************************************/
     705                 :          0 : void EditBox::SelectionChanged()
     706                 :            : {
     707                 :          0 :     aSelChangedLink.Call(this);
     708                 :          0 : }
     709                 :            : 
     710                 :            : /*************************************************************************
     711                 :            : #*  Member:     EditBox                                 Date:20.05.98
     712                 :            : #*------------------------------------------------------------------------
     713                 :            : #*
     714                 :            : #*  Class:      EditBox
     715                 :            : #*
     716                 :            : #*  Function:   When the size is changed, MultiLineEdit must
     717                 :            : #*              be adapted..
     718                 :            : #*
     719                 :            : #*  Input:      ---
     720                 :            : #*
     721                 :            : #*  Output:     ---
     722                 :            : #*
     723                 :            : #************************************************************************/
     724                 :          0 : void EditBox::Resize()
     725                 :            : {
     726                 :          0 :     Size aSize=GetOutputSizePixel();
     727 [ #  # ][ #  # ]:          0 :     if(pMEdit!=NULL) pMEdit->SetOutputSizePixel(aSize);
     728                 :          0 : }
     729                 :            : 
     730                 :            : /*************************************************************************
     731                 :            : #*  Member:     GetFocus                                    Date:26.05.98
     732                 :            : #*------------------------------------------------------------------------
     733                 :            : #*
     734                 :            : #*  Class:      EditBox
     735                 :            : #*
     736                 :            : #*  Function:   When the Control is activated,
     737                 :            : #*              the Selection is repealed and the Cursor set
     738                 :            : #*              at the end.
     739                 :            : #*
     740                 :            : #*  Input:      ---
     741                 :            : #*
     742                 :            : #*  Output:     ---
     743                 :            : #*
     744                 :            : #************************************************************************/
     745                 :          0 : void EditBox::GetFocus()
     746                 :            : {
     747         [ #  # ]:          0 :     if(pMEdit!=NULL)
     748                 :            :     {
     749                 :          0 :         pMEdit->GrabFocus();
     750                 :            :     }
     751                 :          0 : }
     752                 :            : 
     753                 :            : 
     754                 :            : 
     755                 :            : /*************************************************************************
     756                 :            : #*  Member:     EditBox                                 Date:20.01.97
     757                 :            : #*------------------------------------------------------------------------
     758                 :            : #*
     759                 :            : #*  Class:      EditBox
     760                 :            : #*
     761                 :            : #*  Function:   When an Event is cleared, this Routine is
     762                 :            : #*              first called and a PostUserEvent is sent.
     763                 :            : #*
     764                 :            : #*  Input:      Notify-Event
     765                 :            : #*
     766                 :            : #*  Output:     ---
     767                 :            : #*
     768                 :            : #************************************************************************/
     769                 :          0 : long EditBox::PreNotify( NotifyEvent& rNEvt )
     770                 :            : {
     771                 :          0 :     long nResult=sal_True;
     772                 :            : 
     773         [ #  # ]:          0 :     if(pMEdit==NULL) return nResult;
     774                 :            : 
     775                 :          0 :     sal_uInt16 nSwitch=rNEvt.GetType();
     776         [ #  # ]:          0 :     if(nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP)
     777                 :            :     {
     778                 :          0 :         const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode();
     779                 :          0 :         sal_uInt16 nKey=aKeyCode.GetCode();
     780 [ #  # ][ #  # ]:          0 :         if( (nKey==KEY_RETURN && !aKeyCode.IsShift()) || nKey==KEY_TAB )
         [ #  # ][ #  # ]
     781                 :            :         {
     782                 :          0 :             nResult=GetParent()->Notify(rNEvt);
     783                 :            :         }
     784                 :            :         else
     785                 :            :         {
     786                 :          0 :             nResult=Control::PreNotify(rNEvt);
     787         [ #  # ]:          0 :             Application::PostUserEvent( LINK( this, EditBox, ChangedHdl ) );
     788                 :            :         }
     789                 :            : 
     790                 :            :     }
     791                 :            :     else
     792                 :            :     {
     793                 :          0 :         nResult=Control::PreNotify(rNEvt);
     794                 :            : 
     795 [ #  # ][ #  # ]:          0 :         if(nSwitch==EVENT_MOUSEBUTTONDOWN || nSwitch==EVENT_MOUSEBUTTONUP)
     796                 :            :         {
     797                 :          0 :             bMouseFlag=sal_True;
     798         [ #  # ]:          0 :             Application::PostUserEvent( LINK( this, EditBox, ChangedHdl ) );
     799                 :            :         }
     800                 :            :     }
     801                 :          0 :     return nResult;
     802                 :            : }
     803                 :            : 
     804                 :            : /*************************************************************************
     805                 :            : #*  Member:     EditBox                                 Date:21.01.97
     806                 :            : #*------------------------------------------------------------------------
     807                 :            : #*
     808                 :            : #*  Class:      EditBox
     809                 :            : #*
     810                 :            : #*  Function:   When an Event cleared wurde, this routine is
     811                 :            : #*              first called.
     812                 :            : #*
     813                 :            : #*  Input:      Key-Event
     814                 :            : #*
     815                 :            : #*  Output:     ---
     816                 :            : #*
     817                 :            : #************************************************************************/
     818                 :          0 : IMPL_LINK_NOARG(EditBox, ChangedHdl)
     819                 :            : {
     820         [ #  # ]:          0 :     if(pMEdit!=NULL)
     821                 :            :     {
     822         [ #  # ]:          0 :         Selection aNewSel=pMEdit->GetSelection();
     823                 :            : 
     824 [ #  # ][ #  # ]:          0 :         if(aNewSel.Min()!=aOldSel.Min() || aNewSel.Max()!=aOldSel.Max())
                 [ #  # ]
     825                 :            :         {
     826         [ #  # ]:          0 :             SelectionChanged();
     827                 :          0 :             aOldSel=aNewSel;
     828                 :            :         }
     829                 :            :     }
     830                 :          0 :     return 0;
     831                 :            : }
     832                 :            : 
     833                 :          0 : void EditBox::UpdateOldSel()
     834                 :            : {
     835                 :            :     //  if selection is set for editing a function, store it as aOldSel,
     836                 :            :     //  so SelectionChanged isn't called in the next ChangedHdl call
     837                 :            : 
     838         [ #  # ]:          0 :     if (pMEdit)
     839                 :          0 :         aOldSel = pMEdit->GetSelection();
     840                 :          0 : }
     841                 :            : //----------------------------------------------------------------------------
     842                 :            : 
     843                 :            : //============================================================================
     844                 :            : //  class RefEdit
     845                 :            : //----------------------------------------------------------------------------
     846                 :            : 
     847                 :            : #define SC_ENABLE_TIME 100
     848                 :            : 
     849                 :          0 : RefEdit::RefEdit( Window* _pParent,IControlReferenceHandler* pParent, const ResId& rResId ) :
     850                 :            :     Edit( _pParent, rResId ),
     851         [ #  # ]:          0 :     pAnyRefDlg( pParent )
     852                 :            : {
     853         [ #  # ]:          0 :     aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
     854         [ #  # ]:          0 :     aTimer.SetTimeout( SC_ENABLE_TIME );
     855                 :          0 : }
     856                 :            : 
     857                 :          0 : RefEdit::RefEdit( Window* pParent, const ResId& rResId ) :
     858                 :            :     Edit( pParent, rResId ),
     859         [ #  # ]:          0 :     pAnyRefDlg( NULL )
     860                 :            : {
     861                 :          0 : }
     862                 :            : 
     863         [ #  # ]:          0 : RefEdit::~RefEdit()
     864                 :            : {
     865         [ #  # ]:          0 :     aTimer.SetTimeoutHdl( Link() );
     866         [ #  # ]:          0 :     aTimer.Stop();
     867         [ #  # ]:          0 : }
     868                 :            : 
     869                 :          0 : void RefEdit::SetRefString( const XubString& rStr )
     870                 :            : {
     871                 :          0 :     Edit::SetText( rStr );
     872                 :          0 : }
     873                 :            : 
     874                 :          0 : void RefEdit::SetRefValid(bool bValid)
     875                 :            : {
     876         [ #  # ]:          0 :     if (bValid)
     877                 :            :     {
     878                 :          0 :         SetControlForeground();
     879                 :          0 :         SetControlBackground();
     880                 :            :     }
     881                 :            :     else
     882                 :            :     {
     883         [ #  # ]:          0 :         SetControlForeground(COL_WHITE);
     884         [ #  # ]:          0 :         SetControlBackground(0xff6563);
     885                 :            :     }
     886                 :          0 : }
     887                 :            : 
     888                 :          0 : void RefEdit::SetText( const XubString& rStr )
     889                 :            : {
     890                 :          0 :     Edit::SetText( rStr );
     891                 :          0 :     UpdateHdl( &aTimer );
     892                 :          0 : }
     893                 :            : 
     894                 :          0 : void RefEdit::StartUpdateData()
     895                 :            : {
     896                 :          0 :     aTimer.Start();
     897                 :          0 : }
     898                 :            : 
     899                 :          0 : void RefEdit::SetRefDialog( IControlReferenceHandler* pDlg )
     900                 :            : {
     901                 :          0 :     pAnyRefDlg = pDlg;
     902                 :            : 
     903         [ #  # ]:          0 :     if( pDlg )
     904                 :            :     {
     905                 :          0 :         aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
     906                 :          0 :         aTimer.SetTimeout( SC_ENABLE_TIME );
     907                 :            :     }
     908                 :            :     else
     909                 :            :     {
     910                 :          0 :         aTimer.SetTimeoutHdl( Link() );
     911                 :          0 :         aTimer.Stop();
     912                 :            :     }
     913                 :          0 : }
     914                 :            : 
     915                 :          0 : void RefEdit::Modify()
     916                 :            : {
     917                 :          0 :     Edit::Modify();
     918         [ #  # ]:          0 :     if( pAnyRefDlg )
     919                 :          0 :         pAnyRefDlg->HideReference();
     920                 :          0 : }
     921                 :            : 
     922                 :          0 : void RefEdit::KeyInput( const KeyEvent& rKEvt )
     923                 :            : {
     924                 :          0 :     const KeyCode& rKeyCode = rKEvt.GetKeyCode();
     925 [ #  # ][ #  # ]:          0 :     if( pAnyRefDlg && !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
         [ #  # ][ #  # ]
     926                 :          0 :         pAnyRefDlg->ReleaseFocus( this );
     927                 :            :     else
     928                 :          0 :         Edit::KeyInput( rKEvt );
     929                 :          0 : }
     930                 :            : 
     931                 :          0 : void RefEdit::GetFocus()
     932                 :            : {
     933                 :          0 :     Edit::GetFocus();
     934                 :          0 :     StartUpdateData();
     935                 :          0 : }
     936                 :            : 
     937                 :          0 : void RefEdit::LoseFocus()
     938                 :            : {
     939                 :          0 :     Edit::LoseFocus();
     940         [ #  # ]:          0 :     if( pAnyRefDlg )
     941                 :          0 :         pAnyRefDlg->HideReference();
     942                 :          0 : }
     943                 :            : 
     944                 :          0 : IMPL_LINK_NOARG(RefEdit, UpdateHdl)
     945                 :            : {
     946         [ #  # ]:          0 :     if( pAnyRefDlg )
     947         [ #  # ]:          0 :         pAnyRefDlg->ShowReference( GetText() );
     948                 :          0 :     return 0;
     949                 :            : }
     950                 :            : 
     951                 :            : 
     952                 :            : //============================================================================
     953                 :            : //  class RefButton
     954                 :            : //----------------------------------------------------------------------------
     955                 :          0 : RefButton::RefButton( Window* _pParent, const ResId& rResId) :
     956                 :            :     ImageButton( _pParent, rResId ),
     957                 :            :     aImgRefStart( ModuleRes( RID_BMP_REFBTN1 ) ),
     958                 :            :     aImgRefDone( ModuleRes( RID_BMP_REFBTN2 ) ),
     959                 :            :     pAnyRefDlg( NULL ),
     960 [ #  # ][ #  # ]:          0 :     pRefEdit( NULL )
         [ #  # ][ #  # ]
     961                 :            : {
     962         [ #  # ]:          0 :     SetStartImage();
     963                 :          0 : }
     964                 :            : 
     965                 :          0 : RefButton::RefButton( Window* _pParent, const ResId& rResId, RefEdit* pEdit, IControlReferenceHandler* _pDlg ) :
     966                 :            :     ImageButton( _pParent, rResId ),
     967                 :            :     aImgRefStart( ModuleRes( RID_BMP_REFBTN1 ) ),
     968                 :            :     aImgRefDone( ModuleRes( RID_BMP_REFBTN2 ) ),
     969                 :            :     pAnyRefDlg( _pDlg ),
     970 [ #  # ][ #  # ]:          0 :     pRefEdit( pEdit )
         [ #  # ][ #  # ]
     971                 :            : {
     972         [ #  # ]:          0 :     SetStartImage();
     973                 :          0 : }
     974                 :            : 
     975                 :          0 : void RefButton::SetStartImage()
     976                 :            : {
     977                 :          0 :     SetModeImage( aImgRefStart );
     978                 :          0 : }
     979                 :            : 
     980                 :          0 : void RefButton::SetEndImage()
     981                 :            : {
     982                 :          0 :     SetModeImage( aImgRefDone );
     983                 :          0 : }
     984                 :            : 
     985                 :          0 : void RefButton::SetReferences( IControlReferenceHandler* pDlg, RefEdit* pEdit )
     986                 :            : {
     987                 :          0 :     pAnyRefDlg = pDlg;
     988                 :          0 :     pRefEdit = pEdit;
     989                 :          0 : }
     990                 :            : 
     991                 :            : //----------------------------------------------------------------------------
     992                 :            : 
     993                 :          0 : void RefButton::Click()
     994                 :            : {
     995         [ #  # ]:          0 :     if( pAnyRefDlg )
     996                 :          0 :         pAnyRefDlg->ToggleCollapsed( pRefEdit, this );
     997                 :          0 : }
     998                 :            : 
     999                 :          0 : void RefButton::KeyInput( const KeyEvent& rKEvt )
    1000                 :            : {
    1001                 :          0 :     const KeyCode& rKeyCode = rKEvt.GetKeyCode();
    1002 [ #  # ][ #  # ]:          0 :     if( pAnyRefDlg && !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
         [ #  # ][ #  # ]
    1003                 :          0 :         pAnyRefDlg->ReleaseFocus( pRefEdit );
    1004                 :            :     else
    1005                 :          0 :         ImageButton::KeyInput( rKEvt );
    1006                 :          0 : }
    1007                 :            : 
    1008                 :          0 : void RefButton::GetFocus()
    1009                 :            : {
    1010                 :          0 :     ImageButton::GetFocus();
    1011         [ #  # ]:          0 :     if( pRefEdit )
    1012                 :          0 :         pRefEdit->StartUpdateData();
    1013                 :          0 : }
    1014                 :            : 
    1015                 :          0 : void RefButton::LoseFocus()
    1016                 :            : {
    1017                 :          0 :     ImageButton::LoseFocus();
    1018         [ #  # ]:          0 :     if( pRefEdit )
    1019                 :          0 :         pRefEdit->Modify();
    1020                 :          0 : }
    1021                 :            : 
    1022                 :            : 
    1023                 :            : } // formula
    1024                 :            : 
    1025                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10