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