LCOV - code coverage report
Current view: top level - sc/source/ui/navipi - navipi.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 3 681 0.4 %
Date: 2014-04-11 Functions: 3 80 3.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <rangelst.hxx>
      21             : #include <sfx2/app.hxx>
      22             : #include <sfx2/bindings.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : #include <sfx2/event.hxx>
      25             : #include <sfx2/imgmgr.hxx>
      26             : #include <sfx2/navigat.hxx>
      27             : #include <svl/stritem.hxx>
      28             : #include <svl/urlbmk.hxx>
      29             : #include <vcl/settings.hxx>
      30             : #include <unotools/charclass.hxx>
      31             : #include <stdlib.h>
      32             : 
      33             : #include "viewdata.hxx"
      34             : #include "tabvwsh.hxx"
      35             : #include "docsh.hxx"
      36             : #include "document.hxx"
      37             : #include "dbdata.hxx"
      38             : #include "rangenam.hxx"
      39             : #include "rangeutl.hxx"
      40             : #include "popmenu.hxx"
      41             : #include "scresid.hxx"
      42             : #include "scmod.hxx"
      43             : #include "navicfg.hxx"
      44             : #include "navcitem.hxx"
      45             : #include "navipi.hrc"
      46             : #include "navipi.hxx"
      47             : #include "navsett.hxx"
      48             : #include "markdata.hxx"
      49             : 
      50             : #include <algorithm>
      51             : 
      52             : //  Timeout, um Notizen zu suchen
      53             : #define SC_CONTENT_TIMEOUT  1000
      54             : 
      55             : //  Toleranz, wieviel ueber der eingeklappten Groesse noch klein ist
      56             : #define SCNAV_MINTOL        5
      57             : 
      58             : //  maximum values for UI
      59             : #define SCNAV_MAXCOL        (MAXCOLCOUNT)
      60             : // macro is sufficient since only used in ctor
      61             : #define SCNAV_COLDIGITS     (static_cast<sal_Int32>( floor( log10( static_cast<double>(SCNAV_MAXCOL)))) + 1)   // 1...256...18278
      62             : // precomputed constant because it is used in every change of spin button field
      63          34 : static const sal_Int32 SCNAV_COLLETTERS = ::ScColToAlpha(SCNAV_MAXCOL).getLength();    // A...IV...ZZZ
      64             : 
      65             : #define SCNAV_MAXROW        (MAXROWCOUNT)
      66             : 
      67           0 : void ScNavigatorDlg::ReleaseFocus()
      68             : {
      69           0 :     SfxViewShell* pCurSh = SfxViewShell::Current();
      70             : 
      71           0 :     if ( pCurSh )
      72             :     {
      73           0 :         Window* pShellWnd = pCurSh->GetWindow();
      74           0 :         if ( pShellWnd )
      75           0 :             pShellWnd->GrabFocus();
      76             :     }
      77           0 : }
      78             : 
      79             : 
      80             : //  class ColumnEdit
      81             : 
      82             : 
      83           0 : ColumnEdit::ColumnEdit( ScNavigatorDlg* pParent, const ResId& rResId )
      84             :     :   SpinField   ( pParent, rResId ),
      85             :         rDlg        ( *pParent ),
      86             :         nCol        ( 0 ),
      87           0 :         nKeyGroup   ( KEYGROUP_ALPHA )
      88             : {
      89           0 :     SetMaxTextLen( SCNAV_COLDIGITS );   // 1...256...18278 or A...IV...ZZZ
      90           0 : }
      91             : 
      92           0 : ColumnEdit::~ColumnEdit()
      93             : {
      94           0 : }
      95             : 
      96           0 : bool ColumnEdit::Notify( NotifyEvent& rNEvt )
      97             : {
      98           0 :     bool nHandled = SpinField::Notify( rNEvt );
      99             : 
     100           0 :     sal_uInt16 nType = rNEvt.GetType();
     101           0 :     if ( nType == EVENT_KEYINPUT )
     102             :     {
     103           0 :         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
     104           0 :         KeyCode aCode = pKEvt->GetKeyCode();
     105             : 
     106           0 :         if ( !aCode.IsMod1() && !aCode.IsMod2() )
     107             :         {
     108             :             //! Eingabeueberpruefung (nur Zahlen oder nur Buchstaben, max 2 bzw 3 Stellen)
     109             :             //! war vor VCL per nicht weitergeleitetem KeyInput
     110             :             //! dafuer was neues ausdenken!!!
     111             : 
     112           0 :             if ( aCode.GetCode() == KEY_RETURN )
     113             :             {
     114           0 :                 ScNavigatorDlg::ReleaseFocus();
     115           0 :                 ExecuteCol();
     116           0 :                 nHandled = true;
     117             :             }
     118             :         }
     119             :     }
     120           0 :     else if ( nType == EVENT_LOSEFOCUS )    // LoseFocus wird bei VCL nicht gerufen
     121           0 :         EvalText();                         // nCol setzen
     122             : 
     123           0 :     return nHandled;
     124             : }
     125             : 
     126           0 : void ColumnEdit::LoseFocus()
     127             : {
     128           0 :     EvalText();
     129           0 : }
     130             : 
     131             : 
     132           0 : void ColumnEdit::Up()
     133             : {
     134           0 :     nCol++;
     135             : 
     136           0 :     if ( nCol <= SCNAV_MAXCOL )
     137           0 :         SetCol( nCol );
     138             :     else
     139           0 :         nCol--;
     140           0 : }
     141             : 
     142           0 : void ColumnEdit::Down()
     143             : {
     144           0 :     if ( nCol>1 )
     145           0 :         SetCol( nCol-1 );
     146           0 : }
     147             : 
     148           0 : void ColumnEdit::First()
     149             : {
     150           0 :     nCol = 1;
     151           0 :     SetText(OUString('A'));
     152           0 : }
     153             : 
     154           0 : void ColumnEdit::Last()
     155             : {
     156           0 :     OUString aStr;
     157           0 :     nCol = NumToAlpha( SCNAV_MAXCOL, aStr );
     158           0 :     SetText( aStr );
     159           0 : }
     160             : 
     161             : 
     162           0 : void ColumnEdit::EvalText()
     163             : {
     164           0 :     OUString aStrCol = GetText();
     165             : 
     166           0 :     if (!aStrCol.isEmpty())
     167             :     {
     168             :         //  nKeyGroup wird bei VCL mangels KeyInput nicht mehr gesetzt
     169             : 
     170           0 :         if ( CharClass::isAsciiNumeric(aStrCol) )
     171           0 :             nCol = NumStrToAlpha( aStrCol );
     172             :         else
     173           0 :             nCol = AlphaToNum( aStrCol );
     174             :     }
     175             :     else
     176           0 :         nCol = 0;
     177             : 
     178           0 :     SetText( aStrCol );
     179           0 :     nKeyGroup = KEYGROUP_ALPHA;
     180           0 : }
     181             : 
     182           0 : void ColumnEdit::ExecuteCol()
     183             : {
     184           0 :     SCROW nRow = rDlg.aEdRow.GetRow();
     185             : 
     186           0 :     EvalText(); // setzt nCol
     187             : 
     188           0 :     if ( (nCol > 0) && (nRow > 0) )
     189           0 :         rDlg.SetCurrentCell( nCol-1, nRow-1 );
     190           0 : }
     191             : 
     192           0 : void ColumnEdit::SetCol( SCCOL nColNo )
     193             : {
     194           0 :     OUString aStr;
     195             : 
     196           0 :     if ( nColNo == 0 )
     197             :     {
     198           0 :         nCol = 0;
     199           0 :         SetText( aStr );
     200             :     }
     201             :     else
     202             :     {
     203           0 :         nColNo = NumToAlpha( nColNo, aStr );
     204           0 :         nCol = nColNo;
     205           0 :         SetText( aStr );
     206           0 :     }
     207           0 : }
     208             : 
     209           0 : SCCOL ColumnEdit::AlphaToNum( OUString& rStr )
     210             : {
     211           0 :     SCCOL  nColumn = 0;
     212             : 
     213           0 :     if ( CharClass::isAsciiAlpha( rStr) )
     214             :     {
     215           0 :         rStr = rStr.toAsciiUpperCase();
     216             : 
     217           0 :         if (::AlphaToCol( nColumn, rStr))
     218           0 :             ++nColumn;
     219             : 
     220           0 :         if ( (rStr.getLength() > SCNAV_COLLETTERS) || (nColumn > SCNAV_MAXCOL) )
     221             :         {
     222           0 :             nColumn = SCNAV_MAXCOL;
     223           0 :             NumToAlpha( nColumn, rStr );
     224             :         }
     225             :     }
     226             :     else
     227           0 :         rStr = "";
     228             : 
     229           0 :     return nColumn;
     230             : }
     231             : 
     232           0 : SCCOL ColumnEdit::NumStrToAlpha( OUString& rStr )
     233             : {
     234           0 :     SCCOL  nColumn = 0;
     235             : 
     236           0 :     if ( CharClass::isAsciiNumeric(rStr) )
     237           0 :         nColumn = NumToAlpha( (SCCOL)rStr.toInt32(), rStr );
     238             :     else
     239           0 :         rStr = "";
     240             : 
     241           0 :     return nColumn;
     242             : }
     243             : 
     244           0 : SCCOL ColumnEdit::NumToAlpha( SCCOL nColNo, OUString& rStr )
     245             : {
     246           0 :     if ( nColNo > SCNAV_MAXCOL )
     247           0 :         nColNo = SCNAV_MAXCOL;
     248           0 :     else if ( nColNo < 1 )
     249           0 :         nColNo = 1;
     250             : 
     251           0 :     ::ScColToAlpha( rStr, nColNo - 1);
     252             : 
     253           0 :     return nColNo;
     254             : }
     255             : 
     256             : 
     257             : //  class RowEdit
     258             : 
     259             : 
     260           0 : RowEdit::RowEdit( ScNavigatorDlg* pParent, const ResId& rResId )
     261             :     :   NumericField( pParent, rResId ),
     262           0 :         rDlg        ( *pParent )
     263             : {
     264           0 :     SetMax( SCNAV_MAXROW);
     265           0 :     SetLast( SCNAV_MAXROW);
     266           0 : }
     267             : 
     268           0 : RowEdit::~RowEdit()
     269             : {
     270           0 : }
     271             : 
     272           0 : bool RowEdit::Notify( NotifyEvent& rNEvt )
     273             : {
     274           0 :     bool nHandled = NumericField::Notify( rNEvt );
     275             : 
     276           0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT )
     277             :     {
     278           0 :         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
     279           0 :         KeyCode aCode = pKEvt->GetKeyCode();
     280           0 :         if ( aCode.GetCode() == KEY_RETURN && !aCode.IsMod1() && !aCode.IsMod2() )
     281             :         {
     282           0 :             ScNavigatorDlg::ReleaseFocus();
     283           0 :             ExecuteRow();
     284           0 :             nHandled = true;
     285             :         }
     286             :     }
     287             : 
     288           0 :     return nHandled;
     289             : }
     290             : 
     291           0 : void RowEdit::LoseFocus()
     292             : {
     293           0 : }
     294             : 
     295           0 : void RowEdit::ExecuteRow()
     296             : {
     297           0 :     SCCOL nCol = rDlg.aEdCol.GetCol();
     298           0 :     SCROW nRow = (SCROW)GetValue();
     299             : 
     300           0 :     if ( (nCol > 0) && (nRow > 0) )
     301           0 :         rDlg.SetCurrentCell( nCol-1, nRow-1 );
     302           0 : }
     303             : 
     304             : 
     305             : //  class ScDocListBox
     306             : 
     307             : 
     308           0 : ScDocListBox::ScDocListBox( ScNavigatorDlg* pParent, const ResId& rResId )
     309             :     :   ListBox ( pParent, rResId ),
     310           0 :         rDlg    ( *pParent )
     311             : {
     312           0 : }
     313             : 
     314           0 : ScDocListBox::~ScDocListBox()
     315             : {
     316           0 : }
     317             : 
     318           0 : void ScDocListBox::Select()
     319             : {
     320           0 :     ScNavigatorDlg::ReleaseFocus();
     321             : 
     322           0 :     OUString aDocName = GetSelectEntry();
     323           0 :     rDlg.aLbEntries.SelectDoc( aDocName );
     324           0 : }
     325             : 
     326             : 
     327             : //  class CommandToolBox
     328             : 
     329             : 
     330           0 : CommandToolBox::CommandToolBox( ScNavigatorDlg* pParent, const ResId& rResId )
     331             :     :   ToolBox ( pParent, rResId ),
     332           0 :         rDlg    ( *pParent )
     333             : {
     334           0 :     InitImageList();    // ImageList members of ScNavigatorDlg must be initialized before!
     335             : 
     336           0 :     SetSizePixel( CalcWindowSizePixel() );
     337           0 :     SetDropdownClickHdl( LINK(this, CommandToolBox, ToolBoxDropdownClickHdl) );
     338           0 :     SetItemBits( IID_DROPMODE, GetItemBits( IID_DROPMODE ) | TIB_DROPDOWNONLY );
     339           0 : }
     340             : 
     341           0 : CommandToolBox::~CommandToolBox()
     342             : {
     343           0 : }
     344             : 
     345           0 : void CommandToolBox::Select( sal_uInt16 nSelId )
     346             : {
     347             :     //  Modus umschalten ?
     348             : 
     349           0 :     if ( nSelId == IID_ZOOMOUT || nSelId == IID_SCENARIOS )
     350             :     {
     351           0 :         NavListMode eOldMode = rDlg.eListMode;
     352           0 :         NavListMode eNewMode = eOldMode;
     353             : 
     354           0 :         if ( nSelId == IID_SCENARIOS )                  // auf Szenario
     355             :         {
     356           0 :             if ( eOldMode == NAV_LMODE_SCENARIOS )
     357           0 :                 eNewMode = NAV_LMODE_AREAS;
     358             :             else
     359           0 :                 eNewMode = NAV_LMODE_SCENARIOS;
     360             :         }
     361             :         else                                            // ein/aus
     362             :         {
     363           0 :             if ( eOldMode == NAV_LMODE_NONE )
     364           0 :                 eNewMode = NAV_LMODE_AREAS;
     365             :             else
     366           0 :                 eNewMode = NAV_LMODE_NONE;
     367             :         }
     368           0 :         rDlg.SetListMode( eNewMode );
     369           0 :         UpdateButtons();
     370             :     }
     371             :     else
     372           0 :         switch ( nSelId )
     373             :         {
     374             :             case IID_DATA:
     375           0 :                 rDlg.MarkDataArea();
     376           0 :                 break;
     377             :             case IID_UP:
     378           0 :                 rDlg.StartOfDataArea();
     379           0 :                 break;
     380             :             case IID_DOWN:
     381           0 :                 rDlg.EndOfDataArea();
     382           0 :                 break;
     383             :             case IID_CHANGEROOT:
     384           0 :                 rDlg.aLbEntries.ToggleRoot();
     385           0 :                 UpdateButtons();
     386           0 :                 break;
     387             :         }
     388           0 : }
     389             : 
     390           0 : void CommandToolBox::Select()
     391             : {
     392           0 :     Select( GetCurItemId() );
     393           0 : }
     394             : 
     395           0 : void CommandToolBox::Click()
     396             : {
     397           0 : }
     398             : 
     399           0 : IMPL_LINK_NOARG(CommandToolBox, ToolBoxDropdownClickHdl)
     400             : {
     401             :     //  Das Popupmenue fuer den Dropmodus muss im Click (Button Down)
     402             :     //  statt im Select (Button Up) aufgerufen werden.
     403             : 
     404           0 :     if ( GetCurItemId() == IID_DROPMODE )
     405             :     {
     406           0 :         ScPopupMenu aPop( ScResId( RID_POPUP_DROPMODE ) );
     407           0 :         aPop.CheckItem( RID_DROPMODE_URL + rDlg.GetDropMode() );
     408           0 :         aPop.Execute( this, GetItemRect(IID_DROPMODE), POPUPMENU_EXECUTE_DOWN );
     409           0 :         sal_uInt16 nId = aPop.GetSelected();
     410             : 
     411           0 :         EndSelection();     // vor SetDropMode (SetDropMode ruft SetItemImage)
     412             : 
     413           0 :         if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
     414           0 :             rDlg.SetDropMode( nId - RID_DROPMODE_URL );
     415             : 
     416             :         //  den gehighlighteten Button aufheben
     417           0 :         Point aPoint;
     418           0 :         MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC );
     419           0 :         MouseMove( aLeave );
     420             :     }
     421             : 
     422           0 :     return 1;
     423             : }
     424             : 
     425           0 : void CommandToolBox::UpdateButtons()
     426             : {
     427           0 :     NavListMode eMode = rDlg.eListMode;
     428           0 :     CheckItem( IID_SCENARIOS,   eMode == NAV_LMODE_SCENARIOS );
     429           0 :     CheckItem( IID_ZOOMOUT,     eMode != NAV_LMODE_NONE );
     430             : 
     431             :     //  Umschalten-Button:
     432           0 :     if ( eMode == NAV_LMODE_SCENARIOS || eMode == NAV_LMODE_NONE )
     433             :     {
     434           0 :         EnableItem( IID_CHANGEROOT, false );
     435           0 :         CheckItem( IID_CHANGEROOT, false );
     436             :     }
     437             :     else
     438             :     {
     439           0 :         EnableItem( IID_CHANGEROOT, true );
     440           0 :         sal_Bool bRootSet = rDlg.aLbEntries.GetRootType() != SC_CONTENT_ROOT;
     441           0 :         CheckItem( IID_CHANGEROOT, bRootSet );
     442             :     }
     443             : 
     444           0 :     sal_uInt16 nImageId = 0;
     445           0 :     switch ( rDlg.nDropMode )
     446             :     {
     447           0 :         case SC_DROPMODE_URL:   nImageId = RID_IMG_DROP_URL;  break;
     448           0 :         case SC_DROPMODE_LINK:  nImageId = RID_IMG_DROP_LINK; break;
     449           0 :         case SC_DROPMODE_COPY:  nImageId = RID_IMG_DROP_COPY; break;
     450             :     }
     451           0 :     SetItemImage( IID_DROPMODE, Image(ScResId(nImageId)) );
     452           0 : }
     453             : 
     454           0 : void CommandToolBox::InitImageList()
     455             : {
     456           0 :     ImageList& rImgLst = rDlg.aCmdImageList;
     457             : 
     458           0 :     sal_uInt16 nCount = GetItemCount();
     459           0 :     for (sal_uInt16 i = 0; i < nCount; i++)
     460             :     {
     461           0 :         sal_uInt16 nId = GetItemId(i);
     462           0 :         SetItemImage( nId, rImgLst.GetImage( nId ) );
     463             :     }
     464           0 : }
     465             : 
     466           0 : void CommandToolBox::DataChanged( const DataChangedEvent& rDCEvt )
     467             : {
     468           0 :     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     469             :     {
     470             :         //  update item images
     471             : 
     472           0 :         InitImageList();
     473           0 :         UpdateButtons();    // drop mode
     474             :     }
     475             : 
     476           0 :     ToolBox::DataChanged( rDCEvt );
     477           0 : }
     478             : 
     479             : 
     480             : //  class ScNavigatorSettings
     481             : 
     482             : 
     483           0 : ScNavigatorSettings::ScNavigatorSettings() :
     484             :     maExpandedVec( SC_CONTENT_COUNT, false ),
     485             :     mnRootSelected( SC_CONTENT_ROOT ),
     486           0 :     mnChildSelected( SC_CONTENT_NOCHILD )
     487             : {
     488           0 : }
     489             : 
     490             : 
     491             : //  class ScNavigatorDlgWrapper
     492             : 
     493             : 
     494          34 : SFX_IMPL_CHILDWINDOWCONTEXT( ScNavigatorDialogWrapper, SID_NAVIGATOR )
     495             : 
     496           0 : ScNavigatorDialogWrapper::ScNavigatorDialogWrapper(
     497             :                                     Window*          pParent,
     498             :                                     sal_uInt16           nId,
     499             :                                     SfxBindings*     pBind,
     500             :                                     SfxChildWinInfo* /* pInfo */ ) :
     501           0 :         SfxChildWindowContext( nId )
     502             : {
     503           0 :     pNavigator = new ScNavigatorDlg( pBind, this, pParent, true );
     504           0 :     SetWindow( pNavigator );
     505             : 
     506             :     //  Einstellungen muessen anderswo gemerkt werden,
     507             :     //  pInfo geht uns (ausser der Groesse) nichts mehr an
     508             : 
     509           0 :     Size aInfoSize = pParent->GetOutputSizePixel();     // von aussen vorgegebene Groesse
     510           0 :     Size aNavSize = pNavigator->GetOutputSizePixel();   // Default-Groesse
     511             : 
     512           0 :     aNavSize.Width()  = std::max( aInfoSize.Width(),  aNavSize.Width() );
     513           0 :     aNavSize.Height() = std::max( aInfoSize.Height(), aNavSize.Height() );
     514           0 :     pNavigator->nListModeHeight = std::max( aNavSize.Height(), pNavigator->nListModeHeight );
     515             : 
     516             :     //  Die Groesse kann in einem anderen Modul geaendert worden sein,
     517             :     //  deshalb muessen in Abhaengigkeit von der momentanen Groesse die
     518             :     //  Inhalte eingeblendet werden oder nicht
     519             : 
     520           0 :     sal_Bool bSmall = ( aInfoSize.Height() <= pNavigator->aInitSize.Height() + SCNAV_MINTOL );
     521           0 :     NavListMode eNavMode = NAV_LMODE_NONE;
     522           0 :     if (!bSmall)
     523             :     {
     524             :         //  wenn Szenario aktiv war, wieder einschalten
     525             : 
     526           0 :         ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
     527           0 :         NavListMode eLastMode = (NavListMode) rCfg.GetListMode();
     528           0 :         if ( eLastMode == NAV_LMODE_SCENARIOS )
     529           0 :             eNavMode = NAV_LMODE_SCENARIOS;
     530             :         else
     531           0 :             eNavMode = NAV_LMODE_AREAS;
     532             :     }
     533             : 
     534             :     //  Die Groesse des Floats nicht neu setzen (sal_False bei SetListMode), damit der
     535             :     //  Navigator nicht aufgeklappt wird, wenn er minimiert war (#38872#).
     536             : 
     537           0 :     pNavigator->SetListMode( eNavMode, false );     // FALSE: Groesse des Float nicht setzen
     538             : 
     539             :     sal_uInt16 nCmdId;
     540           0 :     switch (eNavMode)
     541             :     {
     542           0 :         case NAV_LMODE_DOCS:        nCmdId = IID_DOCS;      break;
     543           0 :         case NAV_LMODE_AREAS:       nCmdId = IID_AREAS;     break;
     544           0 :         case NAV_LMODE_DBAREAS:     nCmdId = IID_DBAREAS;   break;
     545           0 :         case NAV_LMODE_SCENARIOS:   nCmdId = IID_SCENARIOS; break;
     546           0 :         default:                    nCmdId = 0;
     547             :     }
     548           0 :     if (nCmdId)
     549             :     {
     550           0 :         pNavigator->aTbxCmd.CheckItem( nCmdId );
     551           0 :         pNavigator->DoResize();
     552             :     }
     553             : 
     554           0 :     pNavigator->bFirstBig = ( nCmdId == 0 );    // dann spaeter
     555           0 : }
     556             : 
     557           0 : void ScNavigatorDialogWrapper::Resizing( Size& rSize )
     558             : {
     559           0 :     ((ScNavigatorDlg*)GetWindow())->Resizing(rSize);
     560           0 : }
     561             : 
     562             : 
     563             : // class ScNavigatorPI
     564             : 
     565             : 
     566             : #define CTRL_ITEMS 4
     567             : 
     568             : #define REGISTER_SLOT(i,id) \
     569             :     ppBoundItems[i]=new ScNavigatorControllerItem(id,*this,rBindings);
     570             : 
     571           0 : ScNavigatorDlg::ScNavigatorDlg( SfxBindings* pB, SfxChildWindowContext* pCW, Window* pParent,
     572             :     const bool bUseStyleSettingsBackground) :
     573             :         Window( pParent, ScResId(RID_SCDLG_NAVIGATOR) ),
     574             :         rBindings   ( *pB ),                                // is used in CommandToolBox ctor
     575             :         aCmdImageList( ScResId( IL_CMD ) ),
     576             :         aFtCol      ( this, ScResId( FT_COL ) ),
     577             :         aEdCol      ( this, ScResId( ED_COL ) ),
     578             :         aFtRow      ( this, ScResId( FT_ROW ) ),
     579             :         aEdRow      ( this, ScResId( ED_ROW ) ),
     580             :         aTbxCmd     ( this, ScResId( TBX_CMD ) ),
     581             :         aLbEntries  ( this, ScResId( LB_ENTRIES ) ),
     582             :         aWndScenarios( this,ScResId( STR_QHLP_SCEN_LISTBOX), ScResId(STR_QHLP_SCEN_COMMENT)),
     583             :         aLbDocuments( this, ScResId( LB_DOCUMENTS ) ),
     584             :         aStrDragMode ( ScResId( STR_DRAGMODE ) ),
     585             :         aStrDisplay  ( ScResId( STR_DISPLAY ) ),
     586             :         aStrActiveWin( ScResId( STR_ACTIVEWIN ) ),
     587             :         pContextWin ( pCW ),
     588             :         pMarkArea   ( NULL ),
     589             :         pViewData   ( NULL ),
     590             :         nListModeHeight( 0 ),
     591             :         nInitListHeight( 0 ),
     592             :         eListMode   ( NAV_LMODE_NONE ),
     593             :         nDropMode   ( SC_DROPMODE_URL ),
     594             :         nCurCol     ( 0 ),
     595             :         nCurRow     ( 0 ),
     596             :         nCurTab     ( 0 ),
     597             :         bFirstBig   ( false ),
     598           0 :         mbUseStyleSettingsBackground(bUseStyleSettingsBackground)
     599             : {
     600           0 :     ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
     601           0 :     nDropMode = rCfg.GetDragMode();
     602             :     //  eListMode wird von aussen gesetzt, Root weiter unten
     603             : 
     604           0 :     aLbDocuments.SetDropDownLineCount(9);
     605           0 :     OUString aOpen(" (");
     606           0 :     aStrActive = aOpen;
     607           0 :     aStrActive += OUString( ScResId( STR_ACTIVE ) );
     608           0 :     aStrActive += ")";                                      // " (aktiv)"
     609           0 :     aStrNotActive = aOpen;
     610           0 :     aStrNotActive += OUString( ScResId( STR_NOTACTIVE ) );
     611           0 :     aStrNotActive += ")";                                   // " (inaktiv)"
     612           0 :     aStrHidden = aOpen;
     613           0 :     aStrHidden += OUString( ScResId( STR_HIDDEN ) );
     614           0 :     aStrHidden += ")";                                      // " (versteckt)"
     615             : 
     616           0 :     aTitleBase = GetText();
     617             : 
     618             :     const long nListboxYPos =
     619             :         ::std::max(
     620           0 :             (aTbxCmd.GetPosPixel().Y() + aTbxCmd.GetSizePixel().Height()),
     621           0 :             (aEdRow.GetPosPixel().Y() + aEdRow.GetSizePixel().Height()) )
     622           0 :         + 4;
     623           0 :     aLbEntries.setPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y);
     624             : 
     625           0 :     nBorderOffset = aLbEntries.GetPosPixel().X();
     626             : 
     627           0 :     aInitSize.Width()  =  aTbxCmd.GetPosPixel().X()
     628           0 :                         + aTbxCmd.GetSizePixel().Width()
     629           0 :                         + nBorderOffset;
     630           0 :     aInitSize.Height() = aLbEntries.GetPosPixel().Y();
     631             : 
     632           0 :     nInitListHeight = aLbEntries.GetSizePixel().Height();
     633           0 :     nListModeHeight =  aInitSize.Height()
     634           0 :                      + nInitListHeight;
     635             : 
     636           0 :     ppBoundItems = new ScNavigatorControllerItem* [CTRL_ITEMS];
     637             : 
     638           0 :     rBindings.ENTERREGISTRATIONS();
     639             : 
     640           0 :     REGISTER_SLOT( 0, SID_CURRENTCELL       );
     641           0 :     REGISTER_SLOT( 1, SID_CURRENTTAB        );
     642           0 :     REGISTER_SLOT( 2, SID_CURRENTDOC        );
     643           0 :     REGISTER_SLOT( 3, SID_SELECT_SCENARIO   );
     644             : 
     645           0 :     rBindings.LEAVEREGISTRATIONS();
     646             : 
     647           0 :     StartListening( *(SFX_APP()) );
     648           0 :     StartListening( rBindings );
     649             : 
     650           0 :     aLbDocuments.Hide();        // bei NAV_LMODE_NONE gibts die nicht
     651             : 
     652           0 :     aLbEntries.InitWindowBits(true);
     653             : 
     654           0 :     aLbEntries.SetSpaceBetweenEntries(0);
     655           0 :     aLbEntries.SetSelectionMode( SINGLE_SELECTION );
     656             :     aLbEntries.SetDragDropMode(     SV_DRAGDROP_CTRL_MOVE |
     657             :                                     SV_DRAGDROP_CTRL_COPY |
     658           0 :                                     SV_DRAGDROP_ENABLE_TOP );
     659             : 
     660             :     //  war eine Kategorie als Root ausgewaehlt?
     661           0 :     sal_uInt16 nLastRoot = rCfg.GetRootType();
     662           0 :     if ( nLastRoot )
     663           0 :         aLbEntries.SetRootType( nLastRoot );
     664             : 
     665           0 :     aLbEntries.Refresh();
     666           0 :     GetDocNames();
     667             : 
     668           0 :     aTbxCmd.UpdateButtons();
     669             : 
     670           0 :     UpdateColumn();
     671           0 :     UpdateRow();
     672           0 :     UpdateTable();
     673           0 :     aLbEntries.Hide();
     674           0 :     aWndScenarios.Hide();
     675           0 :     aWndScenarios.SetPosPixel( aLbEntries.GetPosPixel() );
     676             : 
     677           0 :     aContentTimer.SetTimeoutHdl( LINK( this, ScNavigatorDlg, TimeHdl ) );
     678           0 :     aContentTimer.SetTimeout( SC_CONTENT_TIMEOUT );
     679             : 
     680           0 :     FreeResource();
     681             : 
     682           0 :     aLbEntries.SetAccessibleRelationLabeledBy(&aLbEntries);
     683           0 :     aTbxCmd.SetAccessibleRelationLabeledBy(&aTbxCmd);
     684           0 :     aLbDocuments.SetAccessibleName(aStrActiveWin);
     685             : 
     686           0 :     if (pContextWin == NULL)
     687             :     {
     688             :         // When the context window is missing then the navigator is
     689             :         // displayed in the sidebar and has the whole deck to fill.
     690             :         // Therefore hide the button that hides all controls below the
     691             :         // top two rows of buttons.
     692           0 :         aTbxCmd.Select(IID_ZOOMOUT);
     693           0 :         aTbxCmd.RemoveItem(aTbxCmd.GetItemPos(IID_ZOOMOUT));
     694             :     }
     695           0 :     aLbEntries.SetNavigatorDlgFlag(true);
     696           0 : }
     697             : 
     698           0 : ScNavigatorDlg::~ScNavigatorDlg()
     699             : {
     700           0 :     aContentTimer.Stop();
     701             : 
     702             :     sal_uInt16 i;
     703           0 :     for ( i=0; i<CTRL_ITEMS; i++ )
     704           0 :         delete ppBoundItems[i];
     705             : 
     706           0 :     delete [] ppBoundItems;
     707           0 :     delete pMarkArea;
     708             : 
     709           0 :     EndListening( *(SFX_APP()) );
     710           0 :     EndListening( rBindings );
     711           0 : }
     712             : 
     713           0 : void ScNavigatorDlg::Resizing( Size& rNewSize )  // Size = Outputsize?
     714             : {
     715           0 :     FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
     716           0 :     if ( pFloat )
     717             :     {
     718           0 :         Size aMinOut = pFloat->GetMinOutputSizePixel();
     719             : 
     720           0 :         if ( rNewSize.Width() < aMinOut.Width() )
     721           0 :             rNewSize.Width() = aMinOut.Width();
     722             : 
     723           0 :         if ( eListMode == NAV_LMODE_NONE )
     724           0 :             rNewSize.Height() = aInitSize.Height();
     725             :         else
     726             :         {
     727           0 :             if ( rNewSize.Height() < aMinOut.Height() )
     728           0 :                 rNewSize.Height() = aMinOut.Height();
     729             :         }
     730             :     }
     731           0 : }
     732             : 
     733           0 : void ScNavigatorDlg::Paint( const Rectangle& rRect )
     734             : {
     735           0 :     if (mbUseStyleSettingsBackground)
     736             :     {
     737           0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     738           0 :         Color aBgColor = rStyleSettings.GetFaceColor();
     739           0 :         Wallpaper aBack( aBgColor );
     740             : 
     741           0 :         SetBackground( aBack );
     742           0 :         aFtCol.SetBackground( aBack );
     743           0 :         aFtRow.SetBackground( aBack );
     744             :     }
     745             :     else
     746             :     {
     747           0 :         aFtCol.SetBackground(Wallpaper());
     748           0 :         aFtRow.SetBackground(Wallpaper());
     749             :     }
     750             : 
     751           0 :     Window::Paint( rRect );
     752           0 : }
     753             : 
     754           0 : void ScNavigatorDlg::DataChanged( const DataChangedEvent& rDCEvt )
     755             : {
     756           0 :     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     757             :     {
     758             :         //  toolbox images are exchanged in CommandToolBox::DataChanged
     759           0 :         Invalidate();
     760             :     }
     761             : 
     762           0 :     Window::DataChanged( rDCEvt );
     763           0 : }
     764             : 
     765           0 : void ScNavigatorDlg::Resize()
     766             : {
     767           0 :     DoResize();
     768           0 : }
     769             : 
     770           0 : void ScNavigatorDlg::DoResize()
     771             : {
     772           0 :     Size aNewSize = GetOutputSizePixel();
     773           0 :     long nTotalHeight = aNewSize.Height();
     774             : 
     775             :     //  bei angedocktem Navigator wird das Fenster evtl. erst klein erzeugt,
     776             :     //  dann kommt ein Resize auf die wirkliche Groesse -> dann Inhalte einschalten
     777             : 
     778           0 :     sal_Bool bSmall = ( nTotalHeight <= aInitSize.Height() + SCNAV_MINTOL );
     779           0 :     if ( !bSmall && bFirstBig )
     780             :     {
     781             :         //  Inhalte laut Config wieder einschalten
     782             : 
     783           0 :         bFirstBig = false;
     784           0 :         NavListMode eNavMode = NAV_LMODE_AREAS;
     785           0 :         ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
     786           0 :         NavListMode eLastMode = (NavListMode) rCfg.GetListMode();
     787           0 :         if ( eLastMode == NAV_LMODE_SCENARIOS )
     788           0 :             eNavMode = NAV_LMODE_SCENARIOS;
     789           0 :         SetListMode( eNavMode, false );         // FALSE: Groesse des Float nicht setzen
     790             :     }
     791             : 
     792             :     //  auch wenn die Inhalte nicht sichtbar sind, die Groessen anpassen,
     793             :     //  damit die Breite stimmt
     794             : 
     795           0 :     Point aEntryPos = aLbEntries.GetPosPixel();
     796           0 :     Point aListPos = aLbDocuments.GetPosPixel();
     797           0 :     aNewSize.Width() -= 2*nBorderOffset;
     798           0 :     Size aDocSize = aLbDocuments.GetSizePixel();
     799           0 :     aDocSize.Width() = aNewSize.Width();
     800             : 
     801           0 :     if(!bSmall)
     802             :     {
     803             : 
     804           0 :         long nListHeight = aLbDocuments.GetSizePixel().Height();
     805           0 :         aNewSize.Height() -= ( aEntryPos.Y() + nListHeight + 2*nBorderOffset );
     806           0 :         if(aNewSize.Height()<0) aNewSize.Height()=0;
     807             : 
     808           0 :         aListPos.Y() = aEntryPos.Y() + aNewSize.Height() + nBorderOffset;
     809             : 
     810           0 :         if(aListPos.Y() > aLbEntries.GetPosPixel().Y())
     811           0 :                             aLbDocuments.SetPosPixel( aListPos );
     812             : 
     813             :     }
     814           0 :     aLbEntries.SetSizePixel( aNewSize );
     815           0 :     aWndScenarios.SetSizePixel( aNewSize );
     816           0 :     aLbDocuments.SetSizePixel( aDocSize );
     817             : 
     818           0 :     sal_Bool bListMode = (eListMode != NAV_LMODE_NONE);
     819           0 :     if (pContextWin != NULL)
     820             :     {
     821           0 :         FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
     822           0 :         if ( pFloat && bListMode )
     823           0 :             nListModeHeight = nTotalHeight;
     824             :     }
     825           0 : }
     826             : 
     827           0 : void ScNavigatorDlg::Notify( SfxBroadcaster&, const SfxHint& rHint )
     828             : {
     829           0 :     if ( rHint.ISA(SfxSimpleHint) )
     830             :     {
     831           0 :         sal_uLong nHintId = ((SfxSimpleHint&)rHint).GetId();
     832             : 
     833           0 :         if ( nHintId == SC_HINT_DOCNAME_CHANGED )
     834             :         {
     835           0 :             aLbEntries.ActiveDocChanged();
     836             :         }
     837           0 :         else if ( NAV_LMODE_NONE == eListMode )
     838             :         {
     839             :             //  Tabellen hier nicht mehr
     840             :         }
     841             :         else
     842             :         {
     843           0 :             switch ( nHintId )
     844             :             {
     845             :                 case SC_HINT_TABLES_CHANGED:
     846           0 :                     aLbEntries.Refresh( SC_CONTENT_TABLE );
     847           0 :                     break;
     848             : 
     849             :                 case SC_HINT_DBAREAS_CHANGED:
     850           0 :                     aLbEntries.Refresh( SC_CONTENT_DBAREA );
     851           0 :                     break;
     852             : 
     853             :                 case SC_HINT_AREAS_CHANGED:
     854           0 :                     aLbEntries.Refresh( SC_CONTENT_RANGENAME );
     855           0 :                     break;
     856             : 
     857             :                 case SC_HINT_DRAW_CHANGED:
     858           0 :                     aLbEntries.Refresh( SC_CONTENT_GRAPHIC );
     859           0 :                     aLbEntries.Refresh( SC_CONTENT_OLEOBJECT );
     860           0 :                     aLbEntries.Refresh( SC_CONTENT_DRAWING );
     861           0 :                     break;
     862             : 
     863             :                 case SC_HINT_AREALINKS_CHANGED:
     864           0 :                     aLbEntries.Refresh( SC_CONTENT_AREALINK );
     865           0 :                     break;
     866             : 
     867             :                 //  SFX_HINT_DOCCHANGED kommt nicht nur bei Dokument-Wechsel
     868             : 
     869             :                 case SC_HINT_NAVIGATOR_UPDATEALL:
     870           0 :                     UpdateAll();
     871           0 :                     break;
     872             : 
     873             :                 case FID_DATACHANGED:
     874             :                 case FID_ANYDATACHANGED:
     875           0 :                     aContentTimer.Start();      // Notizen nicht sofort suchen
     876           0 :                     break;
     877             :                 case FID_KILLEDITVIEW:
     878           0 :                     aLbEntries.ObjectFresh( SC_CONTENT_OLEOBJECT );
     879           0 :                     aLbEntries.ObjectFresh( SC_CONTENT_DRAWING );
     880           0 :                     aLbEntries.ObjectFresh( SC_CONTENT_GRAPHIC );
     881           0 :                     break;
     882             :                 default:
     883           0 :                     break;
     884             :             }
     885             :         }
     886             :     }
     887           0 :     else if ( rHint.ISA(SfxEventHint) )
     888             :     {
     889           0 :         sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId();
     890           0 :         if ( nEventId == SFX_EVENT_ACTIVATEDOC )
     891             :         {
     892           0 :             aLbEntries.ActiveDocChanged();
     893           0 :             UpdateAll();
     894             :         }
     895             :     }
     896           0 : }
     897             : 
     898           0 : IMPL_LINK( ScNavigatorDlg, TimeHdl, Timer*, pTimer )
     899             : {
     900           0 :     if ( pTimer != &aContentTimer )
     901           0 :         return 0;
     902             : 
     903           0 :     aLbEntries.Refresh( SC_CONTENT_NOTE );
     904           0 :     return 0;
     905             : }
     906             : 
     907           0 : void ScNavigatorDlg::SetDropMode(sal_uInt16 nNew)
     908             : {
     909           0 :     nDropMode = nNew;
     910           0 :     aTbxCmd.UpdateButtons();
     911             : 
     912           0 :     ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
     913           0 :     rCfg.SetDragMode(nDropMode);
     914           0 : }
     915             : 
     916           0 : void ScNavigatorDlg::CursorPosChanged()
     917             : {
     918             :     //! Eintraege selektieren ???
     919             : 
     920             : //  if ( GetDBAtCursor( aStrDbName ) )
     921             : //  if ( GetAreaAtCursor( aStrAreaName ) )
     922           0 : }
     923             : 
     924           0 : void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo, SCROW nRowNo )
     925             : {
     926           0 :     if ( (nColNo+1 != nCurCol) || (nRowNo+1 != nCurRow) )
     927             :     {
     928             :         // SID_CURRENTCELL == Item #0 Cache leeren, damit das Setzen der
     929             :         // aktuellen Zelle auch in zusammengefassten Bereichen funktioniert.
     930           0 :         ppBoundItems[0]->ClearCache();
     931             : 
     932           0 :         ScAddress aScAddress( nColNo, nRowNo, 0 );
     933           0 :         OUString aAddr(aScAddress.Format(SCA_ABS));
     934             : 
     935           0 :         sal_Bool bUnmark = false;
     936           0 :         if ( GetViewData() )
     937           0 :             bUnmark = !pViewData->GetMarkData().IsCellMarked( nColNo, nRowNo );
     938             : 
     939           0 :         SfxStringItem   aPosItem( SID_CURRENTCELL, aAddr );
     940           0 :         SfxBoolItem     aUnmarkItem( FN_PARAM_1, bUnmark );     // ggf. Selektion aufheben
     941             : 
     942             :         rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
     943             :                                   SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
     944           0 :                                   &aPosItem, &aUnmarkItem, 0L );
     945             :     }
     946           0 : }
     947             : 
     948           0 : void ScNavigatorDlg::SetCurrentCellStr( const OUString& rName )
     949             : {
     950           0 :     ppBoundItems[0]->ClearCache();
     951           0 :     SfxStringItem   aNameItem( SID_CURRENTCELL, rName );
     952             : 
     953             :     rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
     954             :                               SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
     955           0 :                               &aNameItem, 0L );
     956           0 : }
     957             : 
     958           0 : void ScNavigatorDlg::SetCurrentTable( SCTAB nTabNo )
     959             : {
     960           0 :     if ( nTabNo != nCurTab )
     961             :     {
     962             :         //  Tabelle fuer Basic ist 1-basiert
     963           0 :         SfxUInt16Item aTabItem( SID_CURRENTTAB, static_cast<sal_uInt16>(nTabNo) + 1 );
     964             :         rBindings.GetDispatcher()->Execute( SID_CURRENTTAB,
     965             :                                   SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
     966           0 :                                   &aTabItem, 0L );
     967             :     }
     968           0 : }
     969             : 
     970           0 : void ScNavigatorDlg::SetCurrentTableStr( const OUString& rName )
     971             : {
     972           0 :     if (!GetViewData()) return;
     973             : 
     974           0 :     ScDocument* pDoc = pViewData->GetDocument();
     975           0 :     SCTAB nCount     = pDoc->GetTableCount();
     976           0 :     OUString aTabName;
     977             : 
     978           0 :     for ( SCTAB i=0; i<nCount; i++ )
     979             :     {
     980           0 :         pDoc->GetName( i, aTabName );
     981           0 :         if ( aTabName.equals(rName) )
     982             :         {
     983           0 :             SetCurrentTable( i );
     984           0 :             return;
     985             :         }
     986           0 :     }
     987             : }
     988             : 
     989           0 : void ScNavigatorDlg::SetCurrentObject( const OUString& rName )
     990             : {
     991           0 :     SfxStringItem aNameItem( SID_CURRENTOBJECT, rName );
     992             :     rBindings.GetDispatcher()->Execute( SID_CURRENTOBJECT,
     993             :                               SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
     994           0 :                               &aNameItem, 0L );
     995           0 : }
     996             : 
     997           0 : void ScNavigatorDlg::SetCurrentDoc( const OUString& rDocName )        // aktivieren
     998             : {
     999           0 :     SfxStringItem aDocItem( SID_CURRENTDOC, rDocName );
    1000             :     rBindings.GetDispatcher()->Execute( SID_CURRENTDOC,
    1001             :                               SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
    1002           0 :                               &aDocItem, 0L );
    1003           0 : }
    1004             : 
    1005           0 : ScTabViewShell* ScNavigatorDlg::GetTabViewShell() const
    1006             : {
    1007           0 :     return PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
    1008             : }
    1009             : 
    1010           0 : ScNavigatorSettings* ScNavigatorDlg::GetNavigatorSettings()
    1011             : {
    1012             :     //  Don't store the settings pointer here, because the settings belong to
    1013             :     //  the view, and the view may be closed while the navigator is open (reload).
    1014             :     //  If the pointer is cached here again later for performance reasons, it has to
    1015             :     //  be forgotten when the view is closed.
    1016             : 
    1017           0 :     ScTabViewShell* pViewSh = GetTabViewShell();
    1018           0 :     return pViewSh ? pViewSh->GetNavigatorSettings() : NULL;
    1019             : }
    1020             : 
    1021           0 : bool ScNavigatorDlg::GetViewData()
    1022             : {
    1023           0 :     ScTabViewShell* pViewSh = GetTabViewShell();
    1024           0 :     pViewData = pViewSh ? pViewSh->GetViewData() : NULL;
    1025             : 
    1026           0 :     return ( pViewData != NULL );
    1027             : }
    1028             : 
    1029           0 : void ScNavigatorDlg::UpdateColumn( const SCCOL* pCol )
    1030             : {
    1031           0 :     if ( pCol )
    1032           0 :         nCurCol = *pCol;
    1033           0 :     else if ( GetViewData() )
    1034           0 :         nCurCol = pViewData->GetCurX() + 1;
    1035             : 
    1036           0 :     aEdCol.SetCol( nCurCol );
    1037           0 :     CheckDataArea();
    1038           0 : }
    1039             : 
    1040           0 : void ScNavigatorDlg::UpdateRow( const SCROW* pRow )
    1041             : {
    1042           0 :     if ( pRow )
    1043           0 :         nCurRow = *pRow;
    1044           0 :     else if ( GetViewData() )
    1045           0 :         nCurRow = pViewData->GetCurY() + 1;
    1046             : 
    1047           0 :     aEdRow.SetRow( nCurRow );
    1048           0 :     CheckDataArea();
    1049           0 : }
    1050             : 
    1051           0 : void ScNavigatorDlg::UpdateTable( const SCTAB* pTab )
    1052             : {
    1053           0 :     if ( pTab )
    1054           0 :         nCurTab = *pTab;
    1055           0 :     else if ( GetViewData() )
    1056           0 :         nCurTab = pViewData->GetTabNo();
    1057             : 
    1058           0 :     CheckDataArea();
    1059           0 : }
    1060             : 
    1061           0 : void ScNavigatorDlg::UpdateAll()
    1062             : {
    1063           0 :     switch ( eListMode )
    1064             :     {
    1065             :         case NAV_LMODE_DOCS:
    1066             :         case NAV_LMODE_DBAREAS:
    1067             :         case NAV_LMODE_AREAS:
    1068           0 :             aLbEntries.Refresh();
    1069           0 :             break;
    1070             : 
    1071             :         case NAV_LMODE_NONE:
    1072             :             //! ???
    1073           0 :             break;
    1074             : 
    1075             :         default:
    1076           0 :             break;
    1077             :     }
    1078             : 
    1079           0 :     aContentTimer.Stop();       // dann nicht nochmal
    1080           0 : }
    1081             : 
    1082           0 : void ScNavigatorDlg::SetListMode( NavListMode eMode, bool bSetSize )
    1083             : {
    1084           0 :     if ( eMode != eListMode )
    1085             :     {
    1086           0 :         if ( eMode != NAV_LMODE_NONE )
    1087           0 :             bFirstBig = false;              // nicht mehr automatisch umschalten
    1088             : 
    1089           0 :         eListMode = eMode;
    1090             : 
    1091           0 :         switch ( eMode )
    1092             :         {
    1093             :             case NAV_LMODE_NONE:
    1094           0 :                 ShowList( false, bSetSize );
    1095           0 :                 break;
    1096             : 
    1097             :             case NAV_LMODE_AREAS:
    1098             :             case NAV_LMODE_DBAREAS:
    1099             :             case NAV_LMODE_DOCS:
    1100           0 :                 aLbEntries.Refresh();
    1101           0 :                 ShowList( true, bSetSize );
    1102           0 :                 break;
    1103             : 
    1104             :             case NAV_LMODE_SCENARIOS:
    1105           0 :                 ShowScenarios( true, bSetSize );
    1106           0 :                 break;
    1107             :         }
    1108             : 
    1109           0 :         aTbxCmd.UpdateButtons();
    1110             : 
    1111           0 :         if ( eMode != NAV_LMODE_NONE )
    1112             :         {
    1113           0 :             ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
    1114           0 :             rCfg.SetListMode( (sal_uInt16) eMode );
    1115             :         }
    1116             :     }
    1117             : 
    1118           0 :     if ( pMarkArea )
    1119           0 :         UnmarkDataArea();
    1120           0 : }
    1121             : 
    1122           0 : void ScNavigatorDlg::ShowList( bool bShow, bool bSetSize )
    1123             : {
    1124           0 :     FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
    1125           0 :     Size aSize = GetParent()->GetOutputSizePixel();
    1126             : 
    1127           0 :     if ( bShow )
    1128             :     {
    1129           0 :         Size aMinSize = aInitSize;
    1130             : 
    1131           0 :         aMinSize.Height() += nInitListHeight;
    1132           0 :         if ( pFloat )
    1133           0 :             pFloat->SetMinOutputSizePixel( aMinSize );
    1134           0 :         aSize.Height() = nListModeHeight;
    1135           0 :         aLbEntries.Show();
    1136           0 :         aLbDocuments.Show();
    1137             :     }
    1138             :     else
    1139             :     {
    1140           0 :         if ( pFloat )
    1141             :         {
    1142           0 :             pFloat->SetMinOutputSizePixel( aInitSize );
    1143           0 :             nListModeHeight = aSize.Height();
    1144             :         }
    1145           0 :         aSize.Height() = aInitSize.Height();
    1146           0 :         aLbEntries.Hide();
    1147           0 :         aLbDocuments.Hide();
    1148             :     }
    1149           0 :     aWndScenarios.Hide();
    1150             : 
    1151           0 :     if ( pFloat )
    1152             :     {
    1153           0 :         if ( bSetSize )
    1154           0 :             pFloat->SetOutputSizePixel( aSize );
    1155             :     }
    1156             :     else
    1157             :     {
    1158           0 :         SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(GetParent());
    1159           0 :         if (pNav != NULL)
    1160             :         {
    1161           0 :             Size aFloating = pNav->GetFloatingSize();
    1162           0 :             aFloating.Height() = aSize.Height();
    1163           0 :             pNav->SetFloatingSize( aFloating );
    1164             :         }
    1165             :     }
    1166           0 : }
    1167             : 
    1168           0 : void ScNavigatorDlg::ShowScenarios( bool bShow, bool bSetSize )
    1169             : {
    1170           0 :     FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
    1171           0 :     Size aSize = GetParent()->GetOutputSizePixel();
    1172             : 
    1173           0 :     if ( bShow )
    1174             :     {
    1175           0 :         Size aMinSize = aInitSize;
    1176           0 :         aMinSize.Height() += nInitListHeight;
    1177           0 :         if ( pFloat )
    1178           0 :             pFloat->SetMinOutputSizePixel( aMinSize );
    1179           0 :         aSize.Height() = nListModeHeight;
    1180             : 
    1181           0 :         rBindings.Invalidate( SID_SELECT_SCENARIO );
    1182           0 :         rBindings.Update( SID_SELECT_SCENARIO );
    1183             : 
    1184           0 :         aWndScenarios.Show();
    1185           0 :         aLbDocuments.Show();
    1186             :     }
    1187             :     else
    1188             :     {
    1189           0 :         if ( pFloat )
    1190             :         {
    1191           0 :             pFloat->SetMinOutputSizePixel( aInitSize );
    1192           0 :             nListModeHeight = aSize.Height();
    1193             :         }
    1194           0 :         aSize.Height() = aInitSize.Height();
    1195           0 :         aWndScenarios.Hide();
    1196           0 :         aLbDocuments.Hide();
    1197             :     }
    1198           0 :     aLbEntries.Hide();
    1199             : 
    1200           0 :     if ( pFloat )
    1201             :     {
    1202           0 :         if ( bSetSize )
    1203           0 :             pFloat->SetOutputSizePixel( aSize );
    1204             :     }
    1205             :     else
    1206             :     {
    1207           0 :         SfxNavigator* pNav = (SfxNavigator*)GetParent();
    1208           0 :         Size aFloating = pNav->GetFloatingSize();
    1209           0 :         aFloating.Height() = aSize.Height();
    1210           0 :         pNav->SetFloatingSize( aFloating );
    1211             :     }
    1212           0 : }
    1213             : 
    1214             : 
    1215             : //      Dokumente fuer Dropdown-Listbox
    1216             : 
    1217           0 : void ScNavigatorDlg::GetDocNames( const OUString* pManualSel )
    1218             : {
    1219           0 :     aLbDocuments.Clear();
    1220           0 :     aLbDocuments.SetUpdateMode( false );
    1221             : 
    1222           0 :     ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
    1223             : 
    1224           0 :     OUString aSelEntry;
    1225           0 :     SfxObjectShell* pSh = SfxObjectShell::GetFirst();
    1226           0 :     while ( pSh )
    1227             :     {
    1228           0 :         if ( pSh->ISA(ScDocShell) )
    1229             :         {
    1230           0 :             OUString aName = pSh->GetTitle();
    1231           0 :             OUString aEntry = aName;
    1232           0 :             if (pSh == pCurrentSh)
    1233           0 :                 aEntry += aStrActive;
    1234             :             else
    1235           0 :                 aEntry += aStrNotActive;
    1236           0 :             aLbDocuments.InsertEntry( aEntry );
    1237             : 
    1238           0 :             if ( pManualSel ? ( aName == *pManualSel )
    1239             :                             : ( pSh == pCurrentSh ) )
    1240           0 :                 aSelEntry = aEntry;                     // kompletter Eintrag zum Selektieren
    1241             :         }
    1242             : 
    1243           0 :         pSh = SfxObjectShell::GetNext( *pSh );
    1244             :     }
    1245             : 
    1246           0 :     aLbDocuments.InsertEntry( aStrActiveWin );
    1247             : 
    1248           0 :     OUString aHidden =  aLbEntries.GetHiddenTitle();
    1249           0 :     if (!aHidden.isEmpty())
    1250             :     {
    1251           0 :         OUString aEntry = aHidden;
    1252           0 :         aEntry += aStrHidden;
    1253           0 :         aLbDocuments.InsertEntry( aEntry );
    1254             : 
    1255           0 :         if ( pManualSel && aHidden == *pManualSel )
    1256           0 :             aSelEntry = aEntry;
    1257             :     }
    1258             : 
    1259           0 :     aLbDocuments.SetUpdateMode( true );
    1260             : 
    1261           0 :     aLbDocuments.SelectEntry( aSelEntry );
    1262           0 : }
    1263             : 
    1264           0 : void ScNavigatorDlg::MarkDataArea()
    1265             : {
    1266           0 :     ScTabViewShell* pViewSh = GetTabViewShell();
    1267             : 
    1268           0 :     if ( pViewSh )
    1269             :     {
    1270           0 :         if ( !pMarkArea )
    1271           0 :             pMarkArea = new ScArea;
    1272             : 
    1273           0 :         pViewSh->MarkDataArea();
    1274           0 :         ScRange aMarkRange;
    1275           0 :         pViewSh->GetViewData()->GetMarkData().GetMarkArea(aMarkRange);
    1276           0 :         pMarkArea->nColStart = aMarkRange.aStart.Col();
    1277           0 :         pMarkArea->nRowStart = aMarkRange.aStart.Row();
    1278           0 :         pMarkArea->nColEnd = aMarkRange.aEnd.Col();
    1279           0 :         pMarkArea->nRowEnd = aMarkRange.aEnd.Row();
    1280           0 :         pMarkArea->nTab = aMarkRange.aStart.Tab();
    1281             :     }
    1282           0 : }
    1283             : 
    1284           0 : void ScNavigatorDlg::UnmarkDataArea()
    1285             : {
    1286           0 :     ScTabViewShell* pViewSh = GetTabViewShell();
    1287             : 
    1288           0 :     if ( pViewSh )
    1289             :     {
    1290           0 :         pViewSh->Unmark();
    1291           0 :         DELETEZ( pMarkArea );
    1292             :     }
    1293           0 : }
    1294             : 
    1295           0 : void ScNavigatorDlg::CheckDataArea()
    1296             : {
    1297           0 :     if ( aTbxCmd.IsItemChecked( IID_DATA ) && pMarkArea )
    1298             :     {
    1299           0 :         if (   nCurTab   != pMarkArea->nTab
    1300           0 :             || nCurCol <  pMarkArea->nColStart+1
    1301           0 :             || nCurCol >  pMarkArea->nColEnd+1
    1302           0 :             || nCurRow <  pMarkArea->nRowStart+1
    1303           0 :             || nCurRow >  pMarkArea->nRowEnd+1 )
    1304             :         {
    1305           0 :             aTbxCmd.SetItemState( IID_DATA, TriState(TRISTATE_TRUE) );
    1306           0 :             aTbxCmd.Select( IID_DATA );
    1307             :         }
    1308             :     }
    1309           0 : }
    1310             : 
    1311           0 : void ScNavigatorDlg::StartOfDataArea()
    1312             : {
    1313             :     //  pMarkArea auswerten ???
    1314             : 
    1315           0 :     if ( GetViewData() )
    1316             :     {
    1317           0 :         ScMarkData& rMark = pViewData->GetMarkData();
    1318           0 :         ScRange aMarkRange;
    1319           0 :         rMark.GetMarkArea( aMarkRange );
    1320             : 
    1321           0 :         SCCOL nCol = aMarkRange.aStart.Col();
    1322           0 :         SCROW nRow = aMarkRange.aStart.Row();
    1323             : 
    1324           0 :         if ( (nCol+1 != aEdCol.GetCol()) || (nRow+1 != aEdRow.GetRow()) )
    1325           0 :             SetCurrentCell( nCol, nRow );
    1326             :     }
    1327           0 : }
    1328             : 
    1329           0 : void ScNavigatorDlg::EndOfDataArea()
    1330             : {
    1331             :     //  pMarkArea auswerten ???
    1332             : 
    1333           0 :     if ( GetViewData() )
    1334             :     {
    1335           0 :         ScMarkData& rMark = pViewData->GetMarkData();
    1336           0 :         ScRange aMarkRange;
    1337           0 :         rMark.GetMarkArea( aMarkRange );
    1338             : 
    1339           0 :         SCCOL nCol = aMarkRange.aEnd.Col();
    1340           0 :         SCROW nRow = aMarkRange.aEnd.Row();
    1341             : 
    1342           0 :         if ( (nCol+1 != aEdCol.GetCol()) || (nRow+1 != aEdRow.GetRow()) )
    1343           0 :             SetCurrentCell( nCol, nRow );
    1344             :     }
    1345           0 : }
    1346             : 
    1347           0 : SfxChildAlignment ScNavigatorDlg::CheckAlignment(
    1348             :                             SfxChildAlignment eActAlign, SfxChildAlignment eAlign )
    1349             : {
    1350             :     SfxChildAlignment eRetAlign;
    1351             : 
    1352             :     //! kein Andocken, wenn Listbox nicht da ???
    1353             : 
    1354           0 :     switch (eAlign)
    1355             :     {
    1356             :         case SFX_ALIGN_TOP:
    1357             :         case SFX_ALIGN_HIGHESTTOP:
    1358             :         case SFX_ALIGN_LOWESTTOP:
    1359             :         case SFX_ALIGN_BOTTOM:
    1360             :         case SFX_ALIGN_LOWESTBOTTOM:
    1361             :         case SFX_ALIGN_HIGHESTBOTTOM:
    1362           0 :             eRetAlign = eActAlign;              // nicht erlaubt
    1363           0 :             break;
    1364             : 
    1365             :         case SFX_ALIGN_LEFT:
    1366             :         case SFX_ALIGN_RIGHT:
    1367             :         case SFX_ALIGN_FIRSTLEFT:
    1368             :         case SFX_ALIGN_LASTLEFT:
    1369             :         case SFX_ALIGN_FIRSTRIGHT:
    1370             :         case SFX_ALIGN_LASTRIGHT:
    1371           0 :             eRetAlign = eAlign;                 // erlaubt
    1372           0 :             break;
    1373             : 
    1374             :         default:
    1375           0 :             eRetAlign = eAlign;
    1376           0 :             break;
    1377             :     }
    1378           0 :     return eRetAlign;
    1379         102 : }
    1380             : 
    1381             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10