xref: /AOO41X/main/sc/source/ui/navipi/navipi.cxx (revision 4d7c9de063a797b8b4f3d45e3561e82ad1f8ef1f)
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
ReleaseFocus()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 
ColumnEdit(ScNavigatorDlg * pParent,const ResId & rResId)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 
~ColumnEdit()106 __EXPORT ColumnEdit::~ColumnEdit()
107 {
108 }
109 
110 //------------------------------------------------------------------------
111 
Notify(NotifyEvent & rNEvt)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 
LoseFocus()144 void __EXPORT ColumnEdit::LoseFocus()
145 {
146     EvalText();
147 }
148 
149 
150 //------------------------------------------------------------------------
151 
Up()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 
Down()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 
First()181 void __EXPORT ColumnEdit::First()
182 {
183     nCol = 1;
184     SetText( 'A' );
185 }
186 
187 //------------------------------------------------------------------------
188 
Last()189 void __EXPORT ColumnEdit::Last()
190 {
191     String aStr;
192     nCol = NumToAlpha( SCNAV_MAXCOL, aStr );
193     SetText( aStr );
194 }
195 
196 
197 //------------------------------------------------------------------------
198 
EvalText()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 
ExecuteCol()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 
SetCol(SCCOL nColNo)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 
AlphaToNum(String & rStr)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 
NumStrToAlpha(String & rStr)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 
NumToAlpha(SCCOL nColNo,String & rStr)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 
RowEdit(ScNavigatorDlg * pParent,const ResId & rResId)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 
~RowEdit()317 __EXPORT RowEdit::~RowEdit()
318 {
319 }
320 
321 //------------------------------------------------------------------------
322 
Notify(NotifyEvent & rNEvt)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 
LoseFocus()344 void __EXPORT RowEdit::LoseFocus()
345 {
346 }
347 
348 //------------------------------------------------------------------------
349 
ExecuteRow()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 
ScDocListBox(ScNavigatorDlg * pParent,const ResId & rResId)363 ScDocListBox::ScDocListBox( ScNavigatorDlg* pParent, const ResId& rResId )
364     :   ListBox ( pParent, rResId ),
365         rDlg    ( *pParent )
366 {
367 }
368 
369 //------------------------------------------------------------------------
370 
~ScDocListBox()371 __EXPORT ScDocListBox::~ScDocListBox()
372 {
373 }
374 
375 //------------------------------------------------------------------------
376 
Select()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 
CommandToolBox(ScNavigatorDlg * pParent,const ResId & rResId)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 
~CommandToolBox()404 __EXPORT CommandToolBox::~CommandToolBox()
405 {
406 }
407 
408 //------------------------------------------------------------------------
409 
Select(sal_uInt16 nSelId)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 
Select()456 void __EXPORT CommandToolBox::Select()
457 {
458     Select( GetCurItemId() );
459 }
460 
461 //------------------------------------------------------------------------
462 
Click()463 void __EXPORT CommandToolBox::Click()
464 {
465 }
466 
467 //------------------------------------------------------------------------
468 
IMPL_LINK(CommandToolBox,ToolBoxDropdownClickHdl,ToolBox *,EMPTYARG)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 
UpdateButtons()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 
InitImageList()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 
DataChanged(const DataChangedEvent & rDCEvt)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 
ScNavigatorSettings()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 
SFX_IMPL_CHILDWINDOWCONTEXT(ScNavigatorDialogWrapper,SID_NAVIGATOR)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 
Resizing(Size & rSize)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 
ScNavigatorDlg(SfxBindings * pB,SfxChildWindowContext * pCW,Window * pParent,const bool bUseStyleSettingsBackground)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     aLbEntries.SetNavigatorDlgFlag(sal_True);
789 }
790 
791 //------------------------------------------------------------------------
792 
~ScNavigatorDlg()793 __EXPORT ScNavigatorDlg::~ScNavigatorDlg()
794 {
795     aContentTimer.Stop();
796 
797     sal_uInt16 i;
798     for ( i=0; i<CTRL_ITEMS; i++ )
799         delete ppBoundItems[i];
800 
801     delete [] ppBoundItems;
802     delete pMarkArea;
803 
804     EndListening( *(SFX_APP()) );
805     EndListening( rBindings );
806 }
807 
808 //------------------------------------------------------------------------
809 
Resizing(Size & rNewSize)810 void __EXPORT ScNavigatorDlg::Resizing( Size& rNewSize )  // Size = Outputsize?
811 {
812     FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
813     if ( pFloat )
814     {
815         Size aMinOut = pFloat->GetMinOutputSizePixel();
816 
817         if ( rNewSize.Width() < aMinOut.Width() )
818             rNewSize.Width() = aMinOut.Width();
819 
820         if ( eListMode == NAV_LMODE_NONE )
821             rNewSize.Height() = aInitSize.Height();
822         else
823         {
824             if ( rNewSize.Height() < aMinOut.Height() )
825                 rNewSize.Height() = aMinOut.Height();
826         }
827     }
828 //  else
829 //      SfxDockingWindow::Resizing(rNewSize);
830 }
831 
832 
833 
Paint(const Rectangle & rRec)834 void ScNavigatorDlg::Paint( const Rectangle& rRec )
835 {
836     if (mbUseStyleSettingsBackground)
837     {
838         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
839         Color aBgColor = rStyleSettings.GetFaceColor();
840         Wallpaper aBack( aBgColor );
841 
842         SetBackground( aBack );
843         aFtCol.SetBackground( aBack );
844         aFtRow.SetBackground( aBack );
845     }
846     else
847     {
848         aFtCol.SetBackground(Wallpaper());
849         aFtRow.SetBackground(Wallpaper());
850     }
851 
852     Window::Paint( rRec );
853 }
854 
DataChanged(const DataChangedEvent & rDCEvt)855 void ScNavigatorDlg::DataChanged( const DataChangedEvent& rDCEvt )
856 {
857     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
858     {
859         //  toolbox images are exchanged in CommandToolBox::DataChanged
860         Invalidate();
861     }
862 
863     Window::DataChanged( rDCEvt );
864 }
865 
866 //------------------------------------------------------------------------
867 
Resize()868 void __EXPORT ScNavigatorDlg::Resize()
869 {
870     DoResize();
871 }
872 
873 //------------------------------------------------------------------------
874 
DoResize()875 void ScNavigatorDlg::DoResize()
876 {
877     Size aNewSize = GetOutputSizePixel();
878     long nTotalHeight = aNewSize.Height();
879 
880     //  #41403# bei angedocktem Navigator wird das Fenster evtl. erst klein erzeugt,
881     //  dann kommt ein Resize auf die wirkliche Groesse -> dann Inhalte einschalten
882 
883     sal_Bool bSmall = ( nTotalHeight <= aInitSize.Height() + SCNAV_MINTOL );
884     if ( !bSmall && bFirstBig )
885     {
886         //  Inhalte laut Config wieder einschalten
887 
888         bFirstBig = sal_False;
889         NavListMode eNavMode = NAV_LMODE_AREAS;
890         ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
891         NavListMode eLastMode = (NavListMode) rCfg.GetListMode();
892         if ( eLastMode == NAV_LMODE_SCENARIOS )
893             eNavMode = NAV_LMODE_SCENARIOS;
894         SetListMode( eNavMode, sal_False );         // FALSE: Groesse des Float nicht setzen
895     }
896 
897     //  auch wenn die Inhalte nicht sichtbar sind, die Groessen anpassen,
898     //  damit die Breite stimmt
899 
900     //@@ 03.11.97 changes begin
901     Point aEntryPos = aLbEntries.GetPosPixel();
902     Point aListPos = aLbDocuments.GetPosPixel();
903     aNewSize.Width() -= 2*nBorderOffset;
904     Size aDocSize = aLbDocuments.GetSizePixel();
905     aDocSize.Width() = aNewSize.Width();
906 
907     if(!bSmall)
908     {
909 
910         long nListHeight = aLbDocuments.GetSizePixel().Height();
911         aNewSize.Height() -= ( aEntryPos.Y() + nListHeight + 2*nBorderOffset );
912         if(aNewSize.Height()<0) aNewSize.Height()=0;
913 
914         aListPos.Y() = aEntryPos.Y() + aNewSize.Height() + nBorderOffset;
915 
916         if(aListPos.Y() > aLbEntries.GetPosPixel().Y())
917                             aLbDocuments.SetPosPixel( aListPos );
918 
919     }
920     aLbEntries.SetSizePixel( aNewSize );
921     aWndScenarios.SetSizePixel( aNewSize );
922     aLbDocuments.SetSizePixel( aDocSize );
923 
924     //@@ 03.11.97 end
925 
926     sal_Bool bListMode = (eListMode != NAV_LMODE_NONE);
927     if (pContextWin != NULL)
928     {
929         FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
930         if ( pFloat && bListMode )
931             nListModeHeight = nTotalHeight;
932     }
933 }
934 
935 //------------------------------------------------------------------------
936 
Notify(SfxBroadcaster &,const SfxHint & rHint)937 void __EXPORT ScNavigatorDlg::Notify( SfxBroadcaster&, const SfxHint& rHint )
938 {
939     if ( rHint.ISA(SfxSimpleHint) )
940     {
941         sal_uLong nHintId = ((SfxSimpleHint&)rHint).GetId();
942 
943         if ( nHintId == SC_HINT_DOCNAME_CHANGED )
944         {
945             aLbEntries.ActiveDocChanged();
946         }
947         else if ( NAV_LMODE_NONE == eListMode )
948         {
949             //  Tabellen hier nicht mehr
950         }
951         else
952         {
953             switch ( nHintId )
954             {
955                 case SC_HINT_TABLES_CHANGED:
956                     aLbEntries.Refresh( SC_CONTENT_TABLE );
957                     break;
958 
959                 case SC_HINT_DBAREAS_CHANGED:
960                     aLbEntries.Refresh( SC_CONTENT_DBAREA );
961                     break;
962 
963                 case SC_HINT_AREAS_CHANGED:
964                     aLbEntries.Refresh( SC_CONTENT_RANGENAME );
965                     break;
966 
967                 case SC_HINT_DRAW_CHANGED:
968                     aLbEntries.Refresh( SC_CONTENT_GRAPHIC );
969                     aLbEntries.Refresh( SC_CONTENT_OLEOBJECT );
970                     aLbEntries.Refresh( SC_CONTENT_DRAWING );
971                     break;
972 
973                 case SC_HINT_AREALINKS_CHANGED:
974                     aLbEntries.Refresh( SC_CONTENT_AREALINK );
975                     break;
976 
977                 //  SFX_HINT_DOCCHANGED kommt nicht nur bei Dokument-Wechsel
978 
979                 case SC_HINT_NAVIGATOR_UPDATEALL:
980                     UpdateAll();
981                     break;
982 
983                 case FID_DATACHANGED:
984                 case FID_ANYDATACHANGED:
985                     aContentTimer.Start();      // Notizen nicht sofort suchen
986                     break;
987                 case FID_KILLEDITVIEW:
988                     aLbEntries.ObjectFresh( SC_CONTENT_OLEOBJECT );
989                     aLbEntries.ObjectFresh( SC_CONTENT_DRAWING );
990                     aLbEntries.ObjectFresh( SC_CONTENT_GRAPHIC );
991                       break;
992                 default:
993                     break;
994             }
995         }
996     }
997     else if ( rHint.ISA(SfxEventHint) )
998     {
999         sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId();
1000         if ( nEventId == SFX_EVENT_ACTIVATEDOC )
1001         {
1002             aLbEntries.ActiveDocChanged();
1003             UpdateAll();
1004         }
1005     }
1006 }
1007 
1008 //------------------------------------------------------------------------
1009 
IMPL_LINK(ScNavigatorDlg,TimeHdl,Timer *,pTimer)1010 IMPL_LINK( ScNavigatorDlg, TimeHdl, Timer*, pTimer )
1011 {
1012     if ( pTimer != &aContentTimer )
1013         return 0;
1014 
1015     aLbEntries.Refresh( SC_CONTENT_NOTE );
1016     return 0;
1017 }
1018 
1019 //------------------------------------------------------------------------
1020 
SetDropMode(sal_uInt16 nNew)1021 void ScNavigatorDlg::SetDropMode(sal_uInt16 nNew)
1022 {
1023     nDropMode = nNew;
1024     aTbxCmd.UpdateButtons();
1025 
1026     ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
1027     rCfg.SetDragMode(nDropMode);
1028 }
1029 
1030 //------------------------------------------------------------------------
1031 
CursorPosChanged()1032 void ScNavigatorDlg::CursorPosChanged()
1033 {
1034     //! Eintraege selektieren ???
1035 
1036 //  if ( GetDBAtCursor( aStrDbName ) )
1037 //  if ( GetAreaAtCursor( aStrAreaName ) )
1038 }
1039 
1040 //------------------------------------------------------------------------
1041 
SetCurrentCell(SCCOL nColNo,SCROW nRowNo)1042 void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo, SCROW nRowNo )
1043 {
1044     if ( (nColNo+1 != nCurCol) || (nRowNo+1 != nCurRow) )
1045     {
1046         // SID_CURRENTCELL == Item #0 Cache leeren, damit das Setzen der
1047         // aktuellen Zelle auch in zusammengefassten Bereichen funktioniert.
1048         ppBoundItems[0]->ClearCache();
1049 
1050         ScAddress aScAddress( nColNo, nRowNo, 0 );
1051         String  aAddr;
1052         aScAddress.Format( aAddr, SCA_ABS );
1053 
1054         sal_Bool bUnmark = sal_False;
1055         if ( GetViewData() )
1056             bUnmark = !pViewData->GetMarkData().IsCellMarked( nColNo, nRowNo );
1057 
1058         SfxStringItem   aPosItem( SID_CURRENTCELL, aAddr );
1059         SfxBoolItem     aUnmarkItem( FN_PARAM_1, bUnmark );     // ggf. Selektion aufheben
1060 
1061         rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
1062                                   SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1063                                   &aPosItem, &aUnmarkItem, 0L );
1064     }
1065 }
1066 
SetCurrentCellStr(const String rName)1067 void ScNavigatorDlg::SetCurrentCellStr( const String rName )
1068 {
1069     ppBoundItems[0]->ClearCache();
1070     SfxStringItem   aNameItem( SID_CURRENTCELL, rName );
1071 
1072     rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
1073                               SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1074                               &aNameItem, 0L );
1075 }
1076 
1077 //------------------------------------------------------------------------
1078 
SetCurrentTable(SCTAB nTabNo)1079 void ScNavigatorDlg::SetCurrentTable( SCTAB nTabNo )
1080 {
1081     if ( nTabNo != nCurTab )
1082     {
1083         //  Tabelle fuer Basic ist 1-basiert
1084         SfxUInt16Item aTabItem( SID_CURRENTTAB, static_cast<sal_uInt16>(nTabNo) + 1 );
1085         rBindings.GetDispatcher()->Execute( SID_CURRENTTAB,
1086                                   SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1087                                   &aTabItem, 0L );
1088     }
1089 }
1090 
SetCurrentTableStr(const String rName)1091 void ScNavigatorDlg::SetCurrentTableStr( const String rName )
1092 {
1093     if (!GetViewData()) return;
1094 
1095     ScDocument* pDoc = pViewData->GetDocument();
1096     SCTAB nCount     = pDoc->GetTableCount();
1097     String aTabName;
1098 
1099     for ( SCTAB i=0; i<nCount; i++ )
1100     {
1101         pDoc->GetName( i, aTabName );
1102         if ( aTabName == rName )
1103         {
1104             SetCurrentTable( i );
1105             return;
1106         }
1107     }
1108 
1109     Sound::Beep();                  // Tabelle nicht gefunden
1110 }
1111 
1112 //------------------------------------------------------------------------
1113 
SetCurrentObject(const String rName)1114 void ScNavigatorDlg::SetCurrentObject( const String rName )
1115 {
1116     SfxStringItem aNameItem( SID_CURRENTOBJECT, rName );
1117     rBindings.GetDispatcher()->Execute( SID_CURRENTOBJECT,
1118                               SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1119                               &aNameItem, 0L );
1120 }
1121 
1122 //------------------------------------------------------------------------
1123 
SetCurrentDoc(const String & rDocName)1124 void ScNavigatorDlg::SetCurrentDoc( const String& rDocName )        // aktivieren
1125 {
1126     SfxStringItem aDocItem( SID_CURRENTDOC, rDocName );
1127     rBindings.GetDispatcher()->Execute( SID_CURRENTDOC,
1128                               SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1129                               &aDocItem, 0L );
1130 }
1131 
1132 //------------------------------------------------------------------------
1133 
GetTabViewShell() const1134 ScTabViewShell* ScNavigatorDlg::GetTabViewShell() const
1135 {
1136     return PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
1137 }
1138 
1139 //------------------------------------------------------------------------
1140 
GetNavigatorSettings()1141 ScNavigatorSettings* ScNavigatorDlg::GetNavigatorSettings()
1142 {
1143     //  #95791# Don't store the settings pointer here, because the settings belong to
1144     //  the view, and the view may be closed while the navigator is open (reload).
1145     //  If the pointer is cached here again later for performance reasons, it has to
1146     //  be forgotten when the view is closed.
1147 
1148     ScTabViewShell* pViewSh = GetTabViewShell();
1149     return pViewSh ? pViewSh->GetNavigatorSettings() : NULL;
1150 }
1151 
1152 //------------------------------------------------------------------------
1153 
GetViewData()1154 sal_Bool ScNavigatorDlg::GetViewData()
1155 {
1156     ScTabViewShell* pViewSh = GetTabViewShell();
1157     pViewData = pViewSh ? pViewSh->GetViewData() : NULL;
1158 
1159     return ( pViewData != NULL );
1160 }
1161 
1162 //------------------------------------------------------------------------
1163 
UpdateColumn(const SCCOL * pCol)1164 void ScNavigatorDlg::UpdateColumn( const SCCOL* pCol )
1165 {
1166     if ( pCol )
1167         nCurCol = *pCol;
1168     else if ( GetViewData() )
1169         nCurCol = pViewData->GetCurX() + 1;
1170 
1171     aEdCol.SetCol( nCurCol );
1172     CheckDataArea();
1173 }
1174 
1175 //------------------------------------------------------------------------
1176 
UpdateRow(const SCROW * pRow)1177 void ScNavigatorDlg::UpdateRow( const SCROW* pRow )
1178 {
1179     if ( pRow )
1180         nCurRow = *pRow;
1181     else if ( GetViewData() )
1182         nCurRow = pViewData->GetCurY() + 1;
1183 
1184     aEdRow.SetRow( nCurRow );
1185     CheckDataArea();
1186 }
1187 
1188 //------------------------------------------------------------------------
1189 
UpdateTable(const SCTAB * pTab)1190 void ScNavigatorDlg::UpdateTable( const SCTAB* pTab )
1191 {
1192     if ( pTab )
1193         nCurTab = *pTab;
1194     else if ( GetViewData() )
1195         nCurTab = pViewData->GetTabNo();
1196 
1197 //  aLbTables.SetTab( nCurTab );
1198     CheckDataArea();
1199 }
1200 
1201 //------------------------------------------------------------------------
1202 
UpdateAll()1203 void ScNavigatorDlg::UpdateAll()
1204 {
1205     switch ( eListMode )
1206     {
1207         case NAV_LMODE_DOCS:
1208         case NAV_LMODE_DBAREAS:
1209         case NAV_LMODE_AREAS:
1210             aLbEntries.Refresh();
1211             break;
1212 
1213         case NAV_LMODE_NONE:
1214             //! ???
1215             break;
1216 
1217         default:
1218             break;
1219     }
1220 
1221     aContentTimer.Stop();       // dann nicht nochmal
1222 }
1223 
1224 //------------------------------------------------------------------------
1225 
SetListMode(NavListMode eMode,sal_Bool bSetSize)1226 void ScNavigatorDlg::SetListMode( NavListMode eMode, sal_Bool bSetSize )
1227 {
1228     if ( eMode != eListMode )
1229     {
1230         if ( eMode != NAV_LMODE_NONE )
1231             bFirstBig = sal_False;              // nicht mehr automatisch umschalten
1232 
1233         eListMode = eMode;
1234 
1235         switch ( eMode )
1236         {
1237             case NAV_LMODE_NONE:
1238                 ShowList( sal_False, bSetSize );
1239                 break;
1240 
1241             case NAV_LMODE_AREAS:
1242             case NAV_LMODE_DBAREAS:
1243             case NAV_LMODE_DOCS:
1244                 aLbEntries.Refresh();
1245                 ShowList( sal_True, bSetSize );
1246                 break;
1247 
1248             case NAV_LMODE_SCENARIOS:
1249                 ShowScenarios( sal_True, bSetSize );
1250                 break;
1251         }
1252 
1253         aTbxCmd.UpdateButtons();
1254 
1255         if ( eMode != NAV_LMODE_NONE )
1256         {
1257             ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
1258             rCfg.SetListMode( (sal_uInt16) eMode );
1259         }
1260     }
1261 
1262     if ( pMarkArea )
1263         UnmarkDataArea();
1264 }
1265 
1266 //------------------------------------------------------------------------
1267 
ShowList(sal_Bool bShow,sal_Bool bSetSize)1268 void ScNavigatorDlg::ShowList( sal_Bool bShow, sal_Bool bSetSize )
1269 {
1270     FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
1271     Size aSize = GetParent()->GetOutputSizePixel();
1272 
1273     if ( bShow )
1274     {
1275         Size aMinSize = aInitSize;
1276 
1277         aMinSize.Height() += nInitListHeight;
1278         if ( pFloat )
1279             pFloat->SetMinOutputSizePixel( aMinSize );
1280         aSize.Height() = nListModeHeight;
1281         aLbEntries.Show();
1282         aLbDocuments.Show();
1283     }
1284     else
1285     {
1286         if ( pFloat )
1287         {
1288             pFloat->SetMinOutputSizePixel( aInitSize );
1289             nListModeHeight = aSize.Height();
1290         }
1291         aSize.Height() = aInitSize.Height();
1292         aLbEntries.Hide();
1293         aLbDocuments.Hide();
1294     }
1295     aWndScenarios.Hide();
1296 
1297     if ( pFloat )
1298     {
1299         if ( bSetSize )
1300             pFloat->SetOutputSizePixel( aSize );
1301     }
1302     else
1303     {
1304         SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(GetParent());
1305         if (pNav != NULL)
1306         {
1307             Size aFloating = pNav->GetFloatingSize();
1308             aFloating.Height() = aSize.Height();
1309             pNav->SetFloatingSize( aFloating );
1310         }
1311     }
1312 }
1313 
1314 //------------------------------------------------------------------------
1315 
ShowScenarios(sal_Bool bShow,sal_Bool bSetSize)1316 void ScNavigatorDlg::ShowScenarios( sal_Bool bShow, sal_Bool bSetSize )
1317 {
1318     FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
1319     Size aSize = GetParent()->GetOutputSizePixel();
1320 
1321     if ( bShow )
1322     {
1323         Size aMinSize = aInitSize;
1324         aMinSize.Height() += nInitListHeight;
1325         if ( pFloat )
1326             pFloat->SetMinOutputSizePixel( aMinSize );
1327         aSize.Height() = nListModeHeight;
1328 
1329         rBindings.Invalidate( SID_SELECT_SCENARIO );
1330         rBindings.Update( SID_SELECT_SCENARIO );
1331 
1332         aWndScenarios.Show();
1333         aLbDocuments.Show();
1334     }
1335     else
1336     {
1337         if ( pFloat )
1338         {
1339             pFloat->SetMinOutputSizePixel( aInitSize );
1340             nListModeHeight = aSize.Height();
1341         }
1342         aSize.Height() = aInitSize.Height();
1343         aWndScenarios.Hide();
1344         aLbDocuments.Hide();
1345     }
1346     aLbEntries.Hide();
1347 
1348     if ( pFloat )
1349     {
1350         if ( bSetSize )
1351             pFloat->SetOutputSizePixel( aSize );
1352     }
1353     else
1354     {
1355         SfxNavigator* pNav = (SfxNavigator*)GetParent();
1356         Size aFloating = pNav->GetFloatingSize();
1357         aFloating.Height() = aSize.Height();
1358         pNav->SetFloatingSize( aFloating );
1359     }
1360 }
1361 
1362 
1363 //------------------------------------------------------------------------
1364 //
1365 //      Dokumente fuer Dropdown-Listbox
1366 //
1367 //------------------------------------------------------------------------
1368 
GetDocNames(const String * pManualSel)1369 void ScNavigatorDlg::GetDocNames( const String* pManualSel )
1370 {
1371     aLbDocuments.Clear();
1372     aLbDocuments.SetUpdateMode( sal_False );
1373 
1374     ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
1375 
1376     String aSelEntry;
1377     SfxObjectShell* pSh = SfxObjectShell::GetFirst();
1378     while ( pSh )
1379     {
1380         if ( pSh->ISA(ScDocShell) )
1381         {
1382             String aName = pSh->GetTitle();
1383             String aEntry = aName;
1384             if (pSh == pCurrentSh)
1385                 aEntry += aStrActive;
1386             else
1387                 aEntry += aStrNotActive;
1388             aLbDocuments.InsertEntry( aEntry );
1389 
1390             if ( pManualSel ? ( aName == *pManualSel )
1391                             : ( pSh == pCurrentSh ) )
1392                 aSelEntry = aEntry;                     // kompletter Eintrag zum Selektieren
1393         }
1394 
1395         pSh = SfxObjectShell::GetNext( *pSh );
1396     }
1397 
1398     aLbDocuments.InsertEntry( aStrActiveWin );
1399 
1400     String aHidden =  aLbEntries.GetHiddenTitle();
1401     if (aHidden.Len())
1402     {
1403         String aEntry = aHidden;
1404         aEntry += aStrHidden;
1405         aLbDocuments.InsertEntry( aEntry );
1406 
1407         if ( pManualSel && aHidden == *pManualSel )
1408             aSelEntry = aEntry;
1409     }
1410 
1411     aLbDocuments.SetUpdateMode( sal_True );
1412 
1413     aLbDocuments.SelectEntry( aSelEntry );
1414 }
1415 
1416 //------------------------------------------------------------------------
1417 
MarkDataArea()1418 void ScNavigatorDlg::MarkDataArea()
1419 {
1420     ScTabViewShell* pViewSh = GetTabViewShell();
1421 
1422     if ( pViewSh )
1423     {
1424         if ( !pMarkArea )
1425             pMarkArea = new ScArea;
1426 
1427         pViewSh->MarkDataArea();
1428         ScRange aMarkRange;
1429         pViewSh->GetViewData()->GetMarkData().GetMarkArea(aMarkRange);
1430         pMarkArea->nColStart = aMarkRange.aStart.Col();
1431         pMarkArea->nRowStart = aMarkRange.aStart.Row();
1432         pMarkArea->nColEnd = aMarkRange.aEnd.Col();
1433         pMarkArea->nRowEnd = aMarkRange.aEnd.Row();
1434         pMarkArea->nTab = aMarkRange.aStart.Tab();
1435     }
1436 }
1437 
1438 //------------------------------------------------------------------------
1439 
UnmarkDataArea()1440 void ScNavigatorDlg::UnmarkDataArea()
1441 {
1442     ScTabViewShell* pViewSh = GetTabViewShell();
1443 
1444     if ( pViewSh )
1445     {
1446         pViewSh->Unmark();
1447         DELETEZ( pMarkArea );
1448     }
1449 }
1450 
1451 //------------------------------------------------------------------------
1452 
CheckDataArea()1453 void ScNavigatorDlg::CheckDataArea()
1454 {
1455     if ( aTbxCmd.IsItemChecked( IID_DATA ) && pMarkArea )
1456     {
1457         if (   nCurTab   != pMarkArea->nTab
1458             || nCurCol <  pMarkArea->nColStart+1
1459             || nCurCol >  pMarkArea->nColEnd+1
1460             || nCurRow <  pMarkArea->nRowStart+1
1461             || nCurRow >  pMarkArea->nRowEnd+1 )
1462         {
1463             aTbxCmd.SetItemState( IID_DATA, TriState(STATE_CHECK) );
1464             aTbxCmd.Select( IID_DATA );
1465         }
1466     }
1467 }
1468 
1469 //------------------------------------------------------------------------
1470 
StartOfDataArea()1471 void ScNavigatorDlg::StartOfDataArea()
1472 {
1473     //  pMarkArea auswerten ???
1474 
1475     if ( GetViewData() )
1476     {
1477         ScMarkData& rMark = pViewData->GetMarkData();
1478         ScRange aMarkRange;
1479         rMark.GetMarkArea( aMarkRange );
1480 
1481         SCCOL nCol = aMarkRange.aStart.Col();
1482         SCROW nRow = aMarkRange.aStart.Row();
1483 
1484         if ( (nCol+1 != aEdCol.GetCol()) || (nRow+1 != aEdRow.GetRow()) )
1485             SetCurrentCell( nCol, nRow );
1486     }
1487 }
1488 
1489 //------------------------------------------------------------------------
1490 
EndOfDataArea()1491 void ScNavigatorDlg::EndOfDataArea()
1492 {
1493     //  pMarkArea auswerten ???
1494 
1495     if ( GetViewData() )
1496     {
1497         ScMarkData& rMark = pViewData->GetMarkData();
1498         ScRange aMarkRange;
1499         rMark.GetMarkArea( aMarkRange );
1500 
1501         SCCOL nCol = aMarkRange.aEnd.Col();
1502         SCROW nRow = aMarkRange.aEnd.Row();
1503 
1504         if ( (nCol+1 != aEdCol.GetCol()) || (nRow+1 != aEdRow.GetRow()) )
1505             SetCurrentCell( nCol, nRow );
1506     }
1507 }
1508 
1509 //------------------------------------------------------------------------
1510 
CheckAlignment(SfxChildAlignment eActAlign,SfxChildAlignment eAlign)1511 SfxChildAlignment __EXPORT ScNavigatorDlg::CheckAlignment(
1512                             SfxChildAlignment eActAlign, SfxChildAlignment eAlign )
1513 {
1514     SfxChildAlignment eRetAlign;
1515 
1516     //! kein Andocken, wenn Listbox nicht da ???
1517 
1518     switch (eAlign)
1519     {
1520         case SFX_ALIGN_TOP:
1521         case SFX_ALIGN_HIGHESTTOP:
1522         case SFX_ALIGN_LOWESTTOP:
1523         case SFX_ALIGN_BOTTOM:
1524         case SFX_ALIGN_LOWESTBOTTOM:
1525         case SFX_ALIGN_HIGHESTBOTTOM:
1526             eRetAlign = eActAlign;              // nicht erlaubt
1527             break;
1528 
1529         case SFX_ALIGN_LEFT:
1530         case SFX_ALIGN_RIGHT:
1531         case SFX_ALIGN_FIRSTLEFT:
1532         case SFX_ALIGN_LASTLEFT:
1533         case SFX_ALIGN_FIRSTRIGHT:
1534         case SFX_ALIGN_LASTRIGHT:
1535             eRetAlign = eAlign;                 // erlaubt
1536             break;
1537 
1538         default:
1539             eRetAlign = eAlign;
1540             break;
1541     }
1542     return eRetAlign;
1543 }
1544 
1545 //------------------------------------------------------------------------
1546 //
1547 //  Drop auf den Navigator - andere Datei laden (File oder Bookmark)
1548 //
1549 //------------------------------------------------------------------------
1550 
1551 #if 0
1552 sal_Bool __EXPORT ScNavigatorDlg::Drop( const DropEvent& rEvt )
1553 {
1554     sal_Bool bReturn = sal_False;
1555 
1556     if ( !aLbEntries.IsInDrag() )       // kein Verschieben innerhalb der TreeListBox
1557     {
1558         String aFileName;
1559 
1560         SvScDataObjectRef pObject = SvScDataObject::PasteDragServer(rEvt);
1561 
1562         sal_uLong nFormat = INetBookmark::HasFormat(*pObject);
1563         INetBookmark aBookmark;
1564         if (aBookmark.Paste(*pObject,nFormat))
1565             aFileName = aBookmark.GetURL();
1566         else
1567         {
1568             //  FORMAT_FILE direkt aus DragServer
1569 
1570             sal_uInt16 nCount = DragServer::GetItemCount();
1571             for ( sal_uInt16 i = 0; i < nCount && !aFileName.Len(); ++i )
1572                 if (DragServer::HasFormat( i, FORMAT_FILE ))
1573                     aFileName = DragServer::PasteFile( i );
1574         }
1575 
1576         if ( aFileName.Len() )
1577             bReturn = aLbEntries.LoadFile( aFileName );
1578     }
1579     return bReturn;
1580 }
1581 
1582 sal_Bool __EXPORT ScNavigatorDlg::QueryDrop( DropEvent& rEvt )
1583 {
1584     sal_Bool bReturn = sal_False;
1585 
1586     if ( !aLbEntries.IsInDrag() )       // kein Verschieben innerhalb der TreeListBox
1587     {
1588         SvScDataObjectRef pObject = SvScDataObject::PasteDragServer(rEvt);
1589         if ( pObject->HasFormat(FORMAT_FILE)
1590             || INetBookmark::HasFormat(*pObject) )
1591         {
1592             rEvt.SetAction(DROP_COPY);      // Kopier-Cursor anzeigen
1593             bReturn = sal_True;
1594         }
1595     }
1596 
1597     return bReturn;
1598 }
1599 #endif
1600 
1601 
1602 
1603