xref: /aoo41x/main/sc/source/ui/navipi/navipi.cxx (revision 37fee4fd)
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, true );
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     const bool bUseStyleSettingsBackground) :
657 		Window( pParent, ScResId(RID_SCDLG_NAVIGATOR) ),
658 		rBindings	( *pB ),								// is used in CommandToolBox ctor
659 		aCmdImageList( ScResId( IL_CMD ) ),
660     	aCmdImageListH( ScResId( ILH_CMD ) ),
661 		aFtCol		( this, ScResId( FT_COL ) ),
662 		aEdCol		( this, ScResId( ED_COL ) ),
663 		aFtRow		( this, ScResId( FT_ROW ) ),
664 		aEdRow		( this, ScResId( ED_ROW ) ),
665 		aTbxCmd		( this, ScResId( TBX_CMD ) ),
666 		aLbEntries	( this, ScResId( LB_ENTRIES ) ),
667         aWndScenarios( this,ScResId( STR_QHLP_SCEN_LISTBOX), ScResId(STR_QHLP_SCEN_COMMENT)),
668 		aLbDocuments( this, ScResId( LB_DOCUMENTS ) ),
669 		aStrDragMode ( ScResId( STR_DRAGMODE ) ),
670 		aStrDisplay  ( ScResId( STR_DISPLAY ) ),
671 		aStrActiveWin( ScResId( STR_ACTIVEWIN ) ),
672 		pContextWin	( pCW ),
673 		pMarkArea	( NULL ),
674 		pViewData	( NULL ),
675 		nListModeHeight( 0 ),
676 		nInitListHeight( 0 ),
677 		eListMode	( NAV_LMODE_NONE ),
678 		nDropMode	( SC_DROPMODE_URL ),
679 		nCurCol		( 0 ),
680 		nCurRow		( 0 ),
681 		nCurTab		( 0 ),
682 		bFirstBig	( sal_False ),
683         mbUseStyleSettingsBackground(bUseStyleSettingsBackground)
684 {
685 	ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
686 	nDropMode = rCfg.GetDragMode();
687 	//	eListMode wird von aussen gesetzt, Root weiter unten
688 
689 	aLbDocuments.SetDropDownLineCount(9);
690 	String aOpen = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
691 	aStrActive = aOpen;
692 	aStrActive += String( ScResId( STR_ACTIVE ) );
693 	aStrActive += ')';										// " (aktiv)"
694 	aStrNotActive = aOpen;
695 	aStrNotActive += String( ScResId( STR_NOTACTIVE ) );
696 	aStrNotActive += ')';									// " (inaktiv)"
697 	aStrHidden = aOpen;
698 	aStrHidden += String( ScResId( STR_HIDDEN ) );
699 	aStrHidden += ')';										// " (versteckt)"
700 
701 	aTitleBase = GetText();
702 
703     long nListboxYPos = aTbxCmd.GetPosPixel().Y() + aTbxCmd.GetSizePixel().Height() + 4;
704     aLbEntries.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y);
705 
706 	nBorderOffset = aLbEntries.GetPosPixel().X();
707 
708 	aInitSize.Width()  =  aTbxCmd.GetPosPixel().X()
709 						+ aTbxCmd.GetSizePixel().Width()
710 						+ nBorderOffset;
711 	aInitSize.Height() = aLbEntries.GetPosPixel().Y();
712 
713 	nInitListHeight	= aLbEntries.GetSizePixel().Height();
714 	nListModeHeight	=  aInitSize.Height()
715 					 + nInitListHeight;
716 
717 	//	kein Resize, eh der ganze Kontext-Kram initialisiert ist!
718 //	SetOutputSizePixel( aInitSize );		//???
719 /*!	FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
720 	if ( pFloat)
721 		pFloat->SetMinOutputSizePixel( aInitSize );
722 */
723 	ppBoundItems = new ScNavigatorControllerItem* [CTRL_ITEMS];
724 
725 	rBindings.ENTERREGISTRATIONS();
726 	//-----------------------------
727 	REGISTER_SLOT( 0, SID_CURRENTCELL		);
728 	REGISTER_SLOT( 1, SID_CURRENTTAB		);
729 	REGISTER_SLOT( 2, SID_CURRENTDOC		);
730 	REGISTER_SLOT( 3, SID_SELECT_SCENARIO	);
731 	//-----------------------------
732 	rBindings.LEAVEREGISTRATIONS();
733 
734 	StartListening( *(SFX_APP()) );
735 	StartListening( rBindings );
736 
737 	aLbDocuments.Hide();		// bei NAV_LMODE_NONE gibts die nicht
738 
739 	aLbEntries.InitWindowBits(sal_True);
740 
741 	aLbEntries.SetSpaceBetweenEntries(0);
742 	aLbEntries.SetSelectionMode( SINGLE_SELECTION );
743 	aLbEntries.SetDragDropMode( 	SV_DRAGDROP_CTRL_MOVE |
744 									SV_DRAGDROP_CTRL_COPY |
745 									SV_DRAGDROP_ENABLE_TOP );
746 
747 	//	war eine Kategorie als Root ausgewaehlt?
748 	sal_uInt16 nLastRoot = rCfg.GetRootType();
749 	if ( nLastRoot )
750 		aLbEntries.SetRootType( nLastRoot );
751 
752 	aLbEntries.Refresh();
753 	GetDocNames();
754 
755 	aTbxCmd.UpdateButtons();
756 
757 	UpdateColumn();
758 	UpdateRow();
759 	UpdateTable();
760 	aLbEntries.Hide();
761 	aWndScenarios.Hide();
762 	aWndScenarios.SetPosPixel( aLbEntries.GetPosPixel() );
763 
764 	aContentTimer.SetTimeoutHdl( LINK( this, ScNavigatorDlg, TimeHdl ) );
765 	aContentTimer.SetTimeout( SC_CONTENT_TIMEOUT );
766 
767 	FreeResource();
768 
769 	aLbEntries.SetAccessibleRelationLabeledBy(&aLbEntries);
770 	aTbxCmd.SetAccessibleRelationLabeledBy(&aTbxCmd);
771 	aLbDocuments.SetAccessibleName(aStrActiveWin);
772 
773     if (pContextWin == NULL)
774     {
775         // When the context window is missing then the navigator is
776         // displayed in the sidebar and has the whole deck to fill.
777         // Therefore hide the button that hides all controls below the
778         // top two rows of buttons.
779         aTbxCmd.Select(IID_ZOOMOUT);
780         aTbxCmd.RemoveItem(aTbxCmd.GetItemPos(IID_ZOOMOUT));
781     }
782 }
783 
784 //------------------------------------------------------------------------
785 
786 __EXPORT ScNavigatorDlg::~ScNavigatorDlg()
787 {
788 	aContentTimer.Stop();
789 
790 	sal_uInt16 i;
791 	for ( i=0; i<CTRL_ITEMS; i++ )
792 		delete ppBoundItems[i];
793 
794 	delete [] ppBoundItems;
795 	delete pMarkArea;
796 
797 	EndListening( *(SFX_APP()) );
798 	EndListening( rBindings );
799 }
800 
801 //------------------------------------------------------------------------
802 
803 void __EXPORT ScNavigatorDlg::Resizing( Size& rNewSize )  // Size = Outputsize?
804 {
805 	FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
806 	if ( pFloat )
807 	{
808 		Size aMinOut = pFloat->GetMinOutputSizePixel();
809 
810 		if ( rNewSize.Width() < aMinOut.Width() )
811 			rNewSize.Width() = aMinOut.Width();
812 
813 		if ( eListMode == NAV_LMODE_NONE )
814 			rNewSize.Height() = aInitSize.Height();
815 		else
816 		{
817 			if ( rNewSize.Height() < aMinOut.Height() )
818 				rNewSize.Height() = aMinOut.Height();
819 		}
820 	}
821 //	else
822 //		SfxDockingWindow::Resizing(rNewSize);
823 }
824 
825 
826 
827 void ScNavigatorDlg::Paint( const Rectangle& rRec )
828 {
829     if (mbUseStyleSettingsBackground)
830     {
831         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
832         Color aBgColor = rStyleSettings.GetFaceColor();
833         Wallpaper aBack( aBgColor );
834 
835         SetBackground( aBack );
836         aFtCol.SetBackground( aBack );
837         aFtRow.SetBackground( aBack );
838     }
839     else
840     {
841         aFtCol.SetBackground(Wallpaper());
842         aFtRow.SetBackground(Wallpaper());
843     }
844 
845 	Window::Paint( rRec );
846 }
847 
848 void ScNavigatorDlg::DataChanged( const DataChangedEvent& rDCEvt )
849 {
850 	if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
851 	{
852 		//	toolbox images are exchanged in CommandToolBox::DataChanged
853 		Invalidate();
854 	}
855 
856     Window::DataChanged( rDCEvt );
857 }
858 
859 //------------------------------------------------------------------------
860 
861 void __EXPORT ScNavigatorDlg::Resize()
862 {
863 	DoResize();
864 }
865 
866 //------------------------------------------------------------------------
867 
868 void ScNavigatorDlg::DoResize()
869 {
870 	Size aNewSize = GetOutputSizePixel();
871 	long nTotalHeight = aNewSize.Height();
872 
873 	//	#41403# bei angedocktem Navigator wird das Fenster evtl. erst klein erzeugt,
874 	//	dann kommt ein Resize auf die wirkliche Groesse -> dann Inhalte einschalten
875 
876 	sal_Bool bSmall = ( nTotalHeight <= aInitSize.Height() + SCNAV_MINTOL );
877 	if ( !bSmall && bFirstBig )
878 	{
879 		//	Inhalte laut Config wieder einschalten
880 
881 		bFirstBig = sal_False;
882 		NavListMode eNavMode = NAV_LMODE_AREAS;
883 		ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
884 		NavListMode eLastMode = (NavListMode) rCfg.GetListMode();
885 		if ( eLastMode == NAV_LMODE_SCENARIOS )
886 			eNavMode = NAV_LMODE_SCENARIOS;
887 		SetListMode( eNavMode, sal_False );			// FALSE: Groesse des Float nicht setzen
888 	}
889 
890 	//	auch wenn die Inhalte nicht sichtbar sind, die Groessen anpassen,
891 	//	damit die Breite stimmt
892 
893 	//@@ 03.11.97 changes begin
894 	Point aEntryPos = aLbEntries.GetPosPixel();
895 	Point aListPos = aLbDocuments.GetPosPixel();
896 	aNewSize.Width() -= 2*nBorderOffset;
897 	Size aDocSize = aLbDocuments.GetSizePixel();
898 	aDocSize.Width() = aNewSize.Width();
899 
900 	if(!bSmall)
901 	{
902 
903 		long nListHeight = aLbDocuments.GetSizePixel().Height();
904 		aNewSize.Height() -= ( aEntryPos.Y() + nListHeight + 2*nBorderOffset );
905 		if(aNewSize.Height()<0)	aNewSize.Height()=0;
906 
907 		aListPos.Y() = aEntryPos.Y() + aNewSize.Height() + nBorderOffset;
908 
909 		if(aListPos.Y() > aLbEntries.GetPosPixel().Y())
910 							aLbDocuments.SetPosPixel( aListPos );
911 
912 	}
913 	aLbEntries.SetSizePixel( aNewSize );
914 	aWndScenarios.SetSizePixel( aNewSize );
915 	aLbDocuments.SetSizePixel( aDocSize );
916 
917 	//@@ 03.11.97 end
918 
919 	sal_Bool bListMode = (eListMode != NAV_LMODE_NONE);
920     if (pContextWin != NULL)
921     {
922         FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
923         if ( pFloat && bListMode )
924             nListModeHeight = nTotalHeight;
925     }
926 }
927 
928 //------------------------------------------------------------------------
929 
930 void __EXPORT ScNavigatorDlg::Notify( SfxBroadcaster&, const SfxHint& rHint )
931 {
932 	if ( rHint.ISA(SfxSimpleHint) )
933 	{
934 		sal_uLong nHintId = ((SfxSimpleHint&)rHint).GetId();
935 
936 		if ( nHintId == SC_HINT_DOCNAME_CHANGED )
937 		{
938 			aLbEntries.ActiveDocChanged();
939 		}
940 		else if ( NAV_LMODE_NONE == eListMode )
941 		{
942 			//	Tabellen hier nicht mehr
943 		}
944 		else
945 		{
946 			switch ( nHintId )
947 			{
948 				case SC_HINT_TABLES_CHANGED:
949 					aLbEntries.Refresh( SC_CONTENT_TABLE );
950 					break;
951 
952 				case SC_HINT_DBAREAS_CHANGED:
953 					aLbEntries.Refresh( SC_CONTENT_DBAREA );
954 					break;
955 
956 				case SC_HINT_AREAS_CHANGED:
957 					aLbEntries.Refresh( SC_CONTENT_RANGENAME );
958 					break;
959 
960 				case SC_HINT_DRAW_CHANGED:
961 					aLbEntries.Refresh( SC_CONTENT_GRAPHIC );
962 					aLbEntries.Refresh( SC_CONTENT_OLEOBJECT );
963 					aLbEntries.Refresh( SC_CONTENT_DRAWING );
964 					break;
965 
966 				case SC_HINT_AREALINKS_CHANGED:
967 					aLbEntries.Refresh( SC_CONTENT_AREALINK );
968 					break;
969 
970 				//	SFX_HINT_DOCCHANGED kommt nicht nur bei Dokument-Wechsel
971 
972 				case SC_HINT_NAVIGATOR_UPDATEALL:
973 					UpdateAll();
974 					break;
975 
976 				case FID_DATACHANGED:
977 				case FID_ANYDATACHANGED:
978 					aContentTimer.Start();		// Notizen nicht sofort suchen
979 					break;
980 
981 				default:
982 					break;
983 			}
984 		}
985 	}
986 	else if ( rHint.ISA(SfxEventHint) )
987 	{
988 		sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId();
989 		if ( nEventId == SFX_EVENT_ACTIVATEDOC )
990 		{
991 			aLbEntries.ActiveDocChanged();
992 			UpdateAll();
993 		}
994 	}
995 }
996 
997 //------------------------------------------------------------------------
998 
999 IMPL_LINK( ScNavigatorDlg, TimeHdl, Timer*, pTimer )
1000 {
1001 	if ( pTimer != &aContentTimer )
1002 		return 0;
1003 
1004 	aLbEntries.Refresh( SC_CONTENT_NOTE );
1005 	return 0;
1006 }
1007 
1008 //------------------------------------------------------------------------
1009 
1010 void ScNavigatorDlg::SetDropMode(sal_uInt16 nNew)
1011 {
1012 	nDropMode = nNew;
1013 	aTbxCmd.UpdateButtons();
1014 
1015 	ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
1016 	rCfg.SetDragMode(nDropMode);
1017 }
1018 
1019 //------------------------------------------------------------------------
1020 
1021 void ScNavigatorDlg::CursorPosChanged()
1022 {
1023 	//!	Eintraege selektieren ???
1024 
1025 //	if ( GetDBAtCursor( aStrDbName ) )
1026 //	if ( GetAreaAtCursor( aStrAreaName ) )
1027 }
1028 
1029 //------------------------------------------------------------------------
1030 
1031 void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo, SCROW nRowNo )
1032 {
1033 	if ( (nColNo+1 != nCurCol) || (nRowNo+1 != nCurRow) )
1034 	{
1035 		// SID_CURRENTCELL == Item #0 Cache leeren, damit das Setzen der
1036 		// aktuellen Zelle auch in zusammengefassten Bereichen funktioniert.
1037 		ppBoundItems[0]->ClearCache();
1038 
1039 		ScAddress aScAddress( nColNo, nRowNo, 0 );
1040 		String	aAddr;
1041 		aScAddress.Format( aAddr, SCA_ABS );
1042 
1043 		sal_Bool bUnmark = sal_False;
1044 		if ( GetViewData() )
1045 			bUnmark = !pViewData->GetMarkData().IsCellMarked( nColNo, nRowNo );
1046 
1047 		SfxStringItem	aPosItem( SID_CURRENTCELL, aAddr );
1048 		SfxBoolItem		aUnmarkItem( FN_PARAM_1, bUnmark );		// ggf. Selektion aufheben
1049 
1050 		rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
1051 								  SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1052 								  &aPosItem, &aUnmarkItem, 0L );
1053 	}
1054 }
1055 
1056 void ScNavigatorDlg::SetCurrentCellStr( const String rName )
1057 {
1058 	ppBoundItems[0]->ClearCache();
1059 	SfxStringItem	aNameItem( SID_CURRENTCELL, rName );
1060 
1061 	rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
1062 							  SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1063 							  &aNameItem, 0L );
1064 }
1065 
1066 //------------------------------------------------------------------------
1067 
1068 void ScNavigatorDlg::SetCurrentTable( SCTAB nTabNo )
1069 {
1070 	if ( nTabNo != nCurTab )
1071 	{
1072 		//	Tabelle fuer Basic ist 1-basiert
1073 		SfxUInt16Item aTabItem( SID_CURRENTTAB, static_cast<sal_uInt16>(nTabNo) + 1 );
1074 		rBindings.GetDispatcher()->Execute( SID_CURRENTTAB,
1075 								  SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1076 								  &aTabItem, 0L );
1077 	}
1078 }
1079 
1080 void ScNavigatorDlg::SetCurrentTableStr( const String rName )
1081 {
1082 	if (!GetViewData()) return;
1083 
1084 	ScDocument* pDoc = pViewData->GetDocument();
1085 	SCTAB nCount	 = pDoc->GetTableCount();
1086 	String aTabName;
1087 
1088 	for ( SCTAB i=0; i<nCount; i++ )
1089 	{
1090 		pDoc->GetName( i, aTabName );
1091 		if ( aTabName == rName )
1092 		{
1093 			SetCurrentTable( i );
1094 			return;
1095 		}
1096 	}
1097 
1098 	Sound::Beep();					// Tabelle nicht gefunden
1099 }
1100 
1101 //------------------------------------------------------------------------
1102 
1103 void ScNavigatorDlg::SetCurrentObject( const String rName )
1104 {
1105 	SfxStringItem aNameItem( SID_CURRENTOBJECT, rName );
1106 	rBindings.GetDispatcher()->Execute( SID_CURRENTOBJECT,
1107 							  SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1108 							  &aNameItem, 0L );
1109 }
1110 
1111 //------------------------------------------------------------------------
1112 
1113 void ScNavigatorDlg::SetCurrentDoc( const String& rDocName )		// aktivieren
1114 {
1115 	SfxStringItem aDocItem( SID_CURRENTDOC, rDocName );
1116 	rBindings.GetDispatcher()->Execute( SID_CURRENTDOC,
1117 							  SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1118 							  &aDocItem, 0L );
1119 }
1120 
1121 //------------------------------------------------------------------------
1122 
1123 ScTabViewShell* ScNavigatorDlg::GetTabViewShell() const
1124 {
1125     return PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
1126 }
1127 
1128 //------------------------------------------------------------------------
1129 
1130 ScNavigatorSettings* ScNavigatorDlg::GetNavigatorSettings()
1131 {
1132     //  #95791# Don't store the settings pointer here, because the settings belong to
1133     //  the view, and the view may be closed while the navigator is open (reload).
1134     //  If the pointer is cached here again later for performance reasons, it has to
1135     //  be forgotten when the view is closed.
1136 
1137     ScTabViewShell* pViewSh = GetTabViewShell();
1138     return pViewSh ? pViewSh->GetNavigatorSettings() : NULL;
1139 }
1140 
1141 //------------------------------------------------------------------------
1142 
1143 sal_Bool ScNavigatorDlg::GetViewData()
1144 {
1145     ScTabViewShell* pViewSh = GetTabViewShell();
1146 	pViewData = pViewSh ? pViewSh->GetViewData() : NULL;
1147 
1148 	return ( pViewData != NULL );
1149 }
1150 
1151 //------------------------------------------------------------------------
1152 
1153 void ScNavigatorDlg::UpdateColumn( const SCCOL* pCol )
1154 {
1155 	if ( pCol )
1156 		nCurCol = *pCol;
1157 	else if ( GetViewData() )
1158 		nCurCol = pViewData->GetCurX() + 1;
1159 
1160 	aEdCol.SetCol( nCurCol );
1161 	CheckDataArea();
1162 }
1163 
1164 //------------------------------------------------------------------------
1165 
1166 void ScNavigatorDlg::UpdateRow( const SCROW* pRow )
1167 {
1168 	if ( pRow )
1169 		nCurRow = *pRow;
1170 	else if ( GetViewData() )
1171 		nCurRow = pViewData->GetCurY() + 1;
1172 
1173 	aEdRow.SetRow( nCurRow );
1174 	CheckDataArea();
1175 }
1176 
1177 //------------------------------------------------------------------------
1178 
1179 void ScNavigatorDlg::UpdateTable( const SCTAB* pTab )
1180 {
1181 	if ( pTab )
1182 		nCurTab = *pTab;
1183 	else if ( GetViewData() )
1184 		nCurTab = pViewData->GetTabNo();
1185 
1186 //	aLbTables.SetTab( nCurTab );
1187 	CheckDataArea();
1188 }
1189 
1190 //------------------------------------------------------------------------
1191 
1192 void ScNavigatorDlg::UpdateAll()
1193 {
1194 	switch ( eListMode )
1195 	{
1196 		case NAV_LMODE_DOCS:
1197 		case NAV_LMODE_DBAREAS:
1198 		case NAV_LMODE_AREAS:
1199             aLbEntries.Refresh();
1200 			break;
1201 
1202 		case NAV_LMODE_NONE:
1203 			//!	???
1204 			break;
1205 
1206 		default:
1207 			break;
1208 	}
1209 
1210 	aContentTimer.Stop();		// dann nicht nochmal
1211 }
1212 
1213 //------------------------------------------------------------------------
1214 
1215 void ScNavigatorDlg::SetListMode( NavListMode eMode, sal_Bool bSetSize )
1216 {
1217 	if ( eMode != eListMode )
1218 	{
1219 		if ( eMode != NAV_LMODE_NONE )
1220 			bFirstBig = sal_False;				// nicht mehr automatisch umschalten
1221 
1222 		eListMode = eMode;
1223 
1224 		switch ( eMode )
1225 		{
1226 			case NAV_LMODE_NONE:
1227                 ShowList( sal_False, bSetSize );
1228 				break;
1229 
1230 			case NAV_LMODE_AREAS:
1231 			case NAV_LMODE_DBAREAS:
1232 			case NAV_LMODE_DOCS:
1233 				aLbEntries.Refresh();
1234                 ShowList( sal_True, bSetSize );
1235 				break;
1236 
1237 			case NAV_LMODE_SCENARIOS:
1238                 ShowScenarios( sal_True, bSetSize );
1239 				break;
1240 		}
1241 
1242 		aTbxCmd.UpdateButtons();
1243 
1244 		if ( eMode != NAV_LMODE_NONE )
1245 		{
1246             ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
1247             rCfg.SetListMode( (sal_uInt16) eMode );
1248 		}
1249 	}
1250 
1251 	if ( pMarkArea )
1252 		UnmarkDataArea();
1253 }
1254 
1255 //------------------------------------------------------------------------
1256 
1257 void ScNavigatorDlg::ShowList( sal_Bool bShow, sal_Bool bSetSize )
1258 {
1259 	FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
1260 	Size aSize = GetParent()->GetOutputSizePixel();
1261 
1262 	if ( bShow )
1263 	{
1264 		Size aMinSize = aInitSize;
1265 
1266 		aMinSize.Height() += nInitListHeight;
1267 		if ( pFloat )
1268 			pFloat->SetMinOutputSizePixel( aMinSize );
1269 		aSize.Height() = nListModeHeight;
1270 		aLbEntries.Show();
1271         aLbDocuments.Show();
1272 	}
1273 	else
1274 	{
1275 		if ( pFloat )
1276 		{
1277 			pFloat->SetMinOutputSizePixel( aInitSize );
1278 			nListModeHeight = aSize.Height();
1279 		}
1280 		aSize.Height() = aInitSize.Height();
1281 		aLbEntries.Hide();
1282 		aLbDocuments.Hide();
1283 	}
1284 	aWndScenarios.Hide();
1285 
1286 	if ( pFloat )
1287 	{
1288 		if ( bSetSize )
1289 			pFloat->SetOutputSizePixel( aSize );
1290 	}
1291 	else
1292 	{
1293 		SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(GetParent());
1294         if (pNav != NULL)
1295         {
1296             Size aFloating = pNav->GetFloatingSize();
1297             aFloating.Height() = aSize.Height();
1298             pNav->SetFloatingSize( aFloating );
1299         }
1300 	}
1301 }
1302 
1303 //------------------------------------------------------------------------
1304 
1305 void ScNavigatorDlg::ShowScenarios( sal_Bool bShow, sal_Bool bSetSize )
1306 {
1307 	FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
1308 	Size aSize = GetParent()->GetOutputSizePixel();
1309 
1310 	if ( bShow )
1311 	{
1312 		Size aMinSize = aInitSize;
1313 		aMinSize.Height() += nInitListHeight;
1314 		if ( pFloat )
1315 			pFloat->SetMinOutputSizePixel( aMinSize );
1316 		aSize.Height() = nListModeHeight;
1317 
1318 		rBindings.Invalidate( SID_SELECT_SCENARIO );
1319 		rBindings.Update( SID_SELECT_SCENARIO );
1320 
1321 		aWndScenarios.Show();
1322 		aLbDocuments.Show();
1323 	}
1324 	else
1325 	{
1326 		if ( pFloat )
1327 		{
1328 			pFloat->SetMinOutputSizePixel( aInitSize );
1329 			nListModeHeight = aSize.Height();
1330 		}
1331 		aSize.Height() = aInitSize.Height();
1332 		aWndScenarios.Hide();
1333 		aLbDocuments.Hide();
1334 	}
1335 	aLbEntries.Hide();
1336 
1337 	if ( pFloat )
1338 	{
1339 		if ( bSetSize )
1340 			pFloat->SetOutputSizePixel( aSize );
1341 	}
1342 	else
1343 	{
1344 		SfxNavigator* pNav = (SfxNavigator*)GetParent();
1345 		Size aFloating = pNav->GetFloatingSize();
1346 		aFloating.Height() = aSize.Height();
1347 		pNav->SetFloatingSize( aFloating );
1348 	}
1349 }
1350 
1351 
1352 //------------------------------------------------------------------------
1353 //
1354 //		Dokumente fuer Dropdown-Listbox
1355 //
1356 //------------------------------------------------------------------------
1357 
1358 void ScNavigatorDlg::GetDocNames( const String* pManualSel )
1359 {
1360 	aLbDocuments.Clear();
1361 	aLbDocuments.SetUpdateMode( sal_False );
1362 
1363 	ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
1364 
1365 	String aSelEntry;
1366 	SfxObjectShell* pSh = SfxObjectShell::GetFirst();
1367 	while ( pSh )
1368 	{
1369 		if ( pSh->ISA(ScDocShell) )
1370 		{
1371 			String aName = pSh->GetTitle();
1372 			String aEntry = aName;
1373 			if (pSh == pCurrentSh)
1374 				aEntry += aStrActive;
1375 			else
1376 				aEntry += aStrNotActive;
1377 			aLbDocuments.InsertEntry( aEntry );
1378 
1379 			if ( pManualSel ? ( aName == *pManualSel )
1380 							: ( pSh == pCurrentSh ) )
1381 				aSelEntry = aEntry;						// kompletter Eintrag zum Selektieren
1382 		}
1383 
1384 		pSh = SfxObjectShell::GetNext( *pSh );
1385 	}
1386 
1387 	aLbDocuments.InsertEntry( aStrActiveWin );
1388 
1389 	String aHidden =  aLbEntries.GetHiddenTitle();
1390 	if (aHidden.Len())
1391 	{
1392 		String aEntry = aHidden;
1393 		aEntry += aStrHidden;
1394 		aLbDocuments.InsertEntry( aEntry );
1395 
1396 		if ( pManualSel && aHidden == *pManualSel )
1397 			aSelEntry = aEntry;
1398 	}
1399 
1400 	aLbDocuments.SetUpdateMode( sal_True );
1401 
1402 	aLbDocuments.SelectEntry( aSelEntry );
1403 }
1404 
1405 //------------------------------------------------------------------------
1406 
1407 void ScNavigatorDlg::MarkDataArea()
1408 {
1409     ScTabViewShell* pViewSh = GetTabViewShell();
1410 
1411 	if ( pViewSh )
1412 	{
1413 		if ( !pMarkArea )
1414 			pMarkArea = new	ScArea;
1415 
1416 		pViewSh->MarkDataArea();
1417 		ScRange aMarkRange;
1418 		pViewSh->GetViewData()->GetMarkData().GetMarkArea(aMarkRange);
1419 		pMarkArea->nColStart = aMarkRange.aStart.Col();
1420 		pMarkArea->nRowStart = aMarkRange.aStart.Row();
1421 		pMarkArea->nColEnd = aMarkRange.aEnd.Col();
1422 		pMarkArea->nRowEnd = aMarkRange.aEnd.Row();
1423 		pMarkArea->nTab = aMarkRange.aStart.Tab();
1424 	}
1425 }
1426 
1427 //------------------------------------------------------------------------
1428 
1429 void ScNavigatorDlg::UnmarkDataArea()
1430 {
1431     ScTabViewShell* pViewSh = GetTabViewShell();
1432 
1433 	if ( pViewSh )
1434 	{
1435 		pViewSh->Unmark();
1436 		DELETEZ( pMarkArea );
1437 	}
1438 }
1439 
1440 //------------------------------------------------------------------------
1441 
1442 void ScNavigatorDlg::CheckDataArea()
1443 {
1444 	if ( aTbxCmd.IsItemChecked( IID_DATA ) && pMarkArea )
1445 	{
1446 		if (   nCurTab   != pMarkArea->nTab
1447 			|| nCurCol <  pMarkArea->nColStart+1
1448 			|| nCurCol >  pMarkArea->nColEnd+1
1449 			|| nCurRow <  pMarkArea->nRowStart+1
1450 			|| nCurRow >  pMarkArea->nRowEnd+1 )
1451 		{
1452 			aTbxCmd.SetItemState( IID_DATA, TriState(STATE_CHECK) );
1453 			aTbxCmd.Select( IID_DATA );
1454 		}
1455 	}
1456 }
1457 
1458 //------------------------------------------------------------------------
1459 
1460 void ScNavigatorDlg::StartOfDataArea()
1461 {
1462 	//	pMarkArea auswerten ???
1463 
1464 	if ( GetViewData() )
1465 	{
1466 		ScMarkData& rMark = pViewData->GetMarkData();
1467 		ScRange aMarkRange;
1468 		rMark.GetMarkArea( aMarkRange );
1469 
1470 		SCCOL nCol = aMarkRange.aStart.Col();
1471 		SCROW nRow = aMarkRange.aStart.Row();
1472 
1473 		if ( (nCol+1 != aEdCol.GetCol()) || (nRow+1 != aEdRow.GetRow()) )
1474 			SetCurrentCell( nCol, nRow );
1475 	}
1476 }
1477 
1478 //------------------------------------------------------------------------
1479 
1480 void ScNavigatorDlg::EndOfDataArea()
1481 {
1482 	//	pMarkArea auswerten ???
1483 
1484 	if ( GetViewData() )
1485 	{
1486 		ScMarkData& rMark = pViewData->GetMarkData();
1487 		ScRange aMarkRange;
1488 		rMark.GetMarkArea( aMarkRange );
1489 
1490 		SCCOL nCol = aMarkRange.aEnd.Col();
1491 		SCROW nRow = aMarkRange.aEnd.Row();
1492 
1493 		if ( (nCol+1 != aEdCol.GetCol()) || (nRow+1 != aEdRow.GetRow()) )
1494 			SetCurrentCell( nCol, nRow );
1495 	}
1496 }
1497 
1498 //------------------------------------------------------------------------
1499 
1500 SfxChildAlignment __EXPORT ScNavigatorDlg::CheckAlignment(
1501 							SfxChildAlignment eActAlign, SfxChildAlignment eAlign )
1502 {
1503 	SfxChildAlignment eRetAlign;
1504 
1505 	//!	kein Andocken, wenn Listbox nicht da ???
1506 
1507 	switch (eAlign)
1508 	{
1509 		case SFX_ALIGN_TOP:
1510 		case SFX_ALIGN_HIGHESTTOP:
1511 		case SFX_ALIGN_LOWESTTOP:
1512 		case SFX_ALIGN_BOTTOM:
1513 		case SFX_ALIGN_LOWESTBOTTOM:
1514 		case SFX_ALIGN_HIGHESTBOTTOM:
1515 			eRetAlign = eActAlign;				// nicht erlaubt
1516 			break;
1517 
1518 		case SFX_ALIGN_LEFT:
1519 		case SFX_ALIGN_RIGHT:
1520 		case SFX_ALIGN_FIRSTLEFT:
1521 		case SFX_ALIGN_LASTLEFT:
1522 		case SFX_ALIGN_FIRSTRIGHT:
1523 		case SFX_ALIGN_LASTRIGHT:
1524 			eRetAlign = eAlign;					// erlaubt
1525 			break;
1526 
1527 		default:
1528 			eRetAlign = eAlign;
1529 			break;
1530 	}
1531 	return eRetAlign;
1532 }
1533 
1534 //------------------------------------------------------------------------
1535 //
1536 //	Drop auf den Navigator - andere Datei laden (File oder Bookmark)
1537 //
1538 //------------------------------------------------------------------------
1539 
1540 #if 0
1541 sal_Bool __EXPORT ScNavigatorDlg::Drop( const DropEvent& rEvt )
1542 {
1543 	sal_Bool bReturn = sal_False;
1544 
1545 	if ( !aLbEntries.IsInDrag() )		// kein Verschieben innerhalb der TreeListBox
1546 	{
1547 		String aFileName;
1548 
1549 		SvScDataObjectRef pObject = SvScDataObject::PasteDragServer(rEvt);
1550 
1551 		sal_uLong nFormat = INetBookmark::HasFormat(*pObject);
1552 		INetBookmark aBookmark;
1553 		if (aBookmark.Paste(*pObject,nFormat))
1554 			aFileName = aBookmark.GetURL();
1555 		else
1556 		{
1557 			//	FORMAT_FILE direkt aus DragServer
1558 
1559 			sal_uInt16 nCount = DragServer::GetItemCount();
1560 			for ( sal_uInt16 i = 0; i < nCount && !aFileName.Len(); ++i )
1561 				if (DragServer::HasFormat( i, FORMAT_FILE ))
1562 					aFileName = DragServer::PasteFile( i );
1563 		}
1564 
1565 		if ( aFileName.Len() )
1566 			bReturn = aLbEntries.LoadFile( aFileName );
1567 	}
1568 	return bReturn;
1569 }
1570 
1571 sal_Bool __EXPORT ScNavigatorDlg::QueryDrop( DropEvent& rEvt )
1572 {
1573 	sal_Bool bReturn = sal_False;
1574 
1575 	if ( !aLbEntries.IsInDrag() )		// kein Verschieben innerhalb der TreeListBox
1576 	{
1577 		SvScDataObjectRef pObject = SvScDataObject::PasteDragServer(rEvt);
1578 		if ( pObject->HasFormat(FORMAT_FILE)
1579 			|| INetBookmark::HasFormat(*pObject) )
1580 		{
1581 			rEvt.SetAction(DROP_COPY);		// Kopier-Cursor anzeigen
1582 			bReturn = sal_True;
1583 		}
1584 	}
1585 
1586 	return bReturn;
1587 }
1588 #endif
1589 
1590 
1591 
1592