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

Generated by: LCOV version 1.10