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