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